| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: terms.inc,v 1.3.2.3 2010/01/29 20:18:25 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * 7 * Plugin to provide an argument handler for a Taxonomy term 8 */ 9 10 /** 11 * Plugins are described by creating a $plugin array which will be used 12 * by the system that includes this file. 13 */ 14 $plugin = array( 15 'title' => t("Taxonomy term (multiple): ID"), 16 // keyword to use for %substitution 17 'keyword' => 'term', 18 'description' => t('Creates a group of taxonomy terms from a list of tids separated by a comma or a plus sign. In general the first term of the list will be used for panes.'), 19 'context' => 'ctools_terms_context', 20 'default' => array('breadcrumb' => TRUE), 21 'settings form' => 'ctools_terms_settings_form', 22 'placeholder form' => array( 23 '#type' => 'textfield', 24 '#description' => t('Enter a term ID or a list of term IDs separated by a + or a ,'), 25 ), 26 'breadcrumb' => 'ctools_terms_breadcrumb', 27 ); 28 29 /** 30 * Discover if this argument gives us the term we crave. 31 */ 32 function ctools_terms_context($arg = NULL, $conf = NULL, $empty = FALSE) { 33 // If unset it wants a generic, unfilled context. 34 if ($empty) { 35 return ctools_context_create_empty('terms'); 36 } 37 38 $terms = ctools_break_phrase($arg); 39 if (empty($terms->value) || !empty($terms->invalid_input)) { 40 return FALSE; 41 } 42 43 $context = ctools_context_create('terms', $terms); 44 $context->original_argument = $arg; 45 return $context; 46 } 47 48 /** 49 * Settings form for the argument 50 */ 51 function ctools_terms_settings_form(&$form, &$form_state, $conf) { 52 $form['settings']['breadcrumb'] = array( 53 '#title' => t('Inject hierarchy of first term into breadcrumb trail'), 54 '#type' => 'checkbox', 55 '#default_value' => !empty($conf['breadcrumb']), 56 '#description' => t('If checked, taxonomy term parents will appear in the breadcrumb trail.'), 57 ); 58 } 59 60 /** 61 * Inject the breadcrumb trail if necessary. 62 */ 63 function ctools_terms_breadcrumb($conf, $context) { 64 if (empty($conf['breadcrumb'])) { 65 return; 66 } 67 68 $current->tid = $context->tids[0]; 69 $breadcrumb = array(); 70 while ($parents = taxonomy_get_parents($current->tid)) { 71 $current = array_shift($parents); 72 $breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid); 73 } 74 75 $breadcrumb = array_merge(drupal_get_breadcrumb(), array_reverse($breadcrumb)); 76 drupal_set_breadcrumb($breadcrumb); 77 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |