/** * @name view * @param unknown_type $arg * @package give you a temple html */ public function view($arg = null) { global $router, $match; $path = $this->stdClass; if ($arg != null) { $path = $arg; //echo $path; } else { if (!is_file(LIBS)) { CacheLibs(); } include LIBS; $m_lib = unserialize($_libs); $dir = explode("lib", $m_lib[$this->stdClass]); $path = substr($dir[1], 0, -4); //echo $path; } // 引入 头文件 $this->common($this->headClass); $rest = display($path); return $rest; }
/** * * @name load * @param unknown_type $stdClass * @package load lang file * @return null */ private function load($stdClass) { $this->stdClass = $stdClass; $seg = getSeg(); if (!is_file(LIBS)) { CacheLibs(); } include LIBS; $m_lib = unserialize($_libs); //echo $m_lib[$this->stdClass]."--"; $langDir = ""; if (array_key_exists($this->stdClass, $m_lib)) { $dn = dirname($m_lib[$this->stdClass]); $dir = explode("lib", $dn); $langDir = $dir[1]; } if (is_file(LANG . $seg . $langDir . $seg . $this->stdClass . ".php")) { include_once LANG . $seg . $langDir . $seg . $this->stdClass . ".php"; } else { if (is_file(LANG . $this->stdClass . ".php")) { include_once LANG . $this->stdClass . ".php"; } else { //echo LANG.$seg.$langDir.$seg.$this->stdClass.".php<br />"; return; //throw new \Exception("Lib '{$stdClass}' lang does not exist."); } } $class = "_" . $this->stdClass; if (class_exists($class)) { if ($stdClass == LANG_COMMON) { $this->langComm = new $class(); } else { $this->langClass = new $class(); } } }
/** * Reversed routing * * url the URL for a named route. Replace regexes with supplied parameters * * @param string $routeName The name of the route. * @param array @params Associative array of parameters to replace placeholders with. * @return string The URL of the route with named parameters in place. */ public function url($routeName, array $params = array()) { // Check if named route exists if (!isset($this->namedRoutes[$routeName])) { //echo "Route '{$routeName}' does not exist."; CacheLibs(); //throw new \Exception("Route '{$routeName}' does not exist. are you flush it"); } // Replace named parameters $route = $this->namedRoutes[$routeName]; // prepend base path to route url again $url = $this->basePath . $route; if (preg_match_all('`(/|\\.|)\\[([^:\\]]*+)(?::([^:\\]]*+))?\\](\\?|)`', $route, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { list($block, $pre, $type, $param, $optional) = $match; if ($pre) { $block = substr($block, 1); } if (isset($params[$param])) { $url = str_replace($block, $params[$param], $url); } elseif ($optional) { $url = str_replace($pre . $block, '', $url); } } } return $url; }
/** * @name PermissionMap * @package 自动装载 后台 lib */ function PermissionMap() { global $routeMap; if (!is_file(LIBS)) { CacheLibs(); } include LIBS; $m_lib = unserialize($_libs); $admin_map_urls = unserialize(ADMIN_MAP_URL); foreach ($m_lib as $k => $v) { $amu = basename(dirname($v)); $lib = substr(basename($v), 0, -4); if (!preg_match("/index/i", $lib)) { if (in_array($amu, $admin_map_urls)) { $routeMap[] = array('method' => 'GET|POST', 'uri' => '/' . $lib . '/[' . ADMIN_ACL_ACTION . ':action]', 'params' => 'usersController#doAction', 'module' => $lib); } } } }