function get_default_display($bundle, $view_mode) { $display = parent::get_default_display($bundle, $view_mode); // Add the node title to the display since we can't get that automatically. $display->title = '%node:title'; // Add the node links, they probably would like these. $pane = panels_new_pane('node_links', 'node_links', TRUE); $pane->css['css_class'] = 'link-wrapper'; $pane->configuration['build_mode'] = $view_mode; $pane->configuration['context'] = 'panelizer'; // @todo -- submitted by does not exist as a pane! That's v. sad. $display->add_pane($pane, 'center'); return $display; }
function get_default_display($bundle, $view_mode) { $display = parent::get_default_display($bundle, $view_mode); // Add the node title to the display since we can't get that automatically. $display->title = '%node:title'; // Add the node links, they probably would like these. $pane = panels_new_pane('node_links', 'node_links', TRUE); $pane->css['css_class'] = 'link-wrapper'; $pane->configuration['build_mode'] = $view_mode; $pane->configuration['context'] = 'panelizer'; // @todo -- submitted by does not exist as a pane! That's v. sad. $display->add_pane($pane, 'center'); unset($pane); // If the content type is enabled for use with Webform, add the custom // submission pane. if (module_exists('webform')) { if ($view_mode == 'page_manager') { if (variable_get('webform_node_' . $bundle)) { $pane = panels_new_pane('entity_field_extra', 'node:webform', TRUE); $pane->configuration['context'] = 'panelizer'; $pane->configuration['view_mode'] = 'full'; $display->add_pane($pane, 'center'); unset($pane); } } } // Add a custom pane for the book navigation block for the Page Manager // display. if (module_exists('book')) { if ($view_mode == 'page_manager') { $pane = panels_new_pane('node_book_nav', 'node_book_nav', TRUE); $pane->configuration['context'] = 'panelizer'; $display->add_pane($pane, 'center'); unset($pane); } } return $display; }
/** * Provide a default display for newly panelized entities. * * This should be implemented by the entity plugin. */ function get_default_display($bundle, $view_mode) { // This is a straight up empty display. $display = panels_new_display(); $display->layout = 'flexible'; $panes = array(); foreach (field_info_instances($this->entity_type, $bundle) as $field_name => $instance) { $view_mode_settings = field_view_mode_settings($this->entity_type, $bundle); $actual_mode = !empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default'; $field_display = $instance['display'][$actual_mode]; $pane = panels_new_pane('entity_field', $this->entity_type . ':' . $field_name, TRUE); $pane->configuration['formatter'] = $field_display['type']; $pane->configuration['formatter_settings'] = $field_display['settings']; $pane->configuration['label'] = $field_display['label']; $pane->configuration['context'] = 'panelizer'; $panes[] = array('#pane' => $pane, '#weight' => $field_display['weight']); } // Use our #weights to sort these so they appear in whatever order the // normal field configuration put them in. uasort($panes, 'element_sort'); foreach ($panes as $pane) { $display->add_pane($pane['#pane'], 'center'); } return $display; }
/** * AJAX entry point to add a new pane. */ function ajax_add_pane($region = NULL, $type_name = NULL, $subtype_name = NULL, $step = NULL) { $content_type = ctools_get_content_type($type_name); $subtype = ctools_content_get_subtype($content_type, $subtype_name); if (!isset($step) || !isset($this->cache->new_pane)) { $pane = panels_new_pane($type_name, $subtype_name, TRUE); $this->cache->new_pane = &$pane; } else { $pane = &$this->cache->new_pane; } $form_state = array( 'display' => &$this->cache->display, 'contexts' => $this->cache->display->context, 'pane' => &$pane, 'cache_key' => $this->display->cache_key, 'display cache' => &$this->cache, 'ajax' => TRUE, 'modal' => TRUE, // This will force the system to not automatically render. 'modal return' => TRUE, 'commands' => array(), ); $form_info = array( 'path' => $this->get_url('add-pane', $region, $type_name, $subtype_name, '%step'), 'show cancel' => TRUE, 'next callback' => 'panels_ajax_edit_pane_next', 'finish callback' => 'panels_ajax_edit_pane_finish', 'cancel callback' => 'panels_ajax_edit_pane_cancel', ); $output = ctools_content_form('add', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $pane->configuration, $step); // If $rc is FALSE, there was no actual form. if ($output === FALSE || !empty($form_state['complete'])) { $pane = $this->cache->new_pane; unset($this->cache->new_pane); // Add the pane to the display $this->display->add_pane($pane, $region); panels_edit_cache_set($this->cache); // Tell the client to draw the pane $this->command_add_pane($pane); // Dismiss the modal. $this->commands[] = ctools_modal_command_dismiss(); } else if (!empty($form_state['cancel'])) { // If cancelling, return to the activity. list($category_key, $category) = $this->get_category($subtype); $this->ajax_select_content($region, $category_key); } else { // This overwrites any previous commands. $this->commands = ctools_modal_form_render($form_state, $output); } }
function edit_form(&$form, &$form_state) { ctools_include('plugins', 'panels'); // If the plugin is not set, then it should be provided as an argument: if (!isset($form_state['item']->plugin)) { $form_state['item']->plugin = $form_state['function args'][2]; } parent::edit_form($form, $form_state); $form['category'] = array('#type' => 'textfield', '#title' => t('Category'), '#description' => t('What category this layout should appear in. If left blank the category will be "Miscellaneous".'), '#default_value' => $form_state['item']->category); ctools_include('context'); ctools_include('display-edit', 'panels'); ctools_include('content'); // Provide actual layout admin UI here. // Create a display for editing: $cache_key = 'builder-' . $form_state['item']->name; // Load the display being edited from cache, if possible. if (!empty($_POST) && is_object($cache = panels_edit_cache_get($cache_key))) { $display =& $cache->display; } else { $content_types = ctools_content_get_available_types(); panels_cache_clear('display', $cache_key); $cache = new stdClass(); $display = panels_new_display(); $display->did = $form_state['item']->name; $display->layout = $form_state['item']->plugin; $display->layout_settings = $form_state['item']->settings; $display->cache_key = $cache_key; $display->editing_layout = TRUE; $cache->display = $display; $cache->content_types = $content_types; $cache->display_title = FALSE; panels_edit_cache_set($cache); } // Set up lipsum content in all of the existing panel regions: $display->content = array(); $display->panels = array(); $custom = ctools_get_content_type('custom'); $layout = panels_get_layout($display->layout); $regions = panels_get_regions($layout, $display); foreach ($regions as $id => $title) { $pane = panels_new_pane('custom', 'custom'); $pane->pid = $id; $pane->panel = $id; $pane->configuration = ctools_content_get_defaults($custom, 'custom'); $pane->configuration['title'] = 'Lorem Ipsum'; $pane->configuration['body'] = $this->lipsum; $display->content[$id] = $pane; $display->panels[$id] = array($id); } $form_state['display'] =& $display; // Tell the Panels form not to display buttons. $form_state['no buttons'] = TRUE; $form_state['no display settings'] = TRUE; $form_state['cache_key'] = $cache_key; $form_state['content_types'] = $cache->content_types; $form_state['display_title'] = FALSE; $form_state['renderer'] = panels_get_renderer_handler('editor', $cache->display); $form_state['renderer']->cache =& $cache; $form = panels_edit_display_form($form, $form_state); // If we leave the standard submit handler, it'll try to reconcile // content from the input, but we've not exposed that to the user. This // makes previews work with the content we forced in. $form['preview']['button']['#submit'] = array('panels_edit_display_form_preview'); }
/** * AJAX entry point to add a new pane. */ function ajax_add_pane($region = NULL, $type_name = NULL, $subtype_name = NULL, $step = NULL) { $content_type = ctools_get_content_type($type_name); $subtype = ctools_content_get_subtype($content_type, $subtype_name); // Determine if we are adding a different pane than previously cached. This // is used to load the different pane into cache so that multistep forms // have the correct context instead of a previously cached version that // does not match the pane currently being added. $is_different_pane = FALSE; if (isset($this->cache) && isset($this->cache->new_pane)) { $diff_type = $type_name != $this->cache->new_pane->type; $diff_subtype = $subtype_name != $this->cache->new_pane->subtype; $is_different_pane = $diff_type || $diff_subtype; } if (!isset($step) || !isset($this->cache->new_pane) || $is_different_pane) { $pane = panels_new_pane($type_name, $subtype_name, TRUE); $this->cache->new_pane =& $pane; } else { $pane =& $this->cache->new_pane; } $form_state = array('display' => &$this->cache->display, 'contexts' => $this->cache->display->context, 'pane' => &$pane, 'cache_key' => $this->display->cache_key, 'display cache' => &$this->cache, 'ajax' => TRUE, 'modal' => TRUE, 'modal return' => TRUE, 'commands' => array()); $form_info = array('path' => $this->get_url('add-pane', $region, $type_name, $subtype_name, '%step'), 'show cancel' => TRUE, 'next callback' => 'panels_ajax_edit_pane_next', 'finish callback' => 'panels_ajax_edit_pane_finish', 'cancel callback' => 'panels_ajax_edit_pane_cancel'); $output = ctools_content_form('add', $form_info, $form_state, $content_type, $pane->subtype, $subtype, $pane->configuration, $step); // If $rc is FALSE, there was no actual form. if ($output === FALSE || !empty($form_state['complete'])) { // References get blown away with AJAX caching. This will fix that. $pane = $form_state['pane']; unset($this->cache->new_pane); // Add the pane to the display $this->display->add_pane($pane, $region); panels_edit_cache_set($this->cache); // Tell the client to draw the pane $this->command_add_pane($pane); // Dismiss the modal. $this->commands[] = ctools_modal_command_dismiss(); } else { if (!empty($form_state['cancel'])) { // If cancelling, return to the activity. list($category_key, $category) = $this->get_category($subtype); $this->ajax_select_content($region, $category_key); } else { // This overwrites any previous commands. $this->commands = ctools_modal_form_render($form_state, $output); } } }
// If the display is new we need to set a display id. if ($display->did == 'new') { // Save the panel display to create a unique display ID. // Also set any defaults like layout, title etc... panels_save_display($display); } // Reset the display. $display->content = array(); $display->panels['contentmain'] = array(); // Add ic-categories view pane. $new_pane = panels_new_pane('views_panes', 'info_center_categories-ic_cat_all', TRUE); $new_pane->panel = 'contentmain'; $display->panels['contentmain'][] = $new_pane->pid; $display->content[$new_pane->pid] = $new_pane; // Save the display. panels_save_display($display); // Add a-z block pane. $new_pane = panels_new_pane('block', 'its_custom_blocks-a_z', TRUE); $new_pane->panel = 'contentmain'; $display->panels['contentmain'][] = $new_pane->pid; $display->content[$new_pane->pid] = $new_pane; // Save the display. panels_save_display($display); // Update panelizer display. $node->panelizer['page_manager']->display = $display; // Update panelizer display id. $node->panelizer['page_manager']->did = $display->did; // Tell panelizer to be overriden. $node->panelizer['page_manager']->name = NULL; // Save the node. node_save($node);