From 87b38b03c10d6d96e85bc89668b0a59882037fce Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Fri, 9 Jan 2015 00:23:49 +0200 Subject: [PATCH] admin log page --- ipf/admin/app.php | 1 + ipf/admin/assets/css/base.css | 5 +-- ipf/admin/controllers/dashboard.php | 22 ++++++++++ ipf/admin/log.php | 13 +++++- ipf/admin/templates/admin/index.html | 6 +-- ipf/admin/templates/admin/log.html | 60 ++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+), 8 deletions(-) create mode 100644 ipf/admin/templates/admin/log.html diff --git a/ipf/admin/app.php b/ipf/admin/app.php index 623de43..1ebf0dc 100644 --- a/ipf/admin/app.php +++ b/ipf/admin/app.php @@ -10,6 +10,7 @@ class IPF_Admin_App extends IPF_Application return array('prefix' => '#^/'.$prefix.'/', 'urls' => array( array('controller' => 'IPF_Admin_Dashboard_Controller', 'urls' => array( array('regex' => '$#', 'func' => 'index'), + array('regex' => 'log/$#', 'func' => 'log'), )), array('controller' => 'IPF_Admin_FileBrowser_Controller', 'urls' => array( array('regex' => 'filebrowser/rename/$#', 'method' => 'POST', 'func' => 'rename'), diff --git a/ipf/admin/assets/css/base.css b/ipf/admin/assets/css/base.css index e0ff9ce..628d4f1 100644 --- a/ipf/admin/assets/css/base.css +++ b/ipf/admin/assets/css/base.css @@ -174,9 +174,8 @@ table#change-history tbody th { width:16em; } #user-tools span {font-size:9px} /* SIDEBAR */ -#content-related h3 { font-size:12px; color:#666; margin-bottom:3px; } -#content-related h4 { font-size:11px; } #content-related .module h2 { background: linear-gradient(to top, #e1e1e1, #fff 16px); color:#666 } +#content-related a.all { display: block; text-align: center; margin: 10px 0; } /* * Dashboard @@ -187,7 +186,7 @@ table#change-history tbody th { width:16em; } .dashboard .module table td { white-space:nowrap; } .dashboard .module table td a { display:block; padding-right:.6em; } /* RECENT ACTIONS MODULE */ -.dashboard ul.actionlist { margin-left:0; } +.dashboard ul.actionlist { margin: 10px 0; } .dashboard ul.actionlist li { list-style-type:none; } /* diff --git a/ipf/admin/controllers/dashboard.php b/ipf/admin/controllers/dashboard.php index e751c20..277b4e3 100644 --- a/ipf/admin/controllers/dashboard.php +++ b/ipf/admin/controllers/dashboard.php @@ -12,5 +12,27 @@ class IPF_Admin_Dashboard_Controller extends IPF_Admin_Base_Controller ); return $this->render('admin/index.html', $context); } + + function log() + { + $currentPage = (int)@$this->request->GET['page']; + if (!$currentPage) + $currentPage = 1; + + $count = IPF_Admin_Log::count(); + + $perPage = 20; + $pagerLayout = new IPF_Pager_Layout; + $pages = $pagerLayout->layout($currentPage, ceil($count / $perPage)); + + $context = array( + 'page_title' => __('Recent Actions'), + 'admin_log' => IPF_Admin_Log::recent($perPage, ($currentPage - 1) * $perPage), + 'count' => $count, + 'current_page' => $currentPage, + 'pages' => $pages, + ); + return $this->render('admin/log.html', $context); + } } diff --git a/ipf/admin/log.php b/ipf/admin/log.php index 22dbdce..a5100c1 100644 --- a/ipf/admin/log.php +++ b/ipf/admin/log.php @@ -2,12 +2,21 @@ class IPF_Admin_Log { - public static function recent() + public static function count() + { + return \PFF\Container::databaseQuery() + ->from('admin_log') + ->select('COUNT(1) AS cnt') + ->fetch('cnt'); + } + + public static function recent($limit=10, $offset=0) { return \PFF\Container::databaseQuery() ->from('admin_log') ->orderBy('created_at DESC') - ->limit(10) + ->limit($limit) + ->offset($offset) ->asObject(true) ->fetchAll(); } diff --git a/ipf/admin/templates/admin/index.html b/ipf/admin/templates/admin/index.html index 5d77d45..95b300b 100644 --- a/ipf/admin/templates/admin/index.html +++ b/ipf/admin/templates/admin/index.html @@ -25,9 +25,8 @@ {/foreach} {/block} diff --git a/ipf/admin/templates/admin/log.html b/ipf/admin/templates/admin/log.html new file mode 100644 index 0000000..74f7413 --- /dev/null +++ b/ipf/admin/templates/admin/log.html @@ -0,0 +1,60 @@ +{extends "admin/base.html"} + +{block breadcrumbs}{/block} + +{block content} +
+

{$page_title}

+
+
+ +
+ + + + + + + + + + + {foreach $admin_log as $log} + + + + + + + {/foreach} + +
{trans 'Action'}{trans 'Type'}{trans 'When'}{trans 'Who'}
{$log.object_class}{$log.created_at|datetime:'%b %e, %Y %H:%M:%S'}{$log.username}
+ +

+ {foreach $pages as $p} + {if $p} + {if $p == $current_page} + {$p} + {else} + {$p} + {/if} + {else} + … + {/if} + {/foreach} + {$count} log records +

+
+ +
+
+
+
+{/block} + -- 2.49.0