From: Andrey Kutejko Date: Sat, 3 Jan 2015 23:09:21 +0000 (+0200) Subject: admin base controller. unify rendering of html X-Git-Tag: 0.6~104 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=d98fa2eec097e4147e88e386725d5745d777ce19;p=ipf.git admin base controller. unify rendering of html --- diff --git a/ipf/admin/app.php b/ipf/admin/app.php index 8d14c98..2b2e9c5 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -76,14 +76,6 @@ class IPF_Admin_App extends IPF_Application ); } - public static function RenderToResponse($tplfile, $params=array(), $request=null) - { - $context = IPF_Project_Template::context($params, $request); - $tmpl = new IPF_Template_File($tplfile, IPF_Project_Template::getDefaultTemplateEnvironment()); - $html = $tmpl->render($context); - return new IPF_HTTP_Response($html); - } - private static $appComponents = array(); public static function applicationComponents($app) diff --git a/ipf/admin/controllers/base.php b/ipf/admin/controllers/base.php new file mode 100644 index 0000000..46328f4 --- /dev/null +++ b/ipf/admin/controllers/base.php @@ -0,0 +1,13 @@ +request); + $tmpl = new IPF_Template_File($template, IPF_Project_Template::getDefaultTemplateEnvironment()); + $html = $tmpl->render($context); + return new IPF_HTTP_Response($html); + } +} + diff --git a/ipf/admin/controllers/components.php b/ipf/admin/controllers/components.php index 34a0299..8bb39de 100644 --- a/ipf/admin/controllers/components.php +++ b/ipf/admin/controllers/components.php @@ -1,6 +1,6 @@ __('Site Administration'), 'admin_log' => $admin_log, ); - return IPF_Admin_App::RenderToResponse('admin/index.html', $context, $this->request); + return $this->render('admin/index.html', $context); } function listItems() { $component = $this->getComponent(array('view')); $context = $component->listItems(); - return IPF_Admin_App::RenderToResponse($component->listTemplate(), $context, $this->request); + return $this->render($component->listTemplate(), $context); } function addItem() { $component = $this->getComponent(array('view', 'add')); $context = $component->addItem(); - return IPF_Admin_App::RenderToResponse($component->addTemplate(), $context, $this->request); + return $this->render($component->addTemplate(), $context); } function editItem() { $component = $this->getComponent(array('view', 'change')); $context = $component->editItem($this->params[3]); - return IPF_Admin_App::RenderToResponse($component->editTemplate(), $context, $this->request); + return $this->render($component->editTemplate(), $context); } function deleteItem() { $component = $this->getComponent(array('view', 'delete')); $context = $component->deleteItem($this->params[3]); - return IPF_Admin_App::RenderToResponse($component->deleteTemplate(), $context, $this->request); + return $this->render($component->deleteTemplate(), $context); } function reorder() diff --git a/ipf/admin/controllers/file_browser.php b/ipf/admin/controllers/file_browser.php index fa665b2..0855e9d 100644 --- a/ipf/admin/controllers/file_browser.php +++ b/ipf/admin/controllers/file_browser.php @@ -1,6 +1,6 @@ $this->relative, 'parent_dir' => $parent_dir, ); - return IPF_Admin_App::RenderToResponse('admin/filebrowser.html', $context, $request); + return $this->render('admin/filebrowser.html', $context); } protected function backToIndex() diff --git a/ipf/admin/controllers/user.php b/ipf/admin/controllers/user.php index 58983c4..6c3b3c5 100644 --- a/ipf/admin/controllers/user.php +++ b/ipf/admin/controllers/user.php @@ -1,6 +1,6 @@ IPF::get('admin_title'), 'form' => $form, ); - return IPF_Admin_App::RenderToResponse('admin/login.html', $context, $this->request); + return $this->render('admin/login.html', $context); } function logout() @@ -31,7 +31,7 @@ class IPF_Admin_User_Controller extends IPF_Controller $context = array( 'page_title' => IPF::get('admin_title'), ); - return IPF_Admin_App::RenderToResponse('admin/logout.html', $context, $this->request); + return $this->render('admin/logout.html', $context); } function impersonate()