コード例 #1
0
ファイル: Model.php プロジェクト: netconstructor/Centurion
 public function init()
 {
     Centurion_Signal::factory('pre_generate')->connect(array($this, 'preGenerate'), $this->_form);
     Centurion_Signal::factory('on_populate_with_instance')->connect(array($this, 'populateWithInstance'), $this->_form);
     Centurion_Signal::factory('pre_populate')->connect(array($this, 'prePopulate'), $this->_form);
     Centurion_Signal::factory('on_form_get_toolbar')->connect(array($this, 'onFormGetToolbar'), $this->_form);
 }
コード例 #2
0
 public function indexAction()
 {
     Translation_Model_Manager::generate();
     Centurion_Signal::factory('clean_cache')->send($this);
     Centurion_Loader_PluginLoader::cleanCache(Centurion_Loader_PluginLoader::getIncludeFileCache());
     Centurion_Loader_PluginLoader::setStaticCachePlugin(null);
 }
コード例 #3
0
 public function getBySlugAction()
 {
     $flatpageRow = $this->_helper->getObjectOr404('cms/flatpage', array('id' => $this->_getParam('id'), 'is_published' => 1, 'published_at__lt' => new Zend_Db_Expr('NOW()')));
     Centurion_Signal::factory('pre_display_rte')->send($flatpageRow, array($flatpageRow));
     Centurion_Cache_TagManager::addTag($flatpageRow);
     return $this->renderToResponse($flatpageRow->flatpage_template->view_script, array('currentFlatpageRow' => $flatpageRow));
 }
コード例 #4
0
ファイル: Flatpage.php プロジェクト: netconstructor/Centurion
 public function getHref()
 {
     switch ($this->flatpage_type) {
         case Cms_Model_DbTable_Flatpage::NORMAL:
             $router = Zend_Controller_Front::getInstance()->getRouter();
             if (!$router->hasRoute(sprintf('%sflatpage_%d', Zend_Registry::get('ROUTE_PREFIX'), $this->pk))) {
                 Centurion_Signal::factory('clean_cache')->send($this);
                 return '/';
             }
             if (strlen($this->body) < 15) {
                 return null;
             }
             return $router->assemble(array('object' => $this), sprintf('%sflatpage_%d', Zend_Registry::get('ROUTE_PREFIX'), $this->pk), true);
             break;
         case Cms_Model_DbTable_Flatpage::REDIRECT:
             if (null !== $this->route) {
                 return Zend_Controller_Front::getInstance()->getRouter()->assemble(array(), $this->route, true);
             } else {
                 return $this->forward_url;
             }
         case Cms_Model_DbTable_Flatpage::NAV_ONLY:
             $children = $this->getDescendantsSelect(false, 1)->filter('is_published = 1')->fetchRow();
             if (null == $children || !$children->count()) {
                 throw new Exception(sprintf('No child flatpage for id %s', $this->pk));
             }
             return $children->href;
         case Cms_Model_DbTable_Flatpage::REDIRECT_BLANK:
             return $this->forward_url;
     }
 }
コード例 #5
0
 protected function _initSignal()
 {
     Centurion_Signal::factory('post_update')->connect(array($this, 'postUpdate'), self::CMS_FLATPAGE_ROW, Centurion_Signal::BEHAVIOR_CONTINUE, Centurion_Signal_Abstract::UNSHIFT);
     Centurion_Signal::factory('post_save')->connect(array($this, 'postSave'), self::CMS_FLATPAGE_ROW);
     Centurion_Signal::factory('pre_delete')->connect(array($this, 'deleteRow'), self::CMS_FLATPAGE_ROW);
     Centurion_Signal::factory('pre_delete')->connect(array($this, 'deleteRowNavigation'), 'Core_Model_DbTable_Row_Navigation');
     Centurion_Signal::factory('post_save')->connect(array($this, 'saveNavigation'), 'Core_Model_DbTable_Row_Navigation');
 }
コード例 #6
0
ファイル: Row.php プロジェクト: netconstructor/Centurion
 public function init()
 {
     if (!class_implements($this->getTable(), 'Core_Traits_Mptt_Model_DbTable_Interface')) {
         throw new Centurion_Traits_Exception(sprintf('Class %s defined as \'Table class\' for the %s row must implement Core_Traits_Mptt_Model_DbTable_Interface', get_class($this->getTable()), get_class($this->_row)));
     }
     Centurion_Signal::factory('pre_save')->connect(array($this, 'preSave'), $this->_row);
     Centurion_Signal::factory('pre_delete')->connect(array($this, 'preDelete'), $this->_row);
 }
コード例 #7
0
ファイル: Row.php プロジェクト: netconstructor/Centurion
 public function init()
 {
     Centurion_Signal::factory('pre_save')->connect(array($this, 'preSave'), $this->_row, Centurion_Signal::BEHAVIOR_CAN_STOP);
     $this->_prefix = $this->getTable()->getLocalizedColsPrefix();
     $special = $this->_specialGets;
     $special['original'] = array($this, 'getOriginal');
     $special['permalink'] = array($this, 'getLocalizedAbsoluteUrl');
     $this->_specialGets = $special;
 }
コード例 #8
0
 public function clearCacheAction()
 {
     //$caches = array();
     //        foreach (Centurion_Config_Manager::get('resources.cachemanager') as $key => $value) {
     //            Zend_Cache::_makeBackend($value['backend']['name'], $value['backend']['options'])->clean(Zend_Cache::CLEANING_MODE_ALL);
     //        }
     Centurion_Signal::factory('clean_cache')->send($this);
     Centurion_Loader_PluginLoader::cleanCache(Centurion_Loader_PluginLoader::getIncludeFileCache());
     Centurion_Loader_PluginLoader::setStaticCachePlugin(null);
 }
コード例 #9
0
ファイル: CacheTest.php プロジェクト: rom1git/Centurion
 public function testCleanCacheSignal()
 {
     $cacheCore = $this->getCacheManager()->getCache('core');
     $str = sha1(uniqid());
     $id = sha1(uniqid());
     $cacheCore->save($str, $id);
     $this->assertEquals($str, $cacheCore->load($id));
     Centurion_Signal::factory('clean_cache')->send($this);
     $this->assertFalse($cacheCore->load($id));
     //TODO: finish
 }
コード例 #10
0
ファイル: CRUD.php プロジェクト: netconstructor/Centurion
 public function init()
 {
     parent::init();
     try {
         $displays = $this->_displays;
         $displays['language__name'] = array('label' => $this->view->translate('Language'));
         $displays['missing'] = array('label' => $this->view->translate('Missing translation'), 'type' => Centurion_Controller_CRUD::COLS_ROW_FUNCTION, 'function' => 'getMissingTranslation');
         $this->_displays = $displays;
     } catch (Exception $e) {
     }
     Centurion_Signal::factory('pre_dispatch')->connect(array($this, 'preDispatch'), $this->_controller);
 }
コード例 #11
0
 public function tearDown()
 {
     global $application;
     Centurion_Controller_Front::getInstance()->resetInstance();
     $this->resetRequest();
     $this->resetResponse();
     $this->request->setPost(array());
     $this->request->setQuery(array());
     Centurion_Signal::unregister();
     Centurion_Auth::getInstance()->clearIdentity();
     Centurion_Loader_PluginLoader::cleanCache();
     return $application->getBootstrap()->bootstrap('cachemanager');
 }
コード例 #12
0
ファイル: DbTable.php プロジェクト: rom1git/Centurion
 /**
  * (non-PHPdoc)
  * @see Centurion/Contrib/core/traits/Version/Model/Core_Traits_Version_Model_DbTable::init()
  */
 public function init()
 {
     parent::init();
     $this->_localizedColsPrefix .= $this->_modelName . '_';
     if (false === Centurion_Config_Manager::get('translation.default_language', false)) {
         throw new Centurion_Traits_Exception('no default language have been set in the configuration. Please add a \'translation.default_language\' entry');
     }
     $this->_languageRefRule = $this->_addReferenceMapRule('language', 'language_id', 'Translation_Model_DbTable_Language');
     $referenceMap = $this->_referenceMap;
     $referenceMap['original'] = array('columns' => 'original_id', 'refColumns' => 'id', 'refTableClass' => get_class($this->_model), 'onDelete' => Zend_Db_Table_Abstract::CASCADE, 'onUpdate' => Zend_Db_Table_Abstract::CASCADE);
     $referenceMap['language'] = array('columns' => 'language_id', 'refColumns' => 'id', 'refTableClass' => 'Translation_Model_DbTable_Language', 'onDelete' => Zend_Db_Table_Abstract::CASCADE, 'onUpdate' => Zend_Db_Table_Abstract::CASCADE);
     Centurion_Signal::factory('on_select_joinInner')->connect(array($this, 'onJoinInner'), $this->_model);
 }
コード例 #13
0
ファイル: Manager.php プロジェクト: netconstructor/Centurion
 /**
  * @return void
  */
 public function connectSignal()
 {
     Centurion_Signal::factory('clean_cache')->connect(array($this, 'cleanCacheSignal'));
     Centurion_Signal::factory('clean_cache_asynchronous')->connect(array($this, 'cleanCacheAsynchronousSignal'));
     Centurion_Signal::factory('post_delete')->connect(array($this, 'signalRow'), 'Centurion_Db_Table_Row_Abstract');
     Centurion_Signal::factory('post_update')->connect(array($this, 'signalRow'), 'Centurion_Db_Table_Row_Abstract');
     Centurion_Signal::factory('post_save')->connect(array($this, 'signalRow'), 'Centurion_Db_Table_Row_Abstract');
     Centurion_Signal::factory('post_insert')->connect(array($this, 'signalRow'), 'Centurion_Db_Table_Row_Abstract');
     Centurion_Signal::factory('post_delete')->connect(array($this, 'signalTable'), 'Centurion_Db_Table_Abstract');
     Centurion_Signal::factory('post_update')->connect(array($this, 'signalTable'), 'Centurion_Db_Table_Abstract');
     Centurion_Signal::factory('pre_delete')->connect(array($this, 'preSignalTable'), 'Centurion_Db_Table_Abstract');
     Centurion_Signal::factory('pre_update')->connect(array($this, 'preSignalTable'), 'Centurion_Db_Table_Abstract');
     Centurion_Signal::factory('post_insert')->connect(array($this, 'insertTable'), 'Centurion_Db_Table_Abstract');
 }
コード例 #14
0
ファイル: DbTable.php プロジェクト: netconstructor/Centurion
 public function init()
 {
     if (!class_implements($this->_rowClass, 'Core_Traits_Mptt_Model_DbTable_Row_Interface')) {
         throw new Centurion_Traits_Exception(sprintf('Class %s defined as row class for model %s must implement Core_Traits_Mptt_Model_DbTable_Row_Interface', $this->_rowClass, get_class($this->_model)));
     }
     $pk = $this->_modelInfo[Centurion_Db_Table_Abstract::PRIMARY];
     if (is_array($pk) && 1 != count($pk)) {
         throw new Centurion_Traits_Exception('Trait MPTT doesn\'t support compound primary key');
     }
     $pk = (array) $pk;
     $primaryKeyCol = array_shift($pk);
     $this->_parentRefRule = $this->_addReferenceMapRule('parent', self::MPTT_PARENT, get_class($this->_model), 'id', array('onDelete' => Centurion_Db_Table_Abstract::SET_NULL, 'onUpdate' => Centurion_Db_Table_Abstract::CASCADE));
     $this->_childrenRefRule = $this->_addDependentTables('children', get_class($this->_model));
     $this->_variables = array('%left%' => self::MPTT_LEFT, '%right%' => self::MPTT_RIGHT, '%parentColumn%' => self::MPTT_PARENT, '%level%' => self::MPTT_LEVEL, '%tree%' => self::MPTT_TREE, '%pk%' => $primaryKeyCol);
     Centurion_Signal::factory('on_dbTable_select')->connect(array($this, 'onSelect'), $this->_model);
 }
コード例 #15
0
ファイル: PreInitTest.php プロジェクト: rom1git/Centurion
 public function testAttach()
 {
     $signal = Centurion_Signal::factory('pre_init');
     $signal->connect(array($this, 'handler'));
     $signal->send('handler');
 }
コード例 #16
0
ファイル: Login.php プロジェクト: netconstructor/Centurion
 /**
  * Returns true if and only if $value passes all validations in the chain
  *
  * Validators are run in the order in which they were added to the chain (FIFO).
  *
  * @param  mixed $value
  * @return boolean
  */
 public function isValid($value, $context = null)
 {
     $adapter = new $this->_authAdapter($this->_dbAdapter, $this->_tableName, $this->_loginColumn, $this->_passwordColumn, $this->_saltingMechanism);
     $adapter->setIdentity($context['login']);
     $adapter->setCredential($value);
     if (null !== $this->_checkColumn) {
         $adapter->getDbSelect()->where($this->_checkColumn);
     }
     try {
         $result = Centurion_Auth::getInstance()->authenticate($adapter);
     } catch (Zend_Auth_Exception $e) {
         $this->_error(self::DB_INVALID);
         return false;
     }
     if ($result->isValid()) {
         Centurion_Signal::factory('pre_login')->send(null, $adapter);
         $result = $adapter->getResultRowObject(null);
         Centurion_Auth::getInstance()->clearIdentity();
         Centurion_Auth::getInstance()->getStorage()->write($result);
         //Zend_Session::writeClose(false);
         Centurion_Signal::factory('post_login')->send(null, $result);
         return true;
     }
     $this->_error(self::NOT_MATCH);
     return false;
 }
コード例 #17
0
ファイル: Form.php プロジェクト: rom1git/Centurion
 /**
  * Render form
  *
  * @param  Zend_View_Interface $view
  * @return string
  */
 public function render(Zend_View_Interface $view = null)
 {
     if (null == $this->getElement('formId')) {
         $this->addElement('hidden', 'formId', array('value' => $this->getFormId()));
         //fix #6328 (hidden element bordered in dom)
         $this->getElement('formId')->setDecorators(array('ViewHelper'));
     }
     Centurion_Signal::factory('on_form_rendering')->send($this);
     if ($this->_clear) {
         $this->renderError();
         foreach ($this->getSubForms() as $key => $form) {
             $form->renderError();
         }
     }
     $this->setDisableTranslator(true);
     return parent::render($view);
 }
コード例 #18
0
ファイル: CRUD.php プロジェクト: rom1git/Centurion
 protected function _cleanCache()
 {
     Centurion_Signal::factory('clean_cache')->send($this, array(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array_merge($this->_cacheTagName, array(sprintf('CRUD_%s', $this->_getModel()->info(Centurion_Db_Table_Abstract::NAME))))));
 }
コード例 #19
0
ファイル: DbTable.php プロジェクト: rom1git/Centurion
 public function init()
 {
     Centurion_Signal::factory('on_select_joinInner')->connect(array($this, 'onJoinInner'), $this->_model->getSelectClass());
 }
コード例 #20
0
 protected function _initSignals()
 {
     //TODO: do it only once
     $resource = $this->getResourceLoader()->getResourceType('signals');
     Centurion_Signal::getPluginLoader()->addPrefixPath($resource['namespace'], $resource['path']);
 }
コード例 #21
0
ファイル: Form.php プロジェクト: netconstructor/Centurion
 /**
  * Populate form
  *
  * Proxies to {@link setDefaults()}
  *
  * @param  array $values
  * @return Zend_Form
  */
 public function populate(array $values)
 {
     Centurion_Signal::factory('pre_populate')->send($this, array($values));
     return parent::populate($values);
 }
コード例 #22
0
ファイル: Action.php プロジェクト: netconstructor/Centurion
 public function postDispatch()
 {
     parent::postDispatch();
     Centurion_Signal::factory('post_dispatch')->send($this);
 }
コード例 #23
0
ファイル: Select.php プロジェクト: rom1git/Centurion
 public function joinInner($name, $cond, $cols = self::SQL_WILDCARD, $schema = null)
 {
     parent::joinInner($name, $cond, $cols, $schema);
     Centurion_Signal::factory('on_select_joinInner')->send($this, array($this, $name));
     return $this;
 }
コード例 #24
0
ファイル: Abstract.php プロジェクト: netconstructor/Centurion
 /**
  * Allows post-delete logic to be applied to row.
  * Subclasses may override this method.
  *
  * @return void
  */
 protected function _postDelete()
 {
     Centurion_Signal::factory('post_delete')->send($this);
 }
コード例 #25
0
 protected function _initSignals()
 {
     Centurion_Signal::factory('post_login')->connect(array($this, 'registerProfile'));
 }
コード例 #26
0
ファイル: Install.php プロジェクト: rom1git/Centurion
 public function acl($env)
 {
     $this->bootstrap($env);
     $application = $this->_application;
     $bootstrap = $application->getBootstrap();
     $front = $bootstrap->getResource('FrontController');
     $modules = $front->getControllerDirectory();
     $default = $front->getDefaultModule();
     $curBootstrapClass = get_class($bootstrap);
     $options = $bootstrap->getOption('resources');
     $options = $options['modules'];
     if (is_array($options) && !empty($options[0])) {
         $diffs = array_diff($options, array_keys($modules));
         if (count($diffs)) {
             throw new Centurion_Application_Resource_Exception(sprintf("The modules %s is not found in your registry (%s)", implode(', ', $diffs), implode(PATH_SEPARATOR, $modules)));
         }
         foreach ($modules as $key => $module) {
             if (!in_array($key, $options) && $key !== $default) {
                 unset($modules[$key]);
                 $front->removeControllerDirectory($key);
             }
         }
         $modules = Centurion_Inflector::sortArrayByArray($modules, array_values($options));
     }
     require_once APPLICATION_PATH . '/../library/Centurion/Contrib/auth/models/DbTable/Permission.php';
     require_once APPLICATION_PATH . '/../library/Centurion/Contrib/auth/models/DbTable/Row/Permission.php';
     $permissionTable = Centurion_Db::getSingleton('auth/permission');
     foreach ($modules as $module => $moduleDirectory) {
         echo "\n\n" . 'Scan new module: ' . $module . "\n";
         $bootstrapClass = $this->_formatModuleName($module) . '_Bootstrap';
         $modulePath = dirname($moduleDirectory);
         $dataPath = $modulePath . '/controllers/';
         if (is_dir($dataPath)) {
             $db = Zend_Db_Table::getDefaultAdapter();
             foreach (new DirectoryIterator($dataPath) as $file) {
                 if ($file->isDot() || !$file->isFile()) {
                     continue;
                 }
                 if (substr($file, 0, 5) !== 'Admin') {
                     continue;
                 }
                 $controllerName = substr($file, 5, -14);
                 $object = Centurion_Inflector::tableize($controllerName, '-');
                 $tab = array('index' => 'View %s %s index', 'list' => 'View %s %s list', 'get' => 'View an %s %s', 'post' => 'Create an %s %s', 'new' => 'Access to creation of an %s %s', 'delete' => 'Delete an %s %s', 'put' => 'Update an %s %s', 'batch' => 'Batch an %s %s', 'switch' => 'Switch an %s %s');
                 foreach ($tab as $key => $description) {
                     list($row, $created) = $permissionTable->getOrCreate(array('name' => $module . '_' . $object . '_' . $key));
                     if ($created) {
                         echo 'Create permission: ' . $module . '_' . $object . '_' . $key . "\n";
                         $row->description = sprintf($description, $module, $object);
                         $row->save();
                     }
                 }
             }
         }
     }
     Centurion_Loader_PluginLoader::clean();
     Centurion_Signal::factory('clean_cache')->send($this);
 }
コード例 #27
0
ファイル: Action.php プロジェクト: rom1git/Centurion
 /**
  * To disseminate the defined main object to the platform
  * @param mixed $object
  */
 public function definingMainObject($object)
 {
     Centurion_Signal::factory('on_defining_main_object')->send($this, array($object));
 }
コード例 #28
0
ファイル: Abstract.php プロジェクト: rom1git/Centurion
 /**
  * Deletes existing rows.
  *
  * @param  array|string $where SQL WHERE clause(s).
  * @return int          The number of rows deleted.
  */
 public function delete($where)
 {
     Centurion_Signal::factory('pre_delete')->send($this, array($where));
     list($found, $return) = Centurion_Traits_Common::checkTraitOverload($this, 'delete', array($where));
     if (!$found) {
         $return = parent::delete($where);
     }
     Centurion_Signal::factory('post_delete')->send($this, array($where));
     return $return;
 }
コード例 #29
0
ファイル: Row.php プロジェクト: rom1git/Centurion
 public function init()
 {
     parent::init();
     Centurion_Signal::factory('pre_save')->connect(array($this, 'preSave'), $this->_row);
 }
コード例 #30
0
ファイル: Model.php プロジェクト: rom1git/Centurion
 public function __construct($form)
 {
     parent::__construct($form);
     Centurion_Signal::factory('pre_generate')->connect(array($this, 'preGenerate'), $form);
     Centurion_Signal::factory('pre_save')->connect(array($this, 'preSave'), $form);
 }