public function __construct() { $this->_requestMethod = strtoupper($_SERVER['REQUEST_METHOD']); switch ($this->_requestMethod) { case 'POST': $this->_data = array_merge($_GET, $_POST); break; case 'GET': default: $this->_data = array_merge($_POST, $_GET); break; } if (isset($_GET[Z_Global::getSubkey('@Z.CONFIG', 'action_var', 'a')])) { $this->_action = $_GET[Z_Global::getSubkey('@Z.CONFIG', 'action_var', 'a')]; } else { $this->_action = 'index'; } if (isset($_GET[Z_Global::getSubkey('@Z.CONFIG', 'controller_var', 'c')])) { $this->_controller = $_GET[Z_Global::getSubkey('@Z.CONFIG', 'controller_var', 'c')]; } else { $this->_controller = 'index'; } if (isset($_GET[Z_Global::getSubkey('@Z.CONFIG', 'module_var', 'm')])) { $this->_module = $_GET[Z_Global::getSubkey('@Z.CONFIG', 'module_var', 'm')]; } else { $this->_module = 'default'; } }
public static function getInstance($name = null) { $class = __CLASS__; if ($name == null) { $db_conf = Z_Global::getSubkey('@Z.Config', 'Database'); $db_conf = $db_conf['default']; $name = 'default'; } elseif (is_string($name)) { $dbconfig = Z_Global::getSubkey('@Z.Config', 'Database'); $db_conf = $dbconfig[$name]; } else { $db_conf = $name; $name = $db_conf['name']; } if (!isset(self::$_Instance[$name])) { self::$_Instance[$name] = new $class($db_conf); } return self::$_Instance[$name]; }
public function generateUrl($action = 'index', $controller = 'index', $module = 'default', $data = array()) { foreach ($this->routers as $router) { $url = $router->generateUrl($action, $controller, $module, $data); if ($url) { return $url; } } $request_uri = $_SERVER['REQUEST_URI']; $tmp = explode('?', $request_uri, 2); $request_uri = $tmp[0]; $main = $request_uri; //if (substr($main, -1) != '/') // $main .= ' if (substr($main, 0, 1) != '/') { $main = "/{$main}"; } if ($action != 'index') { $data[Z_Global::getSubkey('@Z.Config', 'action_var', 'a')] = $action; } if ($module != 'default') { $data[Z_Global::getSubkey('@Z.Config', 'module_var', 'm')] = $module; } if ($controller != 'index') { $data[Z_Global::getSubkey('@Z.Config', 'controller_var', 'c')] = $controller; } $cnt = 0; foreach ($data as $key => $value) { if ($cnt == 0) { $main .= '?'; } else { $main .= '&'; } $main .= urlencode($key) . '=' . urlencode($value); $cnt++; } return $main; }