function add_meta() { ctools_include('display-edit', 'panels'); ctools_include('content'); if (empty($this->display->cache_key)) { $this->cache = panels_edit_cache_get_default($this->display); } // @todo we may need an else to load the cache, but I am not sure we // actually need to load it if we already have our cache key, and doing // so is a waste of resources. ctools_include('cleanstring'); $this->clean_key = ctools_cleanstring($this->display->cache_key); panels_ipe_get_cache_key($this->clean_key); ctools_include('ajax'); ctools_include('modal'); ctools_modal_add_js(); ctools_add_css('panels_dnd', 'panels'); ctools_add_css('panels_admin', 'panels'); ctools_add_js('panels_ipe', 'panels_ipe'); ctools_add_css('panels_ipe', 'panels_ipe'); $settings = array('formPath' => url($this->get_url('save-form'))); drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting'); drupal_add_js(array('PanelsIPESettings' => array($this->clean_key => $settings)), 'setting'); jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.sortable')); parent::add_meta(); }
function add_meta() { ctools_include('display-edit', 'panels'); ctools_include('content'); if (empty($this->display->cache_key)) { $this->cache = panels_edit_cache_get_default($this->display); } // @todo we may need an else to load the cache, but I am not sure we // actually need to load it if we already have our cache key, and doing // so is a waste of resources. ctools_include('cleanstring'); $this->clean_key = ctools_cleanstring($this->display->cache_key); $button = array('#type' => 'link', '#title' => t('Customize this page'), '#href' => $this->get_url('save_form'), '#id' => 'panels-ipe-customize-page', '#attributes' => array('class' => array('panels-ipe-startedit', 'panels-ipe-pseudobutton')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button); // @todo this actually should be an IPE setting instead. if (user_access('change layouts in place editing')) { $button = array('#type' => 'link', '#title' => t('Change layout'), '#href' => $this->get_url('change_layout'), '#attributes' => array('class' => array('panels-ipe-change-layout', 'panels-ipe-pseudobutton', 'ctools-modal-layout')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button); } ctools_include('ajax'); ctools_include('modal'); ctools_modal_add_js(); ctools_add_css('panels_dnd', 'panels'); ctools_add_css('panels_admin', 'panels'); ctools_add_js('panels_ipe', 'panels_ipe'); ctools_add_css('panels_ipe', 'panels_ipe'); drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting'); drupal_add_library('system', 'ui.draggable'); drupal_add_library('system', 'ui.droppable'); drupal_add_library('system', 'ui.sortable'); parent::add_meta(); }
function add_meta() { ctools_include('display-edit', 'panels'); ctools_include('content'); if (empty($this->display->cache_key)) { $this->cache = panels_edit_cache_get_default($this->display); } // @todo we may need an else to load the cache, but I am not sure we // actually need to load it if we already have our cache key, and doing // so is a waste of resources. ctools_include('cleanstring'); $this->clean_key = ctools_cleanstring($this->display->cache_key); $button = array('#type' => 'link', '#title' => t('Customize this page'), '#href' => $this->get_url('save_form'), '#id' => 'panels-ipe-customize-page', '#attributes' => array('class' => array('panels-ipe-startedit', 'panels-ipe-pseudobutton')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button); // @todo this actually should be an IPE setting instead. if (user_access('change layouts in place editing')) { $button = array('#type' => 'link', '#title' => t('Change layout'), '#href' => $this->get_url('change_layout'), '#attributes' => array('class' => array('panels-ipe-change-layout', 'panels-ipe-pseudobutton', 'ctools-modal-layout')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>'); panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button); } ctools_include('ajax'); ctools_include('modal'); ctools_modal_add_js(); ctools_add_css('panels_dnd', 'panels'); ctools_add_css('panels_admin', 'panels'); ctools_add_css('panels_ipe', 'panels_ipe'); // Add the JavaScript for the IPE. This must go as early as possible so // that its behaviors run first, allowing it to clone parts of the DOM // before other behaviors have been applied to them. drupal_add_js(drupal_get_path('module', 'panels_ipe') . '/js/panels_ipe.js', array('group' => JS_LIBRARY, 'weight' => -1000)); drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting'); drupal_add_library('system', 'ui.draggable'); drupal_add_library('system', 'ui.droppable'); drupal_add_library('system', 'ui.sortable'); parent::add_meta(); }
/** * Create a command array to add a new pane. */ function command_add_pane($pid) { if (is_object($pid)) { $pane = $pid; } else { $pane = $this->display->content[$pid]; } ctools_include('cleanstring'); $region_id = ctools_cleanstring($pane->panel); $this->commands[] = ctools_ajax_command_append("#panels-ipe-regionid-{$region_id} div.panels-ipe-sort-container", $this->render_pane($pane)); $this->commands[] = ctools_ajax_command_changed("#panels-ipe-display-{$this->clean_key}"); }
/** * Render the panels display for a given panelizer entity. * * @param stdClass $entity * A fully-loaded entity object controlled by panelizer. * @param array $args * Optional array of arguments to pass to the panels display. * @param string $address * An optional address to send to the renderer to use for addressable * content. * * @return array * If the entity isn't panelized, this returns NULL. Otherwise, it returns an * associative array as meant for use with CTools with the following keys: * - 'content': String containing the rendered panels display output. * - 'no_blocks': Boolean defining if the panels display wants to hide core * blocks or not when being rendered. */ function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL) { if (empty($entity->panelizer[$view_mode]) || empty($entity->panelizer[$view_mode]->display)) { return FALSE; } list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $panelizer = $entity->panelizer[$view_mode]; $display = $panelizer->display; $display->context = $this->get_contexts($panelizer, $entity); $display->args = $args; $display->css_id = $panelizer->css_id; // This means the IPE will use our cache which means it will get appropriate // allowed content should it be selected. $display->cache_key = implode(':', array('panelizer', $this->entity_type, $entity_id, $view_mode)); // Check to see if there is any CSS. if (!empty($panelizer->css)) { ctools_include('css'); $filename = ctools_css_retrieve($display->cache_key); if (!$filename) { $filename = ctools_css_store($display->cache_key, $panelizer->css); } drupal_add_css($filename, array('group' => CSS_THEME)); } if ($view_mode == 'page_manager') { // We think this is handled as a page, so set the current page display. panels_get_current_page_display($display); } // Allow applications to alter the panelizer and the display before rendering them. drupal_alter('panelizer_pre_render', $panelizer, $display, $entity); ctools_include('plugins', 'panels'); $renderer = panels_get_renderer($panelizer->pipeline, $display); // If the IPE is enabled, but the user does not have access to edit // the entity, load the standard renderer instead. // Use class_parents so we don't try to autoload the class we are testing. $parents = class_parents($renderer); if (!empty($parents['panels_renderer_editor']) && (!$this->panelizer_access('content', $entity, $view_mode) && !$this->entity_access('update', $entity))) { $renderer = panels_get_renderer_handler('standard', $display); } $renderer->address = $address; $info = array('content' => panels_render_display($display, $renderer), 'no_blocks' => !empty($panelizer->no_blocks)); $info['classes_array'] = array(); if (!empty($panelizer->css_class)) { ctools_include('cleanstring'); foreach (explode(' ', $panelizer->css_class) as $class) { $class = ctools_context_keyword_substitute($class, array(), $display->context); if ($class) { $info['classes_array'][] = ctools_cleanstring($class); } } } if (!empty($parents['panels_renderer_editor'])) { ctools_add_js('panelizer-ipe', 'panelizer'); drupal_add_js(drupal_get_path('module', 'panelizer') . "/js/panelizer-ipe.js", array('group' => JS_LIBRARY)); } $info['title'] = $panelizer->display->get_title(); return $info; }
/** * Clean up the panel pane variables for the template. */ function bht_theme_preprocess_panels_pane(&$variables) { $pane =& $variables['pane']; $content =& $variables['content']; // Set basic classes. $variables['classes_array'] = array(); $variables['classes_array'][] = 'pane'; if (!empty($variables['admin_links'])) { $variables['classes_array'][] = 'contextual-links-region'; } // Add some usable classes based on type/subtype. while (!empty($content) && gettype($content) == 'array' && !isset($content['#entity_type']) && !isset($content['#theme'])) { $content = reset($content); } // Set the entity. $entity = NULL; if (isset($content['#entity'])) { $entity = $content['#entity']; } elseif (isset($content['#entity_type']) && isset($content['#' . $content['#entity_type']])) { $entity = $content['#' . $content['#entity_type']]; } // Add the entity specific classes. if (isset($content['#entity_type']) && isset($content['#bundle'])) { $variables['classes_array'][] = 'pane--' . $content['#entity_type']; $variables['classes_array'][] = 'pane--' . $content['#bundle']; } elseif (!empty($pane->type)) { ctools_include('cleanstring'); $type_class = $pane->type ? ctools_cleanstring($pane->type, array('lower case' => TRUE)) : ''; $variables['classes_array'][] = 'pane--' . $type_class; } // Add id and custom class if sent in. if (!empty($pane->css['css_id'])) { $variables['id'] = ' id="' . $pane->css['css_id'] . '"'; } if (!empty($pane->css['css_class'])) { $variables['classes_array'][] = $pane->css['css_class']; } // Set a BEM pane title. $needle = array_search('pane-title', $variables['title_attributes_array']['class']); if ($needle !== FALSE) { unset($variables['title_attributes_array']['class'][$needle]); } $variables['title_attributes_array']['class'][] = 'pane__title'; // Check if the bean block has a link set. if (isset($entity) && get_class($entity) == 'Bean') { if (isset($entity->field_link) && !empty($entity->field_link)) { $link = $entity->field_link; // Get the link array. while (!isset($link['url']) && gettype($link) == 'array') { $link = reset($link); } // Parse the link address from the link array. if (isset($link['url']) && strlen($link['url']) > 0) { // Get the internal source link. $linkurl = theme_get_relative_link($link['url']); // If an internal link is found, wrap the block content in a link. if ($linkurl && ($needle = array_search('panels_pane__block', $variables['theme_hook_suggestions'])) !== FALSE) { // Add a theme hook suggestion before the specific nid-delta suggestion. array_splice($variables['theme_hook_suggestions'], ++$needle, 0, 'panels_pane__block__bean_has_link'); // Add the block--has-link class. $variables['classes_array'][] .= ' pane--bean-has-link'; // Add the internal path to the block variables. $variables['link'] = $linkurl; // Add possible link options. $variables['link_options'] = array(); } } } } }
/** * Render the panels display for a given panelizer entity. * * @param stdClass $entity * A fully-loaded entity object controlled by panelizer. * @param array $args * Optional array of arguments to pass to the panels display. * @param string $address * An optional address to send to the renderer to use for addressable * content. * * @return array * If the entity isn't panelized, this returns NULL. Otherwise, it returns an * associative array as meant for use with CTools with the following keys: * - 'content': String containing the rendered panels display output. * - 'no_blocks': Boolean defining if the panels display wants to hide core * blocks or not when being rendered. */ function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL) { if (empty($entity->panelizer[$view_mode]) || empty($entity->panelizer[$view_mode]->display)) { return FALSE; } list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity); $panelizer = $entity->panelizer[$view_mode]; $display = $panelizer->display; $display->context = $this->get_contexts($panelizer, $entity); $display->args = $args; $display->css_id = $panelizer->css_id; // This means the IPE will use our cache which means it will get appropriate // allowed content should it be selected. $display->cache_key = implode(':', array('panelizer', $this->entity_type, $entity_id, $view_mode)); // Check to see if there is any CSS. if (!empty($panelizer->css)) { ctools_include('css'); $filename = ctools_css_retrieve($display->cache_key); if (!$filename) { $filename = ctools_css_store($display->cache_key, $panelizer->css); } drupal_add_css($filename, array('group' => CSS_THEME)); } if ($view_mode == 'page_manager') { // We think this is handled as a page, so set the current page display. panels_get_current_page_display($display); } ctools_include('plugins', 'panels'); $renderer = panels_get_renderer($panelizer->pipeline, $display); $renderer->address = $address; $info = array('content' => panels_render_display($display, $renderer), 'no_blocks' => !empty($panelizer->no_blocks)); $info['classes_array'] = array(); if (!empty($panelizer->css_class)) { ctools_include('cleanstring'); foreach (explode(' ', $panelizer->css_class) as $class) { $class = ctools_context_keyword_substitute($class, array(), $display->context); if ($class) { $info['classes_array'][] = ctools_cleanstring($class); } } } $info['title'] = $display->get_title(); return $info; }