Example #1
0
 protected static function fetchContent(&$f, &$a, &$p, $main = false)
 {
     if (!$f->ctrl) {
         return array();
     }
     $ctrl = $f->ctrl . 'Controller';
     $C = new $ctrl($f, $a, $p);
     if (!method_exists($C, $a)) {
         self::$setCache = 0;
         self::$actionFound = 0;
         array_unshift($p, $a);
         $a = 'index';
     }
     $data = $C->{$a}();
     if (is_object($data) || is_array($data)) {
         if (is_array($data) && isset($data['total'])) {
             $total = $data['total'];
             $data = $data['data'];
         } else {
             $total = 0;
         }
         View::$frame = sprintf('tpl/%s%sframe.tpl.php', View::$theme, $f->path);
         $tpl = sprintf('tpl/%s%s/%s.tpl.php', View::$theme, $f->path, $a);
         $input = array('folder' => $f, 'params' => $p, 'data' => $data, 'total' => $total);
         $ret = View::render($tpl, $input);
         if ($main) {
             self::$data =& $data;
             if (User::$id && !in_array($a, array('add', 'edit', 'post')) && method_exists($C, 'panel')) {
                 $ret .= View::renderPanel($C->panel($data));
             }
         }
         return $ret;
     }
     if (strpos($data, '/') === 0 || strpos($data, 'http') === 0) {
         if (strpos($data, '/user/login') === 0 || strpos($data, '/error/denied') === 0) {
             $_SESSION['LOGIN_REFERER'] = $_SERVER['REQUEST_URI'];
         }
         self::redirect($data);
     }
     // anything else
     echo $data;
     die;
 }