public static function dispatch($request) { $registry = Registry::getInstance(); $config = $registry->get('config'); $carray = $config->getArray(); self::$_request = $request; if (self::$_request->isComponent()) { $componente = self::$_request->getComponent(); restore_include_path(); set_include_path('../lib/' . PATH_SEPARATOR . get_include_path()); set_include_path('../app/Components/' . $componente . '/app/' . PATH_SEPARATOR . get_include_path()); set_include_path('../app/Components/' . $componente . '/app/Controller/' . PATH_SEPARATOR . get_include_path()); set_include_path('../app/Model/' . PATH_SEPARATOR . get_include_path()); self::initSite('../app/Components/' . $componente . '/app/Config/config.ini', $componente); self::$_request->constructsFromGet(); } if ($carray['general']['debug'] != true) { ob_start(); } $controller = self::$_request->getController(); $action = self::$_request->getAction(); $params = self::$_request->getParams(); self::preController(); $app = self::runController(); self::postController(); if ($carray['general']['debug'] != true) { ob_end_clean(); } // Manage view ob_start(); $layout = NULL; if (!empty($carray['general']['layout'])) { $layout = $carray['general']['layout']; } $template = $app->getView()->getTemplate($layout); self::loadTemplate($app->getView(), $template); $output = ob_get_clean(); echo $output; }
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; }