Definition in file panels_page.admin.inc.
Go to the source code of this file.
| _panels_page_insert | ( | &$ | panel_page | ) |
Insert a new panel page into the database.
Definition at line 1017 of file panels_page.admin.inc.
References _panels_page_save_value(), panels_page_fields(), and panels_save_display().
Referenced by panels_page_save().
01017 { 01018 $fields = $types = $values = array(); 01019 01020 // Save the primary display, thus creating a $display->did. 01021 panels_save_display($panel_page->primary); 01022 $panel_page->did = $panel_page->primary->did; 01023 $panel_page->pid = db_next_id('{panels_page}_pid'); 01024 01025 $clone = drupal_clone($panel_page); 01026 01027 // Add these manually rather than putting them in panels_page_fields() itself 01028 $all_fields = array_merge(panels_page_fields(), array("pid" => "%d", "did" => "%d")); 01029 foreach ($all_fields as $field => $placeholder) { 01030 if (isset($panel_page->$field)) { 01031 $fields[] = $field; 01032 $placeholders[] = $placeholder; 01033 $values[] = _panels_page_save_value($field, $clone->$field); 01034 } 01035 } 01036 01037 // Build the query adding the new pid and did. 01038 $sql = 'INSERT INTO {panels_page} (' . implode(', ', $fields) . ') VALUES (' . implode(' , ', $placeholders) . ')'; 01039 01040 db_query($sql, $values); 01041 01042 menu_rebuild(); 01043 // Return the pid for convenience. 01044 return $panel_page->pid; 01045 }
| _panels_page_save_value | ( | $ | field, | |
| $ | value | |||
| ) |
Process values for saving based upon data in the schema
Definition at line 1084 of file panels_page.admin.inc.
Referenced by _panels_page_insert(), and _panels_page_update().
01084 { 01085 switch ($field) { 01086 case 'arguments': 01087 case 'displays': 01088 case 'contexts': 01089 case 'relationships': 01090 case 'switcher_options': 01091 return serialize($value); 01092 case 'access': 01093 return implode(', ', (array) $value); 01094 default: 01095 return $value; 01096 } 01097 }
| _panels_page_update | ( | &$ | panel_page | ) |
Save an existing panel page to the database.
Definition at line 1050 of file panels_page.admin.inc.
References _panels_page_save_value(), panels_page_fields(), and panels_save_display().
Referenced by panels_page_save().
01050 { 01051 $values = $pairs = array(); 01052 01053 // Save the display if one was given to us. 01054 if (!empty($panel_page->display)) { 01055 panels_save_display($panel_page->display); 01056 if (!empty($panel_page->export)) { 01057 $panel_page->displays[$panel_page->export]['did'] = $panel_page->display->did; 01058 unset($panel_page->displays[$panel_page->export]['display']); 01059 $panel_page->current = $panel_page->export; 01060 } 01061 } 01062 01063 // Build arrays of fields and types (resp. pairs of both) and of values. 01064 foreach (panels_page_fields() as $field => $placeholder) { 01065 // Skip empty values. 01066 if (isset($panel_page->$field)) { 01067 $pairs[] = $field . " = " . $placeholder; 01068 $values[] = _panels_page_save_value($field, $panel_page->$field); 01069 } 01070 } 01071 01072 // Build the query filtering by the primary key. 01073 $sql = 'UPDATE {panels_page} SET ' . implode(', ', $pairs) . ' WHERE pid = %d'; 01074 $values[] = $panel_page->pid; 01075 01076 db_query($sql, $values); 01077 // Return the pid for convenience. 01078 return $panel_page->pid; 01079 }
| panels_page_add_page | ( | $ | layout = NULL |
) |
Handle the add panel-page page.
Definition at line 179 of file panels_page.admin.inc.
References panels_get_layouts(), panels_new_display(), panels_page_sanitize(), and panels_print_layout_link().
00179 { 00180 $layouts = panels_get_layouts(); 00181 00182 // If the layout given is invalid, unset it. 00183 if (is_array($layout) && isset($layouts[$layout])) { 00184 drupal_set_message(t('The chosen layout %layout is invalid. Please select a new one.', array('%layout' => $layout)), 'warning'); 00185 unset($layout); 00186 } 00187 // If no page layout is given, choose one first. 00188 if ($layout === NULL) { 00189 foreach ($layouts as $id => $layout) { 00190 $output .= panels_print_layout_link($id, $layout, $_GET['q'] . '/' . $id); 00191 } 00192 return $output; 00193 } 00194 00195 $panel_page = new stdClass(); 00196 $panel_page->primary = panels_new_display(); 00197 $panel_page->display =& $panel_page->primary; 00198 $panel_page->display->layout = $layout; 00199 $panel_page->pid = 'new'; 00200 $panel_page->did = 'new'; 00201 00202 drupal_set_title(t('Add panel page')); 00203 return drupal_get_form('panels_page_edit_form', panels_page_sanitize($panel_page)); 00204 }
| panels_page_admin_view | ( | $ | panel_page, | |
| $ | args | |||
| ) |
Definition at line 879 of file panels_page.admin.inc.
References panels_context_load_contexts(), and panels_page_get_url().
00879 { 00880 $form = array(); 00881 00882 $form['fieldset'] = array( 00883 '#type' => 'fieldset', 00884 '#title' => t('Administrative view: enter arguments'), 00885 '#collapsible' => TRUE, 00886 ); 00887 00888 $required_args = strpos($panel_page->path, '%') === false ? 0 : count(split($panel_page->path, '%')); 00889 00890 $url = panels_page_get_url($panel_page, $args); 00891 if ($args_missing = max($required_args - count($args), 0)) { 00892 $value = $url; 00893 $description = format_plural($args_missing, 00894 '1 argument is missing to generate a valid URL.', 00895 '@count arguments are missing to generate a valid URL.' 00896 ); 00897 } 00898 else { 00899 $value = l($url, $url); 00900 $description = t('Click to see the real panel page.'); 00901 } 00902 $form['fieldset']['url'] = array( 00903 '#type' => 'item', 00904 '#title' => t('Real panel URL'), 00905 '#value' => $value, 00906 '#description' => $description, 00907 ); 00908 00909 $contexts = panels_context_load_contexts($panel_page); 00910 $count = 0; 00911 foreach ($contexts as $id => $context) { 00912 if (substr($id, 0, 8) == 'argument') { 00913 $required = ($count + 1 <= $required_args) ? TRUE : FALSE; 00914 $description = $required ? t('Required argument (occupies %-placeholder number !position)', array('!position' => $count + 1)) : t('Optional argument'); 00915 $form['fieldset']["arg$count"] = array( 00916 '#type' => 'textfield', 00917 '#title' => check_plain($context->identifier), 00918 '#default_value' => isset($args[$count]) ? $args[$count] : '', 00919 '#required' => $required, 00920 '#description' => $description, 00921 ); 00922 } 00923 if (isset($args[$count])) { 00924 unset($args[$count]); 00925 } 00926 $count++; 00927 } 00928 00929 $add = ''; 00930 if ($args) { 00931 $add = implode('/', $args); 00932 } 00933 $form['fieldset']['additional'] = array( 00934 '#type' => 'textfield', 00935 '#title' => t('Additional arguments'), 00936 '#description' => t('Separated by /'), 00937 '#default_value' => $add, 00938 ); 00939 00940 $form['fieldset']['submit'] = array( 00941 '#type' => 'submit', 00942 '#value' => t('Change arguments'), 00943 ); 00944 00945 $form['panel_page'] = array( 00946 '#type' => 'value', 00947 '#value' => $panel_page, 00948 ); 00949 $form['contexts'] = array( 00950 '#type' => 'value', 00951 '#value' => $contexts, 00952 ); 00953 00954 return $form; 00955 }
| panels_page_admin_view_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
Definition at line 957 of file panels_page.admin.inc.
00957 { 00958 $count = 0; 00959 $url = "admin/panels/panel-page/" . $form_values['panel_page']->name . "/preview"; 00960 foreach ($form_values['contexts'] as $context) { 00961 $url .= "/" . $form_values["arg$count"]; 00962 $count++; 00963 } 00964 if (!empty($form_values['additional'])) { 00965 $url .= "/" . $form_values['additional']; 00966 } 00967 return $url; 00968 }
| panels_page_advanced_form | ( | $ | panel_page, | |
| $ | next = NULL | |||
| ) |
The form to edit the advanced settings of a panel page.
Definition at line 408 of file panels_page.admin.inc.
References panels_get_path().
00408 { 00409 drupal_add_css(panels_get_path('css/panels_admin.css')); 00410 00411 $form['panel_page'] = array( 00412 '#type' => 'value', 00413 '#value' => $panel_page, 00414 ); 00415 00416 $form['right'] = array( 00417 '#prefix' => '<div class="right-container">', 00418 '#suffix' => '</div>', 00419 ); 00420 00421 $form['left'] = array( 00422 '#prefix' => '<div class="left-container">', 00423 '#suffix' => '</div>', 00424 ); 00425 00426 $form['right']['advanced'] = array( 00427 '#type' => 'fieldset', 00428 '#collapsible' => FALSE, 00429 '#collapsed' => FALSE, 00430 '#title' => t('Advanced settings'), 00431 ); 00432 00433 $form['right']['advanced']['no_blocks'] = array( 00434 '#type' => 'checkbox', 00435 '#default_value' => $panel_page->no_blocks, 00436 '#title' => t('Disable Drupal blocks/regions'), 00437 '#description' => t('Check this to have the panel page disable all regions displayed in the theme.'), 00438 ); 00439 00440 $rids = array(); 00441 $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name"); 00442 while ($obj = db_fetch_object($result)) { 00443 $rids[$obj->rid] = $obj->name; 00444 } 00445 00446 $form['right']['advanced']['access'] = array( 00447 '#type' => 'checkboxes', 00448 '#title' => t('Access'), 00449 '#default_value' => $panel_page->access, 00450 '#options' => $rids, 00451 '#description' => t('Only the checked roles will be able to see this panel in any form; if no roles are checked, access will not be restricted.'), 00452 ); 00453 00454 $form['right']['advanced']['css'] = array( 00455 '#type' => 'textarea', 00456 '#title' => t('CSS code'), 00457 '#description' => t('Enter well-formed CSS code here; this code will be embedded into the page, and should only be used for minor adjustments; it is usually better to try to put CSS for the page into the theme if possible.'), 00458 '#default_value' => $panel_page->css, 00459 ); 00460 00461 $form['left']['menu-info'] = array( 00462 '#type' => 'fieldset', 00463 '#collapsible' => FALSE, 00464 '#title' => t('Menu'), 00465 ); 00466 00467 $form['left']['menu-info']['menu'] = array( 00468 '#type' => 'checkbox', 00469 '#title' => t('Provide Menu'), 00470 '#return_value' => 1, 00471 '#default_value' => $panel_page->menu, 00472 '#description' => t('If checked this panel be given a menu entry in the Drupal menu system. If not checked the data in this group will be ignored.'), 00473 ); 00474 00475 $form['left']['menu-info']['menu_tab'] = array( 00476 '#type' => 'checkbox', 00477 '#title' => t('Provide Menu as Tab'), 00478 '#return_value' => 1, 00479 '#default_value' => $panel_page->menu_tab, 00480 '#description' => t("If checked this panel's menu entry will be provided as a tab rather than in the main menu system."), 00481 ); 00482 00483 $form['left']['menu-info']['menu_tab_weight'] = array( 00484 '#type' => 'textfield', 00485 '#title' => t('Tab Weight'), 00486 '#default_value' => $panel_page->menu_tab_weight, 00487 '#size' => 5, 00488 '#description' => t('If this is a menu tab, select the weight; lower numbers will be further to the left.'), 00489 ); 00490 00491 $form['left']['menu-info']['menu_title'] = array( 00492 '#type' => 'textfield', 00493 '#title' => t('Menu Title'), 00494 '#default_value' => $panel_page->menu_title, 00495 '#size' => 35, 00496 '#maxlength' => 255, 00497 '#description' => t('Enter the title to use for the menu entry or tab. If blank, the page title will be used.'), 00498 ); 00499 00500 $form['left']['menu-info']['default-tab'] = array( 00501 '#type' => 'fieldset', 00502 '#collapsible' => TRUE, 00503 '#collapsed' => TRUE, 00504 '#title' => t('Default Menu Tab'), 00505 ); 00506 00507 $form['left']['menu-info']['default-tab']['menu_tab_default'] = array( 00508 '#type' => 'checkbox', 00509 '#title' => t('Make Default Menu Tab'), 00510 '#return_value' => 1, 00511 '#default_value' => $panel_page->menu_tab_default, 00512 '#description' => t("If checked this panel's menu entry will be provided as a tab, and will be the default tab for that URL path. For example, if the URL is 'tracker/all' and it is set as the default menu tab, it will be put into the menu as 'tracker' and 'tracker/all' will be the default tab. The following settings allow you to customize the parent item, for example 'tracker'. For tabs to work properly, one tab in the group must be set as the default."), 00513 ); 00514 00515 $form['left']['menu-info']['default-tab']['menu_tab_default_parent_type'] = array( 00516 '#type' => 'select', 00517 '#title' => t('Parent Menu Item Type'), 00518 '#default_value' => $panel_page->menu_tab_default_parent_type, 00519 '#options' => array( 00520 'tab' => t("Tab"), 00521 'normal' => t("Normal menu item"), 00522 'existing' => t("Already exists (don't create)"), 00523 ), 00524 '#description' => t("Select type of parent item to use for this default menu tab. You can either specify the parent should be a tab (the default), a normal menu item, or to use the menu item that already exists at the specified URL. For example, if the URL for the default tab is 'tracker/all', then 'tracker' would already have to be a valid menu item to use this final choice."), 00525 ); 00526 00527 $form['left']['menu-info']['default-tab']['menu_parent_tab_weight'] = array( 00528 '#type' => 'textfield', 00529 '#title' => t('Tab Weight'), 00530 '#default_value' => $panel_page->menu_parent_tab_weight, 00531 '#size' => 5, 00532 '#description' => t('If the parent menu item is a tab, select the weight; lower numbers will be further to the left.'), 00533 ); 00534 00535 $form['left']['menu-info']['default-tab']['menu_parent_title'] = array( 00536 '#type' => 'textfield', 00537 '#title' => t('Parent Menu Item Title'), 00538 '#default_value' => $panel_page->menu_parent_title, 00539 '#size' => 35, 00540 '#maxlength' => 255, 00541 '#description' => t('If the Parent Menu Item is being defined by this panel (if you set the %type_field to either %tab or %menu), you can specify its title here. If blank, the menu title will be used if that is defined, or the page title if not.', array('%type_field' => t('Parent Menu Item Type'), '%tab' => t('Tab'), '%menu' => t('Normal menu item'))), 00542 ); 00543 00544 $label = ($next) ? t('Save and proceed') : t('Save'); 00545 $form['submit'] = array( 00546 '#type' => 'submit', 00547 '#value' => $label, 00548 ); 00549 00550 return $form; 00551 }
| panels_page_advanced_form_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
Process submission of the panel page edit form.
Definition at line 556 of file panels_page.admin.inc.
References panels_page_save().
00556 { 00557 $panel_page = $form_values['panel_page']; 00558 00559 $panel_page->css = $form_values['css']; 00560 $panel_page->no_blocks = $form_values['no_blocks']; 00561 $panel_page->menu = $form_values['menu']; 00562 $panel_page->menu_tab = $form_values['menu_tab']; 00563 $panel_page->menu_tab_weight = $form_values['menu_tab_weight']; 00564 $panel_page->menu_title = $form_values['menu_title']; 00565 $panel_page->menu_tab_default = $form_values['menu_tab_default']; 00566 $panel_page->menu_tab_default_parent_type = $form_values['menu_tab_default_parent_type']; 00567 $panel_page->menu_parent_title = $form_values['menu_parent_title']; 00568 $panel_page->menu_parent_tab_weight = $form_values['menu_parent_tab_weight']; 00569 00570 $panel_page->access = array_keys(array_filter($form_values['access'])); 00571 00572 drupal_set_message(t('Your changes have been saved.')); 00573 panels_page_save($panel_page); 00574 if ($form_values['submit'] == t('Save and proceed')) { 00575 return "admin/panels/panel-page/$panel_page->name/edit/context/next"; 00576 } 00577 }
| panels_page_context_form | ( | $ | panel_page, | |
| $ | next = NULL | |||
| ) |
The form to edit the context settings of a panel page.
Definition at line 598 of file panels_page.admin.inc.
References panels_common_add_argument_form(), panels_common_add_context_form(), panels_common_add_context_js(), panels_common_add_relationship_form(), panels_get_layout(), panels_get_path(), and panels_load_include().
00598 { 00599 drupal_add_css(panels_get_path('css/panels_admin.css')); 00600 $layout = panels_get_layout($panel_page->display->layout); 00601 00602 $form['panel_page'] = array( 00603 '#type' => 'value', 00604 '#value' => $panel_page, 00605 ); 00606 00607 $form['right'] = array( 00608 '#prefix' => '<div class="right-container">', 00609 '#suffix' => '</div>', 00610 ); 00611 00612 $form['left'] = array( 00613 '#prefix' => '<div class="left-container">', 00614 '#suffix' => '</div>', 00615 ); 00616 00617 panels_load_include('common'); 00618 00619 $settings = panels_common_add_argument_form('panel_page', $form, $form['left']['arguments_table'], $panel_page); 00620 $settings += panels_common_add_context_form('panel_page', $form, $form['right']['contexts_table'], $panel_page); 00621 $settings += panels_common_add_relationship_form('panel_page', $form, $form['left']['relationships_table'], $panel_page); 00622 panels_common_add_context_js($settings); 00623 00624 $label = ($next) ? t('Save and proceed') : t('Save'); 00625 $form['submit'] = array( 00626 '#type' => 'submit', 00627 '#value' => $label, 00628 ); 00629 00630 return $form; 00631 }
| panels_page_context_form_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
Process submission of the panel page edit form.
Definition at line 636 of file panels_page.admin.inc.
References panels_common_cache_clear(), panels_common_save_context(), panels_delete_display(), panels_get_argument(), and panels_page_save().
00636 { 00637 $panel_page = $form_values['panel_page']; 00638 00639 // Organize these from the common form. 00640 panels_common_save_context('argument', $panel_page->arguments, $form_values); 00641 panels_common_save_context('context', $panel_page->contexts, $form_values); 00642 panels_common_save_context('relationship', $panel_page->relationships, $form_values); 00643 00644 // Match up our displays, carry them forward and add new ones. 00645 $old_displays = $panel_page->displays; 00646 $panel_page->displays = array(); 00647 00648 foreach ($panel_page->arguments as $id => $argument) { 00649 $def = panels_get_argument($argument['name']); 00650 if (function_exists($def['displays'])) { 00651 // Figure out which instance of this particular argument type we're using. 00652 00653 $displays = $def['displays']($argument['argument_settings'], $argument['id']); 00654 foreach ($displays as $did => $info) { 00655 $pdid = "argument_$id" . '-' . $did; 00656 if (isset($old_displays[$pdid])) { 00657 $panel_page->displays[$pdid] = $old_displays[$pdid]; 00658 unset($old_displays[$pdid]); 00659 // ensure titles get updated if necessary 00660 $panel_page->displays[$pdid]['title'] = $info['title']; 00661 } 00662 else { 00663 $panel_page->displays[$pdid] = array( 00664 'did' => 'new', 00665 'title' => $info['title'], 00666 'default' => "argument_$id" . '-' . $info['default'], 00667 'argument_id' => $id, 00668 'context' => $info['context'], 00669 ); 00670 } 00671 } 00672 } 00673 } 00674 00675 // Remove remaining old displays. 00676 foreach ($old_displays as $id => $info) { 00677 if (is_numeric($info['did'])) { 00678 panels_delete_display($info['did']); 00679 drupal_set_message(t('Removed unused display @title', $info['title'])); 00680 } 00681 } 00682 00683 drupal_set_message(t('Your changes have been saved.')); 00684 panels_page_save($panel_page); 00685 panels_common_cache_clear('panel_object:panel_page', $panel_page->name); 00686 menu_rebuild(); 00687 if ($form_values['submit'] == t('Save and proceed')) { 00688 return "admin/panels/panel-page/$panel_page->name/edit/content"; 00689 } 00690 }
| panels_page_delete_confirm | ( | $ | panel_page | ) |
Provide a form to confirm deletion of a panel page.
Definition at line 141 of file panels_page.admin.inc.
References panels_page_get_title(), and panels_page_load().
00141 { 00142 if (!is_object($panel_page)) { 00143 $panel_page = panels_page_load($panel_page); 00144 } 00145 $form['pid'] = array('#type' => 'value', '#value' => $panel_page->pid); 00146 $form['did'] = array('#type' => 'value', '#value' => $panel_page->did); 00147 if ($panel_page->type != t('Overridden')) { 00148 return confirm_form($form, 00149 t('Are you sure you want to delete "@title"?', array('@title' => panels_page_get_title($panel_page))), 00150 $_GET['destination'] ? $_GET['destination'] : 'admin/panels/panel-page', 00151 t('This action cannot be undone.'), 00152 t('Delete'), t('Cancel') 00153 ); 00154 } 00155 else { 00156 return confirm_form($form, 00157 t('Are you sure you want to revert "@title" to its default setup?', array('@title' => panels_page_get_title($panel_page))), 00158 $_GET['destination'] ? $_GET['destination'] : 'admin/panels/panel-page', 00159 t('This action cannot be undone.'), 00160 t('Revert'), t('Cancel') 00161 ); 00162 } 00163 }
| panels_page_delete_confirm_submit | ( | $ | form_id, | |
| $ | form | |||
| ) |
Handle the submit button to delete a panel page.
Definition at line 168 of file panels_page.admin.inc.
References panels_page_delete().
00168 { 00169 if ($form['confirm']) { 00170 panels_page_delete((object) $form); 00171 // TODO: Is this necessary or did we feed it the location already? 00172 return 'admin/panels/panel-page'; 00173 } 00174 }
| panels_page_disable_page | ( | $ | name = NULL |
) |
Disable a default panel.
Definition at line 126 of file panels_page.admin.inc.
References panels_page_default_panels().
00126 { 00127 $defaults = panels_page_default_panels(); 00128 if (isset($defaults[$name])) { 00129 $status = variable_get('panel_page_defaults', array()); 00130 $status[$name] = TRUE; 00131 variable_set('panel_page_defaults', $status); 00132 drupal_set_message(t('Panel page disabled')); 00133 menu_rebuild(); 00134 } 00135 drupal_goto(); 00136 }
| panels_page_edit | ( | $ | panel_page | ) |
Edit a panel page.
Called from both the add and edit points to provide for common flow.
Definition at line 211 of file panels_page.admin.inc.
References panels_load_display(), panels_page_get_title(), and panels_page_load().
00211 { 00212 if (!is_object($panel_page)) { 00213 $panel_page = panels_page_load($panel_page); 00214 } 00215 00216 if (empty($panel_page->display)) { 00217 $panel_page->display = panels_load_display($panel_page->did); 00218 } 00219 00220 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00221 return drupal_get_form('panels_page_edit_form', $panel_page); 00222 }
| panels_page_edit_advanced | ( | $ | name, | |
| $ | next = NULL | |||
| ) |
Edit advanced settings of a panel page.
Definition at line 399 of file panels_page.admin.inc.
References panels_page_get_title(), and panels_page_load().
00399 { 00400 $panel_page = panels_page_load($name); 00401 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00402 return drupal_get_form('panels_page_advanced_form', $panel_page, $next); 00403 }
| panels_page_edit_content | ( | $ | panel_page, | |
| $ | did = NULL | |||
| ) |
Pass through to the panels content editor.
Definition at line 761 of file panels_page.admin.inc.
References panels_common_get_allowed_types(), panels_context_load_contexts(), panels_edit(), panels_load_include(), panels_page_fetch_display(), panels_page_get_title(), panels_page_load(), and panels_page_save_display().
00761 { 00762 if (!is_object($panel_page)) { 00763 $panel_page = panels_page_load($panel_page); 00764 } 00765 00766 panels_page_fetch_display($panel_page, $did); 00767 $display = $panel_page->display; 00768 00769 // Collect a list of contexts required by the arguments on this page. 00770 $contexts = panels_context_load_contexts($panel_page); 00771 00772 $display->context = $contexts; 00773 $display->args = array(); 00774 00775 // Get a list of available content. 00776 panels_load_include('common'); 00777 $content_types = panels_common_get_allowed_types('panels_page', $contexts); 00778 00779 $output = panels_edit($display, NULL, $content_types); 00780 if (is_object($output)) { 00781 $panel_page->display = $output; 00782 panels_page_save_display($panel_page); 00783 00784 // And do the drupal_goto that a submit function ordinarily would have. 00785 $dest = "admin/panels/panel-page/$panel_page->name/edit/content"; 00786 if ($did) { 00787 $dest .= "/$did"; 00788 } 00789 drupal_goto($dest); 00790 } 00791 00792 // Print this with theme('page') so that blocks are disabled while editing a display. 00793 // This is important because negative margins in common block layouts (i.e, Garland) 00794 // messes up the drag & drop. 00795 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00796 print theme('page', $output, FALSE); 00797 }
| panels_page_edit_context | ( | $ | name, | |
| $ | next = NULL | |||
| ) |
Edit advanced settings of a panel page.
Definition at line 582 of file panels_page.admin.inc.
References panels_common_cache_get(), panels_common_cache_set(), panels_page_get_title(), and panels_page_load().
00582 { 00583 if (!empty($_POST)) { 00584 $panel_page = panels_common_cache_get('panel_object:panel_page', $name); 00585 } 00586 else { 00587 $panel_page = panels_page_load($name); 00588 panels_common_cache_set('panel_object:panel_page', $name, $panel_page); 00589 } 00590 00591 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00592 return drupal_get_form('panels_page_context_form', $panel_page, $next); 00593 }
| panels_page_edit_export | ( | $ | panel_page | ) |
Page callback to export a panel page to PHP code.
Definition at line 802 of file panels_page.admin.inc.
References panels_page_export(), and panels_page_load().
00802 { 00803 if (!is_object($panel_page)) { 00804 $panel_page = panels_page_load($panel_page); 00805 } 00806 drupal_set_title(check_plain($panel_page->title)); 00807 $code = panels_page_export($panel_page); 00808 00809 $lines = substr_count($code, "\n"); 00810 $form['code'] = array( 00811 '#type' => 'textarea', 00812 '#title' => $panel_page->title, 00813 '#default_value' => $code, 00814 '#rows' => $lines, 00815 ); 00816 return $form; 00817 }
| panels_page_edit_form | ( | $ | panel_page, | |
| $ | next = NULL | |||
| ) |
The form to edit the page portion of a panel.
Definition at line 227 of file panels_page.admin.inc.
References panels_context_load_contexts(), panels_get_layout(), panels_get_path(), panels_load_include(), and panels_print_layout_icon().
00227 { 00228 panels_load_include('common'); 00229 drupal_add_css(panels_get_path('css/panels_admin.css')); 00230 $layout = panels_get_layout($panel_page->display->layout); 00231 00232 $form['pid'] = array( 00233 '#type' => 'value', 00234 '#value' => $panel_page->pid, 00235 ); 00236 00237 $form['panel_page'] = array( 00238 '#type' => 'value', 00239 '#value' => $panel_page, 00240 ); 00241 00242 $form['right'] = array( 00243 '#prefix' => '<div class="layout-container">', 00244 '#suffix' => '</div>', 00245 ); 00246 00247 $form['left'] = array( 00248 '#prefix' => '<div class="panel-page-info-container">', 00249 '#suffix' => '</div>', 00250 ); 00251 00252 $form['left']['info'] = array( 00253 '#type' => 'fieldset', 00254 '#title' => t('Page settings'), 00255 ); 00256 00257 $form['right']['layout'] = array( 00258 '#type' => 'fieldset', 00259 '#title' => t('Layout'), 00260 ); 00261 00262 $form['right']['layout']['layout-icon'] = array( 00263 '#value' => panels_print_layout_icon($panel_page->display->layout, $layout), 00264 ); 00265 00266 $form['right']['layout']['layout-display'] = array( 00267 '#value' => check_plain($layout['title']), 00268 ); 00269 00270 $panel_page->context = $panel_page->display->context = panels_context_load_contexts($panel_page); 00271 00272 $form['right']['layout']['layout-content'] = array( 00273 '#value' => theme('panels_common_content_list', $panel_page->display), //$content, 00274 ); 00275 00276 $contexts = theme('panels_common_context_list', $panel_page); 00277 if ($contexts) { 00278 $form['right']['context'] = array( 00279 '#type' => 'fieldset', 00280 '#title' => t('Contexts'), 00281 ); 00282 00283 $form['right']['context']['context'] = array( 00284 '#value' => $contexts, 00285 ); 00286 } 00287 00288 $form['left']['info']['name'] = array( 00289 '#type' => 'textfield', 00290 '#size' => 35, 00291 '#default_value' => $panel_page->name, 00292 '#title' => t('Panel name'), 00293 '#description' => t('A unique name used to identify this panel page internally. It must be only be alpha characters and underscores. No spaces, numbers or uppercase characters.'), 00294 '#required' => TRUE, 00295 ); 00296 00297 $form['left']['info']['title'] = array( 00298 '#type' => 'textfield', 00299 '#size' => 35, 00300 '#default_value' => $panel_page->title, 00301 '#title' => t('Page title'), 00302 '#description' => t("The page title for this panels layout. It will be used as the main title on this panel page, unless it is overriden later."), 00303 ); 00304 00305 $form['left']['info']['css_id'] = array( 00306 '#type' => 'textfield', 00307 '#size' => 35, 00308 '#default_value' => $panel_page->css_id, 00309 '#title' => t('CSS ID'), 00310 '#description' => t('The CSS ID to apply to this page'), 00311 ); 00312 00313 $form['left']['info']['path'] = array( 00314 '#type' => 'textfield', 00315 '#size' => 35, 00316 '#default_value' => $panel_page->path, 00317 '#title' => t('Path'), 00318 '#description' => t('The URL path to give this page, i.e, path/to/page. You may use "%" as an argument placeholder: i.e, node/%/panel'), 00319 '#required' => TRUE, 00320 ); 00321 00322 $label = ($panel_page->pid == 'new') ? t('Save and proceed') : t('Save'); 00323 $form['submit'] = array( 00324 '#type' => 'submit', 00325 '#value' => $label, 00326 ); 00327 00328 return $form; 00329 }
| panels_page_edit_form_submit | ( | $ | form_id, | |
| $ | form_values | |||
| ) |
Process submission of the panel page edit form
Definition at line 370 of file panels_page.admin.inc.
References panels_get_layout(), panels_page_save(), and panels_page_save_import().
00370 { 00371 $panel_page = $form_values['panel_page']; 00372 00373 $panel_page->title = $form_values['title']; 00374 $panel_page->name = preg_replace("/[\W]+/", '', $form_values['name']); 00375 $panel_page->css_id = $form_values['css_id']; 00376 $panel_page->path = $form_values['path']; 00377 00378 if ($panel_page->pid == 'new') { 00379 isset($_SESSION['pp_import']) ? panels_page_save_import($panel_page) : panels_page_save($panel_page); 00380 unset ($_SESSION['pp_import']); 00381 drupal_set_message(t('Your new panel page %title has been saved.', array('%title' => $panel_page->title))); 00382 $GLOBALS['form_values']['pid'] = $panel_page->pid; 00383 $layout = panels_get_layout($panel_page->display->layout); 00384 00385 if (!empty($layout['settings form'])) { 00386 return "admin/panels/panel-page/$panel_page->name/edit/settings/next"; 00387 } 00388 return "admin/panels/panel-page/$panel_page->name/edit/advanced/next"; 00389 } 00390 else { 00391 drupal_set_message(t('Your changes have been saved.')); 00392 panels_page_save($panel_page); 00393 } 00394 }
| panels_page_edit_form_validate | ( | $ | form_id, | |
| $ | form_values, | |||
| $ | form | |||
| ) |
Validate a panel page edit form.
Definition at line 334 of file panels_page.admin.inc.
00334 { 00335 // Validate the system name; check for its presence, pass it through a preg 00336 // filter for allowed characters, and test for uniqueness. 00337 if (!$form_values['name']) { 00338 form_error($form['left']['info']['name'], t('Panel name is required.')); 00339 } 00340 else if (preg_match("/[^A-Za-z0-9_]/", $form_values['name'])) { 00341 form_error($form['left']['info']['name'], t('Panel name must be alphanumeric or underscores only.')); 00342 } 00343 else if (!preg_match("/[A-Za-z_]/", $form_values['name'])) { 00344 form_error($form['left']['info']['name'], t('Panel name must not consist exclusively of numbers.')); 00345 } 00346 else { 00347 if (db_result(db_query("SELECT pid FROM {panels_page} WHERE name = '%s' AND pid <> %d", $form_values['name'], $form_values['pid']))) { 00348 form_error($form['left']['info']['name'], t('Panel name must be unique.')); 00349 } 00350 } 00351 00352 // Validate the path; check for its presence, uniqueness within panels_page, 00353 // and uniqueness with respect to path aliases. 00354 if (!$form_values['path']) { 00355 form_error($form['left']['info']['path'], t('Path is required.')); 00356 } 00357 else { 00358 if ($result = db_result(db_query("SELECT pid FROM {panels_page} WHERE path = '%s' AND pid <> %d", $form_values['path'], $form_values['pid']))) { 00359 form_error($form['left']['info']['path'], t('Path may not be the same as another panel page path.')); 00360 } 00361 if (db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $form_values['path']))) { 00362 form_error($form['left']['info']['path'], t('The path you have chosen is already aliased to @src.', array('@src' => $result))); 00363 } 00364 } 00365 }
| panels_page_edit_layout | ( | $ | panel_page, | |
| $ | did = NULL | |||
| ) |
Pass through to the panels layout editor.
Definition at line 695 of file panels_page.admin.inc.
References panels_edit_layout(), panels_page_fetch_display(), panels_page_get_title(), panels_page_load(), and panels_page_save_display().
00695 { 00696 if (!is_object($panel_page)) { 00697 $panel_page = panels_page_load($panel_page); 00698 } 00699 00700 panels_page_fetch_display($panel_page, $did); 00701 $display = $panel_page->display; 00702 00703 // The following form will return the $display upon successful submit, if 00704 // we didn't send the $dest. Which we don't, here. That way we can update 00705 // our panel_page if necessary and do our own goto. 00706 $output = panels_edit_layout($panel_page->display, t('Save')); 00707 if (is_object($output)) { 00708 $panel_page->display = $output; 00709 panels_page_save_display($panel_page); 00710 00711 $dest = "admin/panels/panel-page/$panel_page->name/edit/layout"; 00712 if ($did) { 00713 $dest .= "/$did"; 00714 } 00715 drupal_goto($dest); 00716 } 00717 00718 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00719 return $output; 00720 }
| panels_page_edit_layout_settings | ( | $ | panel_page, | |
| $ | did = NULL, |
|||
| $ | next = NULL | |||
| ) |
Pass through to the panels layout settings editor.
Definition at line 725 of file panels_page.admin.inc.
References panels_edit_layout_settings(), panels_page_fetch_display(), panels_page_get_title(), panels_page_load(), and panels_page_save_display().
00725 { 00726 if (!is_object($panel_page)) { 00727 $panel_page = panels_page_load($panel_page); 00728 } 00729 00730 panels_page_fetch_display($panel_page, $did); 00731 $display = $panel_page->display; 00732 00733 if (empty($next)) { 00734 $button = t('Save'); 00735 $dest = "admin/panels/panel-page/$panel_page->name/edit/settings"; 00736 if ($did) { 00737 $dest .= "/$did"; 00738 } 00739 } 00740 else { 00741 $button = t('Save and proceed'); 00742 $dest = "admin/panels/panel-page/$panel_page->name/edit/advanced/next"; 00743 } 00744 00745 // The following form will return the $display upon successful submit, if 00746 // we didn't send the $dest. Which we don't, here. 00747 $output = panels_edit_layout_settings($display, $button, NULL, $panel_page->title); 00748 if (is_object($output)) { 00749 $panel_page->display = $output; 00750 panels_page_save_display($panel_page); 00751 drupal_goto($dest); 00752 } 00753 00754 drupal_set_title(check_plain(panels_page_get_title($panel_page))); 00755 return $output; 00756 }
| panels_page_enable_page | ( | $ | name = NULL |
) |
Enable a default panel.
Definition at line 111 of file panels_page.admin.inc.
References panels_page_default_panels().
00111 { 00112 $defaults = panels_page_default_panels(); 00113 if (isset($defaults[$name])) { 00114 $status = variable_get('panel_page_defaults', array()); 00115 $status[$name] = FALSE; 00116 variable_set('panel_page_defaults', $status); 00117 menu_rebuild(); 00118 drupal_set_message(t('Panel page enabled')); 00119 } 00120 drupal_goto(); 00121 }
| panels_page_import_form | ( | ) |
Form to for the panel page import
Definition at line 835 of file panels_page.admin.inc.
00835 { 00836 $form['panel_page'] = array( 00837 '#type' => 'textarea', 00838 '#title' => t('Panel page code'), 00839 '#cols' => 60, 00840 '#rows' => 15, 00841 '#description' => t('Cut and paste the results of an exported panel page here.'), 00842 ); 00843 00844 $form['submit'] = array( 00845 '#type' => 'submit', 00846 '#value' => t('Import'), 00847 ); 00848 00849 $form['#redirect'] = FALSE; 00850 return $form; 00851 }
| panels_page_import_form_submit | ( | $ | form_id, | |
| $ | form | |||
| ) |
Handle the submit button on importing a panel page.
Definition at line 856 of file panels_page.admin.inc.
00856 { 00857 ob_start(); 00858 eval($form['panel_page']); 00859 ob_end_clean(); 00860 00861 if (isset($page)) { 00862 drupal_set_title(t('Import panel page "@s"', array('@s' => $page->title))); 00863 // Backwards-compatibility for exports that predate the new fetching system. 00864 if (!is_object($page->primary)) { 00865 $page->primary =& $page->display; 00866 } 00867 // As $page contains non-stdClass objects, 00868 // it needs to be serialized before being stored in the session variable. 00869 $_SESSION['pp_import'] = serialize($page); 00870 $output = drupal_get_form('panels_page_edit_form', $page); 00871 print theme('page', $output); 00872 exit; 00873 } 00874 else { 00875 drupal_set_message(t('Unable to get a panel page out of that.')); 00876 } 00877 }
| panels_page_import_page | ( | ) |
Page callback to import a panel page from PHP code.
Definition at line 822 of file panels_page.admin.inc.
00822 { 00823 if ($_POST['form_id'] == 'panels_page_edit_form') { 00824 $panel_page = unserialize($_SESSION['pp_import']); 00825 drupal_set_title(t('Import panel page "@s"', array('@s' => $panel_page->title))); 00826 return drupal_get_form('panels_page_edit_form', $panel_page); 00827 } 00828 00829 return drupal_get_form('panels_page_import_form'); 00830 }
| panels_page_list_page | ( | ) |
Provide a list of panels, with links to edit or delete them.
Definition at line 14 of file panels_page.admin.inc.
References panels_get_layouts(), panels_load_displays(), panels_page_get_title(), and panels_page_load_all().
00014 { 00015 $layouts = panels_get_layouts(); 00016 $items = array(); 00017 $sorts = array(); 00018 00019 $header = array( 00020 array('data' => t('Page title'), 'field' => 'title'), 00021 array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'), 00022 array('data' => t('Type'), 'field' => 'type'), 00023 t('Layout'), 00024 array('data' => t('URL'), 'field' => 'url'), 00025 t('Operations'), 00026 ); 00027 00028 // Load all panel pages and their primary displays. 00029 $panel_pages = panels_page_load_all(); 00030 $dids = array(); 00031 foreach ($panel_pages as $panel_page) { 00032 if (empty($panel_page->display)) { 00033 $dids[] = $panel_page->did; 00034 } 00035 } 00036 $displays = panels_load_displays($dids); 00037 00038 foreach ($panel_pages as $panel_page) { 00039 $ops = array(); 00040 if (empty($panel_page->disabled)) { 00041 $ops[] = l(t('Edit'), "admin/panels/panel-page/$panel_page->name/edit/general"); 00042 $ops[] = l(t('Export'), "admin/panels/panel-page/$panel_page->name/export"); 00043 } 00044 if ($panel_page->type != t('Default')) { 00045 $text = $panel_page->type == t('Overridden') ? t('Revert') : t('Delete'); 00046 $ops[] = l($text, "admin/panels/panel-page/$panel_page->name/delete"); 00047 } 00048 else { 00049 if (empty($panel_page->disabled)) { 00050 $ops[] = l(t('Disable'), "admin/panels/panel-page/disable/$panel_page->name", NULL, drupal_get_destination()); 00051 } 00052 else { 00053 $ops[] = l(t('Enable'), "admin/panels/panel-page/enable/$panel_page->name", NULL, drupal_get_destination()); 00054 } 00055 } 00056 00057 $path = empty($panel_page->disabled) && strpos($panel_page->path, '%') === FALSE ? l($panel_page->path, $panel_page->path) : check_plain($panel_page->path); 00058 $item = array(); 00059 $item[] = check_plain(panels_page_get_title($panel_page)); 00060 $item[] = check_plain($panel_page->name); 00061 // this is safe as it's always programmatic 00062 $item[] = $panel_page->type; 00063 00064 if (empty($panel_page->display)) { 00065 $panel_page->display = $displays[$panel_page->did]; 00066 } 00067 $item[] = check_plain($layouts[$panel_page->display->layout]['title']); 00068 $item[] = $path; 00069 $item[] = implode(' | ', $ops); 00070 $items[] = $item; 00071 $ts = tablesort_init($header); 00072 switch ($ts['sql']) { 00073 case 'title': 00074 $sorts[] = $item[0]; 00075 break; 00076 00077 case 'name': 00078 default: 00079 $sorts[] = $item[1]; 00080 break; 00081 00082 case 'type': 00083 $sorts[] = $panel_page->type . $item[0]; 00084 break; 00085 00086 case 'url': 00087 $sorts[] = $panel_page->path; 00088 break; 00089 } 00090 } 00091 00092 if (drupal_strtolower($ts['sort']) == 'desc') { 00093 arsort($sorts); 00094 } 00095 else { 00096 asort($sorts); 00097 } 00098 00099 $i = array(); 00100 foreach ($sorts as $id => $title) { 00101 $i[] = $items[$id]; 00102 } 00103 00104 $output = theme('table', $header, $i); 00105 return $output; 00106 }
| panels_page_save | ( | &$ | panel_page | ) |
Main entry point for panels_page save functions.
Definition at line 1005 of file panels_page.admin.inc.
References _panels_page_insert(), _panels_page_update(), and panels_page_sanitize().
Referenced by panels_page_advanced_form_submit(), panels_page_context_form_submit(), panels_page_edit_form_submit(), panels_page_save_display(), and panels_page_save_import().
01005 { 01006 panels_page_sanitize($panel_page); 01007 01008 return empty($panel_page->pid) || $panel_page->pid == 'new' ? 01009 _panels_page_insert($panel_page) : 01010 _panels_page_update($panel_page); 01011 }
| panels_page_save_display | ( | &$ | panel_page | ) |
Check to see if the panel page needs to be saved due to a display having been just saved.
Wrapper for panels_page_save().
Definition at line 976 of file panels_page.admin.inc.
References panels_export_display(), and panels_page_save().
Referenced by panels_page_edit_content(), panels_page_edit_layout(), and panels_page_edit_layout_settings().
00976 { 00977 if (empty($panel_page->displays[$panel_page->current]['did']) || $panel_page->displays[$panel_page->current]['did'] == 'new') { 00978 if (!empty($panel_page->export)) { 00979 $code = panels_export_display($panel_page->display); 00980 eval($code); 00981 $panel_page->display =& $display; 00982 } 00983 return panels_page_save($panel_page); 00984 } 00985 }
| panels_page_save_import | ( | &$ | panel_page | ) |
Prepare an imported panel page for insertion into the database, then insert it.
Wrapper for panels_page_save().
Definition at line 993 of file panels_page.admin.inc.
References panels_page_save(), and panels_save_display().
Referenced by panels_page_edit_form_submit().
00993 { 00994 foreach ($panel_page->displays as $id => $info) { 00995 $imported_display = panels_save_display($info['display']); 00996 $panel_page->displays[$id]['did'] = $imported_display->did; 00997 unset($panel_page->displays[$id]['display']); 00998 } 00999 return panels_page_save($panel_page); 01000 }
1.5.6