/** * A simple caching mechanism to avoid reloading rule array */ private function load_rules() { if (URL::instance()->rules != null) { return; } URL::instance()->rules = RewriteRules::get_active(); }
function get_rules() { $rules = $this->rules; $rules = RewriteRules::sort_rules(RewriteRules::get_active()); $this->rules = $rules; return $rules; }
public function action_plugin_ui($plugin_id, $action) { if ($plugin_id == $this->plugin_id()) { switch ($action) { case _t('Configure', 'customquery'): $ui = new FormUI('customquery'); foreach (RewriteRules::get_active()->getArrayCopy() as $rule) { if (strpos($rule->name, 'display_') === 0 and $rule->name != 'display_404') { $ui->append('text', $rule->name, 'customquery__' . $rule->name, 'Number of Posts for ' . $rule->name); } } $ui->append('submit', 'save', _t('Save')); $ui->out(); break; } } }
/** * All handlers must implement act() to conform to handler API. * This is the default implementation of act(), which attempts * to call a class member method of $this->act_$action(). Any * subclass is welcome to override this default implementation. * * @param string $action the action that was in the URL rule */ public function act($action) { if (null === $this->handler_vars) { $this->handler_vars = new SuperGlobal(array()); } $this->action = $action; $this->theme->assign('matched_rule', URL::get_matched_rule()); $request = new StdClass(); foreach (RewriteRules::get_active() as $rule) { $request->{$rule->name} = false; } $request->{$this->theme->matched_rule->name} = true; $this->theme->assign('request', $request); $action_hook = 'plugin_act_' . $action; $before_action_hook = 'before_' . $action_hook; $after_action_hook = 'after_' . $action_hook; Plugins::act($before_action_hook, $this); Plugins::act($action_hook, $this); Plugins::act($after_action_hook); }
/** * Load the active theme and create a new Theme instance. * Also, assign the request variables. */ public function setup_theme() { $this->theme = Themes::create(); $this->theme->assign('matched_rule', URL::get_matched_rule()); $request = new StdClass(); foreach (RewriteRules::get_active() as $rule) { $request->{$rule->name} = false; } $request->{$this->theme->matched_rule->name} = true; $this->theme->assign('request', $request); }
/** * Display the login form * * @param string $name Pre-fill the name field with this name */ protected function login_form($name) { // Display the login form. $this->theme = Themes::create(); if (!$this->theme->template_exists('login')) { $this->theme = Themes::create('admin', 'RawPHPEngine', Site::get_dir('admin_theme', TRUE)); $this->theme->assign('admin_page', 'login'); } $request = new StdClass(); foreach (RewriteRules::get_active() as $rule) { $request->{$rule->name} = $rule->name == URL::get_matched_rule()->name; } $this->theme->assign('request', $request); $this->theme->assign('habari_username', htmlentities($name, ENT_QUOTES, 'UTF-8')); $this->display('login'); return TRUE; }
public function setup() { $this->rules = RewriteRules::get_active(); }