예제 #1
0
 public final function render()
 {
     if (!$this->controller) {
         $this->set_controller();
     }
     $return = moojon_runner::render(moojon_paths::get_view_path(self::get_app_name($this), self::get_controller_name($this->controller), $this->controller->get_view()), $this->controller, $this->uri);
     $layout = $this->get_layout();
     if ($layout !== false) {
         $return = str_replace('YIELD', $return, moojon_runner::render(moojon_paths::get_layout_path($layout), $this->controller), $this->uri);
     }
     return $return;
 }
예제 #2
0
 public static function render()
 {
     if (ENVIRONMENT != 'production') {
         $div = new moojon_div_tag(null, array('id' => 'debug'));
         $div->add_child(new moojon_h2_tag('Session'));
         $ul = new moojon_ul_tag();
         foreach ($_SESSION as $key => $value) {
             if (is_array($value)) {
                 $value = 'array(' . implode(', ', $value) . ')';
             }
             $ul->add_child(new moojon_li_tag("{$key}: {$value}"));
         }
         $div->add_child($ul);
         $div->add_child(new moojon_h2_tag('Cookie'));
         $ul = new moojon_ul_tag();
         foreach ($_COOKIE as $key => $value) {
             if (is_array($value)) {
                 $value = 'array(' . implode(', ', $value) . ')';
             }
             $ul->add_child(new moojon_li_tag("{$key}: {$value}"));
         }
         $div->add_child($ul);
         $div->add_child(new moojon_h2_tag('URL'));
         $ul = new moojon_ul_tag();
         $app = APP;
         $controller = CONTROLLER;
         $action = ACTION;
         $ul->add_child(new moojon_li_tag("App: {$app}"));
         $ul->add_child(new moojon_li_tag("Controller: {$controller}"));
         $ul->add_child(new moojon_li_tag("Action: {$action}"));
         $div->add_child($ul);
         $div->add_child(new moojon_h2_tag('Paths'));
         $ul = new moojon_ul_tag();
         $app_path = moojon_paths::get_app_path($app);
         $controller_path = moojon_paths::get_controller_path($app, $controller);
         $view_path = moojon_paths::get_view_path($app, $controller, $action);
         $ul->add_child(new moojon_li_tag("app_path: {$app_path}"));
         $ul->add_child(new moojon_li_tag("controller_path: {$controller_path}"));
         $ul->add_child(new moojon_li_tag("view_path: {$view_path}"));
         $div->add_child($ul);
         echo $div->render();
     }
 }
예제 #3
0
 protected static final function validate_matches($matches, $validate = true)
 {
     if ($validate) {
         if (!array_key_exists('app', $matches) || !array_key_exists('controller', $matches) || !array_key_exists('action', $matches)) {
             return false;
         }
         if ($path = moojon_paths::get_app_path($matches['app'])) {
             require_once $path;
         } else {
             return false;
         }
         if ($path = moojon_paths::get_controller_path($matches['app'], $matches['controller'])) {
             require_once $path;
         } else {
             return false;
         }
         if (!method_exists(self::get_controller_class($matches['controller']), $matches['action']) && !moojon_paths::get_view_path($matches['app'], $matches['controller'], $matches['action'])) {
             return false;
         }
     }
     return true;
 }