/** * @since 19/02/2014 */ public function getcleanurlpagebyidnodeAction() { $id = (int) $this->_getParam('id', null); $page = new Pagstructure(); $data = $page->get($id); $label = Sydney_Tools_Sydneyglobals::getConf('general')->url->newFormat && !empty($data['url']) ? $data['url'] : Sydney_Tools_Friendlyurls::getUrlLabel($data['label']); $this->view->resultSet = array('url' => Sydney_Tools_Friendlyurls::getFriendlyUrl($id, $label, 'page', new Zend_View_Helper_Url())); }
/** * Edit or create a node of the structure. * * @return void * @todo implement validators * @todo implement the advanced options (templates...) */ public function editprocessAction() { $vNotEmpty = new Zend_Validate_NotEmpty(); $r = $this->getRequest(); $eid = 0; if ($vNotEmpty->isValid($r->label)) { $table = new Pagstructure(); if ($r->ishome == '1') { $ishome = 1; $homeRowsTbl = new Pagstructure(); $homeRow = $homeRowsTbl->fetchRow('ishome = 1 AND safinstances_id = ' . $this->safinstancesId); if (is_object($homeRow)) { if (isset($homeRow->id) && $homeRow->id > 0 && $homeRow->id != $r->id) { $homeRow->ishome = 1; } else { $homeRow->ishome = 0; } } } else { $ishome = 0; } // Create a page if ($r->id <= 0 || !$r->id) { $oldnode = null; $data = array('label' => $r->label, 'htmltitle' => $r->htmltitle, 'url' => Sydney_Tools_Friendlyurls::getUrlLabel($r->url), 'parent_id' => $r->parent_id ? $r->parent_id : null, 'ishome' => $ishome, 'safinstances_id' => $this->safinstancesId, 'metakeywords' => '', 'metadesc' => '', 'iscachable' => '', 'cachetime' => '', 'redirecttoid' => '', 'usersgroups_id' => $r->usersgroups_id, 'shortdesc' => '', 'colorcode' => '', 'layout' => ''); $eid = $table->insert($data); // GDE : 27/08/2010 Add trace of current action Sydney_Db_Trace::add('trace.event.create_page' . ' [' . $r->label . ']', 'adminpages', Sydney_Tools::getTableName($table), 'createpage', $eid); } elseif ($r->id > 0) { // edit an entry $nodeDB = new Pagstructure(); $node = $nodeDB->fetchRow('id = ' . $r->id . ' AND safinstances_id = ' . $this->safinstancesId); // #120 - place on latest position in new node if parent change if ($node->parent_id != (int) $r->parent_id) { // get last position $node->pagorder = $nodeDB->getLatestPoitionInNode($r->parent_id); } /* * @change GDE - 05/2014 - Content Translation * Save translation of content (on native table for default language and on translation table for others) */ $node->label = $this->view->nodeTranslate->translate($node->label, $r->label, $r->id); $node->htmltitle = $this->view->nodeTranslate->translate($node->htmltitle, $r->htmltitle, $r->id, 'htmltitle'); $requestUrl = Sydney_Tools_Friendlyurls::getUrlLabel($r->url); $node->url = $this->view->nodeTranslate->translate($node->url, $requestUrl, $r->id, 'url'); $node->parent_id = $r->parent_id ? $r->parent_id : null; $node->ishome = $ishome; $node->redirecttoid = $r->redirecttoid; if ($node->usersgroups_id != $r->usersgroups_id) { $node->usersgroups_id = $r->usersgroups_id; $nodeDB->updateAccessRights($node->id, $r->usersgroups_id, true); } $node->save(); $eid = $r->id; // GDE : 27/08/2010 - Add trace of current action Sydney_Db_Trace::add('trace.event.update_page_properties' . ' [' . $r->label . ']', 'adminpages', Sydney_Tools::getTableName($nodeDB), 'editproperties', $eid); } // save the update of the homepage if everything went OK and we change the home page if ($r->ishome == '1' && is_object($homeRow) && $homeRow->id != $r->id) { $homeRow->save(); } } if ($eid > 0) { // update menu $mns = new PagstructurePagmenus(); $mns->delete('pagstructure_id = ' . $eid); 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); } }
/** * Cette m�thode va v�rifier le label de l'url (slug) * Si le label courant est diff�rent du label suppos�, on redirige vers le label suppos� * @author JTO * @since 19/02/2014 */ private function _checkUrlLabel() { $currentUrlLabel = trim($this->getRequest()->slug); $realUrlLabel = trim($this->view->thisnode['url']); $id = (int) $this->view->thisnode['id']; if (!empty($currentUrlLabel) && $this->view->thisnode) { // Cas 1 - Nouvelle url if (!empty($realUrlLabel)) { if ($realUrlLabel != $currentUrlLabel) { $url = Sydney_Tools_Friendlyurls::getFriendlyUrl($id, $realUrlLabel, 'page', new Zend_View_Helper_Url()); $this->redirect($url, array('code' => 301)); } } else { // On est dans l'ancien syst�me d'url ou le titrede la page = le label url // On doit donc calculer le label de l'url SUPPOSE et le confronter // au label re�u dans l'url // Si diff�rent on fait une redirection vers la VRAI url $supposedUrlLabel = Sydney_Tools_Friendlyurls::getUrlLabel($this->view->thisnode['label']); if ($supposedUrlLabel != $currentUrlLabel) { $url = Sydney_Tools_Friendlyurls::getFriendlyUrl($id, $supposedUrlLabel, 'page', new Zend_View_Helper_Url()); $this->redirect($url, array('code' => 301)); } } } }