| 1 |
<?php |
<?php |
| 2 |
// $Id: taxonomy_context.module,v 1.82.4.6 2009/10/02 22:25:36 nancyw Exp $ |
// $Id: taxonomy_context.module,v 1.82.4.7 2009/10/03 03:00:02 nancyw Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 82 |
'page arguments' => array('taxonomy_context_admin_settings'), |
'page arguments' => array('taxonomy_context_admin_settings'), |
| 83 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 84 |
'access arguments' => array('administer site configuration'), |
'access arguments' => array('administer site configuration'), |
| 85 |
|
'file' => 'taxonomy_context.admin.inc', |
| 86 |
); |
); |
| 87 |
$items['taxonomy/vocabulary'] = array( |
|
| 88 |
|
$voc_path = module_exists('taxonomy_list') ? 'context/vocabulary' : 'taxonomy/vocabulary'; |
| 89 |
|
$items[$voc_path] = array( |
| 90 |
'title' => 'Categories', |
'title' => 'Categories', |
| 91 |
'page callback' => 'taxonomy_context_vocabulary_page', |
'page callback' => 'taxonomy_context_vocabulary_page', |
| 92 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 93 |
'access arguments' => array('access content'), |
'access arguments' => array('access content'), |
| 94 |
'type' => MENU_SUGGESTED_ITEM, |
'type' => MENU_SUGGESTED_ITEM, |
| 95 |
); |
); |
| 96 |
|
|
| 97 |
$items['activemenu/tc'] = array( |
$items['activemenu/tc'] = array( |
| 98 |
'title' => 'activemenu tc', |
'title' => 'activemenu tc', |
| 99 |
'page callback' => 'taxonomy_context_js', |
'page callback' => 'taxonomy_context_js', |
| 182 |
*/ |
*/ |
| 183 |
function taxonomy_context_help($path, $arg) { |
function taxonomy_context_help($path, $arg) { |
| 184 |
// If we're on a 2nd or subsequent page, don't show taxonomy info. |
// If we're on a 2nd or subsequent page, don't show taxonomy info. |
| 185 |
if (arg(0) == 'taxonomy' && empty($_GET['from'])) { |
// $path will be "taxonomy/term/%" or "taxonomy/vocabulary". |
| 186 |
|
if (($arg[0] == 'taxonomy' || $arg[0] == 'context') && empty($_GET['from'])) { |
| 187 |
$context = taxonomy_context_get_context(); |
$context = taxonomy_context_get_context(); |
| 188 |
switch (arg(1)) { |
switch ($arg[1]) { |
| 189 |
case 'term': |
case 'term': |
| 190 |
if (variable_get('taxonomy_context_show_term', TRUE) && $context->tid) { |
if (variable_get('taxonomy_context_show_term', TRUE) && $context->tid) { |
| 191 |
$output .= taxonomy_context_show_term($context->tid); |
$output .= taxonomy_context_show_term($context->tid); |
| 314 |
$context = array('tid' => NULL, 'root_tid' => NULL, 'nid' => NULL, "vid" => NULL); |
$context = array('tid' => NULL, 'root_tid' => NULL, 'nid' => NULL, "vid" => NULL); |
| 315 |
$mode = arg(0); |
$mode = arg(0); |
| 316 |
switch ($mode) { |
switch ($mode) { |
| 317 |
|
// If the taxonomy_list module is also enabled, our path becomes "context/vocabulary". |
| 318 |
|
case 'context': |
| 319 |
case 'taxonomy': |
case 'taxonomy': |
| 320 |
switch (arg(1)) { |
switch (arg(1)) { |
| 321 |
case 'vocabulary': |
case 'vocabulary': |
| 326 |
case 'term': |
case 'term': |
| 327 |
$tidcurrs = preg_split('/[+ ,]/', arg(2)); |
$tidcurrs = preg_split('/[+ ,]/', arg(2)); |
| 328 |
$context['tid'] = $tidcurrs[0]; |
$context['tid'] = $tidcurrs[0]; |
| 329 |
list($top_parent) = taxonomy_get_parents_all($context['tid']); |
$parents = taxonomy_get_parents_all($tid); |
| 330 |
|
// Note that list() is right to left, so it gets the last element. |
| 331 |
|
list($top_parent) = $parents; |
| 332 |
$context['root_tid'] = $top_parent->tid; |
$context['root_tid'] = $top_parent->tid; |
| 333 |
$term = taxonomy_get_term($context['tid']); |
$term = taxonomy_get_term($context['tid']); |
| 334 |
$context['vid'] = $term->vid; |
$context['vid'] = $term->vid; |
| 603 |
return $object; |
return $object; |
| 604 |
} |
} |
| 605 |
|
|
|
function taxonomy_context_admin_settings() { |
|
|
// We need the CSS here. |
|
|
drupal_add_css(drupal_get_path('module', 'taxonomy_context') . '/taxonomy_context.css'); |
|
|
|
|
|
$form = array(); |
|
|
$endis = array(t('Disabled'), t('Enabled')); |
|
|
|
|
|
$form['general_settings'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('General Settings'), |
|
|
'#collapsible' => TRUE, |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_use_style'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Use style for term and subterm display'), |
|
|
'#default_value' => variable_get('taxonomy_context_use_style', 0), |
|
|
'#options' => $endis, |
|
|
'#description' => t('Include style declaration to clean up display of taxonomy info. Disable this option if you wish to do this instead through editing theme .css files.'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_show_term'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show term info'), |
|
|
'#default_value' => variable_get('taxonomy_context_show_term', 1), |
|
|
'#options' => $endis, |
|
|
'#description' => t('Show additional information about current term (from description).'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_show_subterms'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show subterm info'), |
|
|
'#default_value' => variable_get('taxonomy_context_show_subterms', 1), |
|
|
'#options' => $endis, |
|
|
'#description' => t('Show listings of subterms (sub-categories) for current term.'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_subterm_indent'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Subterm indent character'), |
|
|
'#default_value' => variable_get('taxonomy_context_subterm_indent', '—'), |
|
|
'#size' => 32, |
|
|
'#description' => t('Subterms will be indented to show hierarchy; this is what is used to show the indentation. It will be repeated for each level of depth.'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_max_depth'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Maximum term depth for overview'), |
|
|
'#default_value' => variable_get('taxonomy_context_max_depth', 1), |
|
|
'#size' => 8, |
|
|
'#description' => t('This is how deep in the hierarchy to show terms on the overview ("menu") page. A value of 1 show only the highest level.'), |
|
|
); |
|
|
$num_titles = variable_get('taxonomy_context_show_titles', 0); |
|
|
$order = variable_get('taxonomy_context_show_order', 'n.title'); |
|
|
|
|
|
$form['general_settings']['titles'] = array( |
|
|
'#type' => 'fieldset', |
|
|
'#title' => t('Node title display'), |
|
|
'#collapsible' => TRUE, |
|
|
); |
|
|
|
|
|
$form['general_settings']['titles']['taxonomy_context_show_titles'] = array( |
|
|
'#type' => 'textfield', |
|
|
'#title' => t('Maximum titles to show for each term'), |
|
|
'#default_value' => variable_get('taxonomy_context_show_titles', 0), |
|
|
'#size' => 8, |
|
|
'#description' => t('This is how many node titles to show for each term on the overview ("menu") page. A value of 0 means don\'t show any.'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['titles']['taxonomy_context_show_order'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Title order'), |
|
|
'#default_value' => variable_get('taxonomy_context_show_order', 'n.title'), |
|
|
'#options' => array( |
|
|
'n.title' => t('by title (ascending)'), |
|
|
'n.sticky DESC, n.created DESC' => t('by standard Drupal order (sticky, most recent)'), |
|
|
), |
|
|
'#description' => t('In what order do you wish to show the titles? This may also affect which titles are shown if there are more than the limit above.'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_node_block'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show nodes in block'), |
|
|
'#default_value' => variable_get('taxonomy_context_node_block', TAXONOMY_CONTEXT_NODE_BLOCK_NONE), |
|
|
'#options' => array(t('None'), t('Sticky'), t('Promoted'), t('All')), |
|
|
'#description' => t('What nodes do you wish to display in taxonomy blocks?'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_block_display'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show block items'), |
|
|
'#default_value' => variable_get('taxonomy_context_block_display', TAXONOMY_CONTEXT_BLOCK_DISPLAY_COLLAPSED), |
|
|
'#options' => array(t('Collapsed'), t('Expanded')), |
|
|
'#description' => t('Do you want items on the menu expanded or collapsed by default?'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_count_nodes'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show node count on overview page'), |
|
|
'#default_value' => variable_get('taxonomy_context_count_nodes', 0), |
|
|
'#options' => $endis, |
|
|
'#description' => t('Show the number of nodes tagged with each term. For example: term-name (nnn)'), |
|
|
); |
|
|
|
|
|
$form['general_settings']['taxonomy_context_block_count_nodes'] = array( |
|
|
'#type' => 'radios', |
|
|
'#title' => t('Show count nodes in block items'), |
|
|
'#default_value' => variable_get('taxonomy_context_block_count_nodes', TAXONOMY_CONTEXT_BLOCK_COUNT_NODES_FALSE), |
|
|
'#options' => $endis, |
|
|
'#description' => t('Show count nodes in block after items. Example: term (nnn)'), |
|
|
); |
|
|
|
|
|
return system_settings_form($form); |
|
|
} |
|
|
|
|
| 606 |
/** |
/** |
| 607 |
* Implementation of hook_activemenu(). |
* Implementation of hook_activemenu(). |
| 608 |
*/ |
*/ |
| 655 |
$type = $term->subterm ? 'subterm' : 'term'; |
$type = $term->subterm ? 'subterm' : 'term'; |
| 656 |
$output = "<div class=\"$type-container\">\n <div class=\"$type\">\n"; |
$output = "<div class=\"$type-container\">\n <div class=\"$type\">\n"; |
| 657 |
$indent = str_repeat($indent_char, $term->depth) .' '; |
$indent = str_repeat($indent_char, $term->depth) .' '; |
| 658 |
if ($term->subterm) { |
$img = taxonomy_image_display($term->tid, NULL, NULL, array('wrapper' => TRUE)); |
| 659 |
$name = taxonomy_image_display($term->tid, NULL, NULL, array('wrapper' => TRUE)) . tt("taxonomy:term:$term->tid:name", $term->name, NULL, TRUE); |
$name = tt("taxonomy:term:$term->tid:name", $term->name, NULL, TRUE); |
| 660 |
$output .= '<h2 class="title">' . $indent . l($name, taxonomy_term_path($term), array('html' => TRUE)) . "</h2>\n"; |
$level = 2 + $term->subterm; |
| 661 |
} |
$output .= '<h' . $level . ' class="title">' |
| 662 |
|
. $img |
| 663 |
|
. $indent |
| 664 |
|
. l($name, taxonomy_term_path($term)) |
| 665 |
|
. "</h$level>"; |
| 666 |
$term->description = tt("taxonomy:term:$term->tid:description", $term->description, NULL, FALSE); |
$term->description = tt("taxonomy:term:$term->tid:description", $term->description, NULL, FALSE); |
| 667 |
$output .= '<div class="' . ($term->teaser ? 'teaser' : 'description') .'">' . $term->description . '</div>'; |
$output .= '<div class="' . ($term->teaser ? 'teaser' : 'description') .'">' . $term->description . '</div>'; |
| 668 |
if ($term->links) { |
if ($term->links) { |
| 729 |
// Indent child terms. |
// Indent child terms. |
| 730 |
$indent = str_repeat($indent_char, $term->depth) .' '; |
$indent = str_repeat($indent_char, $term->depth) .' '; |
| 731 |
$node_list = array(); |
$node_list = array(); |
| 732 |
|
$indent = str_repeat($indent_char, $term->depth) .' '; |
| 733 |
|
$img = taxonomy_image_display($term->tid, NULL, NULL, array('wrapper' => TRUE)); |
| 734 |
|
$name = tt("taxonomy:term:$term->tid:name", $term->name, NULL, TRUE); |
| 735 |
$items[] = array( |
$items[] = array( |
| 736 |
'data' => $indent . l($term->name, taxonomy_term_path($term)), |
'data' => $img . $indent . l($name, taxonomy_term_path($term)), |
| 737 |
'children' => _taxonomy_context_get_titles($term->tid), |
'children' => _taxonomy_context_get_titles($term->tid), |
| 738 |
'class' => 'vocabulary-list depth-'. $term->depth, |
'class' => 'vocabulary-list depth-'. $term->depth, |
| 739 |
); |
); |
|
|
|
| 740 |
} |
} |
| 741 |
$output .= theme('item_list', $items); |
$output .= theme('item_list', $items); |
| 742 |
return $output .'</div>'; |
return $output .'</div>'; |
| 747 |
* Prevents from losing the breadcrumb. |
* Prevents from losing the breadcrumb. |
| 748 |
*/ |
*/ |
| 749 |
function taxonomy_context_views_post_view(&$view) { |
function taxonomy_context_views_post_view(&$view) { |
| 750 |
if (arg(0) == 'taxonomy' && empty($_GET['from'])) { |
if ((arg(0) == 'taxonomy' || arg(0) == 'context') && empty($_GET['from'])) { |
| 751 |
$context = taxonomy_context_get_context(); |
$context = taxonomy_context_get_context(); |
| 752 |
switch (arg(1)) { |
switch (arg(1)) { |
| 753 |
case 'term': |
case 'term': |