From 17a9a8e09cee7e6ccee7a83f7ef0e8252f7887df Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Mon, 5 Jan 2015 23:20:51 +0200 Subject: [PATCH] separate dashboard and components controllers --- ipf/admin/app.php | 6 ++++-- ipf/admin/component.php | 2 +- ipf/admin/controllers/components.php | 13 +------------ ipf/admin/controllers/dashboard.php | 16 ++++++++++++++++ ipf/admin/controllers/user.php | 4 ++-- ipf/admin/log.php | 2 +- ipf/admin/templates/admin/base.html | 2 +- ipf/admin/templates/admin/change.html | 6 +++--- ipf/admin/templates/admin/delete.html | 6 +++--- ipf/admin/templates/admin/index.html | 6 +++--- ipf/admin/templates/admin/items.html | 2 +- ipf/admin/templates/admin/logout.html | 2 +- 12 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 ipf/admin/controllers/dashboard.php diff --git a/ipf/admin/app.php b/ipf/admin/app.php index e6c5904..27f8f52 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -8,6 +8,9 @@ class IPF_Admin_App extends IPF_Application public static function urls($prefix='admin') { return array('prefix' => '#^/'.$prefix.'/', 'urls' => array( + array('controller' => 'IPF_Admin_Dashboard_Controller', 'urls' => array( + array('regex' => '$#', 'func' => 'index'), + )), array('controller' => 'IPF_Admin_FileBrowser_Controller', 'urls' => array( array('regex' => 'filebrowser/rename/$#', 'method' => 'POST', 'func' => 'rename'), array('regex' => 'filebrowser/move/$#', 'method' => 'POST', 'func' => 'move'), @@ -16,8 +19,7 @@ class IPF_Admin_App extends IPF_Application array('regex' => 'filebrowser/upload/$#', 'method' => 'POST', 'func' => 'upload'), array('regex' => 'filebrowser/$#'), )), - array('controller' => 'IPF_Admin_Controller', 'urls' => array( - array('regex' => '$#', 'func' => 'index'), + array('controller' => 'IPF_Admin_Components_Controller', 'urls' => array( array('regex' => '([\w\_\-]+)/([\w\_\-]+)/$#i', 'func' => 'listItems'), array('regex' => '([\w\_\-]+)/([\w\_\-]+)/reorder/$#i', 'func' => 'reorder'), array('regex' => '([\w\_\-]+)/([\w\_\-]+)/add/$#i', 'func' => 'addItem'), diff --git a/ipf/admin/component.php b/ipf/admin/component.php index f07523c..e683531 100644 --- a/ipf/admin/component.php +++ b/ipf/admin/component.php @@ -166,7 +166,7 @@ abstract class IPF_Admin_Component { $url = @$this->request->POST['ipf_referrer']; if (!$url) - $url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Controller', 'listItems'), array($this->app->slug(), $this->slug())); + $url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Components_Controller', 'listItems'), array($this->app->slug(), $this->slug())); return new IPF_HTTP_Response_Redirect($url); } diff --git a/ipf/admin/controllers/components.php b/ipf/admin/controllers/components.php index 399b65c..89954d3 100644 --- a/ipf/admin/controllers/components.php +++ b/ipf/admin/controllers/components.php @@ -1,18 +1,7 @@ ensureUserIsStaff(); - - $context = array( - 'page_title' => __('Site Administration'), - 'admin_log' => IPF_Admin_Log::recent(), - ); - return $this->render('admin/index.html', $context); - } - function listItems() { $component = $this->getComponent(array('view')); diff --git a/ipf/admin/controllers/dashboard.php b/ipf/admin/controllers/dashboard.php new file mode 100644 index 0000000..e751c20 --- /dev/null +++ b/ipf/admin/controllers/dashboard.php @@ -0,0 +1,16 @@ +ensureUserIsStaff(); + + $context = array( + 'page_title' => __('Site Administration'), + 'admin_log' => IPF_Admin_Log::recent(), + ); + return $this->render('admin/index.html', $context); + } +} + diff --git a/ipf/admin/controllers/user.php b/ipf/admin/controllers/user.php index 6c3b3c5..bfbb50b 100644 --- a/ipf/admin/controllers/user.php +++ b/ipf/admin/controllers/user.php @@ -6,7 +6,7 @@ class IPF_Admin_User_Controller extends IPF_Admin_Base_Controller { $success_url = trim(\PFF\Arr::get($this->request->REQUEST, 'next', '')); if (!$success_url) - $success_url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Controller', 'index')); + $success_url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Dashboard_Controller', 'index')); if ($this->request->method == 'POST') { $form = new IPF_Admin_Forms_Login($this->request->POST); @@ -38,7 +38,7 @@ class IPF_Admin_User_Controller extends IPF_Admin_Base_Controller { $success_url = trim(\PFF\Arr::get($this->request->REQUEST, 'next', '')); if (!$success_url) - $success_url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Controller', 'index')); + $success_url = IPF_HTTP_URL::urlForView(array('IPF_Admin_Dashboard_Controller', 'index')); if (!$this->request->user->isAnonymous() && $this->request->user->is_superuser) { $user = \PFF\Container::auth()->findUser($this->params[1]); diff --git a/ipf/admin/log.php b/ipf/admin/log.php index 9425db4..22dbdce 100644 --- a/ipf/admin/log.php +++ b/ipf/admin/log.php @@ -29,7 +29,7 @@ class IPF_Admin_Log public static function logObject($component, $action, $object, $object_id=null) { - $url = $object_id ? IPF_HTTP_URL::urlForView(array('IPF_Admin_Controller', 'editItem'), array($component->app->slug(), $component->slug(), $object_id)) : ''; + $url = $object_id ? IPF_HTTP_URL::urlForView(array('IPF_Admin_Components_Controller', 'editItem'), array($component->app->slug(), $component->slug(), $object_id)) : ''; self::log($component->request->user, $action, (string)$object, $component->verbose_name(), $url); } } diff --git a/ipf/admin/templates/admin/base.html b/ipf/admin/templates/admin/base.html index d63ba65..ddaebbb 100644 --- a/ipf/admin/templates/admin/base.html +++ b/ipf/admin/templates/admin/base.html @@ -42,7 +42,7 @@

{$app.name}

diff --git a/ipf/admin/templates/admin/change.html b/ipf/admin/templates/admin/change.html index 910df4f..df21503 100644 --- a/ipf/admin/templates/admin/change.html +++ b/ipf/admin/templates/admin/change.html @@ -9,8 +9,8 @@ {block breadcrumbs} {/block} @@ -38,7 +38,7 @@ {/block}
- {if ($mode=='change') && $component->isAccessible(array('delete'))}

{trans 'Delete'}

{/if} + {if ($mode=='change') && $component->isAccessible(array('delete'))}

{trans 'Delete'}

{/if} {if ($mode=='change') && $component->isAccessible(array('change'))}{/if} {if ($mode=='add') && $component->isAccessible(array('add'))}{/if} diff --git a/ipf/admin/templates/admin/delete.html b/ipf/admin/templates/admin/delete.html index 7b991b2..d73ae97 100644 --- a/ipf/admin/templates/admin/delete.html +++ b/ipf/admin/templates/admin/delete.html @@ -2,9 +2,9 @@ {block breadcrumbs} {/block} diff --git a/ipf/admin/templates/admin/index.html b/ipf/admin/templates/admin/index.html index 8ad6a40..5d77d45 100644 --- a/ipf/admin/templates/admin/index.html +++ b/ipf/admin/templates/admin/index.html @@ -14,9 +14,9 @@ {foreach $app.components as $component} - {$component->verbose_name()} - {if $component->isAccessible(array('add'))}{trans 'Add'}{/if} - {trans 'Change'} + {$component->verbose_name()} + {if $component->isAccessible(array('add'))}{trans 'Add'}{/if} + {trans 'Change'} {/foreach} diff --git a/ipf/admin/templates/admin/items.html b/ipf/admin/templates/admin/items.html index 8d6799e..e6786ee 100644 --- a/ipf/admin/templates/admin/items.html +++ b/ipf/admin/templates/admin/items.html @@ -1,6 +1,6 @@ {extends "admin/base.html"} -{block breadcrumbs}{/block} +{block breadcrumbs}{/block} {block content}
diff --git a/ipf/admin/templates/admin/logout.html b/ipf/admin/templates/admin/logout.html index 243e937..bb2eda2 100644 --- a/ipf/admin/templates/admin/logout.html +++ b/ipf/admin/templates/admin/logout.html @@ -7,7 +7,7 @@

Logged out

Thanks for spending some quality time with the Web site today.

-

Log in again.

+

Log in again.


{/block} -- 2.49.0