<?php
+use \PFF\Functions as F;
+use \PFF\Placeholder as P;
+
class IPF_Admin_App extends IPF_Application
{
public static function urls()
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,
);
}
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);
}
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; }
/* 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; }
.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; }
.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;
+}
+
$(function(){
+ $('.toggle-sidebar').on('change', function() {
+ $('body').toggleClass('pushed');
+ return false;
+ });
+
$('.dateinput').each(function(){
var opts = {
dateFormat: $(this).data('format') || 'yy-mm-dd'
</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'}">☰</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>
{block bodyclass}dashboard{/block}
+{block sidebar_toggle}{/block}
+{block navigation}{/block}
+
{block content}
<div id="content" class="colMS">
<h1>{$page_title}</h1>
{
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')
$context = array(
'page_title' => __('Site Administration'),
- 'app_list' => $app_list,
'admin_log' => $admin_log,
);
return IPF_Admin_App::RenderToResponse('admin/index.html', $context, $request);