/** * Clean the cache for the structure and the page content * @param int $safinstancesId * @return Boolean */ public function clearPageCache($safinstancesId) { try { PagstructureOp::cleanCache($safinstancesId); foreach (glob($this->cachePath . '/zend_cache---internal-metadatas---publicms_*') as $filename) { unlink($filename); } foreach (glob($this->cachePath . '/zend_cache---publicms_*') as $filename) { unlink($filename); } return true; } catch (Exception $e) { return false; } }
/** * * @param $id * @return unknown_type */ public function unpublish($id) { $safeInstanceId = Zend_Registry::getInstance()->get('config')->get('db')->safinstances_id; $sql = "UPDATE pagstructure SET status = 'draft',datemodified=NOW(),who_modified = '" . Sydney_Tools::who() . "' WHERE id = " . $id; $this->_db->query($sql); // clean cache of the structure PagstructureOp::cleanCache($safeInstanceId); // clean cache of pages $cache = new Sydney_Cache_Manager(); $cache->clearPageCache($safeInstanceId); }
/** * */ public function editadvancedprocessAction() { $r = $this->getRequest(); $eid = 0; if ($r->id > 0) { $nodeDB = new Pagstructure(); $node = $nodeDB->fetchRow('id = ' . $r->id . ' AND safinstances_id = ' . $this->safinstancesId); $node->metakeywords = $r->metakeywords; $node->metadesc = $r->metadesc; $node->iscachable = $r->iscachable; $node->cachetime = $r->cachetime; $node->redirecttoid = $r->redirecttoid; $node->shortdesc = $r->shortdesc; $node->colorcode = $r->colorcode; $node->layout = $r->layout; $node->save(); $eid = $r->id; // GDE : 27/08/2010 - Add trace of current action Sydney_Db_Trace::add('trace.event.update_advanced_properties' . ' [' . $node->label . ']', 'adminpages', Sydney_Tools::getTableName($nodeDB), 'editadvancedproperties', $eid); } // update the linked menu $mns = new PagstructurePagmenus(); $mns->delete('pagstructure_id = ' . $eid); //Zend_Debug::dump($r->menus); if (is_array($r->menus)) { foreach ($r->menus as $mid) { $crow = $mns->createRow(); $crow->pagstructure_id = $eid; $crow->pagmenus_id = $mid; $crow->save(); } } PagstructureOp::cleanCache($this->safinstancesId); $this->redirect('/adminpages/pages/edit/id/' . $eid); }
/** * Updates the structure order for all posted nodes (for the current saf instance). * URL : /adminpages/services/updatestrorder/format/json * @return void */ public function updatestrorderAction() { $msg = 'error! Generic'; $status = 0; try { $data = Zend_Json::decode($this->getRequest()->jsondata); $i = 0; $sql = ''; foreach ($data as $n) { $sql .= "UPDATE pagstructure SET\n\t\t\t\t\t\t\tparent_id = '" . $n['parentid'] . "',\n\t\t\t\t\t\t\tpagorder = '" . $n['ndborder'] . "'\n\t\t\t\t\t\t\tWHERE id = '" . $n['dbid'] . "'\n\t\t\t\t\t\t\tAND safinstances_id='" . $this->safinstancesId . "'; "; $i++; } $this->_db->query($sql); $msg = 'Structure order updated. ' . $i . ' nodes affected.'; PagstructureOp::cleanCache($this->safinstancesId); $status = 1; Sydney_Db_Trace::add('trace.event.reorder_page', 'adminpages', 'pagstructure', 'updatepageorder', '', ''); // */ } catch (Exception $e) { $msg = 'error! the order could not be saved. error : ' . $e; $status = 0; } $this->view->ResultSet = array('message' => $msg, 'status' => $status, 'modal' => false); }
public function __construct($id = 0) { $this->_schema = Sydney_Tools_Sydneyglobals::getConf()->db->params->dbname; parent::__construct($id); }
/** * Auto initialization of important params for sydney * @return void */ public function init() { // register general sydney helpers $this->view->addHelperPath(Sydney_Tools_Paths::getCorePath() . '/library/Sydney/View/Helper', 'Sydney_View_Helper'); $this->_initWebInstanceHelpers(); // setup the basics $this->_registry = Zend_Registry::getInstance(); $this->_config = $this->_registry->get('config'); $this->_db = $this->_registry->get('db'); $this->safinstancesId = $this->_config->db->safinstances_id; $this->_translate = $this->_registry->get('Zend_Translate'); $this->view->translate = $this->_registry->get('Zend_Translate'); $this->_auth = Sydney_Auth::getInstance(); // Auto Login if identity and credentials stored in cookie $u = $this->getRequest()->getParam('username'); $p = $this->getRequest()->getParam('password'); if (!$this->_auth->hasIdentity() && $this->_getParam('action') != 'login' && $this->_getParam('action') != 'logout' && empty($u) && empty($p)) { $adapter = Sydney_Auth_Adaptater_DbTable::getAuthAdapter($this->getRequest()); if ($adapter instanceof Zend_Auth_Adapter_Interface) { $auth = Sydney_Auth::getInstance(); if ($auth->authenticate($adapter)->isValid()) { $this->_helper->redirector->gotoUrl($this->getRequest()->getRequestUri()); exit; } } } // Init list secured pages $this->setAuthPagelist(); // setup user $udata = new Zend_Session_Namespace('userdata'); if (isset($udata->user)) { $this->usersData = $udata->user; } if (isset($this->usersData['users_id'])) { $this->usersId = $this->usersData['users_id']; } // sets some interesting vars in the view $this->view->config = $this->_config; $this->view->cdn = $this->_config->general->cdn; $this->view->users_data = $this->usersData; $this->view->safinstances_id = $this->safinstancesId; $this->view->auth = $this->_auth; $this->view->siteTitle = $this->_config->general->siteTitle; $this->view->printme = $this->_getParam('printme', 'no'); // @todo TODO change this ... $llg = 'en'; if (isset($this->_config->general->lang) && $this->_config->general->lang != '') { $llg = $this->_config->general->lang; } $this->view->headScript()->appendFile($this->view->cdn . '/sydneyassets/scripts/i18n/' . $llg . '.js', 'text/javascript'); // setup some layout vars if ($this->layout !== null) { $this->layout->registry = $this->_registry; $this->layout->auth = $this->_auth; $this->layout->translate = $this->_registry->get('Zend_Translate'); $this->layout->avmodules = $this->availableModules; } $this->view->moduleName = $this->_getParam('module'); $this->view->controllerName = $this->_getParam('controller'); $this->view->actionName = $this->_getParam('action'); // set up the log $this->logger = new Sydney_Log(); $this->logger->setEventItem('className', get_class($this)); $this->logger->addFilterDatabase(); if (isset($this->getRequest()->sydneylayout) && $this->getRequest()->sydneylayout == 'no') { $this->_helper->layout->disableLayout(); $this->sydneyLayout = 'no'; } if (isset($this->getRequest()->sydneylayout) && $this->getRequest()->sydneylayout != 'no' && $this->getRequest()->sydneylayout != 'yes') { $this->_helper->layout->setLayout('layout-' . $this->getRequest()->sydneylayout); } $this->view->sydneylayout = $this->sydneyLayout; /** * load structure if not exist */ if (!is_array($this->view->structure) && $this->getRequest()->layout != 'no') { $this->structure = new Pagstructure(); $this->view->adminmode = false; // if identified then get structure from database if (Sydney_Auth::getInstance()->hasIdentity()) { $this->structure->setFilter('status', 'published'); $this->view->structure = $this->structure->toArray($this->safinstancesId); } else { // else use structure cached or build cache $cache = Zend_Registry::get('cache'); $cn = PagstructureOp::getCacheNames($this->safinstancesId); $this->view->structure = $cache->load($cn[0]); //cn[0] > cachename $this->structure->stringNodes = $cache->load($cn[1]); //cn[1] > cachename2 if (!is_array($this->view->structure)) { $this->structure->setFilter('status', 'published'); $this->view->structure = $this->structure->toArray($this->safinstancesId); $cache->save($this->view->structure, $cn[0]); $cache->save($this->structure->getStringNodes(), $cn[1]); } } $r = $this->getRequest(); if (isset($r->layout) && $r->layout == 'no') { Zend_Layout::getMvcInstance()->disableLayout(true); } $pages = $this->_getPageId(); $this->view->breadCrumData = $this->structure->getBreadCrumData($this->safinstancesId, $pages[0]); } // change language if necessary $settingsNms = new Zend_Session_Namespace('appSettings'); $curLang = $this->getCurrentLangCode(); if ($settingsNms->ApplicationLanguage != $curLang) { $settingsNms->ApplicationLanguage = $curLang; $bootstrapper = Zend_Registry::get('bootstrapper'); $bootstrapper->setRequestLang($curLang); $bootstrapper->setTranslationObject(); } $this->view->lang = $settingsNms->ApplicationLanguage; $pages = isset($pages) ? $pages : $this->_getPageId(); $this->_manageCanonicalLinks($pages[0]); }