[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/page_manager/theme/ -> page_manager.theme.inc (source)

   1  <?php
   2  // $Id
   3  
   4  /**
   5   * @file
   6   * Preprocess functions for page manager editing templates.
   7   */
   8  
   9  /**
  10   * Preprocess the page manager edit page.
  11   */
  12  function template_preprocess_page_manager_edit_page(&$vars) {
  13    ctools_include('ajax');
  14    ctools_include('modal');
  15    ctools_modal_add_js();
  16    ctools_add_js('dependent');
  17  
  18    drupal_add_css(drupal_get_path('module', 'page_manager') . '/css/page-manager.css');
  19    ctools_add_css('wizard');
  20  
  21    $task = $vars['page']->task;
  22    $task_handler_plugins = page_manager_get_task_handler_plugins($task);
  23    foreach ($task_handler_plugins as $id => $plugin) {
  24      if (isset($plugin['admin css'])) {
  25        foreach ($plugin['admin css'] as $file) {
  26          drupal_add_css($file);
  27        }
  28      }
  29      if (isset($plugin['admin js'])) {
  30        foreach ($plugin['admin js'] as $file) {
  31          drupal_add_js($file);
  32        }
  33      }
  34    }
  35  
  36    $page = &$vars['page'];
  37  
  38    $vars['locked'] = '';
  39    $vars['changed'] = '';
  40    if (!empty($page->locked)) {
  41      $vars['locked'] = theme('page_manager_lock', $page);
  42      $vars['changed'] = theme('page_manager_changed', t('Locked'), t('This page is being edited by another user and you cannot make changes to it.'));
  43    }
  44    else if (!empty($page->new)) {
  45      $vars['changed'] = theme('page_manager_changed', t('New'), t('This page is newly created and has not yet been saved to the database. It will not be available until you save it.'));
  46    }
  47    else if (!empty($page->changed)) {
  48      $vars['changed'] = theme('page_manager_changed', t('Changed'), t('This page has been modified, but these modifications are not yet live. While modifying this page, it is locked from modification by other users.'));
  49    }
  50  
  51    $form_state = array(
  52      'page' => &$vars['page'],
  53    );
  54  
  55    $active = $vars['content']['active'];
  56    if ($active[0] == 'handlers' && isset($vars['operations'][$active[1]])) {
  57      $vars['operations']['secondary'] = $vars['operations'][$active[1]];
  58    }
  59  }
  60  
  61  /**
  62   * Remove some items from the form so they don't submit.
  63   */
  64  function theme_page_manager_list_pages_form($form) {
  65    // Don't render these:
  66  /*
  67    unset($form['form_id']);
  68    unset($form['form_build_id']);
  69    unset($form['form_token']);
  70  */
  71    return '<div class="clear-block">' . drupal_render($form) . '</div>';
  72  }
  73  
  74  /**
  75   * Turn the rearrange form into a table with tablesorting on.
  76   */
  77  function theme_page_manager_handler_rearrange($form) {
  78    // Assemble the data for a table from everything in $form['handlers']
  79    foreach (element_children($form['handlers']) as $id) {
  80      // provide a reference shortcut.
  81      $element = &$form['handlers'][$id];
  82      if (isset($element['title'])) {
  83        $row = array();
  84  
  85        $row[] = array(
  86          'data' => drupal_render($element['title']),
  87          'class' => 'page-manager-handler',
  88        );
  89  
  90        $element['weight']['#attributes']['class'] = 'weight';
  91        $row[] = drupal_render($element['weight']);
  92  
  93        $rows[] = array('data' => $row, 'class' => 'draggable', 'id' => 'page-manager-row-' . $id);
  94      }
  95    }
  96  
  97    if (empty($rows)) {
  98      $rows[] = array(array('data' => t('No task handlers are defined for this task.'), 'colspan' => '5'));
  99    }
 100  
 101    $header = array(
 102      array('data' => t('Variant'), 'class' => 'page-manager-handler'),
 103      t('Weight'),
 104    );
 105  
 106    drupal_add_tabledrag('page-manager-arrange-handlers', 'order', 'sibling', 'weight');
 107  
 108    $output = theme('table', $header, $rows, array('id' => 'page-manager-arrange-handlers'));
 109    $output .= drupal_render($form);
 110    return $output;
 111  }
 112  
 113  /**
 114   * Draw the "this task is locked from editing" box.
 115   */
 116  function theme_page_manager_lock($page) {
 117    $account  = user_load($page->locked->uid);
 118    $name     = theme('username', $account);
 119    $lock_age = format_interval(time() - $page->locked->updated);
 120    $break    = url(page_manager_edit_url($page->task_name, array('actions', 'break-lock')));
 121  
 122    ctools_add_css('ctools');
 123    $output = '<div class="ctools-locked">';
 124    $output .= t('This page is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="!break">break this lock</a>.', array('!user' => $name, '!age' => $lock_age, '!break' => $break));
 125    $output .= '</div>';
 126    return $output;
 127  }
 128  
 129  /**
 130   * Draw the "you have unsaved changes and this task is locked." message.
 131   */
 132  function theme_page_manager_changed($text, $description) {
 133    ctools_add_css('ctools');
 134    $output = '<div class="page-manager-changed" title="' . $description . '">';
 135    $output .= $text;
 136    $output .= '</div>';
 137  
 138    return $output;
 139  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7