You are here

popup_breadcrumb.module in Popup 6.x

File

modules/popup_breadcrumb/popup_breadcrumb.module
View source
<?php

//$id:

/* ----- Hook implementation ---- */

/**
 * Implementation of hook_menu
 */
function popup_breadcrumb_menu() {
  return array(
    'admin/settings/popup/settings' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'file' => 'includes/popup_breadcrumb.admin.inc',
      'title' => 'Settings',
      'type' => MENU_DEFAULT_LOCAL_TASK,
      'weight' => -1,
    ),
    'admin/settings/popup/breadcrumb' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'description' => 'Configure popup breadcrumbs',
      'file' => 'includes/popup_breadcrumb.admin.inc',
      'page arguments' => array(
        'popup_breadcrumb_settings',
      ),
      'page callback' => 'drupal_get_form',
      'title' => 'Popup breadcrumb',
      'type' => MENU_LOCAL_TASK,
      'weight' => 0,
    ),
    'admin/settings/popup/breadcrumb/delete' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'file' => 'includes/popup_breadcrumb.admin.inc',
      'page callback' => '_popup_breadcrumb_delete',
      'type' => MENU_CALLBACK,
    ),
    'admin/settings/popup/breadcrumb/reset' => array(
      'access arguments' => array(
        'administer popup elements',
      ),
      'file' => 'includes/popup_breadcrumb.admin.inc',
      'page callback' => '_popup_breadcrumb_reset',
      'type' => MENU_CALLBACK,
    ),
  );
}

/* ---- Themeing hooks ---- */

/**
 * Implementation of hook_theme
 */
function popup_breadcrumb_theme() {
  return array(
    'popup_breadcrumb_settings' => array(
      'arguments' => array(
        'form' => array(),
      ),
    ),
  );
}

/**
 * Implementation of hook_preprocess_page
 */
function popup_breadcrumb_preprocess_page(&$variables) {
  if (!drupal_is_front_page()) {
    module_load_include('inc', 'popup_breadcrumb', 'includes/popup_breadcrumb.admin');
    $settings = _popup_breadcrumb_settings();
    $path_args = _popup_breadcrumb_arguments($settings);
    $breadcrumb = $settings['home-link'] ? array(
      l(t('Home'), variable_get('site-frontpage', '')),
    ) : array();
    module_load_include('inc', 'popup', 'includes/popup.api');
    if (count($settings['views'])) {
      foreach ($settings['views'] as $view_settings) {
        $args = array();
        foreach ($view_settings['arguments'] as $index => $argument_enabled) {
          if ($argument_enabled) {
            $args[] = $path_args[$index - 1];
          }
        }
        $view = views_get_view($view_settings['view']);
        $attributes = _popup_breadcrumb_title_attributes($view_settings['title_type'], $path_args[$view_settings['title_link_argument'] - 1]);
        $attributes['format'] = $settings['format'];
        $attributes['view'] = $view_settings['view'];
        $attributes['display'] = $view_settings['display'];
        $attributes['args'] = implode(',', $args);
        $attributes['empty-body'] = 'none';
        $breadcrumb[] = _popup_view($attributes);
      }
    }
    $breadcrumb = array_filter($breadcrumb);
    if (($settings['append-title'] == 1 && arg(0) == 'node' || $settings['append-title'] == 2) && !drupal_is_front_page()) {
      $breadcrumb[] = drupal_get_title();
    }
    $variables['breadcrumb'] = theme('breadcrumb', $breadcrumb);
    $variables['styles'] = drupal_get_css();
  }
}

/**
 * Implementation of theme_popup_breadcrumb_settings
 * Themes the popup breadcrumb settings form
 */
function theme_popup_breadcrumb_settings($form) {
  $table_rows = array();
  $header = array(
    '',
    'Name',
    array(
      'data' => '<div>' . t('View') . '</div>&nbsp;',
      'class' => 'section',
    ),
    'Display',
    'Arguments',
    array(
      'data' => '<div>' . t('Title') . '</div>Derive from',
      'class' => 'section',
    ),
    'Argument',
    'Weight',
    array(
      'data' => '',
      'class' => 'section',
    ),
  );
  foreach ($form['rows'] as $row_id => $row) {
    if (substr($row_id, 0, 1) != '#') {
      $table_rows[$row_id] = array(
        'class' => 'draggable',
        'data' => array(
          '',
        ),
      );
      foreach ($row as $field_id => $field) {
        if (substr($field_id, 0, 1) != '#') {
          if ($field_id == 'view' || $field_id == 'title_type') {
            $table_rows[$row_id]['data'][] = array(
              'data' => drupal_render($form['rows'][$row_id][$field_id]),
              'class' => 'section',
            );
          }
          else {
            $table_rows[$row_id]['data'][] = drupal_render($form['rows'][$row_id][$field_id]);
          }
        }
      }
    }
  }
  $form['table'] = array(
    '#value' => '<div class="form-item"><label>' . t('Breadcrumb levels') . ':</label>' . theme('table', $header, $table_rows, array(
      'id' => 'breadcrumb-table',
      'class' => "popup-settings-table",
    )) . '</div>',
    '#weight' => -1,
  );
  $output .= drupal_render($form);
  drupal_add_tabledrag('breadcrumb-table', 'order', 'sibling', 'row-weight');
  return $output;
}

Functions

Namesort descending Description
popup_breadcrumb_menu Implementation of hook_menu
popup_breadcrumb_preprocess_page Implementation of hook_preprocess_page
popup_breadcrumb_theme Implementation of hook_theme
theme_popup_breadcrumb_settings Implementation of theme_popup_breadcrumb_settings Themes the popup breadcrumb settings form