page_manager.theme.inc 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * @file
  4. * Preprocess functions for page manager editing templates.
  5. */
  6. /**
  7. * Preprocess the page manager edit page.
  8. */
  9. function template_preprocess_page_manager_edit_page(&$vars) {
  10. ctools_include('ajax');
  11. ctools_include('modal');
  12. ctools_modal_add_js();
  13. ctools_add_js('dependent');
  14. ctools_add_css('page-manager', 'page_manager');
  15. ctools_add_css('wizard');
  16. $task = $vars['page']->task;
  17. $page = &$vars['page'];
  18. $vars['locked'] = '';
  19. $vars['changed'] = '';
  20. if (!empty($page->locked)) {
  21. $vars['locked'] = theme('page_manager_lock', array('page' => $page));
  22. $vars['changed'] = theme('page_manager_changed', array('text' => t('Locked'), 'description' => t('This page is being edited by another user and you cannot make changes to it.')));
  23. }
  24. else if (!empty($page->new)) {
  25. $vars['changed'] = theme('page_manager_changed', array('text' => t('New'), 'description' => t('This page is newly created and has not yet been saved to the database. It will not be available until you save it.')));
  26. }
  27. else if (!empty($page->changed)) {
  28. $vars['changed'] = theme('page_manager_changed', array('text' => t('Changed'), 'description' => 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.')));
  29. }
  30. $form_state = array(
  31. 'page' => &$vars['page'],
  32. );
  33. $active = $vars['content']['active'];
  34. if ($active[0] == 'handlers' && isset($vars['operations'][$active[1]])) {
  35. $vars['operations']['secondary'] = $vars['operations'][$active[1]];
  36. }
  37. }
  38. /**
  39. * Turn the rearrange form into a table with tablesorting on.
  40. */
  41. function theme_page_manager_handler_rearrange($vars) {
  42. $form = &$vars['form'];
  43. // Assemble the data for a table from everything in $form['handlers']
  44. foreach (element_children($form['handlers']) as $id) {
  45. // provide a reference shortcut.
  46. $element = &$form['handlers'][$id];
  47. if (isset($element['title'])) {
  48. $row = array();
  49. $row[] = array(
  50. 'data' => render($element['title']),
  51. 'class' => array('page-manager-handler'),
  52. );
  53. $element['weight']['#attributes']['class'][] = 'weight';
  54. $row[] = render($element['weight']);
  55. $rows[] = array('data' => $row, 'class' => array('draggable'), 'id' => 'page-manager-row-' . $id);
  56. }
  57. }
  58. if (empty($rows)) {
  59. $rows[] = array(array('data' => t('No task handlers are defined for this task.'), 'colspan' => '5'));
  60. }
  61. $header = array(
  62. array('data' => t('Variant'), 'class' => array('page-manager-handler')),
  63. t('Weight'),
  64. );
  65. drupal_add_tabledrag('page-manager-arrange-handlers', 'order', 'sibling', 'weight');
  66. $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'page-manager-arrange-handlers')));
  67. $output .= drupal_render_children($form);
  68. return $output;
  69. }
  70. /**
  71. * Draw the "this task is locked from editing" box.
  72. */
  73. function theme_page_manager_lock($vars) {
  74. $page = $vars['page'];
  75. $account = user_load($page->locked->uid);
  76. $name = theme('username', array('account' => $account));
  77. $lock_age = format_interval(REQUEST_TIME - $page->locked->updated);
  78. $break = url(page_manager_edit_url($page->task_name, array('actions', 'break-lock')));
  79. ctools_add_css('ctools');
  80. $output = '<div class="ctools-locked">';
  81. $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));
  82. $output .= '</div>';
  83. return $output;
  84. }
  85. /**
  86. * Draw the "you have unsaved changes and this task is locked." message.
  87. */
  88. function theme_page_manager_changed($vars) {
  89. $text = $vars['text'];
  90. $description = $vars['description'];
  91. ctools_add_css('ctools');
  92. $output = '<div class="page-manager-changed" title="' . $description . '">';
  93. $output .= $text;
  94. $output .= '</div>';
  95. return $output;
  96. }