You are here

protected function JuiceboxGalleryDrupal::buildContextualLinks in Juicebox HTML5 Responsive Image Galleries 7.2

Utility to build a render array of contextual links that can be used to administer a gallery.

Parameters

string $xml_path: The path to the Juicebox XML for this gallery.

array $context: Optional contextual information that may be used in the links:

  • conf_path: A Drupal path within the admin interface where the gallery can be configured.

boolean $omit_xml_link: Whether-or-not to omit a contextul link to the gallery XML.

Return value

array Drupal render array for the contextual links.

See also

JuiceboxGalleryDrupalInterface::buildGallery()

1 call to JuiceboxGalleryDrupal::buildContextualLinks()
JuiceboxGalleryDrupal::buildEmbed in includes/JuiceboxGalleryDrupal.inc
Build a render array of the embed code for a Juicebox gallery after images and options have been added.

File

includes/JuiceboxGalleryDrupal.inc, line 270
Class to extend a JuiceboxGalleryDecorator object with Drupal-specific logic and structures.

Class

JuiceboxGalleryDrupal
Class to extend a JuiceboxGalleryDecorator object with Drupal-specific logic and structures.

Code

protected function buildContextualLinks($xml_path = '', $context = array(), $omit_xml_link = FALSE) {
  $c_links = array();
  if (module_exists('contextual') && user_access('access contextual links')) {
    $links = array();

    // Add link to the gallery-specific configuration if we have it.
    if (!empty($context['conf_path']) && drupal_valid_path($context['conf_path'])) {
      $links['gallery_config'] = array(
        'title' => t('Configure galleries of this type'),
        'href' => $context['conf_path'],
        'query' => drupal_get_destination(),
      );
    }

    // Add a link to the global Juicebox options.
    if (drupal_valid_path('admin/config/media/juicebox')) {
      $links['global_config'] = array(
        'title' => t('Configure global Juicebox options'),
        'href' => 'admin/config/media/juicebox',
        'query' => drupal_get_destination(),
      );
    }
    if (!$omit_xml_link) {
      $links['xml'] = array(
        'title' => t('View gallery XML'),
        'href' => $xml_path,
      );
    }

    // Add link to toggle debug view.
    if ($this
      ->accessDebugDisplay()) {
      $query = drupal_get_query_parameters();
      if (empty($query['jb-debug'])) {
        $query['jb-debug'] = 1;
        $title = t('Toggle debug info on');
      }
      else {
        unset($query['jb-debug']);
        $title = t('Toggle debug info off');
      }
      $links['toggle_debug'] = array(
        'title' => $title,
        'href' => current_path(),
        'query' => $query,
        'fragment' => $this
          ->getId(),
      );
    }

    // If we have links, build a render array for the contextual links.
    if ($links) {

      // Add the contextual-links-region wrapper to the Juicebox parent.
      $this->settings['custom_parent_classes'] = trim($this->settings['custom_parent_classes'] . ' contextual-links-region');
      $c_links = array(
        '#prefix' => '<div class="contextual-links-wrapper">',
        '#suffix' => '</div>',
        '#theme' => 'links__contextual',
        '#links' => $links,
        '#attributes' => array(
          'class' => array(
            'contextual-links',
          ),
        ),
        '#attached' => array(
          'library' => array(
            array(
              'contextual',
              'contextual-links',
            ),
          ),
          'css' => array(
            drupal_get_path('module', 'juicebox') . '/css/admin_styles.css',
          ),
        ),
      );
    }
  }
  return $c_links;
}