Exemple #1
0
 public static function execute()
 {
     if ($uri = trim(router::$uri, '/')) {
         router::$arguments = explode('/', $uri);
         router::$module = array_shift(router::$arguments);
         router::$controller = array_shift(router::$arguments);
         router::$action = array_shift(router::$arguments);
     } else {
         //当$uri 为空,则尝试Query_string模式
         router::$arguments = $_GET;
         router::$module = arr::take('module', router::$arguments);
         router::$controller = arr::take('controller', router::$arguments);
         router::$action = arr::take('action', router::$arguments);
     }
 }
Exemple #2
0
 public static function navbar($data, $current = '')
 {
     $html = array();
     if (is_array($data)) {
         $current = empty($current) ? router::action() : $current;
         $current = empty($current) ? $data[0]['id'] : $current;
         $html[] = '';
         $html[] = '<div class="navbar">';
         $html[] = '	<ul>';
         foreach ($data as $item) {
             if (is_array($item)) {
                 $class = $current == $item['id'] ? 'current' : (empty($item['href']) ? 'hidden' : 'normal');
                 $href = empty($item['href']) ? '#' : $item['href'];
                 $html[] = '		<li class="' . $item['class'] . ' ' . $class . '"><a href="' . $href . '"  id="' . $item['id'] . '"><span>' . $item['title'] . '</span></a></li>';
             } else {
                 $html[] = '		<li class="' . $item['class'] . ' ' . $class . '">' . $item . '</li>';
             }
         }
         $html[] = '	</ul>';
         $html[] = '</div>';
     }
     echo implode("\n", $html);
 }
Exemple #3
0
 /**
  * 解析URI
  * 
  * URI 由模块名/控制器/动作/参数组成,采用如下的格式:
  *
  * @code php
  * module/controller/action/param1/vlaue1/param2/value2
  * @endcode
  *
  */
 public static function execute()
 {
     if ($uri = trim(router::$uri, '/')) {
         router::$arguments = explode('/', $uri);
         //分配module、controller、action
         router::$module = array_shift(router::$arguments);
         router::$controller = array_shift(router::$arguments);
         router::$action = array_shift(router::$arguments);
         //处理参数
         $arguments = array();
         for ($i = 0, $cnt = count(router::$arguments); $i < $cnt; $i++) {
             $arguments[$i] = rawurldecode(router::$arguments[$i]);
         }
         router::$arguments = $arguments;
         //unset($_GET['zotop']);
         //$_GET = array_merge($_GET, array('module'=>router::$module,'controller'=>router::$controller,'action'=>router::$action), $arguments);
     } else {
         //当$uri 为空,则尝试Query_string模式
         router::$arguments = $_GET;
         router::$module = arr::take('module', router::$arguments);
         router::$controller = arr::take('controller', router::$arguments);
         router::$action = arr::take('action', router::$arguments);
     }
 }
Exemple #4
0
 /**
  * 返回当前URL路由的动作名称,未能获取则返回当前应用的默认动作
  *
  * @return string
  */
 public static function action()
 {
     $action = router::action();
     if (empty($action)) {
         $action = application::$action;
     }
     return $action;
 }
Exemple #5
0
 public static function controllerMethod()
 {
     $action = router::action();
     if ($action) {
         return 'on' . ucfirst($action);
     }
     return 'onDefault';
 }
Exemple #6
0
 /**
  * 返回当前URL路由的动作名称,未能获取则返回当前应用的默认动作
  *
  * @return string
  */
 public static function getAction()
 {
     $action = router::action();
     if (empty($action)) {
         $action = zotop::application(APP_NAME, 'action');
     }
     return empty($action) ? 'default' : $action;
 }