public function initialize() { $this->_controller = 'Index'; $this->_action = 'index'; $this->_params = array(); $config = Model3_Registry::get('config'); $configData = $config->getArray(); $this->_multilang = $configData['m3_internationalization']['inter_multilang']; $this->_lang = $configData['m3_internationalization']['inter_default_lang']; }
public function redirect($path = '', $useBaseUrl = true, $permanent = false) { $fullPath = $path; $config = Model3_Registry::get('config'); $configData = $config->getArray(); if ($configData['m3_internationalization']['inter_multilang'] == true) { $fullPath = $configData['m3_internationalization']['inter_default_lang'] . '/' . $path; } if ($useBaseUrl == true) { $fullPath = $this->_request->getBaseUrl() . '/' . $fullPath; } if ($permanent == true) { header("HTTP/1.1 301 Moved Permanently"); } header('Location: ' . $fullPath); exit; }
public function url($options = null, $propague = false) { $reset = false; $strlenController = 0; $strlenAction = 0; if ($options == null) { $options = array(); } $url = $this->_baseUrl . '/'; $config = Model3_Registry::get('config'); $configData = $config->getArray(); if ($configData['m3_internationalization']['inter_multilang'] == true) { if (array_key_exists('lang', $options)) { $url .= $options['lang']; $url .= '/'; } else { $url .= $this->_request->getLang(); $url .= '/'; } } if (array_key_exists('component', $options)) { if ($options['component'] != null) { $url .= $options['component']; $url .= '/'; $reset = true; } unset($options['component']); } else { if ($this->_request->isComponent()) { $url .= $this->_request->geComponent(); $url .= '/'; } } if (array_key_exists('module', $options)) { if ($options['module'] != null) { $url .= $options['module']; $url .= '/'; $reset = true; } unset($options['module']); } else { if ($this->_request->isModule()) { $url .= $this->_request->getModule(); $url .= '/'; } } if (array_key_exists('controller', $options)) { if ($options['controller'] != null) { $url .= $options['controller']; if ($options['controller'] == 'Index') { $strlenController = strlen($url); } $reset = true; } unset($options['controller']); } else { if (!$reset) { $url .= $this->_request->getController(); } else { $url .= 'Index'; $strlenController = strlen($url); } } $url .= '/'; if (array_key_exists('action', $options)) { if ($options['action'] != null) { $url .= $options['action']; if ($options['action'] == 'index') { $strlenController = strlen($url); } } unset($options['action']); } else { if (!$reset) { $url .= $this->_request->getAction(); } else { $url .= 'index'; $strlenAction = strlen($url); } } $url .= '/'; if ($propague == true) { $params = $this->_request->getParams(); foreach ($params as $key => $param) { if (array_key_exists($key, $options)) { if ($options[$key] != null) { $url .= $key . '/'; $url .= $options[$key]; $url .= '/'; } unset($options[$key]); } else { $url .= $key . '/'; $url .= $param; $url .= '/'; } } } foreach ($options as $key => $option) { $url .= $key . '/' . $option . '/'; } /** * Limpiaremos la url en caso de que termine en index/ o en Index/index/ */ if ($strlenAction != 0 && $strlenAction + 1 == strlen($url)) { if ($strlenController != 0 && $strlenController + 1 == strlen($url)) { $url = substr($url, 0, $strlenController - 5); } else { $url = substr($url, 0, $strlenAction - 5); } } return $url; }