/[drupal]/drupal/modules/system/system.module
ViewVC logotype

Diff of /drupal/modules/system/system.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.836, Tue Nov 3 06:47:23 2009 UTC revision 1.837, Sat Nov 7 13:35:21 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: system.module,v 1.835 2009/11/03 05:27:18 webchick Exp $  // $Id: system.module,v 1.836 2009/11/03 06:47:23 webchick Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 217  function system_permission() { Line 217  function system_permission() {
217        'title' => t('Access administration pages'),        'title' => t('Access administration pages'),
218        'description' => t('View the administration panel and browse the help system.'),        'description' => t('View the administration panel and browse the help system.'),
219      ),      ),
220        'access contextual links' => array(
221          'title' => t('Access contextual links'),
222          'description' => t('Use contextual links to perform actions related to elements on a page.'),
223        ),
224      'access site in maintenance mode' => array(      'access site in maintenance mode' => array(
225        'title' => t('Access site in maintenance mode'),        'title' => t('Access site in maintenance mode'),
226        'description' => t('Log in when the site is in maintenance mode.'),        'description' => t('Log in when the site is in maintenance mode.'),
# Line 3516  function theme_system_settings_form($var Line 3520  function theme_system_settings_form($var
3520    
3521  /**  /**
3522   * Template variable preprocessor for contextual links.   * Template variable preprocessor for contextual links.
3523     *
3524     * @see system_build_contextual_links()
3525   */   */
3526  function system_preprocess(&$variables, $hook) {  function system_preprocess(&$variables, $hook) {
3527    static $hooks;    static $hooks;
3528    
3529      // Initialize the $contextual_links template variable.
3530      $variables['contextual_links'] = array();
3531    
3532      // Nothing to do here if the user is not permitted to access contextual links.
3533      if (!user_access('access contextual links')) {
3534        return;
3535      }
3536    
3537    if (!isset($hooks)) {    if (!isset($hooks)) {
3538      $hooks = theme_get_registry();      $hooks = theme_get_registry();
3539    }    }
3540    
   // Initialize contextual links template variable.  
   $variables['contextual_links'] = array();  
   
3541    // Determine the primary theme function argument.    // Determine the primary theme function argument.
3542    if (isset($hooks[$hook]['variables'])) {    if (isset($hooks[$hook]['variables'])) {
3543      $keys = array_keys($hooks[$hook]['variables']);      $keys = array_keys($hooks[$hook]['variables']);
# Line 3539  function system_preprocess(&$variables, Line 3550  function system_preprocess(&$variables,
3550      $element = $variables[$key];      $element = $variables[$key];
3551    }    }
3552    
3553    if (isset($element) && is_array($element) && isset($element['#contextual_links'])) {    if (isset($element) && is_array($element) && !empty($element['#contextual_links'])) {
3554      $variables['contextual_links'] = system_build_contextual_links($element);      $variables['contextual_links'] = system_build_contextual_links($element);
3555      if (!empty($variables['contextual_links'])) {      if (!empty($variables['contextual_links'])) {
3556        $variables['classes_array'][] = 'contextual-links-region';        $variables['classes_array'][] = 'contextual-links-region';
# Line 3551  function system_preprocess(&$variables, Line 3562  function system_preprocess(&$variables,
3562   * Build a renderable array for contextual links.   * Build a renderable array for contextual links.
3563   *   *
3564   * @param $element   * @param $element
3565   *   A renderable array containing a #contextual_links property.   *   A renderable array containing a #contextual_links property, which is a
3566     *   keyed array. Each key is the name of the implementing module, and each
3567     *   value is an array that forms the function arguments for
3568     *   menu_contextual_links(). For example:
3569     *   @code
3570     *     array('#contextual_links' => array(
3571     *       'block' => array('admin/structure/block/manage', array('system', 'navigation')),
3572     *       'menu' => array('admin/structure/menu/manage', array('navigation')),
3573     *     ))
3574     *   @endcode
3575   *   *
3576   * @return   * @return
3577   *   A renderable array representing contextual links.   *   A renderable array representing contextual links.
3578     *
3579     * @see menu_contextual_links()
3580   */   */
3581  function system_build_contextual_links($element) {  function system_build_contextual_links($element) {
3582    static $destination;    static $destination;
3583    
3584    // Transform contextual links into parameters suitable for theme_link().    // Retrieve contextual menu links.
3585    $items = call_user_func_array('array_merge_recursive', $element['#contextual_links']);    $items = array();
3586    $build = array();    foreach ($element['#contextual_links'] as $module => $args) {
3587    if (empty($items)) {      $items += menu_contextual_links($module, $args[0], $args[1]);
     return $build;  
3588    }    }
3589    
3590      // Transform contextual links into parameters suitable for theme_link().
3591    if (!isset($destination)) {    if (!isset($destination)) {
3592      $destination = drupal_get_destination();      $destination = drupal_get_destination();
3593    }    }
# Line 3584  function system_build_contextual_links($ Line 3606  function system_build_contextual_links($
3606      $item['localized_options']['query'] += $destination;      $item['localized_options']['query'] += $destination;
3607      $links[$class] += $item['localized_options'];      $links[$class] += $item['localized_options'];
3608    }    }
3609      $build = array();
3610    if ($links) {    if ($links) {
3611      $build = array(      $build = array(
3612        '#theme' => 'links',        '#theme' => 'links',

Legend:
Removed from v.1.836  
changed lines
  Added in v.1.837

  ViewVC Help
Powered by ViewVC 1.1.2