First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
41
modules/toolbar/toolbar-rtl.css
Normal file
41
modules/toolbar/toolbar-rtl.css
Normal file
|
@ -0,0 +1,41 @@
|
|||
|
||||
#toolbar,
|
||||
#toolbar * {
|
||||
text-align: right;
|
||||
}
|
||||
#toolbar ul li {
|
||||
float: right;
|
||||
}
|
||||
#toolbar ul li a {
|
||||
display: inline-block;
|
||||
float: none;
|
||||
zoom: 1;
|
||||
}
|
||||
#toolbar div.toolbar-menu {
|
||||
padding: 5px 50px 5px 50px;
|
||||
}
|
||||
#toolbar-user {
|
||||
float: left;
|
||||
}
|
||||
#toolbar ul#toolbar-user li {
|
||||
float: none;
|
||||
display: inline;
|
||||
}
|
||||
#toolbar-menu {
|
||||
float: none;
|
||||
}
|
||||
#toolbar-home {
|
||||
float: right;
|
||||
}
|
||||
#toolbar ul li.home a {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
}
|
||||
#toolbar div.toolbar-menu a.toggle {
|
||||
left: 10px;
|
||||
right: auto;
|
||||
}
|
||||
* html #toolbar {
|
||||
left: 0;
|
||||
padding-left: 0;
|
||||
}
|
150
modules/toolbar/toolbar.css
Normal file
150
modules/toolbar/toolbar.css
Normal file
|
@ -0,0 +1,150 @@
|
|||
|
||||
body.toolbar {
|
||||
padding-top: 2.2em;
|
||||
}
|
||||
body.toolbar-drawer {
|
||||
padding-top: 5.3em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggressive resets so we can achieve a consistent look in hostile CSS
|
||||
* environments.
|
||||
*/
|
||||
#toolbar,
|
||||
#toolbar * {
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
line-height: inherit;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
outline: 0;
|
||||
padding: 0;
|
||||
text-align: left; /* LTR */
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base styles.
|
||||
*
|
||||
* We use a keyword for the toolbar font size to make it display consistently
|
||||
* across different themes, while still allowing browsers to resize the text.
|
||||
*/
|
||||
#toolbar {
|
||||
background: #666;
|
||||
color: #ccc;
|
||||
font: normal small "Lucida Grande", Verdana, sans-serif;
|
||||
left: 0;
|
||||
margin: 0 -20px;
|
||||
padding: 0 20px;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
-moz-box-shadow: 0 3px 20px #000;
|
||||
-webkit-box-shadow: 0 3px 20px #000;
|
||||
box-shadow: 0 3px 20px #000;
|
||||
filter: progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10');
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(color=#000000, direction='180', strength='10')";
|
||||
z-index: 600;
|
||||
}
|
||||
#toolbar div.collapsed {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
#toolbar a {
|
||||
color: #fff;
|
||||
font-size: .846em;
|
||||
text-decoration: none;
|
||||
}
|
||||
#toolbar ul li,
|
||||
#toolbar ul li a {
|
||||
float: left; /* LTR */
|
||||
}
|
||||
|
||||
/**
|
||||
* Administration menu.
|
||||
*/
|
||||
#toolbar div.toolbar-menu {
|
||||
background: #000;
|
||||
line-height: 20px;
|
||||
padding: 5px 50px 5px 10px; /* LTR */
|
||||
position: relative;
|
||||
}
|
||||
#toolbar-home a span {
|
||||
background: url(toolbar.png) no-repeat 0 -45px;
|
||||
display: block;
|
||||
height: 14px;
|
||||
margin: 3px 0px;
|
||||
text-indent: -9999px;
|
||||
vertical-align: text-bottom;
|
||||
width: 11px;
|
||||
}
|
||||
#toolbar-user {
|
||||
float: right; /* LTR */
|
||||
}
|
||||
#toolbar-menu {
|
||||
float: left; /* LTR */
|
||||
}
|
||||
#toolbar div.toolbar-menu a.toggle {
|
||||
background: url(toolbar.png) 0 -20px no-repeat;
|
||||
bottom: 0;
|
||||
cursor: pointer;
|
||||
height: 25px;
|
||||
overflow: hidden;
|
||||
position: absolute;
|
||||
right: 10px; /* LTR */
|
||||
text-indent: -9999px;
|
||||
width: 25px;
|
||||
}
|
||||
#toolbar div.toolbar-menu a.toggle:focus,
|
||||
#toolbar div.toolbar-menu a.toggle:hover {
|
||||
background-position: -50px -20px;
|
||||
}
|
||||
#toolbar div.toolbar-menu a.toggle-active {
|
||||
background-position: -25px -20px;
|
||||
}
|
||||
#toolbar div.toolbar-menu a.toggle-active.toggle:focus,
|
||||
#toolbar div.toolbar-menu a.toggle-active.toggle:hover {
|
||||
background-position: -75px -20px;
|
||||
}
|
||||
#toolbar div.toolbar-menu ul li a {
|
||||
padding: 0 10px;
|
||||
-moz-border-radius: 10px;
|
||||
-webkit-border-radius: 10px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
#toolbar div.toolbar-menu ul li a:focus,
|
||||
#toolbar div.toolbar-menu ul li a:hover,
|
||||
#toolbar div.toolbar-menu ul li a:active,
|
||||
#toolbar div.toolbar-menu ul li a.active:focus {
|
||||
background: #444;
|
||||
}
|
||||
#toolbar div.toolbar-menu ul li a.active:hover,
|
||||
#toolbar div.toolbar-menu ul li a.active:active,
|
||||
#toolbar div.toolbar-menu ul li a.active,
|
||||
#toolbar div.toolbar-menu ul li.active-trail a {
|
||||
background: url(toolbar.png) 0 0 repeat-x;
|
||||
text-shadow: #333 0 1px 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapsed drawer of additional toolbar content.
|
||||
*/
|
||||
#toolbar div.toolbar-drawer {
|
||||
position: relative;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
/**
|
||||
* IE 6 Fix.
|
||||
*
|
||||
* IE 6 shows elements with position:fixed as position:static so we replace
|
||||
* it with position:absolute; toolbar needs its z-index to stay above overlay.
|
||||
*/
|
||||
* html #toolbar {
|
||||
left: -20px;
|
||||
margin: 0;
|
||||
padding-right: 0;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
}
|
11
modules/toolbar/toolbar.info
Normal file
11
modules/toolbar/toolbar.info
Normal file
|
@ -0,0 +1,11 @@
|
|||
name = Toolbar
|
||||
description = Provides a toolbar that shows the top-level administration menu items and links from other modules.
|
||||
core = 7.x
|
||||
package = Core
|
||||
version = VERSION
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-06-21
|
||||
version = "7.56"
|
||||
project = "drupal"
|
||||
datestamp = "1498069849"
|
||||
|
111
modules/toolbar/toolbar.js
Normal file
111
modules/toolbar/toolbar.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
(function ($) {
|
||||
|
||||
Drupal.toolbar = Drupal.toolbar || {};
|
||||
|
||||
/**
|
||||
* Attach toggling behavior and notify the overlay of the toolbar.
|
||||
*/
|
||||
Drupal.behaviors.toolbar = {
|
||||
attach: function(context) {
|
||||
|
||||
// Set the initial state of the toolbar.
|
||||
$('#toolbar', context).once('toolbar', Drupal.toolbar.init);
|
||||
|
||||
// Toggling toolbar drawer.
|
||||
$('#toolbar a.toggle', context).once('toolbar-toggle').click(function(e) {
|
||||
Drupal.toolbar.toggle();
|
||||
// Allow resize event handlers to recalculate sizes/positions.
|
||||
$(window).triggerHandler('resize');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve last saved cookie settings and set up the initial toolbar state.
|
||||
*/
|
||||
Drupal.toolbar.init = function() {
|
||||
// Retrieve the collapsed status from a stored cookie.
|
||||
var collapsed = $.cookie('Drupal.toolbar.collapsed');
|
||||
|
||||
// Expand or collapse the toolbar based on the cookie value.
|
||||
if (collapsed == 1) {
|
||||
Drupal.toolbar.collapse();
|
||||
}
|
||||
else {
|
||||
Drupal.toolbar.expand();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Collapse the toolbar.
|
||||
*/
|
||||
Drupal.toolbar.collapse = function() {
|
||||
var toggle_text = Drupal.t('Show shortcuts');
|
||||
$('#toolbar div.toolbar-drawer').addClass('collapsed');
|
||||
$('#toolbar a.toggle')
|
||||
.removeClass('toggle-active')
|
||||
.attr('title', toggle_text)
|
||||
.html(toggle_text);
|
||||
$('body').removeClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
|
||||
$.cookie(
|
||||
'Drupal.toolbar.collapsed',
|
||||
1,
|
||||
{
|
||||
path: Drupal.settings.basePath,
|
||||
// The cookie should "never" expire.
|
||||
expires: 36500
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Expand the toolbar.
|
||||
*/
|
||||
Drupal.toolbar.expand = function() {
|
||||
var toggle_text = Drupal.t('Hide shortcuts');
|
||||
$('#toolbar div.toolbar-drawer').removeClass('collapsed');
|
||||
$('#toolbar a.toggle')
|
||||
.addClass('toggle-active')
|
||||
.attr('title', toggle_text)
|
||||
.html(toggle_text);
|
||||
$('body').addClass('toolbar-drawer').css('paddingTop', Drupal.toolbar.height());
|
||||
$.cookie(
|
||||
'Drupal.toolbar.collapsed',
|
||||
0,
|
||||
{
|
||||
path: Drupal.settings.basePath,
|
||||
// The cookie should "never" expire.
|
||||
expires: 36500
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Toggle the toolbar.
|
||||
*/
|
||||
Drupal.toolbar.toggle = function() {
|
||||
if ($('#toolbar div.toolbar-drawer').hasClass('collapsed')) {
|
||||
Drupal.toolbar.expand();
|
||||
}
|
||||
else {
|
||||
Drupal.toolbar.collapse();
|
||||
}
|
||||
};
|
||||
|
||||
Drupal.toolbar.height = function() {
|
||||
var $toolbar = $('#toolbar');
|
||||
var height = $toolbar.outerHeight();
|
||||
// In modern browsers (including IE9), when box-shadow is defined, use the
|
||||
// normal height.
|
||||
var cssBoxShadowValue = $toolbar.css('box-shadow');
|
||||
var boxShadow = (typeof cssBoxShadowValue !== 'undefined' && cssBoxShadowValue !== 'none');
|
||||
// In IE8 and below, we use the shadow filter to apply box-shadow styles to
|
||||
// the toolbar. It adds some extra height that we need to remove.
|
||||
if (!boxShadow && /DXImageTransform\.Microsoft\.Shadow/.test($toolbar.css('filter'))) {
|
||||
height -= $toolbar[0].filters.item("DXImageTransform.Microsoft.Shadow").strength;
|
||||
}
|
||||
return height;
|
||||
};
|
||||
|
||||
})(jQuery);
|
363
modules/toolbar/toolbar.module
Normal file
363
modules/toolbar/toolbar.module
Normal file
|
@ -0,0 +1,363 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Administration toolbar for quick access to top level administration items.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function toolbar_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/help#toolbar':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Toolbar module displays links to top-level administration menu items and links from other modules at the top of the screen. For more information, see the online handbook entry for <a href="@toolbar">Toolbar module</a>.', array('@toolbar' => 'http://drupal.org/documentation/modules/toolbar/')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Displaying administrative links') . '</dt>';
|
||||
$output .= '<dd>' . t('The Toolbar module displays a bar containing top-level administrative links across the top of the screen. Below that, the Toolbar module has a <em>drawer</em> section where it displays links provided by other modules, such as the core <a href="@shortcuts-help">Shortcut module</a>. The drawer can be hidden/shown by using the show/hide shortcuts link at the end of the toolbar.', array('@shortcuts-help' => url('admin/help/shortcut'))) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_permission().
|
||||
*/
|
||||
function toolbar_permission() {
|
||||
return array(
|
||||
'access toolbar' => array(
|
||||
'title' => t('Use the administration toolbar'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function toolbar_theme($existing, $type, $theme, $path) {
|
||||
$items['toolbar'] = array(
|
||||
'render element' => 'toolbar',
|
||||
'template' => 'toolbar',
|
||||
'path' => drupal_get_path('module', 'toolbar'),
|
||||
);
|
||||
$items['toolbar_toggle'] = array(
|
||||
'variables' => array(
|
||||
'collapsed' => NULL,
|
||||
'attributes' => array(),
|
||||
),
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function toolbar_menu() {
|
||||
$items['toolbar/toggle'] = array(
|
||||
'title' => 'Toggle drawer visibility',
|
||||
'type' => MENU_CALLBACK,
|
||||
'page callback' => 'toolbar_toggle_page',
|
||||
'access arguments' => array('access toolbar'),
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu callback; toggles the visibility of the toolbar drawer.
|
||||
*/
|
||||
function toolbar_toggle_page() {
|
||||
global $base_path;
|
||||
// Toggle the value in the cookie.
|
||||
setcookie('Drupal.toolbar.collapsed', !_toolbar_is_collapsed(), NULL, $base_path);
|
||||
// Redirect the user from where he used the toggle element.
|
||||
drupal_goto();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats an element used to toggle the toolbar drawer's visibility.
|
||||
*
|
||||
* @param $variables
|
||||
* An associative array containing:
|
||||
* - collapsed: A boolean value representing the toolbar drawer's visibility.
|
||||
* - attributes: An associative array of HTML attributes.
|
||||
*
|
||||
* @return
|
||||
* An HTML string representing the element for toggling.
|
||||
*
|
||||
* @ingroup themable
|
||||
*/
|
||||
function theme_toolbar_toggle($variables) {
|
||||
if ($variables['collapsed']) {
|
||||
$toggle_text = t('Show shortcuts');
|
||||
}
|
||||
else {
|
||||
$toggle_text = t('Hide shortcuts');
|
||||
$variables['attributes']['class'][] = 'toggle-active';
|
||||
}
|
||||
return l($toggle_text, 'toolbar/toggle', array('query' => drupal_get_destination(), 'attributes' => array('title' => $toggle_text) + $variables['attributes']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the current state of the toolbar drawer's visibility.
|
||||
*
|
||||
* @return
|
||||
* TRUE when drawer is collapsed, FALSE when it is expanded.
|
||||
*/
|
||||
function _toolbar_is_collapsed() {
|
||||
// PHP converts dots into underscores in cookie names to avoid problems with
|
||||
// its parser, so we use a converted cookie name.
|
||||
return isset($_COOKIE['Drupal_toolbar_collapsed']) ? $_COOKIE['Drupal_toolbar_collapsed'] : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_page_build().
|
||||
*
|
||||
* Add admin toolbar to the page_top region automatically.
|
||||
*/
|
||||
function toolbar_page_build(&$page) {
|
||||
$page['page_top']['toolbar'] = array(
|
||||
'#pre_render' => array('toolbar_pre_render'),
|
||||
'#access' => user_access('access toolbar'),
|
||||
'toolbar_drawer' => array(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prerender function for the toolbar.
|
||||
*
|
||||
* Since building the toolbar takes some time, it is done just prior to
|
||||
* rendering to ensure that it is built only if it will be displayed.
|
||||
*/
|
||||
function toolbar_pre_render($toolbar) {
|
||||
$toolbar = array_merge($toolbar, toolbar_view());
|
||||
return $toolbar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_html().
|
||||
*
|
||||
* Add some page classes, so global page theming can adjust to the toolbar.
|
||||
*/
|
||||
function toolbar_preprocess_html(&$vars) {
|
||||
if (isset($vars['page']['page_top']['toolbar']) && user_access('access toolbar')) {
|
||||
$vars['classes_array'][] = 'toolbar';
|
||||
if (!_toolbar_is_collapsed()) {
|
||||
$vars['classes_array'][] = 'toolbar-drawer';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_toolbar().
|
||||
*
|
||||
* Adding the 'overlay-displace-top' class to the toolbar pushes the overlay
|
||||
* down, so it appears below the toolbar.
|
||||
*/
|
||||
function toolbar_preprocess_toolbar(&$variables) {
|
||||
$variables['classes_array'][] = "overlay-displace-top";
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_system_info_alter().
|
||||
*
|
||||
* Indicate that the 'page_top' region (in which the toolbar will be displayed)
|
||||
* is an overlay supplemental region that should be refreshed whenever its
|
||||
* content is updated.
|
||||
*
|
||||
* This information is provided for any module that might need to use it, not
|
||||
* just the core Overlay module.
|
||||
*/
|
||||
function toolbar_system_info_alter(&$info, $file, $type) {
|
||||
if ($type == 'theme') {
|
||||
$info['overlay_supplemental_regions'][] = 'page_top';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the admin menu as a structured array ready for drupal_render().
|
||||
*
|
||||
* @return
|
||||
* Array of links and settings relating to the admin menu.
|
||||
*/
|
||||
function toolbar_view() {
|
||||
global $user;
|
||||
|
||||
$module_path = drupal_get_path('module', 'toolbar');
|
||||
$build = array(
|
||||
'#theme' => 'toolbar',
|
||||
'#attached'=> array(
|
||||
'js' => array(
|
||||
$module_path . '/toolbar.js',
|
||||
array(
|
||||
'data' => array('tableHeaderOffset' => 'Drupal.toolbar.height'),
|
||||
'type' => 'setting'
|
||||
),
|
||||
),
|
||||
'css' => array(
|
||||
$module_path . '/toolbar.css',
|
||||
),
|
||||
'library' => array(array('system', 'jquery.cookie')),
|
||||
),
|
||||
);
|
||||
|
||||
// Retrieve the admin menu from the database.
|
||||
$links = toolbar_menu_navigation_links(toolbar_get_menu_tree());
|
||||
$build['toolbar_menu'] = array(
|
||||
'#theme' => 'links__toolbar_menu',
|
||||
'#links' => $links,
|
||||
'#attributes' => array('id' => 'toolbar-menu'),
|
||||
'#heading' => array('text' => t('Administrative toolbar'), 'level' => 'h2', 'class' => 'element-invisible'),
|
||||
);
|
||||
|
||||
// Add logout & user account links or login link.
|
||||
if ($user->uid) {
|
||||
$links = array(
|
||||
'account' => array(
|
||||
'title' => t('Hello <strong>@username</strong>', array('@username' => format_username($user))),
|
||||
'href' => 'user',
|
||||
'html' => TRUE,
|
||||
'attributes' => array('title' => t('User account')),
|
||||
),
|
||||
'logout' => array(
|
||||
'title' => t('Log out'),
|
||||
'href' => 'user/logout',
|
||||
),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$links = array(
|
||||
'login' => array(
|
||||
'title' => t('Log in'),
|
||||
'href' => 'user',
|
||||
),
|
||||
);
|
||||
}
|
||||
$build['toolbar_user'] = array(
|
||||
'#theme' => 'links__toolbar_user',
|
||||
'#links' => $links,
|
||||
'#attributes' => array('id' => 'toolbar-user'),
|
||||
);
|
||||
|
||||
// Add a "home" link.
|
||||
$link = array(
|
||||
'home' => array(
|
||||
'title' => '<span class="home-link">Home</span>',
|
||||
'href' => '<front>',
|
||||
'html' => TRUE,
|
||||
'attributes' => array('title' => t('Home')),
|
||||
),
|
||||
);
|
||||
$build['toolbar_home'] = array(
|
||||
'#theme' => 'links',
|
||||
'#links' => $link,
|
||||
'#attributes' => array('id' => 'toolbar-home'),
|
||||
);
|
||||
|
||||
// Add an anchor to be able to toggle the visibility of the drawer.
|
||||
$build['toolbar_toggle'] = array(
|
||||
'#theme' => 'toolbar_toggle',
|
||||
'#collapsed' => _toolbar_is_collapsed(),
|
||||
'#attributes' => array('class' => array('toggle')),
|
||||
);
|
||||
|
||||
// Prepare the drawer links CSS classes.
|
||||
$toolbar_drawer_classes = array(
|
||||
'toolbar-drawer',
|
||||
'clearfix',
|
||||
);
|
||||
if(_toolbar_is_collapsed()) {
|
||||
$toolbar_drawer_classes[] = 'collapsed';
|
||||
}
|
||||
$build['toolbar_drawer_classes'] = implode(' ', $toolbar_drawer_classes);
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the top level items below the 'admin' path.
|
||||
*
|
||||
* @return
|
||||
* An array containing a menu tree of top level items below the 'admin' path.
|
||||
*/
|
||||
function toolbar_get_menu_tree() {
|
||||
$tree = array();
|
||||
$admin_link = db_query('SELECT * FROM {menu_links} WHERE menu_name = :menu_name AND module = :module AND link_path = :path', array(':menu_name' => 'management', ':module' => 'system', ':path' => 'admin'))->fetchAssoc();
|
||||
if ($admin_link) {
|
||||
$tree = menu_build_tree('management', array(
|
||||
'expanded' => array($admin_link['mlid']),
|
||||
'min_depth' => $admin_link['depth'] + 1,
|
||||
'max_depth' => $admin_link['depth'] + 1,
|
||||
));
|
||||
}
|
||||
|
||||
return $tree;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a links array from a menu tree array.
|
||||
*
|
||||
* Based on menu_navigation_links(). Adds path based IDs and icon placeholders
|
||||
* to the links.
|
||||
*
|
||||
* @return
|
||||
* An array of links as defined above.
|
||||
*/
|
||||
function toolbar_menu_navigation_links($tree) {
|
||||
$links = array();
|
||||
foreach ($tree as $item) {
|
||||
if (!$item['link']['hidden'] && $item['link']['access']) {
|
||||
// Make sure we have a path specific ID in place, so we can attach icons
|
||||
// and behaviors to the items.
|
||||
$id = str_replace(array('/', '<', '>'), array('-', '', ''), $item['link']['href']);
|
||||
|
||||
$link = $item['link']['localized_options'];
|
||||
$link['href'] = $item['link']['href'];
|
||||
// Add icon placeholder.
|
||||
$link['title'] = '<span class="icon"></span>' . check_plain($item['link']['title']);
|
||||
// Add admin link ID.
|
||||
$link['attributes'] = array('id' => 'toolbar-link-' . $id);
|
||||
if (!empty($item['link']['description'])) {
|
||||
$link['title'] .= ' <span class="element-invisible">(' . $item['link']['description'] . ')</span>';
|
||||
$link['attributes']['title'] = $item['link']['description'];
|
||||
}
|
||||
$link['html'] = TRUE;
|
||||
|
||||
$class = ' path-' . $id;
|
||||
if (toolbar_in_active_trail($item['link']['href'])) {
|
||||
$class .= ' active-trail';
|
||||
}
|
||||
$links['menu-' . $item['link']['mlid'] . $class] = $link;
|
||||
}
|
||||
}
|
||||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether an item is in the active trail.
|
||||
*
|
||||
* Useful when using a menu generated by menu_tree_all_data() which does
|
||||
* not set the 'in_active_trail' flag on items.
|
||||
*
|
||||
* @return
|
||||
* TRUE when path is in the active trail, FALSE if not.
|
||||
*
|
||||
* @todo
|
||||
* Look at migrating to a menu system level function.
|
||||
*/
|
||||
function toolbar_in_active_trail($path) {
|
||||
$active_paths = &drupal_static(__FUNCTION__);
|
||||
|
||||
// Gather active paths.
|
||||
if (!isset($active_paths)) {
|
||||
$active_paths = array();
|
||||
$trail = menu_get_active_trail();
|
||||
foreach ($trail as $item) {
|
||||
if (!empty($item['href'])) {
|
||||
$active_paths[] = $item['href'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return in_array($path, $active_paths);
|
||||
}
|
BIN
modules/toolbar/toolbar.png
Normal file
BIN
modules/toolbar/toolbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 558 B |
39
modules/toolbar/toolbar.tpl.php
Normal file
39
modules/toolbar/toolbar.tpl.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default template for admin toolbar.
|
||||
*
|
||||
* Available variables:
|
||||
* - $classes: String of classes that can be used to style contextually through
|
||||
* CSS. It can be manipulated through the variable $classes_array from
|
||||
* preprocess functions. The default value has the following:
|
||||
* - toolbar: The current template type, i.e., "theming hook".
|
||||
* - $toolbar['toolbar_user']: User account / logout links.
|
||||
* - $toolbar['toolbar_menu']: Top level management menu links.
|
||||
* - $toolbar['toolbar_drawer']: A place for extended toolbar content.
|
||||
*
|
||||
* Other variables:
|
||||
* - $classes_array: Array of html class attribute values. It is flattened
|
||||
* into a string within the variable $classes.
|
||||
*
|
||||
* @see template_preprocess()
|
||||
* @see template_preprocess_toolbar()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
?>
|
||||
<div id="toolbar" class="<?php print $classes; ?> clearfix">
|
||||
<div class="toolbar-menu clearfix">
|
||||
<?php print render($toolbar['toolbar_home']); ?>
|
||||
<?php print render($toolbar['toolbar_user']); ?>
|
||||
<?php print render($toolbar['toolbar_menu']); ?>
|
||||
<?php if ($toolbar['toolbar_drawer']):?>
|
||||
<?php print render($toolbar['toolbar_toggle']); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="<?php echo $toolbar['toolbar_drawer_classes']; ?>">
|
||||
<?php print render($toolbar['toolbar_drawer']); ?>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue