public function url($urlOptions = array(), $name = null, $reset = false, $encode = true) { if (!$urlOptions) { $urlOptions = array(); } if (!$name) { if (Staticroute::getCurrentRoute() instanceof Staticroute) { $name = Staticroute::getCurrentRoute()->getName(); } } if ($name && ($route = Staticroute::getByName($name))) { return $route->assemble($urlOptions, $reset, $encode); } // this is to add support for arrays as values for the default Zend_View_Helper_Url $unset = array(); foreach ($urlOptions as $optionName => $optionValues) { if (is_array($optionValues)) { foreach ($optionValues as $key => $value) { $urlOptions[$optionName . "[" . $key . "]"] = $value; } $unset[] = $optionName; } } foreach ($unset as $optionName) { unset($urlOptions[$optionName]); } try { return parent::url($urlOptions, $name, $reset, $encode); } catch (Exception $e) { throw new Exception("Route '" . $name . "' for building the URL not found"); } }
private function deleteRouteIfExist($routeName) { $routeHinder = Staticroute::getByName($routeName); if ($routeHinder instanceof Staticroute) { $routeHinder->delete(); } }
/** * Check if at least one static route is present. * This is the minimum required for the plugin to work. * @return bool TRUE if at least one static route is present. */ public static function hasStaticRoutes() { $conf = self::getStaticRoutesConfig(); foreach ($conf->routes->route as $def) { $route = Staticroute::getByName($def->name); if ($route) { return true; } } return false; }
public function init() { parent::init(); try { $this->_locale = Zend_Registry::get('Zend_Locale'); } catch (Exception $e) { $this->_locale = new Zend_Locale('en'); Zend_Registry::set('Zend_Locale', $this->_locale); } $this->view->locale = $this->_locale; $this->_translate = $this->initTranslation(); $this->view->setScriptPath(array_merge($this->view->getScriptPaths(), array(PIMCORE_WEBSITE_PATH . '/views/scripts/', PIMCORE_WEBSITE_PATH . '/views/layouts/', PIMCORE_WEBSITE_PATH . '/views/scripts/blog/'))); // additional helpers $this->_helper->addPrefix('Modern_Controller_Action_Helper'); $this->view->addHelperPath('Modern/View/Helper', 'Modern_View_Helper_'); $this->_messenger = $this->_helper->getHelper('FlashMessenger'); Modern_View_Helper_FlashMessenger::setPartial('partial/messenger.php'); Zend_View_Helper_PaginationControl::setDefaultViewPartial('partial/paginator-search.php'); // fix main blog list pagination if (!Staticroute::getCurrentRoute() instanceof Staticroute) { Staticroute::setCurrentRoute(Staticroute::getByName('blog')); } }
public function removeStaticRoutes() { $conf = new Zend_Config_Xml(PIMCORE_PLUGINS_PATH . '/Blog/install/staticroutes.xml'); foreach ($conf->routes->route as $def) { $route = Staticroute::getByName($def->name); if ($route) { $route->delete(); } } }