Révision 64156087
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/panels/plugins/display_renderers/panels_renderer_editor.class.php | ||
---|---|---|
4 | 4 |
* @file |
5 | 5 |
* Class file to control the main Panels editor. |
6 | 6 |
*/ |
7 |
|
|
8 | 7 |
class panels_renderer_editor extends panels_renderer_standard { |
9 | 8 |
|
10 | 9 |
/** |
... | ... | |
20 | 19 |
* builder that do not actually have real content. |
21 | 20 |
*/ |
22 | 21 |
var $no_edit_links = FALSE; |
23 |
// ------------------------------------------------------------------------- |
|
24 |
// Display edit rendering. |
|
22 |
// -------------------------------------------------------------------------. |
|
23 |
/** |
|
24 |
* Display edit rendering. |
|
25 |
*/ |
|
25 | 26 |
|
26 | 27 |
function edit() { |
27 | 28 |
$form_state = array( |
... | ... | |
119 | 120 |
$buttons = $this->get_pane_links($pane, $content_type); |
120 | 121 |
|
121 | 122 |
// Render administrative buttons for the pane. |
122 |
|
|
123 | 123 |
$block = new stdClass(); |
124 | 124 |
if (empty($content_type)) { |
125 | 125 |
$block->title = '<em>' . t('Missing content type') . '</em>'; |
... | ... | |
136 | 136 |
$settings['Panels']['RegionLock'][$pane->pid] = $pane->locks['regions']; |
137 | 137 |
drupal_add_js($settings, 'setting'); |
138 | 138 |
} |
139 |
else if ($pane->locks['type'] == 'immovable') {
|
|
139 |
elseif ($pane->locks['type'] == 'immovable') { |
|
140 | 140 |
$grabber_class = 'grab-title not-grabber'; |
141 | 141 |
} |
142 | 142 |
} |
... | ... | |
163 | 163 |
$output .= '<span class="buttons">' . $buttons . '</span>'; |
164 | 164 |
} |
165 | 165 |
$output .= '<span class="text" title="' . check_plain($title) . '">' . $title . '</span>'; |
166 |
$output .= '</div>'; // grabber
|
|
167 |
|
|
166 |
$output .= '</div>'; |
|
167 |
// Grabber. |
|
168 | 168 |
$output .= '<div class="panel-pane-collapsible">'; |
169 | 169 |
$output .= '<div class="pane-title">' . $block->title . '</div>'; |
170 | 170 |
$output .= '<div class="pane-content">' . filter_xss_admin(render($block->content)) . '</div>'; |
171 |
$output .= '</div>'; // panel-pane-collapsible
|
|
172 |
|
|
173 |
$output .= '</div>'; // panel-pane
|
|
174 |
|
|
171 |
$output .= '</div>'; |
|
172 |
// panel-pane-collapsible. |
|
173 |
$output .= '</div>'; |
|
174 |
// panel-pane. |
|
175 | 175 |
return $output; |
176 | 176 |
} |
177 | 177 |
|
... | ... | |
360 | 360 |
|
361 | 361 |
if (user_access('administer pane access')) { |
362 | 362 |
$contexts = $this->display->context; |
363 |
// Make sure we have the logged in user context |
|
363 |
// Make sure we have the logged in user context.
|
|
364 | 364 |
if (!isset($contexts['logged-in-user'])) { |
365 | 365 |
$contexts['logged-in-user'] = ctools_access_get_loggedin_context(); |
366 | 366 |
} |
... | ... | |
408 | 408 |
case 'immovable': |
409 | 409 |
$lock_method = t('Immovable'); |
410 | 410 |
break; |
411 |
|
|
411 | 412 |
case 'regions': |
412 | 413 |
$lock_method = t('Regions'); |
413 | 414 |
break; |
415 |
|
|
414 | 416 |
case 'none': |
415 | 417 |
default: |
416 | 418 |
$lock_method = t('No lock'); |
... | ... | |
464 | 466 |
); |
465 | 467 |
|
466 | 468 |
// Allow others to add/remove links from pane context menu. |
467 |
// Grouped by 'top', 'style', 'visibility', 'lock', 'cache' and 'bottom' |
|
469 |
// Grouped by 'top', 'style', 'visibility', 'lock', 'cache' and 'bottom'.
|
|
468 | 470 |
drupal_alter('get_pane_links', $links, $pane, $content_type); |
469 | 471 |
|
470 | 472 |
$dropdown_links = $links['top']; |
... | ... | |
499 | 501 |
|
500 | 502 |
// ----------------------------------------------------------------------- |
501 | 503 |
// Display edit AJAX callbacks and helpers. |
502 |
|
|
503 | 504 |
/** |
504 | 505 |
* Generate a URL path for the AJAX editor. |
505 | 506 |
*/ |
... | ... | |
612 | 613 |
if (!empty($content_type['top level'])) { |
613 | 614 |
$category = 'root'; |
614 | 615 |
} |
615 |
else if (isset($content_type['category'])) {
|
|
616 |
elseif (isset($content_type['category'])) { |
|
616 | 617 |
if (is_array($content_type['category'])) { |
617 | 618 |
list($category, $weight) = $content_type['category']; |
618 | 619 |
} |
... | ... | |
668 | 669 |
} |
669 | 670 |
} |
670 | 671 |
|
671 |
// Now sort |
|
672 |
// Now sort.
|
|
672 | 673 |
natcasesort($category_names); |
673 | 674 |
foreach ($category_names as $category => $name) { |
674 | 675 |
$output[$category] = $categories[$category]; |
... | ... | |
733 | 734 |
$pane = $form_state['pane']; |
734 | 735 |
unset($this->cache->new_pane); |
735 | 736 |
|
736 |
// Add the pane to the display |
|
737 |
// Add the pane to the display.
|
|
737 | 738 |
$this->display->add_pane($pane, $region); |
738 | 739 |
panels_edit_cache_set($this->cache); |
739 | 740 |
|
740 |
// Tell the client to draw the pane |
|
741 |
// Tell the client to draw the pane.
|
|
741 | 742 |
$this->command_add_pane($pane); |
742 | 743 |
|
743 | 744 |
// Dismiss the modal. |
744 | 745 |
$this->commands[] = ctools_modal_command_dismiss(); |
745 | 746 |
} |
746 |
else if (!empty($form_state['cancel'])) {
|
|
747 |
elseif (!empty($form_state['cancel'])) { |
|
747 | 748 |
// If cancelling, return to the activity. |
748 | 749 |
list($category_key, $category) = $this->get_category($subtype); |
749 | 750 |
$this->ajax_select_content($region, $category_key); |
... | ... | |
786 | 787 |
'cancel callback' => 'panels_ajax_edit_pane_cancel', |
787 | 788 |
); |
788 | 789 |
|
789 |
$output = ctools_content_form('edit', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $pane->configuration, $step);
|
|
790 |
$output = ctools_content_form('edit', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $pane->configuration, $step); |
|
790 | 791 |
|
791 | 792 |
// If $rc is FALSE, there was no actual form. |
792 | 793 |
if ($output === FALSE || !empty($form_state['cancel'])) { |
793 | 794 |
// Dismiss the modal. |
794 | 795 |
$this->commands[] = ctools_modal_command_dismiss(); |
795 | 796 |
} |
796 |
else if (!empty($form_state['complete'])) {
|
|
797 |
elseif (!empty($form_state['complete'])) { |
|
797 | 798 |
// References get blown away with AJAX caching. This will fix that. |
798 | 799 |
$this->cache->display->content[$pid] = $form_state['pane']; |
799 | 800 |
|
... | ... | |
852 | 853 |
$conf = &$this->display->cache; |
853 | 854 |
$title = t('Cache method for this display'); |
854 | 855 |
} |
855 |
else if (!empty($this->display->content[$pid])) {
|
|
856 |
elseif (!empty($this->display->content[$pid])) { |
|
856 | 857 |
$pane = &$this->display->content[$pid]; |
857 | 858 |
$subtype = ctools_content_get_subtype($pane->type, $pane->subtype); |
858 | 859 |
$conf = &$pane->cache; |
... | ... | |
896 | 897 |
else { |
897 | 898 |
$this->cache->method = $form_state['method']; |
898 | 899 |
panels_edit_cache_set($this->cache); |
899 |
// send them to next form.
|
|
900 |
// Send them to next form.
|
|
900 | 901 |
return $this->ajax_cache_settings($pid); |
901 | 902 |
} |
902 | 903 |
} |
... | ... | |
917 | 918 |
$conf = &$this->display->cache; |
918 | 919 |
$title = t('Cache settings for this display'); |
919 | 920 |
} |
920 |
else if (!empty($this->display->content[$pid])) {
|
|
921 |
elseif (!empty($this->display->content[$pid])) { |
|
921 | 922 |
$pane = &$this->display->content[$pid]; |
922 | 923 |
$subtype = ctools_content_get_subtype($pane->type, $pane->subtype); |
923 | 924 |
|
... | ... | |
979 | 980 |
break; |
980 | 981 |
|
981 | 982 |
case 'region': |
982 |
$style = isset($this->display->panel_settings[$pid]['style']) ? $this->display->panel_settings[$pid]['style'] : '-1'; // -1 signifies to use the default setting. |
|
983 |
$style = isset($this->display->panel_settings[$pid]['style']) ? $this->display->panel_settings[$pid]['style'] : '-1'; |
|
984 |
// -1 signifies to use the default setting. |
|
983 | 985 |
$title = t('Panel style for region "!region"', array('!region' => $this->plugins['layout']['regions'][$pid])); |
984 | 986 |
break; |
985 | 987 |
|
... | ... | |
1032 | 1034 |
} |
1033 | 1035 |
|
1034 | 1036 |
// If there's no settings form, just change the style and exit. |
1035 |
switch($type) { |
|
1037 |
switch ($type) {
|
|
1036 | 1038 |
case 'display': |
1037 | 1039 |
$this->display->panel_settings['style'] = $form_state['style']; |
1038 | 1040 |
if (isset($this->display->panel_settings['style_settings']['default'])) { |
... | ... | |
1062 | 1064 |
if ($type == 'pane') { |
1063 | 1065 |
$this->command_update_pane($pane); |
1064 | 1066 |
} |
1065 |
else if ($type == 'region') {
|
|
1067 |
elseif ($type == 'region') { |
|
1066 | 1068 |
$this->command_update_region_links($pid); |
1067 | 1069 |
} |
1068 | 1070 |
else { |
... | ... | |
1075 | 1077 |
panels_edit_cache_set($this->cache); |
1076 | 1078 |
} |
1077 | 1079 |
|
1078 |
// send them to next form.
|
|
1080 |
// Send them to next form.
|
|
1079 | 1081 |
return $this->ajax_style_settings($type, $pid); |
1080 | 1082 |
} |
1081 | 1083 |
} |
... | ... | |
1214 | 1216 |
} |
1215 | 1217 |
|
1216 | 1218 |
// Copy settings from form state back into the cache. |
1217 |
if(!empty($form_state['values']['settings'])) { |
|
1219 |
if (!empty($form_state['values']['settings'])) {
|
|
1218 | 1220 |
if ($type == 'pane') { |
1219 | 1221 |
$this->cache->display->content[$pid]->style['settings'] = $form_state['values']['settings']; |
1220 | 1222 |
} |
1221 |
else if($type == 'region') {
|
|
1223 |
elseif ($type == 'region') {
|
|
1222 | 1224 |
$this->cache->display->panel_settings['style_settings'][$pid] = $form_state['values']['settings']; |
1223 | 1225 |
} |
1224 | 1226 |
} |
... | ... | |
1230 | 1232 |
if ($type == 'pane') { |
1231 | 1233 |
$this->command_update_pane($pane); |
1232 | 1234 |
} |
1233 |
else if ($type == 'region') {
|
|
1235 |
elseif ($type == 'region') { |
|
1234 | 1236 |
$this->command_update_region_links($pid); |
1235 | 1237 |
} |
1236 | 1238 |
else { |
... | ... | |
1354 | 1356 |
|
1355 | 1357 |
$output = ctools_modal_form_wrapper('panels_edit_add_access_test_form', $form_state); |
1356 | 1358 |
if (!empty($form_state['executed'])) { |
1357 |
// Set up the plugin in cache |
|
1359 |
// Set up the plugin in cache.
|
|
1358 | 1360 |
$plugin = ctools_get_access_plugin($form_state['values']['type']); |
1359 | 1361 |
$this->cache->new_plugin = ctools_access_new_test($plugin); |
1360 | 1362 |
panels_edit_cache_set($this->cache); |
1361 | 1363 |
|
1362 |
// go to the next step.
|
|
1364 |
// Go to the next step.
|
|
1363 | 1365 |
return $this->ajax_access_configure_test($pid, 'add'); |
1364 | 1366 |
} |
1365 | 1367 |
|
... | ... | |
1387 | 1389 |
$pane->access['plugins'][] = $this->cache->new_plugin; |
1388 | 1390 |
$id = max(array_keys($pane->access['plugins'])); |
1389 | 1391 |
} |
1390 |
else if (empty($pane->access['plugins'][$id])) {
|
|
1392 |
elseif (empty($pane->access['plugins'][$id])) { |
|
1391 | 1393 |
ctools_modal_render(t('Error'), t('Invalid test id.')); |
1392 | 1394 |
} |
1393 | 1395 |
|
... | ... | |
1407 | 1409 |
return; |
1408 | 1410 |
} |
1409 | 1411 |
|
1410 |
// Unset the new plugin |
|
1412 |
// Unset the new plugin.
|
|
1411 | 1413 |
if (isset($this->cache->new_plugin)) { |
1412 | 1414 |
unset($this->cache->new_plugin); |
1413 | 1415 |
} |
... | ... | |
1483 | 1485 |
// |
1484 | 1486 |
// These are used to make sure that child implementations can control their |
1485 | 1487 |
// own AJAX commands as needed. |
1486 |
|
|
1487 | 1488 |
/** |
1488 | 1489 |
* Create a command array to redraw a pane. |
1489 | 1490 |
*/ |
... | ... | |
1527 | 1528 |
function command_update_region_links($id) { |
1528 | 1529 |
$this->commands[] = ajax_command_replace('.panels-region-links-' . $id, $this->get_region_links($id)); |
1529 | 1530 |
} |
1531 |
|
|
1530 | 1532 |
} |
1531 | 1533 |
|
1532 | 1534 |
/** |
... | ... | |
1559 | 1561 |
} |
1560 | 1562 |
|
1561 | 1563 |
// -------------------------------------------------------------------------- |
1562 |
// Forms for the editor object |
|
1563 |
|
|
1564 |
// Forms for the editor object. |
|
1564 | 1565 |
/** |
1565 |
* Choose cache method form |
|
1566 |
* Choose cache method form.
|
|
1566 | 1567 |
*/ |
1567 | 1568 |
function panels_edit_cache_method_form($form, &$form_state) { |
1568 | 1569 |
ctools_form_include($form_state, 'plugins', 'panels'); |
... | ... | |
1612 | 1613 |
} |
1613 | 1614 |
|
1614 | 1615 |
/** |
1615 |
* Cache settings form |
|
1616 |
* Cache settings form.
|
|
1616 | 1617 |
*/ |
1617 | 1618 |
function panels_edit_cache_settings_form($form, &$form_state) { |
1618 | 1619 |
ctools_form_include($form_state, 'plugins', 'panels'); |
... | ... | |
1674 | 1675 |
} |
1675 | 1676 |
|
1676 | 1677 |
/** |
1677 |
* Choose style form |
|
1678 |
* Choose style form.
|
|
1678 | 1679 |
*/ |
1679 | 1680 |
function panels_edit_style_type_form($form, &$form_state) { |
1680 | 1681 |
ctools_form_include($form_state, 'plugins', 'panels'); |
... | ... | |
1726 | 1727 |
} |
1727 | 1728 |
|
1728 | 1729 |
/** |
1729 |
* Style settings form |
|
1730 |
* Style settings form.
|
|
1730 | 1731 |
*/ |
1731 | 1732 |
function panels_edit_style_settings_form($form, &$form_state) { |
1732 | 1733 |
ctools_form_include($form_state, 'plugins', 'panels'); |
... | ... | |
1755 | 1756 |
'#value' => t('Save'), |
1756 | 1757 |
); |
1757 | 1758 |
|
1758 |
|
|
1759 | 1759 |
// Need a cancel button since the style cache can persist and impact the wrong |
1760 | 1760 |
// pane (or region, or display). |
1761 | 1761 |
$form['cancel_style'] = array( |
... | ... | |
2038 | 2038 |
} |
2039 | 2039 |
|
2040 | 2040 |
/** |
2041 |
* Validate handler for visibility rule settings |
|
2041 |
* Validate handler for visibility rule settings.
|
|
2042 | 2042 |
*/ |
2043 | 2043 |
function panels_edit_configure_access_test_form_validate(&$form, &$form_state) { |
2044 | 2044 |
if (!empty($form_state['clicked_button']['#remove'])) { |
... | ... | |
2051 | 2051 |
} |
2052 | 2052 |
|
2053 | 2053 |
/** |
2054 |
* Submit handler for visibility rule settings |
|
2054 |
* Submit handler for visibility rule settings.
|
|
2055 | 2055 |
*/ |
2056 | 2056 |
function panels_edit_configure_access_test_form_submit(&$form, &$form_state) { |
2057 | 2057 |
if (!empty($form_state['clicked_button']['#remove'])) { |
... | ... | |
2069 | 2069 |
} |
2070 | 2070 |
$form_state['test']['not'] = !empty($form_state['values']['not']); |
2071 | 2071 |
} |
2072 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules