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)); }
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); }
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); }
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; } }
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); }
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'); }
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; }
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); }
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 }
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); }
/** * (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); }
/** * @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'); }
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); }
public function testAttach() { $signal = Centurion_Signal::factory('pre_init'); $signal->connect(array($this, 'handler')); $signal->send('handler'); }
/** * 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; }
/** * 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); }
/** * 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; }
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; }
/** * 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)); $return = parent::delete($where); Centurion_Signal::factory('post_delete')->send($this, array($where)); return $return; }
protected function _initSignals() { Centurion_Signal::factory('post_login')->connect(array($this, 'registerProfile')); }
/** * @param $env * @param bool $acceptAll * @param bool $ignoreLaunched * @throws Exception * @throws Centurion_Application_Resource_Exception * * @todo: rajouter la gestion des php * @todo: refractoring */ public function update($env, $acceptAll = false, $ignoreLaunched = true) { if ($acceptAll === 'true') { $acceptAll = true; } if ($ignoreLaunched === 'true') { $ignoreLaunched = true; } if ($acceptAll === 'false') { $acceptAll = false; } if ($ignoreLaunched === 'false') { $ignoreLaunched = false; } $this->bootstrap($env); $application = $this->_application; $bootstrap = $application->getBootstrap(); $front = $bootstrap->getResource('FrontController'); $modules = $front->getControllerDirectory(); $default = $front->getDefaultModule(); $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)); } $db = Zend_Db_Table::getDefaultAdapter(); foreach ($modules as $module => $moduleDirectory) { $modulePath = dirname($moduleDirectory); $dataPath = $modulePath . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR; echo $dataPath; if (is_dir($dataPath)) { echo 'Open ' . $dataPath . "\n"; $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dataPath, FilesystemIterator::SKIP_DOTS | FilesystemIterator::KEY_AS_FILENAME)); $files = iterator_to_array($files); ksort($files); $files = array_merge(array('schema.sql' => null, 'data.sql' => null), $files); foreach ($files as $file) { if (null == $file) { continue; } if ($file->isDir()) { continue; } if (Centurion_Inflector::extension($file) !== '.sql') { continue; } $choice = null; if (file_exists($file->getPathname() . '.' . APPLICATION_ENV . '.done')) { if ($ignoreLaunched) { continue; } if (!$acceptAll) { echo sprintf('The file %s seems to be already executed. Do you want to launch it?' . "\n", $file->getPathname()); } } if (!$acceptAll) { echo sprintf('Find a new file file %s. Do you want to launch it?' . "\n", $file->getPathname()); } else { $choice = '1'; } if (null == $choice) { do { echo '1) Execute' . "\n"; echo '2) Ignore' . "\n"; echo '3) Mark it without execute it' . "\n"; echo '? '; $choice = trim(fgets(STDIN)); } while (!in_array($choice, array('1', '2', '3'))); } if ($choice == '2') { echo "\n\n"; continue; } if ($choice == '1') { echo sprintf('Exec the file %s' . "\n", $file->getPathname()); try { $db->beginTransaction(); $query = ''; foreach (new SplFileObject($file->getPathname()) as $line) { $query .= $line; if (substr(rtrim($query), -1) == ';') { $statement = $db->query($query); $statement->closeCursor(); unset($statement); $query = ''; } } $db->commit(); } catch (Exception $e) { $db->rollback(); throw $e; } } touch($file->getPathname() . '.' . APPLICATION_ENV . '.done'); echo "\n\n"; } } } Centurion_Loader_PluginLoader::clean(); Centurion_Signal::factory('clean_cache')->send($this); }
/** * 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); }
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)))))); }
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); }
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); }
/** * 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); }
public function init() { Centurion_Signal::factory('on_select_joinInner')->connect(array($this, 'onJoinInner'), $this->_model->getSelectClass()); }
public function postDispatch() { parent::postDispatch(); Centurion_Signal::factory('post_dispatch')->send($this); }
public function init() { parent::init(); Centurion_Signal::factory('pre_save')->connect(array($this, 'preSave'), $this->_row); }
/** * 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)); }