function on_exception($message, $e = null) { if ($this->_exception) { return; } // triggered twice? $this->_exception = true; if (!$e) { $e = new Exception($message); } $this->renderer->set_data('exception', $e); if (loader::in_ajax()) { $this->renderer->set_ajax_message($e->getMessage())->set_ajax_result(false)->ajax_flush(); } else { $this->renderer->set_template('error'); // @todo вникуда: output_editor override this } }
/** run action (entry pooint) */ function run($action = null) { if (preg_match('/[^\\w_-]/', $this->params->op)) { throw new controller_exception(__METHOD__ . ': Bad action'); } $action = $action ?: $this->params->op; $action = $action ?: 'index'; $this->run_before(); $this->render_controller(); $this->action($action); if (!$this->_disable_render) { $this->render(); } $this->renderer->set_page_title($this->title); $this->run_after(); // visible in templates as {$controller.key} $this->renderer->set_data('controller', $this->response->as_array()); }
/** * Render * @param tf_renderer $r */ function render(tf_renderer $r) { // Back if (core::in_editor()) { $site = null; $sites = $this->get_sites(); $r->set_current('sites', $sites->render()); $site_id = $this->request->get_ident('site_id'); $site_id = $site_id ? $site_id : $this->request->all('site_id'); if (!$site_id) { $site = $sites->get_item(); } else { $site = $sites->get_item_by_id($site_id); } if ($site) { $this->set_current_site($site); } $r->set_current('site', $site ? $site->with_tree()->render() : false); } else { // Front if ($this->_site) { $r->set_current('site', $this->_site->with_tree()->render()); } } }
/** * Direct to renderer * * @param mixed $t * @param mixed $append */ function set_title($t, $append = true) { $t = $this->context->T($t); $this->renderer->set_page_title($t, $append); }