You are here

class panels_renderer_ipe in Panels 6.3

Same name and namespace in other branches
  1. 7.3 panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php \panels_renderer_ipe

Renderer class for all In-Place Editor (IPE) behavior.

Hierarchy

Expanded class hierarchy of panels_renderer_ipe

1 string reference to 'panels_renderer_ipe'
ipe.inc in panels_ipe/plugins/display_renderers/ipe.inc

File

panels_ipe/plugins/display_renderers/panels_renderer_ipe.class.php, line 6

View source
class panels_renderer_ipe extends panels_renderer_editor {

  // The IPE operates in normal render mode, not admin mode.
  var $admin = FALSE;
  function render() {
    $output = parent::render();
    return "<div id='panels-ipe-display-{$this->clean_key}' class='panels-ipe-display-container'>{$output}</div>";
  }
  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();
  }

  /**
   * Override & call the parent, then pass output through to the dnd wrapper
   * theme function.
   *
   * @param $pane
   */
  function render_pane(&$pane) {
    $output = parent::render_pane($pane);
    if (empty($output)) {
      return;
    }
    if (empty($pane->IPE_empty)) {

      // Add an inner layer wrapper to the pane content before placing it into
      // draggable portlet
      $output = "<div class=\"panels-ipe-portlet-content\">{$output}</div>";
    }
    else {
      $output = "<div class=\"panels-ipe-portlet-content panels-ipe-empty-pane\">{$output}</div>";
    }

    // Hand it off to the plugin/theme for placing draggers/buttons
    $output = theme('panels_ipe_pane_wrapper', $output, $pane, $this->display, $this);
    return "<div id=\"panels-ipe-paneid-{$pane->pid}\" class=\"panels-ipe-portlet-wrapper panels-ipe-portlet-marker\">" . $output . "</div>";
  }
  function render_pane_content(&$pane) {
    $content = parent::render_pane_content($pane);
    if (!is_object($content)) {
      $content = new StdClass();
    }

    // Ensure that empty panes have some content.
    if (empty($content->content)) {

      // Get the administrative title.
      $content_type = ctools_get_content_type($pane->type);
      $title = ctools_content_admin_title($content_type, $pane->subtype, $pane->configuration, $this->display->context);
      $content->content = t('Placeholder for empty "@title"', array(
        '@title' => $title,
      ));
      $pane->IPE_empty = TRUE;
    }
    return $content;
  }

  /**
   * Add an 'empty' pane placeholder above all the normal panes.
   *
   * @param $region_id
   * @param $panes
   */
  function render_region($region_id, $panes) {

    // Generate this region's 'empty' placeholder pane from the IPE plugin.
    $empty_ph = theme('panels_ipe_placeholder_pane', $region_id, $this->plugins['layout']['panels'][$region_id]);

    // Wrap the placeholder in some guaranteed markup.
    $panes['empty_placeholder'] = '<div class="panels-ipe-placeholder panels-ipe-on panels-ipe-portlet-marker panels-ipe-portlet-static">' . $empty_ph . "</div>";

    // Generate this region's add new pane button. FIXME waaaaay too hardcoded
    $panes['add_button'] = theme('panels_ipe_add_pane_button', $region_id, $this->display, $this);
    $output = parent::render_region($region_id, $panes);
    $output = theme('panels_ipe_region_wrapper', $output, $region_id, $this->display);
    $classes = 'panels-ipe-region';
    return "<div id='panels-ipe-regionid-{$region_id}' class='panels-ipe-region'>{$output}</div>";
  }

  /**
   * AJAX entry point to create the controller form for an IPE.
   */
  function ajax_save_form($break = NULL) {
    ctools_include('form');
    if (!empty($this->cache->locked)) {
      if ($break != 'break') {
        $account = user_load($this->cache->locked->uid);
        $name = theme('username', $account);
        $lock_age = format_interval(time() - $this->cache->locked->updated);
        $message = t("This panel is being edited by user !user, and is therefore locked from editing by others. This lock is !age old.\n\nClick OK to break this lock and discard any changes made by !user.", array(
          '!user' => $name,
          '!age' => $lock_age,
        ));
        $this->commands[] = array(
          'command' => 'unlockIPE',
          'message' => $message,
          'break_path' => url($this
            ->get_url('save-form', 'break')),
        );
        return;
      }

      // Break the lock.
      panels_edit_cache_break_lock($this->cache);
    }
    $form_state = array(
      'display' => &$this->display,
      'content_types' => $this->cache->content_types,
      'rerender' => FALSE,
      'no_redirect' => TRUE,
      // Panels needs this to make sure that the layout gets callbacks
      'layout' => $this->plugins['layout'],
    );
    $output = ctools_build_form('panels_ipe_edit_control_form', $form_state);
    if ($output) {

      // At this point, we want to save the cache to ensure that we have a lock.
      panels_edit_cache_set($this->cache);
      $this->commands[] = array(
        'command' => 'initIPE',
        'key' => $this->clean_key,
        'data' => $output,
      );
      return;
    }

    // no output == submit
    if (!empty($form_state['clicked_button']['#save-display'])) {

      // Saved. Save the cache.
      panels_edit_cache_save($this->cache);
    }
    else {

      // Cancelled. Clear the cache.
      panels_edit_cache_clear($this->cache);
    }
    $this->commands[] = array(
      'command' => 'endIPE',
      'key' => $this->clean_key,
      'data' => $output,
    );
  }

  /**
   * Create a command array to redraw a pane.
   */
  function command_update_pane($pid) {
    if (is_object($pid)) {
      $pane = $pid;
    }
    else {
      $pane = $this->display->content[$pid];
    }
    $this->commands[] = ctools_ajax_command_replace("#panels-ipe-paneid-{$pane->pid}", $this
      ->render_pane($pane));
    $this->commands[] = ctools_ajax_command_changed("#panels-ipe-display-{$this->clean_key}");
  }

  /**
   * 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];
    }
    $this->commands[] = ctools_ajax_command_append("#panels-ipe-regionid-{$pane->panel} div.panels-ipe-sort-container", $this
      ->render_pane($pane));
    $this->commands[] = ctools_ajax_command_changed("#panels-ipe-display-{$this->clean_key}");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
panels_renderer_editor::$commands property An array of AJAX commands to return. If populated it will automatically be used by the AJAX router.
panels_renderer_editor::ajax_access_add_test function AJAX entry point for to add a visibility rule.
panels_renderer_editor::ajax_access_configure_test function AJAX entry point for to configure vsibility rule.
panels_renderer_editor::ajax_access_settings function AJAX entry point to configure access settings for a pane.
panels_renderer_editor::ajax_add_pane function AJAX entry point to add a new pane.
panels_renderer_editor::ajax_cache_method function AJAX entry point to configure the cache method for a pane or the display.
panels_renderer_editor::ajax_cache_settings function AJAX entry point to configure the cache settings for a pane or the display.
panels_renderer_editor::ajax_edit_pane function AJAX entry point to edit a pane.
panels_renderer_editor::ajax_hide function AJAX command to show a pane.
panels_renderer_editor::ajax_layout function AJAX Router function for layout owned AJAX calls.
panels_renderer_editor::ajax_panel_title function AJAX entry point to select which pane is currently the title.
panels_renderer_editor::ajax_pane_css function AJAX entry point to configure CSS for a pane.
panels_renderer_editor::ajax_select_content function AJAX command to present a dialog with a list of available content.
panels_renderer_editor::ajax_show function AJAX command to show a pane.
panels_renderer_editor::ajax_style function AJAX Router function for style owned AJAX calls.
panels_renderer_editor::ajax_style_settings function AJAX entry point to configure the style for a display, region or pane.
panels_renderer_editor::ajax_style_type function AJAX entry point to select the style for a display, region or pane.
panels_renderer_editor::command_update_display_links function Create a command to update the links on a display after a change was made.
panels_renderer_editor::command_update_region_links function Create a command to update the links on a region after a change was made.
panels_renderer_editor::edit function
panels_renderer_editor::get_categories function Create a list of categories from all of the content type.
panels_renderer_editor::get_category function Return the category name and the category key of a given content type.
panels_renderer_editor::get_display_links function Get the links for a panel display.
panels_renderer_editor::get_pane_links function Render the links to display when editing a pane.
panels_renderer_editor::get_region_links function Render the links to display when editing a region.
panels_renderer_editor::get_style function Get the appropriate style from the panel in the cache.
panels_renderer_editor::get_style_links function Get the style links.
panels_renderer_editor::get_url function Generate a URL path for the AJAX editor.
panels_renderer_editor::render_add_content_link function Render a single link to add a content type.
panels_renderer_editor::render_category function Render all of the content links in a category.
panels_renderer_editor::render_category_selector function Render the selector widget in the add content modal to select categories.
panels_renderer_ipe::$admin property TRUE if this renderer is rendering in administrative mode which will allow layouts to have extra functionality. Overrides panels_renderer_editor::$admin
panels_renderer_ipe::add_meta function Attach out-of-band page metadata (e.g., CSS and JS). Overrides panels_renderer_editor::add_meta
panels_renderer_ipe::ajax_save_form function AJAX entry point to create the controller form for an IPE.
panels_renderer_ipe::command_add_pane function Create a command array to add a new pane. Overrides panels_renderer_editor::command_add_pane
panels_renderer_ipe::command_update_pane function Create a command array to redraw a pane. Overrides panels_renderer_editor::command_update_pane
panels_renderer_ipe::render function Build inner content, then hand off to layout-specified theme function for final render step. Overrides panels_renderer_editor::render
panels_renderer_ipe::render_pane function Override & call the parent, then pass output through to the dnd wrapper theme function. Overrides panels_renderer_editor::render_pane
panels_renderer_ipe::render_pane_content function Render the interior contents of a single pane. Overrides panels_renderer_standard::render_pane_content
panels_renderer_ipe::render_region function Add an 'empty' pane placeholder above all the normal panes. Overrides panels_renderer_editor::render_region
panels_renderer_standard::$display property The fully-loaded Panels display object that is to be rendered. "Fully loaded" is defined as: 1. Having been produced by panels_load_displays(), whether or this page request or at some time in the past and the object was exported. 2. Having…
panels_renderer_standard::$meta_location property Where to add standard meta information. There are three possibilities:
panels_renderer_standard::$plugin property The plugin that defines this handler.
panels_renderer_standard::$plugins property An associative array of loaded plugins. Used primarily as a central location for storing plugins that require additional loading beyond reading the plugin definition, which is already statically cached by ctools_get_plugins(). An example is layout…
panels_renderer_standard::$prefix property Include rendered HTML prior to the layout.
panels_renderer_standard::$prepared property A multilevel array of data prepared for rendering. The first level of the array indicates the type of prepared data. The standard renderer populates and uses two top-level keys, 'panes' and 'regions':
panels_renderer_standard::$prep_run property Boolean state variable, indicating whether or not the prepare() method has been run.
panels_renderer_standard::$rendered property A multilevel array of rendered data. The first level of the array indicates the type of rendered data, typically with up to three keys: 'layout', 'regions', and 'panes'. The relevant rendered data is stored as the value…
panels_renderer_standard::$suffix property Include rendered HTML after the layout.
panels_renderer_standard::add_css function Add CSS information to the renderer.
panels_renderer_standard::init function Receive and store the display object to be rendered. 1
panels_renderer_standard::prepare function Prepare the attached display for rendering. 2
panels_renderer_standard::prepare_panes function Prepare the list of panes to be rendered, accounting for visibility/access settings and rendering order.
panels_renderer_standard::prepare_regions function Prepare the list of regions to be rendered.
panels_renderer_standard::render_layout function Perform display/layout-level render operations.
panels_renderer_standard::render_panes function Render all prepared panes, first by dispatching to their plugin's render callback, then handing that output off to the pane's style plugin. 1
panels_renderer_standard::render_regions function Render all prepared regions, placing already-rendered panes into their appropriate positions therein. 1