| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_context.module,v 1.82.4.10 2009/10/03 20:11:30 nancyw Exp $ |
// $Id: taxonomy_context.module,v 1.82.4.11 2009/10/05 18:23:10 nancyw Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 62 |
} |
} |
| 63 |
|
|
| 64 |
// Helper function for when taxonomy_image module is not installed. |
// Helper function for when taxonomy_image module is not installed. |
| 65 |
if (!function_exists('taxonomy_image_display')) { |
if (!module_exists('taxonomy_image')) { |
| 66 |
function taxonomy_image_display($tid, $tags = NULL, $profile = NULL, $overrides = array()) { |
function taxonomy_image_display($tid, $tags = NULL, $profile = NULL, $overrides = array()) { |
| 67 |
return NULL; |
return NULL; |
| 68 |
} |
} |
| 219 |
$keys = array('term' => 'tid', 'vocabulary' => 'vid'); |
$keys = array('term' => 'tid', 'vocabulary' => 'vid'); |
| 220 |
if (in_array($type, array('term', 'vocabulary')) && user_access('administer taxonomy')) { |
if (in_array($type, array('term', 'vocabulary')) && user_access('administer taxonomy')) { |
| 221 |
$links['administer_'. $type] = array( |
$links['administer_'. $type] = array( |
| 222 |
'title' => t('edit'), |
'title' => t('edit !object_name', array('!object_name' => $object->name)), |
| 223 |
'href' => 'admin/content/taxonomy/edit/'. $type .'/'. $object->$keys[$type], |
'href' => 'admin/content/taxonomy/edit/'. $type .'/'. $object->$keys[$type], |
| 224 |
'attributes' => array('title' => t('Edit this !type.', array('!type' => $type))) |
'attributes' => array('title' => t('Edit this !type.', array('!type' => $type))) |
| 225 |
); |
); |
| 293 |
} |
} |
| 294 |
|
|
| 295 |
/** |
/** |
| 296 |
|
* Implementation of hook_link_alter(). |
| 297 |
|
* Remove current term from taxonomy links. |
| 298 |
|
*/ |
| 299 |
|
function taxonomy_context_link_alter(&$links, $node) { |
| 300 |
|
// Only do this on taxonomy/term/xxx if we want it. |
| 301 |
|
if (arg(0) == 'taxonomy' && arg(1) == 'term' && variable_get('taxonomy_context_suppress_current', 0)) { |
| 302 |
|
$tid = arg(2); |
| 303 |
|
unset($links["taxonomy_term_$tid"]); |
| 304 |
|
} |
| 305 |
|
} |
| 306 |
|
|
| 307 |
|
/** |
| 308 |
* Implementation of hook_nodeapi(). |
* Implementation of hook_nodeapi(). |
| 309 |
*/ |
*/ |
| 310 |
function taxonomy_context_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
function taxonomy_context_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { |
| 311 |
switch ($op) { |
switch ($op) { |
| 312 |
case 'view': |
case 'view': |
| 313 |
|
// @TODO: would this be better in hook_link or hook_link_alter? |
| 314 |
|
// Display taxonomy information in node body. |
| 315 |
|
// "Disabled" is standard Drupal behavior; |
| 316 |
|
// "enabled" adds the taxonomy context information to the content area. |
| 317 |
if ((arg(0) == 'node') && variable_get('taxonomy_context_inline_' . $node->type, 0)) { |
if ((arg(0) == 'node') && variable_get('taxonomy_context_inline_' . $node->type, 0)) { |
| 318 |
$node->content['taxonomy_context_taxonomy'] = array( |
$node->content['taxonomy_context_taxonomy'] = array( |
| 319 |
'#value' => '', |
'#value' => '', |
| 325 |
$node->content['taxonomy_context_taxonomy']['#value'] .= theme('taxonomy_context_vocabulary_list', $vocabulary); |
$node->content['taxonomy_context_taxonomy']['#value'] .= theme('taxonomy_context_vocabulary_list', $vocabulary); |
| 326 |
} |
} |
| 327 |
} |
} |
| 328 |
|
// @TODO: ??? |
| 329 |
$node->taxonomy = array(); |
$node->taxonomy = array(); |
| 330 |
} |
} |
| 331 |
if (variable_get("taxonomy_context_breadcrumb_$node->type", 0)) { |
if (variable_get("taxonomy_context_breadcrumb_$node->type", 0)) { |
| 564 |
$parents[] = $parent->tid; |
$parents[] = $parent->tid; |
| 565 |
} |
} |
| 566 |
|
|
| 567 |
|
// @TODO: Is depth important here? |
| 568 |
$terms = $tid ? taxonomy_get_children($tid, $vid) : taxonomy_get_tree($vid, 0, -1, 1); |
$terms = $tid ? taxonomy_get_children($tid, $vid) : taxonomy_get_tree($vid, 0, -1, 1); |
| 569 |
|
|
| 570 |
if ($terms) { |
if ($terms) { |