]> git.andy128k.dev Git - ipf.git/commitdiff
admin sidebar
authorAndrey Kutejko <andy128k@gmail.com>
Mon, 27 Oct 2014 21:59:18 +0000 (23:59 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Mon, 27 Oct 2014 21:59:18 +0000 (23:59 +0200)
ipf/admin/app.php
ipf/admin/static/admin/css/base.css
ipf/admin/static/admin/js/admin.js
ipf/admin/templates/admin/base.html
ipf/admin/templates/admin/index.html
ipf/admin/views.php

index b87d0e3646ca43ae56678ceb16cd3f8a54d7f4c5..96af5195ee789df4ed7af3321e3fc1e1ed2ec35c 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+use \PFF\Functions as F;
+use \PFF\Placeholder as P;
+
 class IPF_Admin_App extends IPF_Application
 {
     public static function urls()
@@ -21,11 +24,31 @@ class IPF_Admin_App extends IPF_Application
 
     public function templateContext($request)
     {
+        $app_list = array();
+        foreach (IPF_Project::getInstance()->appList() as $app) {
+            $components = array();
+            foreach (IPF_Admin_App::applicationComponents($app) as $component) {
+                if ($component->isAccessible(array('view'), $request)) {
+                    $component->request = $request;
+                    $components[] = $component;
+                }
+            }
+
+            if ($components) {
+                $app_list[] = (object)array(
+                    'name' => $app->getTitle(),
+                    'path' => $app->slug(),
+                    'components' => $components,
+                );
+            }
+        }
+
         return array(
             'IPF_VER' => IPF::version(),
             'ADMIN_MEDIA_URL' => IPF::get('static_url') . 'admin/',
             'admin_title' => IPF::get('admin_title'),
             'indexpage_url' => IPF::get('indexpage_url', '/'),
+            'app_list' => $app_list,
         );
     }
 
@@ -72,12 +95,13 @@ class IPF_Admin_App extends IPF_Application
         if (count(array_diff($requiredPermissions, $component->getPerms($request))))
             return false;
 
-        if ($request->user->is_superuser || !self::ArePermissionsEnabled())
+        if ($request->user->is_superuser || !\IPF_Auth_App::ArePermissionsEnabled())
             return true;
 
-        $authPermissions = \PFF\Arr($requiredPermissions)
-            ->map('sprintf', '%s|%s|%s', $component->app->slug(), $component->slug(), \PFF\Symbol::_())
-            ->arr();
+        $authPermissions = F::bind('array_map',
+                F::bind('sprintf', '%s|%s|%s', $component->app->slug(), $component->slug(), P::p()),
+                P::p())
+            ->call($requiredPermissions);
 
         return $request->user->can($authPermissions);
     }
index cf47a4ea3bb137119b0fd2c18911b84813039589..6b15c6f27c7bb012d6d7c8c7cf1d9a8101e4c3ca 100644 (file)
@@ -114,8 +114,20 @@ div.system-message { background: #ffc; margin: 10px; padding: 6px 8px; font-size
 div.system-message p.system-message-title { padding:4px 5px 4px 25px; margin:0; color:red; background:#ffc url(../img/icon_error.gif) 5px .3em no-repeat; }
 .description { font-size:12px; padding:5px 0 0 12px; }
 
+/*
+ * Navigation
+ */
+.toggle-sidebar {display: none;}
+.toggle-sidebar ~ label {display: inline-block; padding:0 8px 0 16px; font-size:18px; margin: 8px 0; font-weight:normal; color: #006a95; cursor: pointer; }
+
+.sidebar h3 {margin: 8px 0 0}
+.sidebar ul {margin: 8px;padding: 0}
+.sidebar li {list-style: none outside none; margin: 0; padding: 0}
+.sidebar li ul {margin-left: 16px}
+
 /* BREADCRUMBS */
-div.breadcrumbs { background:#AFAFAF url(../img/breadcrubms-bg.gif) left repeat-x; padding:2px 8px 3px 16px; font-size:11px;  color:#444;  border-top:1px solid #DCDCDC; border-bottom:1px solid #8C8C8C; text-align:left; }
+.navigation { padding: 8px 16px; }
+div.breadcrumbs { display: inline-block; font-size: 11px; color:#444; text-align:left; }
 
 /* ACTION ICONS */
 .addlink { padding-left:12px; background:url(../img/icon_addlink.gif) 0 .2em no-repeat; }
@@ -142,7 +154,7 @@ table#change-history tbody th { width:16em; }
 /* PAGE STRUCTURE */
 #container { position:relative; width:100%; min-width:760px; padding:0; }
 #content { margin:10px 15px; }
-#header { width:100%; }
+.header { width:100%; height: 40px; }
 #content-main { float:left; width:100%; }
 #content-related { float:right; width:18em; position:relative; margin-right:-19em; }
 #footer { clear:both; padding:10px; }
@@ -157,9 +169,10 @@ table#change-history tbody th { width:16em; }
 .dashboard #content { width:500px; }
 
 /*  HEADER  */
-#header { background:#BDBDBD url(../img/topbg.gif) left repeat-x; color:#565656; overflow:hidden; border-bottom:1px solid #8B8B8B;}
-#header a:link, #header a:visited { color:#006A95; }
-#header a:hover { text-decoration:underline; }
+.header { background:#BDBDBD url(../img/topbg.gif) left repeat-x; color:#565656; overflow:hidden; border-bottom:1px solid #8B8B8B;}
+.header a:link, .header a:visited { color:#006A95; }
+.header a:hover { text-decoration:underline; }
+#branding { display: inline-block; }
 #branding h1 { padding:0 16px; font-size:18px; margin:8px 0; font-weight:normal; }
 #branding h2 { padding:0 10px; font-size:14px; margin:-8px 0 8px 0; font-weight:normal; color:#ffc; }
 #user-tools { position:absolute; top:0; right:0; padding:8px 10px; font-size:11px; text-align:right; }
@@ -182,3 +195,38 @@ table#change-history tbody th { width:16em; }
 .dashboard ul.actionlist { margin-left:0; }
 .dashboard ul.actionlist li { list-style-type:none; }
 
+/*
+ * Sidebar
+ */
+body {
+  -webkit-transition: margin-left 0.3s ease;
+     -moz-transition: margin-left 0.3s ease;
+          transition: margin-left 0.3s ease;
+}
+
+body.pushed {margin-left: 200px}
+
+.sidebar {
+  position: fixed;
+  left: -200px;
+  top: 0;
+
+  margin: 0;
+  padding: 0;
+  width: 199px;
+  height: 100%;
+  overflow: auto;
+
+  background: #f0f0f0;
+  border-right: 1px solid #999;1
+
+  -webkit-transition: left 0.3s ease;
+     -moz-transition: left 0.3s ease;
+          transition: left 0.3s ease;
+}
+
+body.pushed .sidebar {
+  display: block;
+  left: 0;
+}
+
index cf0225aeacbc05039b9dc45b3c92ba2067c1521a..833048b7ef88e0cbf38669ce2a304da17a24020d 100644 (file)
@@ -1,4 +1,9 @@
 $(function(){
+    $('.toggle-sidebar').on('change', function() {
+        $('body').toggleClass('pushed');
+        return false;
+    });
+
     $('.dateinput').each(function(){
         var opts = {
             dateFormat: $(this).data('format') || 'yy-mm-dd'
index a487302ac162dab56532ca734245cd0e818d6926..0f510b0d8befc6bd4c3eb4617c191b72dfbf4a60 100644 (file)
 </head>
 
 <body class="{block bodyclass}{/block}">
+
 <div id="container">
-    <div id="header">
-        <div id="branding">
-            <h1 id="site-name"><a href={if isset($indexpage_url)}"{$indexpage_url}"{else}"/"{/if}>{$admin_title}</a></h1>
-        </div>
-        {block usertools}<div id="user-tools">{trans 'Welcome'}, <strong>{$user}</strong>. <a href="{url 'IPF_Admin_Views_Logout'}">{trans 'Log out'}</a><br /><span id="ipfver">Version: {$IPF_VER}</span></div>{/block}
+  <div class="header">
+    {block sidebar_toggle}
+    <input id="toggle-sidebar" class="toggle-sidebar" type="checkbox">
+    <label for="toggle-sidebar" title="{trans 'Open sidebar'}">&#9776;</label>
+    {/block}
+
+    <div id="branding">
+      <h1 id="site-name"><a href={if isset($indexpage_url)}"{$indexpage_url}"{else}"/"{/if}>{$admin_title}</a></h1>
+    </div>
+    {block usertools}
+      <div id="user-tools">
+        {trans 'Welcome'}, <strong>{$user}</strong>. <a href="{url 'IPF_Admin_Views_Logout'}">{trans 'Log out'}</a><br />
+        <span id="ipfver">Version: {$IPF_VER}</span>
+      </div>
+    {/block}
+  </div>
+  {block navigation}
+    <div class="navigation">
+      {block breadcrumbs}{/block}
+
+      {block sidebar}
+      <div class="sidebar">
+        <div class="header"></div>
+
+        <ul>
+          {foreach $app_list as $app}
+          <li>
+            <h3>{$app.name}</h3>
+            <ul>
+              {foreach $app.components as $component}
+              <li><a href="{url 'IPF_Admin_Views_ListItems', array($app.path, $component->slug())}">{$component->verbose_name()}</a></li>
+              {/foreach}
+            </ul>
+          </li>
+          {/foreach}
+        </ul>
+      </div>
+      {/block}
+
     </div>
-    {block breadcrumbs}{/block}
-    {block content}{/block}
-    <div id="footer"></div>
+  {/block}
+  {block content}{/block}
+  <div id="footer"></div>
 </div>
+
 {block commonjs}
   <script type="text/javascript" src="{$ADMIN_MEDIA_URL}js/jquery.js"></script>
   <script type="text/javascript" src="{$ADMIN_MEDIA_URL}js/jquery-ui.custom.js"></script>
index 50bfc1fe46e06a2e24302cbf6ff34b8b2eab2677..403518ca01825684902912b168db22ece612df39 100644 (file)
@@ -2,6 +2,9 @@
 
 {block bodyclass}dashboard{/block}
 
+{block sidebar_toggle}{/block}
+{block navigation}{/block}
+
 {block content}
 <div id="content" class="colMS">
     <h1>{$page_title}</h1>
index d1bb7c8cf7c5b7a88ae749056d9aace169645580..729546a1e57e372f88a9317713789931f6d8540c 100644 (file)
@@ -4,26 +4,6 @@ function IPF_Admin_Views_Index($request, $match)
 {
     IPF_Admin_App::ensureUserIsStaff($request);
 
-    $apps = array();
-    $app_list = new IPF_Template_ContextVars();
-    foreach (IPF_Project::getInstance()->appList() as $app) {
-        $components = array();
-        foreach (IPF_Admin_App::applicationComponents($app) as $component) {
-            if ($component->isAccessible(array('view'), $request)) {
-                $component->request = $request;
-                $components[] = $component;
-            }
-        }
-
-        if ($components) {
-            $app_list[] = (object)array(
-                'name' => $app->getTitle(),
-                'path' => $app->slug(),
-                'components' => $components,
-            );
-        }
-    }
-
     $admin_log = \PFF\Container::databaseQuery()
         ->from('admin_log')
         ->orderBy('created_at DESC')
@@ -33,7 +13,6 @@ function IPF_Admin_Views_Index($request, $match)
 
     $context = array(
         'page_title' => __('Site Administration'),
-        'app_list' => $app_list,
         'admin_log' => $admin_log,
     );
     return IPF_Admin_App::RenderToResponse('admin/index.html', $context, $request);