Definition in file term.inc.
Go to the source code of this file.
Functions | |
| panels_term_choose_display ($conf, $context) | |
| panels_term_context ($arg=NULL, $conf=NULL, $empty=FALSE) | |
| panels_term_displays ($conf, $id) | |
| panels_term_panels_arguments () | |
| panels_term_settings_form ($conf) | |
| panels_term_settings_form_submit (&$values) | |
| panels_term_title ($context) | |
| panels_term_choose_display | ( | $ | conf, | |
| $ | context | |||
| ) |
Based upon the settings and the context, choose which display to use.
Definition at line 183 of file term.inc.
00183 { 00184 if (empty($context->data)) { 00185 return; 00186 } 00187 00188 if (!empty($conf['displays'][$context->data->vid])) { 00189 return $context->data->vid; 00190 } 00191 00192 // Please note that 'default' is a special display. 00193 if (!empty($conf['own_default'])) { 00194 return 'default'; 00195 } 00196 00197 // Empty return says to use the default display. 00198 return; 00199 }
| panels_term_context | ( | $ | arg = NULL, |
|
| $ | conf = NULL, |
|||
| $ | empty = FALSE | |||
| ) |
Discover if this argument gives us the term we crave.
Definition at line 29 of file term.inc.
References panels_context_create(), and panels_context_create_empty().
00029 { 00030 // If unset it wants a generic, unfilled context. 00031 if ($empty) { 00032 return panels_context_create_empty('term'); 00033 } 00034 00035 switch ($conf['input_form']) { 00036 case 'tid': 00037 default: 00038 if (!is_numeric($arg)) { 00039 return FALSE; 00040 } 00041 $term = taxonomy_get_term($arg); 00042 break; 00043 00044 case 'term': 00045 $terms = taxonomy_get_term_by_name($arg); 00046 if (count($terms) != 1) { 00047 foreach ($terms as $potential) { 00048 foreach ($conf['vids'] as $vid => $active) { 00049 if ($active == 1 && $potential->vid == $vid) { 00050 $term = $potential; 00051 // break out of the foreaches AND the case 00052 break 3; 00053 } 00054 } 00055 } 00056 } 00057 $term = array_shift($terms); 00058 break; 00059 } 00060 00061 if (empty($term)) { 00062 return FALSE; 00063 } 00064 00065 if (!empty($conf['vids']) && array_filter($conf['vids']) && empty($conf['vids'][$term->vid])) { 00066 return FALSE; 00067 } 00068 00069 return panels_context_create('term', $term); 00070 }
| panels_term_displays | ( | $ | conf, | |
| $ | id | |||
| ) |
What additional displays does this argument provide?
Definition at line 153 of file term.inc.
00153 { 00154 $displays = array(); 00155 if (!empty($conf['own_default'])) { 00156 $displays['default'] = array( 00157 'title' => t('Taxonomy term @id Default', array('@id' => $id)), 00158 'context' => 'term', 00159 ); 00160 } 00161 00162 if (is_array($conf['displays'])) { 00163 $options = array(); 00164 foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) { 00165 $options[$vid] = $vocabulary->name; 00166 } 00167 foreach (array_keys(array_filter($conf['displays'])) as $vid) { 00168 $displays[$vid] = array( 00169 'title' => t('Taxonomy term @id @vocabulary', array('@id' => $id, '@vocabulary' => $options[$vid])), 00170 // Tell it to base the template for this display off of the default. 00171 'default' => 'default', 00172 'context' => 'term', 00173 ); 00174 } 00175 } 00176 00177 return $displays; 00178 }
| panels_term_panels_arguments | ( | ) |
Definition at line 10 of file term.inc.
00010 { 00011 $args['term'] = array( 00012 'title' => t("Taxonomy term"), 00013 // keyword to use for %substitution 00014 'keyword' => 'term', 00015 'description' => t('Restricts the argument to a taxonomy term.'), 00016 'context' => 'panels_term_context', 00017 'settings form' => 'panels_term_settings_form', 00018 'settings form submit' => 'panels_term_settings_form_submit', 00019 'title function' => 'panels_term_title', 00020 'displays' => 'panels_term_displays', 00021 'choose display' => 'panels_term_choose_display', 00022 ); 00023 return $args; 00024 }
| panels_term_settings_form | ( | $ | conf | ) |
Settings form for the argument
Definition at line 75 of file term.inc.
00075 { 00076 if (empty($conf)) { 00077 $conf = array( 00078 'input_form' => 'tid', 00079 ); 00080 } 00081 00082 $options = array(); 00083 foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) { 00084 $options[$vid] = $vocabulary->name; 00085 } 00086 00087 $form['input_form'] = array( 00088 '#title' => t('Argument type'), 00089 '#type' => 'radios', 00090 '#options' => array('tid' => t('Term ID'), 'term' => t('Term name')), 00091 '#default_value' => $conf['input_form'], 00092 '#prefix' => '<div class="clear-block">', 00093 '#suffix' => '</div>', 00094 ); 00095 00096 00097 $form['vids'] = array( 00098 '#title' => t('Vocabularies'), 00099 '#type' => 'checkboxes', 00100 '#options' => $options, 00101 '#description' => t('You can restrict this argument to use the checked vocabularies. Arguments from non-conforming vocabularies will be ignored, and Panels will behave as if no argument were given. Leave all unchecked to impose no restriction.'), 00102 '#default_value' => $conf['vids'], 00103 '#prefix' => '<div class="clear-block">', 00104 '#suffix' => '</div>', 00105 ); 00106 00107 $form['own_default'] = array( 00108 '#title' => t('Use different default display'), 00109 '#type' => 'checkbox', 00110 '#description' => t('If checked, when this argument is present it will use its own display rather than the default. Vocabularies not selected in the "Own display" field will use this one.'), 00111 '#default_value' => $conf['own_default'], 00112 ); 00113 00114 $form['displays'] = array( 00115 '#title' => t('Own display'), 00116 '#type' => 'checkboxes', 00117 '#options' => $options, 00118 '#default_value' => $conf['displays'], 00119 '#description' => t('Each checked vocabulary will get its own special display to layout its content. Only vocabularies set above should be set here. Vocabularies not set here will use the default display.'), 00120 '#prefix' => '<div class="clear-block">', 00121 '#suffix' => '</div>', 00122 ); 00123 00124 return $form; 00125 }
| panels_term_settings_form_submit | ( | &$ | values | ) |
There appears to be a bit of a bug with the way we're handling forms; it causes 'checkboxes' to get invalid values added to them when empty. This takes care of that.
Definition at line 132 of file term.inc.
00132 { 00133 $vocs = taxonomy_get_vocabularies(); 00134 if (!empty($values['vids'])) { 00135 foreach ($values['vids'] as $vid => $value) { 00136 if (empty($vocs[$vid])) { 00137 unset($values['vids'][$vid]); 00138 } 00139 } 00140 } 00141 if (!empty($values['displays'])) { 00142 foreach ($values['displays'] as $vid => $value) { 00143 if (empty($vocs[$vid])) { 00144 unset($values['displays'][$vid]); 00145 } 00146 } 00147 } 00148 }
| panels_term_title | ( | $ | context | ) |
1.5.6