コード例 #1
0
 public static function run()
 {
     $route_class = false;
     $routes_classes = Runtime::model()->routes;
     $route = 'index';
     $request_pieces = self::requestUriPieces();
     if (isset($request_pieces[0]) && trim($request_pieces[0]) == '') {
         foreach ($routes_classes as $routes_class) {
             if (in_array('index', get_class_methods('\\' . $routes_class))) {
                 $parameters = array();
                 unset($request_pieces);
                 forward_static_call_array(array('\\' . $routes_class, 'index'), $parameters);
                 return;
             }
         }
     }
     if (isset($request_pieces[0]) && trim($request_pieces[0]) != '') {
         foreach ($routes_classes as $routes_class) {
             if (isset($request_pieces[0]) && in_array($request_pieces[0], Routes::routes('\\' . $routes_class))) {
                 $route = Routes::route('\\' . $routes_class, trim($request_pieces[0]));
                 array_shift($request_pieces);
                 $parameters = array();
                 if (isset($request_pieces[0])) {
                     $parameters = $request_pieces;
                 }
                 unset($request_pieces);
                 forward_static_call_array(array('\\' . $routes_class, $route), $parameters);
                 return;
             }
         }
     }
     if (isset(Runtime::model()->module)) {
         return forward_static_call_array(array('\\' . Runtime::model()->module, 'run'), array());
     }
 }
コード例 #2
0
 public static function collections($collection = 'collections', $key = null)
 {
     $module = static::$module;
     if ($collection == 'collections' && isset($module::model()->assets->boot_collections)) {
         $collections = $module::model()->assets->boot_collections;
         echo '{';
         echo "\n";
         foreach ($collections as $loop_key => $collection) {
             if ($loop_key != 0) {
                 echo ",\n";
             }
             echo '"' . $collection . '":';
             echo self::collections($collection);
         }
         echo "\n";
         echo '}';
         return;
     }
     $modules = ModuleRegistry::modules();
     foreach ($modules as $module) {
         if (!empty($module::model()->collections)) {
             if (isset($collection) && in_array($collection, ApplicationRoutes::routes($module::model()->collections))) {
                 forward_static_call_array(array($module::model()->collections, ApplicationRoutes::route($module::model()->collections, $collection)), $key != null ? array($key) : array());
                 return;
             }
         }
     }
     return;
 }
コード例 #3
0
 public static function xhr()
 {
     $call = false;
     $args = array();
     if (isset($_POST['sub']) && !empty($_POST['sub'])) {
         $call = $_POST['sub'];
     } elseif (isset($_GET['sub']) && !empty($_GET['sub'])) {
         $call = $_GET['sub'];
     }
     $call_pieces = explode('/', $call);
     if (!isset($call_pieces[1])) {
         return;
     }
     if (!isset($call_pieces[2])) {
         return;
     }
     $context = strtolower($call_pieces[1]);
     $modules_context = ModuleRegistry::modulesContext();
     if (!array_key_exists($context, $modules_context)) {
         return;
     }
     $module_key = $modules_context[$context];
     $request_type = $call_pieces[0];
     $module = ModuleRegistry::module($module_key);
     if (!isset($module::model()->xhr->{$request_type})) {
         return;
     }
     $routes_class = $module::model()->xhr->{$request_type};
     if (!in_array($call_pieces[2], ApplicationRoutes::routes($routes_class))) {
         return;
     }
     $route = ApplicationRoutes::route($routes_class, $call_pieces[2]);
     if (isset($_POST['args']) && !empty($_POST['args'])) {
         if (500000 < strlen(http_build_query($_POST))) {
             return;
         }
         $args = $_POST['args'];
     } elseif (isset($_GET['args']) && !empty($_GET['args'])) {
         if (500000 < strlen(http_build_query($_GET))) {
             return;
         }
         $args = $_GET['args'];
     }
     echo XHRRequest::call($routes_class, $route, $args);
     return true;
 }