/** * URL Generator for Smarty Templates. * * Examples: * {link_to href="/news/show"} * * Type: function<br> * Name: a<br> * Purpose: Generates the proper URL from the href parameter given<br> * * @param array $params * * @return string */ function Smarty_function_link_to($params) { // method parameter "href" if (empty($params['href'])) { $errormessage = 'You are using the <font color="#FF0033">{link_to}</font> command, but the <font color="#FF0033">Parameter "href" is missing.</font>'; $errormessage .= ' Try to append the parameter in the following way: <font color="#66CC00">href="/news/show"</font>.'; trigger_error($errormessage); return; } else { // convert from internal slashed format to URL return \Koch\Router\Router::buildURL($params['href']); } }
/** * array_map callback function. * * 1) convert short urls * 2) execute callback conditions of menu items * 3) use name as title, if title is not defined * * @param array $modulenavigation */ function applyCallbacks(array $modulenavigation) { /* * 1) Convert Short Urls * * This replaces the values of the 'url' key (array['url']), * because these might be shorthands, like "/index/show". */ $modulenavigation['url'] = \Koch\Router\Router::buildURL($modulenavigation['url']); /* * 2) Conditions of menu items * * If the condition of the menu item is not met, * then condition is set to false, otherwise true. */ if ($modulenavigation['condition'] !== null) { /* * the if statement evaluates the content of the key condition * and compares it to false, then reassigns the boolean value as * the condition value. * * for now you might define 'condition' => extension_loaded('apc') * * @todo check usage of closures */ if ($modulenavigation['condition'] === false) { $modulenavigation['condition'] = false; } else { $modulenavigation['condition'] = true; } } /* * 3) use name as title, if title is not defined */ if ($modulenavigation['title'] === '') { $modulenavigation['title'] = $modulenavigation['name']; } return $modulenavigation; }
/** * Set action of this form (which is the target url). * * @param $action string Target URL of the action of this form. * @return Koch_Form */ public function setAction($action) { $this->action = \Koch\Router\Router::buildURL($action); return $this; }