You may peruse a list of your current panels layouts and edit them, or click add to create a new page.

'); case 'admin/build/panel-page/add': return t('

Choose a layout for your new page from the list below.

'); } } /** * Implementation of hook_perm() */ function panels_page_perm() { return array('create panel-pages', 'access all panel-pages'); } /** * Implementation of hook_menu() */ function panels_page_menu($may_cache) { if ($may_cache) { $access = user_access('create panel-pages'); $items[] = array( 'path' => 'admin/build/panel-page', 'title' => t('Panel pages'), 'access' => $access, 'callback' => 'panels_page_list_page', 'description' => t('Create and administer panel-pages (complex layout pages with URLs)'), ); $items[] = array( 'path' => 'admin/build/panel-page/list', 'title' => t('List'), 'access' => $access, 'callback' => 'panels_page_list_page', 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[] = array( 'path' => 'admin/build/panel-page/add', 'title' => t('Add'), 'access' => $access, 'callback' => 'panels_page_add_page', 'type' => MENU_LOCAL_TASK, ); $items[] = array( 'path' => 'admin/build/panel-page/settings', 'title' => t('Settings'), 'access' => $access, 'callback' => 'drupal_get_form', 'callback arguments' => array('panels_page_settings'), 'type' => MENU_LOCAL_TASK, ); $items[] = array( 'path' => 'admin/build/panel-page/add/layout', 'title' => t('Add'), 'access' => $access, 'callback' => 'panels_page_add_layout_page', 'type' => MENU_LOCAL_TASK, ); // load panels from database $result = db_query("SELECT * FROM {panels_page}"); while ($panel_page = db_fetch_object($result)) { $panel_page->access = ($panel_page->access ? explode(', ', $panel_page->access) : array()); panels_page_menu_items($items, $panel_page->path, $panel_page, FALSE); panels_page_menu_items($items, 'admin/build/panel-page/' . $panel_page->pid, $panel_page, TRUE); } } return $items; } function panels_page_menu_items(&$items, $base, $page, $basic = FALSE) { $view_access = panels_page_access($page); $access = user_access('create panel-pages'); if ($basic) { $items[] = array( 'path' => $base, 'title' => t('View'), 'access' => $view_access, 'callback' => 'panels_page_view_page', 'callback arguments' => array($page->pid), 'weight' => -10, 'type' => MENU_CALLBACK, ); } else { _panels_page_create_menu_item($items, $page, $base, $view_access); } $items[] = array( 'path' => $base . '/view', 'title' => t('View'), 'access' => $view_access, 'callback' => 'panels_page_view_page', 'callback arguments' => array($page->pid), 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[] = array( 'path' => $base . '/edit', 'title' => t('Edit'), 'access' => $access, 'callback' => 'panels_page_edit', 'callback arguments' => array($page->pid), 'weight' => -5, 'type' => MENU_LOCAL_TASK, ); $items[] = array( 'path' => $base . '/edit/general', 'title' => t('General'), 'access' => $access, 'callback' => 'panels_page_edit', 'callback arguments' => array($page->pid), 'weight' => -5, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items[] = array( 'path' => $base . '/edit/layout', 'title' => t('Layout'), 'access' => $access, 'callback' => 'panels_page_edit_layout', 'callback arguments' => array($page->pid), 'weight' => -3, 'type' => MENU_LOCAL_TASK, ); $display = panels_load_display($page->did); $layout = panels_get_layout($display->layout); if (!empty($layout['settings form'])) { $items[] = array( 'path' => $base . '/edit/settings', 'title' => t('Layout settings'), 'access' => $access, 'callback' => 'panels_page_edit_layout_settings', 'callback arguments' => array($page->pid), 'weight' => -3, 'type' => MENU_LOCAL_TASK, ); } $items[] = array( 'path' => $base . '/edit/content', 'title' => t('Content'), 'access' => $access, 'callback' => 'panels_page_edit_content', 'callback arguments' => array($page->pid), 'weight' => -1, 'type' => MENU_LOCAL_TASK, ); $items[] = array( 'path' => $base . '/delete', 'title' => t('Delete panel page'), 'access' => $access, 'callback' => 'drupal_get_form', 'callback arguments' => array('panels_page_delete_confirm', $page->pid), 'type' => MENU_CALLBACK, ); } // This stuff is lifted pretty much directly from Views. /** * Helper function to add a menu item for a panel. */ function panels_page_get_title($panel_page, $context = 'page', $default_title = NULL) { if ($context == 'menu-parent' && $panel_page->menu_parent_title) { return $panel_page->menu_parent_title; } if (in_array($context, array('menu', 'menu-parent')) && $panel_page->menu_title) { return $panel_page->menu_title; } if ($panel_page->title) { return $panel_page->title; } if (is_null($default_title)) { return t('No title'); } else { return $default_title; } } function _panels_page_create_menu_item(&$items, $panel_page, $path, $access, $local_task_type = MENU_NORMAL_ITEM, $args = array()) { $title = filter_xss_admin(panels_page_get_title($panel_page, 'menu')); $type = _panels_page_menu_type($panel_page); if ($type == MENU_LOCAL_TASK || $type == MENU_DEFAULT_LOCAL_TASK) { $weight = $panel_page->menu_tab_weight; } $items[] = _panels_page_menu_item($path, $title, $panel_page, $args, $access, $type, $weight); if ($type == MENU_DEFAULT_LOCAL_TASK && dirname($path) && dirname($path) != '.') { switch ($panel_page->menu_tab_default_parent_type) { case 'tab': $parent_type = MENU_LOCAL_TASK; break; case 'normal': $parent_type = MENU_NORMAL_ITEM; break; default: case 'existing': $parent_type = 0; break; } if ($parent_type) { $title = filter_xss_admin(panels_page_get_title($panel_page, 'menu-parent')); $weight = $panel_page->menu_parent_tab_weight; $items[] = _panels_page_menu_item(dirname($path), $title, $panel_page, $args, $access, $parent_type, $weight); } } } /** * Helper function to create a menu item for a panel. */ function _panels_page_menu_item($path, $title, $panel_page, $args, $access, $type, $weight = NULL) { $retval = array('path' => $path, 'title' => $title, 'callback' => 'panels_page_view_page', 'callback arguments' => array($panel_page->pid), 'access' => user_access('access content') && $access, 'type' => $type, ); if ($weight !== NULL) { $retval['weight'] = $weight; } return $retval; } /** * Determine what menu type a panel needs to use. */ function _panels_page_menu_type($panel_page) { if ($panel_page->menu) { if ($panel_page->menu_tab_default) { $type = MENU_DEFAULT_LOCAL_TASK; } else if ($panel_page->menu_tab) { $type = MENU_LOCAL_TASK; } else { $type = MENU_NORMAL_ITEM; } } else { $type = MENU_CALLBACK; } return $type; } /** * Determine if the specified user has access to a panel. */ function panels_page_access($panel_page, $account = NULL) { if (!$account) { global $user; $account = $user; } // Administrator privileges if (user_access('access all panel-pages', $account)) { return TRUE; } // All views with an empty access setting are available to all roles. if (!$panel_page->access || !is_array($panel_page->access)) { return TRUE; } // Otherwise, check roles static $roles = array(); if (!isset($roles[$account->uid])) { $roles[$account->uid] = array_keys($account->roles); $roles[$account->uid][] = $account->uid ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID; } return array_intersect($panel_page->access, $roles[$account->uid]); } // --------------------------------------------------------------------------- // panel page administrative pages /** * Settings for panel pages */ function panels_page_settings() { $content_types = panels_get_content_types(); $default_types = variable_get('panels_page_default', NULL); if (!isset($default_types)) { $default_types = array('block' => TRUE, 'views' => TRUE, 'other' => TRUE); $skip = TRUE; } foreach ($content_types as $id => $info) { if (empty($info['single'])) { $default_options[$id] = t('New @s', array('@s' => $info['title'])); } } $default_options['other'] = t('New content of other types'); $form['panels_page_default'] = array( '#type' => 'checkboxes', '#title' => t('New content behavior'), '#description' => t('Select the default behavior of new content added to the system. If checked, new content will automatically be immediately available to be added to Panels pages. If not checked, new content will not be available until specifically allowed here.'), '#options' => $default_options, '#default_value' => array_keys(array_filter($default_types)), ); if ($skip) { $form['markup'] = array('#value' => t('

Click Submit to be presented with a complete list of available content types set to the defaults you selected.

')); $form['skip'] = array('#type' => 'value', '#value' => TRUE); } else { // Rebuild the entire list, setting appropriately from defaults. Give // each type its own checkboxes set unless it's 'single' in which // case it can go into our fake other set. $available_content_types = panels_get_available_content_types(); $allowed_content_types = variable_get('panels_page_allowed_types', array()); foreach ($available_content_types as $id => $types) { foreach ($types as $type => $info) { $key = $id . '-' . $type; $checkboxes = empty($content_types[$id]['single']) ? $id : 'other'; $options[$checkboxes][$key] = $info['title']; if (!isset($allowed_content_types[$key])) { $allowed[$checkboxes][$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other']; } else { $allowed[$checkboxes][$key] = $allowed_content_types[$key]; } } } $form['content_types'] = array('#tree' => TRUE); // cheat a bit $content_types['other'] = array('title' => t('Other'), 'weight' => 10); foreach ($content_types as $id => $info) { if (isset($allowed[$id])) { $form['content_types'][$id] = array( '#prefix' => '
', '#suffix' => '
', '#type' => 'checkboxes', '#title' => t('Allowed @s content', array('@s' => $info['title'])), '#options' => $options[$id], '#default_value' => array_keys(array_filter($allowed[$id])), ); } } } $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), ); drupal_add_css(drupal_get_path('module', 'panels_page') . '/css/panels_page.css'); return $form; } function panels_page_settings_submit($form_id, $form_values) { variable_set('panels_page_default', $form_values['panels_page_default']); if (!$form_values['skip']) { // merge the broken apart array neatly back together variable_set('panels_page_allowed_types', call_user_func_array('array_merge', $form_values['content_types'])); } drupal_set_message(t('Your changes have been saved.')); } /** * Provide a list of panels, with links to edit or delete them. */ function panels_page_list_page() { $layouts = panels_get_layouts(); $result = db_query("SELECT p.*, d.layout FROM {panels_page} p INNER JOIN {panels_display} d ON p.did = d.did ORDER BY p.title"); while ($panel_page = db_fetch_object($result)) { $item = array(); $item[] = check_plain(panels_page_get_title($panel_page)); $item[] = check_plain($layouts[$panel_page->layout]['title']); $item[] = l($panel_page->path, $panel_page->path); $item[] = implode(' | ', array( l(t('Edit'), "admin/build/panel-page/$panel_page->pid/edit"), l(t('Delete'), "admin/build/panel-page/$panel_page->pid/delete"), )); $items[] = $item; } $header = array( t('Page title'), t('Layout'), t('URL'), t('Operations'), ); $output = theme('table', $header, $items); return $output; } /* * Provide a form to confirm deletion of a panel page. */ function panels_page_delete_confirm($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } $form['pid'] = array('#type' => 'value', '#value' => $panel_page->pid); $form['did'] = array('#type' => 'value', '#value' => $panel_page->did); return confirm_form( $form, t('Are you sure you want to delete "@title"?', array('@title' => panels_page_get_title($panel_page))), $_GET['destination'] ? $_GET['destination'] : 'admin/build/panel-page', t('This action cannot be undone.'), t('Delete'), t('Cancel') ); } /* * Handle the submit button to delete a panel page. */ function panels_page_delete_confirm_submit($formid, $form) { if ($form['confirm']) { panels_page_delete((object) $form); // TODO: Is this necessary or did we feed it the location already? return 'admin/build/panel-page'; } } /** * Handle the add panel-page page */ function panels_page_add_page($layout = NULL) { $layouts = panels_get_layouts(); if ($layout === NULL) { foreach ($layouts as $id => $layout) { $output .= panels_print_layout_link($id, $layout, $_GET['q'] . '/' . $id); } return $output; } if (!$layouts[$layout]) { return drupal_not_found(); } $panel_page->display = panels_new_display(); $panel_page->display->layout = $layout; $panel_page->pid = 'new'; $panel_page->did = 'new'; return panels_page_edit($panel_page); } /** * Edit a panel page. Called from both the add and edit points to provide * for common flow. */ function panels_page_edit($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } return drupal_get_form('panels_page_edit_form', $panel_page); } /** * The form to edit the page portion of a panel. */ function panels_page_edit_form($panel_page) { drupal_add_css(panels_get_path('css/panels_admin.css')); $layout = panels_get_layout($panel_page->display->layout); $form['pid'] = array( '#type' => 'value', '#value' => $panel_page->pid, ); $form['panel_page'] = array( '#type' => 'value', '#value' => $panel_page ); $form['right'] = array( '#prefix' => '
', '#suffix' => '
', ); $form['left'] = array( '#prefix' => '
', '#suffix' => '
', ); $form['right']['advanced'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Advanced settings'), ); $form['right']['layout'] = array( '#type' => 'fieldset', '#title' => t('Layout'), ); $form['left']['info'] = array( '#type' => 'fieldset', '#title' => t('Page settings'), ); $form['right']['layout'] = array( '#type' => 'fieldset', '#title' => t('Layout'), ); $form['right']['layout']['layout-icon'] = array( '#value' => panels_print_layout_icon($panel_page->display->layout, $layout), ); $form['right']['layout']['layout-display'] = array( '#value' => check_plain($layout['title']), ); $content = '
'; foreach (panels_get_panels($layout, $panel_page->display) as $panel_id => $title) { $content .= "
$title
"; if ($panel_page->display->panels[$panel_id]) { $content .= '
    '; foreach ($panel_page->display->panels[$panel_id] as $pid) { $content .= '
  1. ' . panels_get_pane_title($panel_page->display->content[$pid]) . '
  2. '; } $content .= '
'; } else { $content .= t('Empty'); } $content .= '
'; } $content .= '
'; $form['right']['layout']['layout-content'] = array( '#value' => $content, ); $form['left']['info']['title'] = array( '#type' => 'textfield', '#size' => 35, '#default_value' => $panel_page->title, '#title' => t('Page title'), '#description' => t('The page title for this panels layout'), ); $form['left']['info']['css_id'] = array( '#type' => 'textfield', '#size' => 35, '#default_value' => $panel_page->css_id, '#title' => t('CSS ID'), '#description' => t('The CSS ID to apply to this page'), ); $form['left']['info']['path'] = array( '#type' => 'textfield', '#size' => 35, '#default_value' => $panel_page->path, '#title' => t('Path'), '#description' => t('The URL path to give this page, i.e, path/to/page'), '#required' => TRUE, ); $form['right']['advanced'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Advanced settings'), ); $form['right']['advanced']['no_blocks'] = array( '#type' => 'checkbox', '#default_value' => $panel_page->no_blocks, '#title' => t('Disable Drupal blocks/regions'), '#description' => t('Check this to have the panel page disable all regions displayed in the theme.'), ); $rids = array(); $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name"); while ($obj = db_fetch_object($result)) { $rids[$obj->rid] = $obj->name; } $form['right']['advanced']['access'] = array( '#type' => 'checkboxes', '#title' => t('Access'), '#default_value' => $panel_page->access, '#options' => $rids, '#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.'), ); $form['right']['advanced']['css'] = array( '#type' => 'textarea', '#title' => t('CSS code'), '#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.'), '#default_value' => $panel_page->css, ); $form['left']['menu-info'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#title' => t('Menu'), ); $form['left']['menu-info']['menu'] = array( '#type' => 'checkbox', '#title' => t('Provide Menu'), '#return_value' => 1, '#default_value' => $panel_page->menu, '#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.'), ); $form['left']['menu-info']['menu_tab'] = array( '#type' => 'checkbox', '#title' => t('Provide Menu as Tab'), '#return_value' => 1, '#default_value' => $panel_page->menu_tab, '#description' => t("If checked this panel's menu entry will be provided as a tab rather than in the main menu system."), ); $form['left']['menu-info']['menu_tab_weight'] = array( '#type' => 'textfield', '#title' => t('Tab Weight'), '#default_value' => $panel_page->menu_tab_weight, '#width' => 10, '#size' => 20, '#description' => t('If this is a menu tab, select the weight; lower numbers will be further to the left.'), ); $form['left']['menu-info']['menu_title'] = array( '#type' => 'textfield', '#title' => t('Menu Title'), '#default_value' => $panel_page->menu_title, '#size' => 35, '#maxlength' => 255, '#description' => t('Enter the title to use for the menu entry or tab. If blank, the page title will be used.'), ); $form['left']['menu-info']['default-tab'] = array( '#type' => 'fieldset', '#collapsible' => TRUE, '#collapsed' => TRUE, '#title' => t('Default Menu Tab'), ); $form['left']['menu-info']['default-tab']['menu_tab_default'] = array( '#type' => 'checkbox', '#title' => t('Make Default Menu Tab'), '#return_value' => 1, '#default_value' => $panel_page->menu_tab_default, '#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."), ); $form['left']['menu-info']['default-tab']['menu_tab_default_parent_type'] = array( '#type' => 'select', '#title' => t('Parent Menu Item Type'), '#default_value' => $panel_page->menu_tab_default_parent_type, '#options' => array( 'tab' => t("Tab"), 'normal' => t("Normal menu item"), 'existing' => t("Already exists (don't create)"), ), '#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."), ); $form['left']['menu-info']['default-tab']['menu_parent_tab_weight'] = array( '#type' => 'textfield', '#title' => t('Tab Weight'), '#default_value' => $panel_page->menu_parent_tab_weight, '#width' => 10, '#description' => t('If the parent menu item is a tab, select the weight; lower numbers will be further to the left.'), ); $form['left']['menu-info']['default-tab']['menu_parent_title'] = array( '#type' => 'textfield', '#title' => t('Parent Menu Item Title'), '#default_value' => $panel_page->menu_parent_title, '#size' => 35, '#maxlength' => 255, '#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'))), ); $label = ($panel_page->pid == 'new') ? t('Next') : t('Save'); $form['submit'] = array( '#type' => 'submit', '#value' => $label, ); return $form; } /** * Validate a panel page edit form */ function panels_page_edit_form_validate($form_id, $form_values, $form) { if (!$form_values['path']) { form_error($form['left']['info']['path'], t('Path is required.')); } else { $result = db_result(db_query("SELECT pid FROM {panels_page} WHERE path = '%s' AND pid <> %d", $form_values['path'], $form_values['pid'])); if ($result) { form_error($form['left']['info']['path'], t('Path may not be the same as another panel page path.')); } } } /** * Process submission of the panel page edit form */ function panels_page_edit_form_submit($form_id, $form_values) { $panel_page = $form_values['panel_page']; $panel_page->title = $form_values['title']; $panel_page->css_id = $form_values['css_id']; $panel_page->css = $form_values['css']; $panel_page->no_blocks = $form_values['no_blocks']; $panel_page->menu = $form_values['menu']; $panel_page->menu_tab = $form_values['menu_tab']; $panel_page->menu_tab_weight = $form_values['menu_tab_weight']; $panel_page->menu_title = $form_values['menu_title']; $panel_page->menu_tab_default = $form_values['menu_tab_default']; $panel_page->menu_tab_default_parent_type = $form_values['menu_tab_default_parent_type']; $panel_page->menu_parent_title = $form_values['menu_parent_title']; $panel_page->menu_parent_tab_weight = $form_values['menu_parent_tab_weight']; $panel_page->path = $form_values['path']; $panel_page->access = array_keys(array_filter($form_values['access'])); if ($panel_page->pid == 'new') { panels_page_save($panel_page); $GLOBALS['form_values']['pid'] = $panel_page->pid; $layout = panels_get_layout($panel_page->display->layout); if ($layout['settings form']) { return "admin/build/panel-page/$panel_page->pid/edit/settings"; } return "admin/build/panel-page/$panel_page->pid/edit/content"; } else { drupal_set_message(t('Your changes have been saved.')); panels_page_save($panel_page); } } /** * Pass through to the panels layout editor. */ function panels_page_edit_layout($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } return panels_edit_layout($panel_page->display, t('Save'), "admin/build/panel-page/$panel_page->pid/edit"); } /** * Pass through to the panels layout settings editor. */ function panels_page_edit_layout_settings($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } return panels_edit_layout_settings($panel_page->display, t('Save'), "admin/build/panel-page/$panel_page->pid/edit/settings"); } /** * Pass through to the panels content editor. */ function panels_page_edit_content($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } $content_types = panels_get_available_content_types(); $default_types = variable_get('panels_page_defaults', array()); $allowed_types = variable_get('panels_page_allowed_types', array()); // By default, if they haven't gone and done the initial setup here, // let all 'other' types (which will be all types) be available. if (!isset($default_types['other'])) { $default_types['other'] = TRUE; } foreach ($content_types as $id => $types) { foreach ($types as $type => $info) { $key = $id . '-' . $type; if (!isset($allowed_types[$key])) { $allowed_types[$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other']; } if (!$allowed_types[$key]) { unset($content_types[$id][$type]); } } } print theme('page', panels_edit($panel_page->display, "admin/build/panel-page/$panel_page->pid/edit", $content_types), FALSE); } // --------------------------------------------------------------------------- // view panels page function panels_page_view_page($panel_page) { if (!is_object($panel_page)) { $panel_page = panels_page_load($panel_page); } if (!$panel_page) { return drupal_not_found(); } $panel_page->display->args = func_get_args(); array_shift($panel_page->display->args); // remove the pid. $panel_page->display->css_id = $panel_page->css_id; $output = panels_render_display($panel_page->display); // set title afterward to ensure title is retained. if ($output == NULL) { watchdog('panels', t('Unable to find requested layout %s', array('%s' => check_plain($panel_page->display->layout)))); return drupal_not_found(); } drupal_set_title(filter_xss_admin(panels_page_get_title($panel_page, 'page', ''))); if ($panel_page->css) { drupal_set_html_head("\n"); } if ($panel_page->no_blocks) { print theme('page', $output, FALSE); } else { return $output; } } // --------------------------------------------------------------------------- // Database functions /** * Load a panel page and its associated display */ function panels_page_load($pid) { static $cache = array(); if (!array_key_exists($pid, $cache)) { $cache[$pid] = db_fetch_object(db_query("SELECT * FROM {panels_page} WHERE pid = %d", $pid)); if (!$cache[$pid]) { return; } $cache[$pid]->access = ($cache[$pid]->access ? explode(', ', $cache[$pid]->access) : array()); $cache[$pid]->display = panels_load_display($cache[$pid]->did); } return $cache[$pid]; } /** * Save a panel page. */ function panels_page_save(&$panel_page) { $display = panels_save_display($panel_page->display); $panel_page->access = implode(', ', $panel_page->access); if ($panel_page->pid && $panel_page->pid != 'new') { db_query( "UPDATE {panels_page} SET " . "title = '%s', " . "access = '%s', " . "path = '%s', " . "css_id = '%s', " . "css = '%s', " . "no_blocks = %d, " . "menu = %d, " . "menu_tab = %d, " . "menu_tab_weight = %d, " . "menu_title = '%s', " . "menu_tab_default = %d, " . "menu_tab_default_parent_type = '%s', " . "menu_parent_title = '%s', " . "menu_parent_tab_weight = %d " . "WHERE pid = %d", $panel_page->title, $panel_page->access, $panel_page->path, $panel_page->css_id, $panel_page->css, $panel_page->no_blocks, $panel_page->menu, $panel_page->menu_tab, $panel_page->menu_tab_weight, $panel_page->menu_title, $panel_page->menu_tab_default, $panel_page->menu_tab_default_parent_type, $panel_page->menu_parent_title, $panel_page->menu_parent_tab_weight, $panel_page->pid ); } else { $panel_page->pid = db_next_id("{panels_page}_pid"); // Yes, this is kind of long but it's a lot easier to match up values. db_query( "INSERT INTO {panels_page} ( " . "pid, " . "title, " . "access, " . "path, " . "css_id, " . "css, " . "no_blocks, " . "menu, " . "menu_tab, " . "menu_tab_weight, " . "menu_title, " . "menu_tab_default, " . "menu_tab_default_parent_type, " . "menu_parent_title, " . "menu_parent_tab_weight, " . "did " . ") " . "VALUES (" . "%d, " . "'%s', " . "'%s', " . "'%s', " . "'%s', " . "'%s', " . "%d, " . "%d, " . "%d, " . "%d, " . "'%s', " . "%d, " . "'%s', " . "'%s', " . "%d, " . "%d " . ")", $panel_page->pid, $panel_page->title, $panel_page->access, $panel_page->path, $panel_page->css_id, $panel_page->css, $panel_page->no_blocks, $panel_page->menu, $panel_page->menu_tab, $panel_page->menu_tab_weight, $panel_page->menu_title, $panel_page->menu_tab_default, $panel_page->menu_tab_default_parent_type, $panel_page->menu_parent_title, $panel_page->menu_parent_tab_weight, $display->did ); } menu_rebuild(); return $panel_page->pid; } /** * Delete a panel page and its associated display. */ function panels_page_delete($panel_page) { db_query("DELETE FROM {panels_page} WHERE pid = %d", $panel_page->pid); return panels_delete_display($panel_page->did); }