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(); } }
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; }
public static function get_actions() { $data = self::get_data(); require_once moojon_paths::get_controller_path($data['app'], $data['controller']); $actions = get_class_methods(self::get_controller_class($data['controller'])); $paths = array(moojon_paths::get_moojon_views_directory(), moojon_paths::get_moojon_views_app_directory(moojon_uri::get_app()), moojon_paths::get_moojon_views_app_controller_directory(moojon_uri::get_app(), moojon_uri::get_controller()), moojon_paths::get_project_views_directory(), moojon_paths::get_project_views_app_directory(moojon_uri::get_app()), moojon_paths::get_project_views_app_controller_directory(moojon_uri::get_app(), moojon_uri::get_controller())); foreach (self::colate_view($paths) as $view) { if (!in_array($actions, $view)) { $actions[] = $view; } } return $actions; }
private final function set_controller() { require_once moojon_paths::get_controller_path($this->app_name, $this->controller_name); $controller_class = self::get_controller_class($this->controller_name); $this->controller = new $controller_class($this, $this->action_name, get_object_vars($this)); }