comparison sites/all/modules/ctools/page_manager/theme/page_manager.theme.inc @ 0:ff03f76ab3fe

initial version
author danieleb <danielebarchiesi@me.com>
date Wed, 21 Aug 2013 18:51:11 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ff03f76ab3fe
1 <?php
2
3 /**
4 * @file
5 * Preprocess functions for page manager editing templates.
6 */
7
8 /**
9 * Preprocess the page manager edit page.
10 */
11 function template_preprocess_page_manager_edit_page(&$vars) {
12 ctools_include('ajax');
13 ctools_include('modal');
14 ctools_modal_add_js();
15 ctools_add_js('dependent');
16
17 ctools_add_css('page-manager', 'page_manager');
18 ctools_add_css('wizard');
19
20 $task = $vars['page']->task;
21
22 $page = &$vars['page'];
23
24 $vars['locked'] = '';
25 $vars['changed'] = '';
26 if (!empty($page->locked)) {
27 $vars['locked'] = theme('page_manager_lock', array('page' => $page));
28 $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.')));
29 }
30 else if (!empty($page->new)) {
31 $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.')));
32 }
33 else if (!empty($page->changed)) {
34 $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.')));
35 }
36
37 $form_state = array(
38 'page' => &$vars['page'],
39 );
40
41 $active = $vars['content']['active'];
42 if ($active[0] == 'handlers' && isset($vars['operations'][$active[1]])) {
43 $vars['operations']['secondary'] = $vars['operations'][$active[1]];
44 }
45 }
46
47 /**
48 * Turn the rearrange form into a table with tablesorting on.
49 */
50 function theme_page_manager_handler_rearrange($vars) {
51 $form = &$vars['form'];
52 // Assemble the data for a table from everything in $form['handlers']
53 foreach (element_children($form['handlers']) as $id) {
54 // provide a reference shortcut.
55 $element = &$form['handlers'][$id];
56 if (isset($element['title'])) {
57 $row = array();
58
59 $row[] = array(
60 'data' => render($element['title']),
61 'class' => array('page-manager-handler'),
62 );
63
64 $element['weight']['#attributes']['class'][] = 'weight';
65 $row[] = render($element['weight']);
66
67 $rows[] = array('data' => $row, 'class' => array('draggable'), 'id' => 'page-manager-row-' . $id);
68 }
69 }
70
71 if (empty($rows)) {
72 $rows[] = array(array('data' => t('No task handlers are defined for this task.'), 'colspan' => '5'));
73 }
74
75 $header = array(
76 array('data' => t('Variant'), 'class' => array('page-manager-handler')),
77 t('Weight'),
78 );
79
80 drupal_add_tabledrag('page-manager-arrange-handlers', 'order', 'sibling', 'weight');
81
82 $output = theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'page-manager-arrange-handlers')));
83 $output .= drupal_render_children($form);
84 return $output;
85 }
86
87 /**
88 * Draw the "this task is locked from editing" box.
89 */
90 function theme_page_manager_lock($vars) {
91 $page = $vars['page'];
92
93 $account = user_load($page->locked->uid);
94 $name = theme('username', array('account' => $account));
95 $lock_age = format_interval(REQUEST_TIME - $page->locked->updated);
96 $break = url(page_manager_edit_url($page->task_name, array('actions', 'break-lock')));
97
98 ctools_add_css('ctools');
99 $output = '<div class="ctools-locked">';
100 $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));
101 $output .= '</div>';
102 return $output;
103 }
104
105 /**
106 * Draw the "you have unsaved changes and this task is locked." message.
107 */
108 function theme_page_manager_changed($vars) {
109 $text = $vars['text'];
110 $description = $vars['description'];
111
112 ctools_add_css('ctools');
113 $output = '<div class="page-manager-changed" title="' . $description . '">';
114 $output .= $text;
115 $output .= '</div>';
116
117 return $output;
118 }