Exemple #1
0
 public static function route()
 {
     self::$URI = isset($_SERVER['REDIRECT_URL']) ? explode('/', $_SERVER['REDIRECT_URL']) : NULL;
     self::$class = isset(self::$URI[URI_Level + 0]) ? self::$URI[URI_Level + 0] : 'main';
     self::$method = isset(self::$URI[URI_Level + 1]) ? self::$URI[URI_Level + 1] : 'index';
     $file_path = 'controllers/' . self::$class . '.php';
     if (!file_exists($file_path)) {
         self::$method = self::$class;
         self::$class = 'main';
         self::$params = isset(self::$URI[URI_Level + 1]) ? array_slice(self::$URI, URI_Level + 1) : array();
     } else {
         self::$params = isset(self::$URI[URI_Level + 2]) ? array_slice(self::$URI, URI_Level + 1) : array();
     }
     $file_path = 'controllers/' . self::$class . '.php';
     include_once $file_path;
     if (!method_exists(self::$class, self::$method)) {
         //echo '404';
         //echo self::$class, self::$method;
         show_404();
     }
     //Static Way
     //call_user_func_array(array(self::$class,self::$method),self::$params);
     //Normal?
     $class = new self::$class();
     call_user_func_array(array($class, self::$method), self::$params);
 }
Exemple #2
0
 public static function navbar($data, $current = '')
 {
     $html = array();
     if (is_array($data)) {
         $current = empty($current) ? router::method(false) : $current;
         $current = empty($current) ? $data[0]['id'] : $current;
         $html[] = '<div class="navbar">';
         $html[] = '	<ul>';
         foreach ($data as $item) {
             if (is_array($item)) {
                 $class = $current == $item['id'] ? 'current' : (empty($item['href']) ? 'hidden' : 'normal');
                 $html[] = '		<li class="' . $class . '"><a href="' . $item['href'] . '"  id="' . $item['id'] . '" class="' . $item['class'] . '"><span>' . $item['title'] . '</span></a></li>';
             } else {
                 $html[] = '		<li class="' . $class . '">' . $item . '</li>';
             }
         }
         $html[] = '	</ul>';
         $html[] = '</div>';
     }
     echo implode("\n", $html);
 }