controller()->url($action, $params); } /** * Retrieve base url * * @return string */ public function baseUrl() { return str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME'])); } /** * Retrieve url of magento * * @return string */ public function mageUrl() { return str_replace('\\', '/', dirname($this->baseUrl())); } /** * Include template * * @param string $name * @return string */ public function template($name) { ob_start(); include $this->controller()->filepath('template/'.$name); return ob_get_clean(); } /** * Set value for key * * @param string $key * @param mixed $value * @return Maged_Controller */ public function set($key, $value) { $this->_data[$key] = $value; return $this; } /** * Get value by key * * @param string $key * @return mixed */ public function get($key) { return isset($this->_data[$key]) ? $this->_data[$key] : null; } /** * Translator * * @param string $string * @return string */ public function __($string) { return $string; } /** * Retrieve link for header menu * * @param mixed $action */ public function getNavLinkParams($action) { $params = 'href="'.$this->url($action).'"'; if ($this->controller()->getAction()==$action) { $params .= ' class="active"'; } return $params; } /** * Retrieve Session Form Key * * @return string */ public function getFormKey() { return $this->controller()->getFormKey(); } /** * Escape html entities * * @param mixed $data * @param array $allowedTags * @return mixed */ public function escapeHtml($data, $allowedTags = null) { if (is_array($data)) { $result = array(); foreach ($data as $item) { $result[] = $this->escapeHtml($item); } } else { // process single item if (strlen($data)) { if (is_array($allowedTags) and !empty($allowedTags)) { $allowed = implode('|', $allowedTags); $result = preg_replace('/<([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)>/si', '##$1$2$3##', $data); $result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8', false); $result = preg_replace('/##([\/\s\r\n]*)(' . $allowed . ')([\/\s\r\n]*)##/si', '<$1$2$3>', $result); } else { $result = htmlspecialchars($data, ENT_COMPAT, 'UTF-8', false); } } else { $result = $data; } } return $result; } }