You are here

function panels_renderer_editor::get_pane_links in Panels 6.3

Same name and namespace in other branches
  1. 7.3 plugins/display_renderers/panels_renderer_editor.class.php \panels_renderer_editor::get_pane_links()

Render the links to display when editing a pane.

1 call to panels_renderer_editor::get_pane_links()
panels_renderer_editor::render_pane in plugins/display_renderers/panels_renderer_editor.class.php
Render a pane using its designated style.

File

plugins/display_renderers/panels_renderer_editor.class.php, line 288
Class file to control the main Panels editor.

Class

panels_renderer_editor
@file Class file to control the main Panels editor.

Code

function get_pane_links($pane, $content_type) {
  $links = array();
  if (!empty($pane->shown)) {
    $links[] = array(
      'title' => t('Disable this pane'),
      'href' => $this
        ->get_url('hide', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-ajax',
      ),
    );
  }
  else {
    $links[] = array(
      'title' => t('Enable this pane'),
      'href' => $this
        ->get_url('show', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-ajax',
      ),
    );
  }
  if (isset($this->display->title_pane) && $this->display->title_pane == $pane->pid) {
    $links['panels-set-title'] = array(
      'title' => t('✓Panel title'),
      'html' => TRUE,
    );
  }
  else {
    $links['panels-set-title'] = array(
      'title' => t('Panel title'),
      'href' => $this
        ->get_url('panel-title', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-ajax',
      ),
    );
  }
  $subtype = ctools_content_get_subtype($content_type, $pane->subtype);
  if (ctools_content_editable($content_type, $subtype, $pane->configuration)) {
    $links[] = array(
      'title' => isset($content_type['edit text']) ? $content_type['edit text'] : t('Settings'),
      'href' => $this
        ->get_url('edit-pane', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    );
  }
  if (user_access('administer advanced pane settings')) {
    $links[] = array(
      'title' => t('CSS properties'),
      'href' => $this
        ->get_url('pane-css', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    );
  }
  if (user_access('administer panels styles')) {
    $links[] = array(
      'title' => '<hr />',
      'html' => TRUE,
    );
    $style_links = $this
      ->get_style_links('pane', $pane->pid);
    $links[] = array(
      'title' => '<span class="dropdown-header">' . t('Style') . '</span>' . theme_links($style_links),
      'html' => TRUE,
      'attributes' => array(
        'class' => 'panels-sub-menu',
      ),
    );
  }
  if (user_access('administer pane access')) {
    $links[] = array(
      'title' => '<hr />',
      'html' => TRUE,
    );
    $contexts = $this->display->context;

    // Make sure we have the logged in user context
    if (!isset($contexts['logged-in-user'])) {
      $contexts['logged-in-user'] = ctools_access_get_loggedin_context();
    }
    $visibility_links = array();
    if (!empty($pane->access['plugins'])) {
      foreach ($pane->access['plugins'] as $id => $test) {
        $plugin = ctools_get_access_plugin($test['name']);
        $access_title = isset($plugin['title']) ? $plugin['title'] : t('Broken/missing access plugin %plugin', array(
          '%plugin' => $test['name'],
        ));
        $access_description = ctools_access_summary($plugin, $contexts, $test);
        $visibility_links[] = array(
          'title' => $access_description,
          'href' => $this
            ->get_url('access-configure-test', $pane->pid, $id),
          'attributes' => array(
            'class' => 'ctools-use-modal panels-italic',
          ),
        );
      }
    }
    if (empty($visibility_links)) {
      $visibility_links[] = array(
        'title' => t('No rules'),
        'attributes' => array(
          'class' => 'panels-text',
        ),
      );
    }
    $visibility_links[] = array(
      'title' => t('Add new rule'),
      'href' => $this
        ->get_url('access-add-test', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    );
    $visibility_links[] = array(
      'title' => t('Settings'),
      'href' => $this
        ->get_url('access-settings', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    );
    $links[] = array(
      'title' => '<span class="dropdown-header">' . t('Visibility rules') . '</span>' . theme_links($visibility_links),
      'html' => TRUE,
      'attributes' => array(
        'class' => 'panels-sub-menu',
      ),
    );
  }
  if (panels_get_caches() && user_access('use panels caching features')) {
    $links[] = array(
      'title' => '<hr />',
      'html' => TRUE,
    );
    $method = isset($pane->cache['method']) ? $pane->cache['method'] : 0;
    $info = panels_get_cache($method);
    $cache_method = isset($info['title']) ? $info['title'] : t('No caching');
    $cache_links[] = array(
      'title' => $cache_method,
      'attributes' => array(
        'class' => 'panels-text',
      ),
    );
    $cache_links[] = array(
      'title' => t('Change'),
      'href' => $this
        ->get_url('cache-method', $pane->pid),
      'attributes' => array(
        'class' => 'ctools-use-modal',
      ),
    );
    if (panels_plugin_get_function('cache', $info, 'settings form')) {
      $cache_links[] = array(
        'title' => t('Settings'),
        'href' => $this
          ->get_url('cache-settings', $pane->pid),
        'attributes' => array(
          'class' => 'ctools-use-modal',
        ),
      );
    }
    $links[] = array(
      'title' => '<span class="dropdown-header">' . t('Caching') . '</span>' . theme_links($cache_links),
      'html' => TRUE,
      'attributes' => array(
        'class' => 'panels-sub-menu',
      ),
    );
  }
  $links[] = array(
    'title' => '<hr />',
    'html' => TRUE,
  );
  $links[] = array(
    'title' => t('Remove'),
    'href' => '#',
    'attributes' => array(
      'class' => 'pane-delete',
      'id' => "pane-delete-panel-pane-{$pane->pid}",
    ),
  );
  return theme('ctools_dropdown', theme('image', ctools_image_path('icon-configure.png', 'panels')), $links, TRUE);
}