'custom_breadcrumbs_panels', 'field' => 'panel_id', 'type' => 'panels', 'name_constructor' => '_custom_breadcrumbs_panels_breadcrumb_name', ); return $breadcrumb_type_info; } /** * Constructs a default name to display in the admin screen. * * @param $breadcrumb * The breadcrumb object. * * @return * A text string that will be used as the breadcrumb name. */ function _custom_breadcrumbs_panels_breadcrumb_name($breadcrumb) { if (isset($breadcrumb->panel_id)) { return $breadcrumb->panel_id; } } /** * Implements hook_menu(). */ function custom_breadcrumbs_panels_menu() { $items = array(); $items['admin/build/custom_breadcrumbs/panels/add'] = array( 'title' => 'Panels', 'page callback' => 'drupal_get_form', 'page arguments' => array('custom_breadcrumbs_panels_form', 'panels'), 'access callback' => 'user_access', 'access arguments' => array('administer custom breadcrumbs'), 'type' => MENU_LOCAL_TASK, 'weight' => 5, ); $items['admin/build/custom_breadcrumbs/panels/edit'] = array( 'title' => 'Edit custom breadcrumb for panels', 'page callback' => 'drupal_get_form', 'page arguments' => array('custom_breadcrumbs_panels_form', 'panels'), 'access callback' => 'user_access', 'access arguments' => array('administer custom breadcrumbs'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implements hook_ctools_render_alter(). */ function custom_breadcrumbs_panels_ctools_render_alter($info, $page, $args, $contexts, $task, $subtask) { // Don't really do anything with the panel. This is just a pretense to insert a breadcrumb. // Is this a node template? if (isset($task['admin path']) && ($task['admin path'] == "node/%node")) { $context = array_pop($contexts); if ($context->type == 'node' && isset ($context->data)) { $node = $context->data; custom_breadcrumbs_nodeapi($node, 'alter', array(), array(1)); return; } } // Is this a taxonomy term template? if (isset($task['admin path']) && ($task['admin path'] == "taxonomy/term/%term") && module_exists('custom_breadcrumbs_taxonomy') && variable_get('custom_breadcrumbs_taxonomy_panels', FALSE)) { module_load_include('inc', 'custom_breadcrumbs_taxonomy'); foreach ($contexts as $context) { if (isset ($context->data->tid)) { $terms = array($context->data->tid => $context->data); _custom_breadcrumbs_taxonomy_set_breadcrumb($context->data->tid, $context->data->vid, TRUE, array(), $terms); return; } } } if ($page) { global $language; $languages = array('language' => $language->language, 'all' => ''); // Check to see if the panel ID matches any custom_breadcrumb panel_id. $id = 'page-'. $subtask['name']; $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_panels', NULL, array('panel_id' => $id), $languages); if (!empty($breadcrumbs)) { if ($breadcrumb = custom_breadcrumbs_select_breadcrumb($breadcrumbs, array('panel' => $info))) { custom_breadcrumbs_set_breadcrumb($breadcrumb, array('panel' => $info)); return; } } if (variable_get('custom_breadcrumbs_set_menu_breadcrumb', FALSE)) { // If a panels breadcrumb has not been defined for this panel, then use the default menu structure. custom_breadcrumbs_set_menu_breadcrumb(); } } } /** * Implements hook_form_alter(). */ function custom_breadcrumbs_panels_form_alter(&$form, $form_state, $form_id) { if ($form_id == 'custom_breadcrumbs_admin_settings') { if (module_exists('custom_breadcrumbs_taxonomy')) { $form['settings']['custom_breadcrumbs_panels'] = array( '#type' => 'fieldset', '#title' => t('Panels'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['settings']['custom_breadcrumbs_panels']['custom_breadcrumbs_taxonomy_panels'] = array( '#type' => 'checkbox', '#title' => t('Use taxonomy breadcrumbs for panels'), '#default_value' => variable_get('custom_breadcrumbs_taxonomy_panels', FALSE), '#description' => t('If enabled, the view argument and/or the taxonomy structure of nodes returned by panels will be used to form the taxonomy breadcrumb trail.'), '#weight' => 45, ); } } } /** * Form builder; Displays an edit form for a panels breadcrumb. * * @ingroup forms * @see custom_breadcrumbs_form_validate() * @see custom_breadcrumbs_form_submit() */ function custom_breadcrumbs_panels_form(&$form_state, $type) { $form = array(); $breadcrumb = NULL; $bid = arg(5); if (isset($bid)) { drupal_set_title(t('Edit Custom Breadcrumb for Panel Page')); $breadcrumbs = custom_breadcrumbs_load_breadcrumbs('custom_breadcrumbs_panels', NULL, array('bid' => $bid)); $breadcrumb = array_pop($breadcrumbs); } else { drupal_set_title(t('Add Custom Breadcrumb for Panel Page')); } $options = array(); $tasks = page_manager_get_tasks_by_type('page'); $pages = array('operations' => array()); page_manager_get_pages($tasks, $pages); foreach ($pages['rows'] as $id => $info) { if (drupal_substr($id, 0, 5) == 'page-') { $options[$id] = $id; } } $form['panel_id'] = array( '#type' => 'select', '#title' => t('Custom Panel Page Id'), '#required' => TRUE, '#options' => $options, '#description' => t('The Panel that this custom breadcrumb trail will apply to.'), '#default_value' => isset($breadcrumb->panel_id) ? $breadcrumb->panel_id : NULL, '#weight' => -10, ); // Store information needed to save this breadcrumb. $form['#module'] = 'custom_breadcrumbs_panels'; $form['#infokey'] = 'panels'; $form += custom_breadcrumbs_common_form_elements($bid, $breadcrumb); $form['visibility_php']['#description'] = t('Determine whether this breadcrumb should be displayed by using a snippet of PHP to return TRUE or FALSE.'); $form['#submit'][] = 'custom_breadcrumbs_form_submit'; $form['#validate'][] = 'custom_breadcrumbs_form_validate'; return $form; }