From e4a12db8af28c039f6d7ca15d7a9f338639f064f Mon Sep 17 00:00:00 2001 From: vinnl Date: Mon, 17 Mar 2008 16:39:24 +0100 Subject: [PATCH] Configuration is now saved during installation, started the Notify module. --- project/data/config/cache.ini | 2 +- project/data/config/general.ini | 2 +- project/index.php | 4 +- project/modules/install/Module.php | 4 +- .../install/controllers/InstallController.php | 24 ++++++++- project/modules/notify/Module.php | 62 ++++++++++++++++++++++ project/modules/notify/Version.php | 39 ++++++++++++++ .../modules/notify/controllers/IndexController.php | 43 +++++++++++++++ .../notify/views/scripts/index/notifications.phtml | 1 + project/modules/page/Module.php | 3 +- project/modules/page/views/scripts/layout.phtml | 3 ++ project/modules/translate/Module.php | 4 +- 12 files changed, 181 insertions(+), 10 deletions(-) create mode 100644 project/modules/notify/Module.php create mode 100644 project/modules/notify/Version.php create mode 100644 project/modules/notify/controllers/IndexController.php create mode 100644 project/modules/notify/views/scripts/index/notifications.phtml diff --git a/project/data/config/cache.ini b/project/data/config/cache.ini index 12ddca3..b23d122 100644 --- a/project/data/config/cache.ini +++ b/project/data/config/cache.ini @@ -1,6 +1,6 @@ ; Configure caching ; See http://framework.zend.com/manual/en/zend.cache.html - +[cache] backend = "File" cache_root = "./data/cache" diff --git a/project/data/config/general.ini b/project/data/config/general.ini index 566cc65..6da5bb3 100644 --- a/project/data/config/general.ini +++ b/project/data/config/general.ini @@ -11,4 +11,4 @@ params.password = password [developers] ; This is only interesting for developers ; Be sure to change setup to "production" on live systems! -setup = dev \ No newline at end of file +setup = dev diff --git a/project/index.php b/project/index.php index c778508..187a21c 100644 --- a/project/index.php +++ b/project/index.php @@ -12,11 +12,11 @@ require 'Zend/Loader.php'; Zend_Loader::registerAutoload(); // Load the general configuration and save it to the registry -$generalConfig = new Zend_Config_Ini('./data/config/general.ini'); +$generalConfig = new Vogel_Config_Ini('./data/config/general.ini'); Zend_Registry::set('generalConfig', $generalConfig); // Load the cache configuration and save it to the registry -$cacheConfig = new Zend_Config_Ini('./data/config/cache.ini'); +$cacheConfig = new Vogel_Config_Ini('./data/config/cache.ini'); Zend_Registry::set('cacheConfig', $cacheConfig); // Register Pivip's view helpers diff --git a/project/modules/install/Module.php b/project/modules/install/Module.php index 5cc4377..b2c6f8d 100644 --- a/project/modules/install/Module.php +++ b/project/modules/install/Module.php @@ -114,8 +114,8 @@ class Install_Module extends Pivip_Module_Abstract } $actionStack->pushStack($nextRequest); $route = new Zend_Controller_Router_Route('install/:phase/*', - array('controller' => - 'install_install', + array('module' => 'install', + 'controller' => 'install', 'action' => 'index', 'phase' => 'index')); $frontController->getRouter()->addRoute('install', $route); diff --git a/project/modules/install/controllers/InstallController.php b/project/modules/install/controllers/InstallController.php index b31a8ca..9a73255 100644 --- a/project/modules/install/controllers/InstallController.php +++ b/project/modules/install/controllers/InstallController.php @@ -53,6 +53,29 @@ class Install_InstallController extends Pivip_Controller_Module_Abstract */ public function configurationAction() { + $generalConfig = Zend_Registry::get('generalConfig'); + if($this->_request->isPost()) + { + $generalConfig->database->params->dbname = + $this->_request->getParam('dbname'); + $generalConfig->database->params->username = + $this->_request->getParam('username'); + $generalConfig->database->params->password = + $this->_request->getParam('password'); + $generalConfig->website->name = + $this->_request->getParam('sitename'); + try + { + $generalConfig->save(); + $this->_forward('modules', 'install', 'install', + $this->_request->getParams()); + } catch(Exception $e) { + $translate = Zend_Registry::get('Zend_Translate'); + $notification = $translate->_('Could not save the configuration. +Is the configuration file writable?'); + $this->_helper->FlashMessenger($notification); + } + } $route = Zend_Controller_Front::getInstance()->getRouter() ->getRoute('install'); $action = $route->assemble(array('phase' => 'configure')); @@ -83,7 +106,6 @@ class Install_InstallController extends Pivip_Controller_Module_Abstract $submit = new Zend_Form_Element_Submit('submit'); $submit->setLabel('Next step'); $form->addElement($submit); - $generalConfig = Zend_Registry::get('generalConfig'); $data = $generalConfig->toArray(); $data = $data['database']['params']; $data['sitename'] = $generalConfig->website->name; diff --git a/project/modules/notify/Module.php b/project/modules/notify/Module.php new file mode 100644 index 0000000..7745829 --- /dev/null +++ b/project/modules/notify/Module.php @@ -0,0 +1,62 @@ + + */ + +/** + * Manage the Notify module + * + * The Notify module allows for displaying of notifications + * + * @see /library/Pivip/Module/Abstract.php + */ +class Notify_Module extends Pivip_Module_Abstract +{ + /** + * Notify needs no installation; returns true. + * + * @return boolean True, Notify need not be installed + */ + public static function isInstalled() + { + return true; + } + + /** + * Communicate that Notify does not need any configuration + * + * @return boolean False, since Notify does not need to be configured. + */ + public static function needsConfiguring() + { + return false; + } + + /** + * Load the module + */ + public static function bootstrap() + { + } +} \ No newline at end of file diff --git a/project/modules/notify/Version.php b/project/modules/notify/Version.php new file mode 100644 index 0000000..dc92ac4 --- /dev/null +++ b/project/modules/notify/Version.php @@ -0,0 +1,39 @@ + + */ + +/** + * Get the current version of the Notify module + */ +class Notify_Version extends Pivip_Version_Abstract +{ + /** + * @return string Notify module's current version + */ + public static function getVersion() + { + return '0.0.0dev'; + } +} \ No newline at end of file diff --git a/project/modules/notify/controllers/IndexController.php b/project/modules/notify/controllers/IndexController.php new file mode 100644 index 0000000..6259226 --- /dev/null +++ b/project/modules/notify/controllers/IndexController.php @@ -0,0 +1,43 @@ + + */ + +/** + * Load a page's blocks + */ +class IndexController extends Pivip_Controller_Module_Abstract +{ + /** + * Loads the blocks of a certain page + * + * @throws Page_Exception + */ + public function notificationsAction() + { + $this->view->notifications = + $this->_helper->FlashMessenger->getMessages(); + } +} \ No newline at end of file diff --git a/project/modules/notify/views/scripts/index/notifications.phtml b/project/modules/notify/views/scripts/index/notifications.phtml new file mode 100644 index 0000000..0448a69 --- /dev/null +++ b/project/modules/notify/views/scripts/index/notifications.phtml @@ -0,0 +1 @@ +notifications); \ No newline at end of file diff --git a/project/modules/page/Module.php b/project/modules/page/Module.php index dfc1040..e6de263 100644 --- a/project/modules/page/Module.php +++ b/project/modules/page/Module.php @@ -97,6 +97,7 @@ class Page_Module extends Pivip_Module_Abstract require_once 'plugins/SegmentMapper.php'; $frontController->registerPlugin(new SegmentMapper()); $frontController->setDefaultModule('page'); - Zend_Layout::startMvc(array('layoutPath' => 'views/')); + Zend_Layout::startMvc(array('layoutPath' => + 'modules/page/views/scripts')); } } \ No newline at end of file diff --git a/project/modules/page/views/scripts/layout.phtml b/project/modules/page/views/scripts/layout.phtml index 6e1a243..3f9b28b 100644 --- a/project/modules/page/views/scripts/layout.phtml +++ b/project/modules/page/views/scripts/layout.phtml @@ -44,6 +44,9 @@ echo $this->headStyle();
+
+ layout()->notifications; ?> +
diff --git a/project/modules/translate/Module.php b/project/modules/translate/Module.php index 5eb6640..957ab3a 100644 --- a/project/modules/translate/Module.php +++ b/project/modules/translate/Module.php @@ -74,12 +74,12 @@ class Translate_Module extends Pivip_Module_Abstract { $separator = '/'; } - $options['backendOptions']['cache_dir'] = $options['cache_root'] + $options['backendOptions']['cache_dir'] = $options['cache']['cache_root'] . $separator . 'modules/translate'; $frontendOptions = array('automatic_serialization' => true); $cache = Zend_Cache::factory('Page', - $cacheConfig->backend, + $cacheConfig->cache->backend, $frontendOptions, $options['backendOptions']); //Zend_Translate::setCache($cache); -- 2.11.4.GIT