Ejemplo n.º 1
0
 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';
     }
 }
Ejemplo n.º 2
0
 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];
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 public static function using($namespace, $loadNow = true)
 {
     $usingArray = Z_Global::get('@Z.USING', array());
     $ns = Z_Global::get('@Z.USING_NAMESPACES', array());
     $root = dirname(__FILE__) . '/Z';
     $ospace = $namespace;
     if (strpos($namespace, ':') !== false) {
         $namespace = explode(':', $namespace, 2);
         $space = $namespace[0];
         $space2 = $namespace[1];
         $namespace = implode(':', $namespace);
         if (isset($ns[$space])) {
             $root = $ns[$space];
             $ospace = $space2;
         }
     }
     if (substr($namespace, -1) == '*') {
         $namespace = str_replace('.', DIRECTORY_SEPARATOR, $namespace);
         $namespace = str_replace('*', '', $namespace);
         $usingArray[$namespace] = '';
     } else {
         $namespace = $ospace;
         $namespace = str_replace('.', DIRECTORY_SEPARATOR, $namespace);
         $tmp = explode(DIRECTORY_SEPARATOR, $namespace);
         $namespace .= '.php';
         $usingArray[$namespace] = $tmp[count($tmp) - 1];
         if ($loadNow) {
             include_once $root . $namespace;
         }
     }
     Z_Global::set('@Z.USING', $usingArray);
 }
Ejemplo n.º 5
0
 public static function clear()
 {
     self::$_dictionary = array();
 }