Index: taxonomy_context.css =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_context/taxonomy_context.css,v retrieving revision 1.11 diff -u -r1.11 taxonomy_context.css --- taxonomy_context.css 16 Jan 2007 22:54:52 -0000 1.11 +++ taxonomy_context.css 16 Feb 2009 14:46:14 -0000 @@ -1,21 +1,30 @@ +/* $Id: $ */ +/** + * @file + * Create a block as a hierarchical menu tree for each vocabulary. + */ + .term, .subterm { background-color: transparent; border: 0px solid #ccc; padding: 0em; margin-bottom: 0em; } + .subterm { padding-left: 15px; } + .term .title { font-weight: bold; font-size: 2.2em; } + .subterm .title { font-weight: bold; font-size: 2em; } + .clearit { clear: both; } - Index: taxonomy_context.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_context/taxonomy_context.info,v retrieving revision 1.1.2.2.2.6 diff -u -r1.1.2.2.2.6 taxonomy_context.info --- taxonomy_context.info 14 Apr 2008 16:00:26 -0000 1.1.2.2.2.6 +++ taxonomy_context.info 16 Feb 2009 14:44:23 -0000 @@ -1,2 +1,3 @@ +; $Id: $ name = Taxonomy context description = "Adds description and child term information to taxonomy term pages, and generates a context-sensitive menu block for each vocabulary." Index: taxonomy_context.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_context/taxonomy_context.install,v retrieving revision 1.3.4.2 diff -u -r1.3.4.2 taxonomy_context.install --- taxonomy_context.install 12 Apr 2008 20:03:11 -0000 1.3.4.2 +++ taxonomy_context.install 16 Feb 2009 15:17:49 -0000 @@ -1,5 +1,9 @@ 'admin/settings/taxonomy_context', - 'title' => t('Taxonomy Context'), - 'description' => t('Create vocabularies and terms to categorize your content.'), - 'callback' => 'taxonomy_context_admin_page', - 'access' => user_access('administer taxonomy context'), - ); + $items[] = array( + 'path' => 'admin/settings/taxonomy_context', + 'title' => t('Taxonomy Context'), + 'description' => t('Create vocabularies and terms to categorize your content.'), + 'callback' => 'taxonomy_context_admin_page', + 'access' => user_access('administer taxonomy context'), + ); + $items[] = array( 'path' => 'taxonomy/vocabulary', 'title' => t('Categories'), 'callback' => 'taxonomy_context_vocabulary_page', 'access' => user_access('access content'), 'type' => MENU_SUGGESTED_ITEM, - ); - $items[] = array('path' => 'admin/settings/taxonomy_context/vocabularies', - 'title' => t('Vocabularies'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -10, - ); - } else { - if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'taxonomy_context') { - // define path to global settings form - $items[] = array( - 'path' => 'admin/settings/taxonomy_context/global', - 'title' => t('Global Settings'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('taxonomy_context_global_settings_form'), - 'type' => MENU_LOCAL_TASK, - ); - // define path to vocabulary settings form - if (arg(3) == 'vocabulary' && is_numeric(arg(4))) { - $vid = arg(4); - $vocab = taxonomy_get_vocabulary($vid); - $items[] = array( - 'path' => 'admin/settings/taxonomy_context/vocabulary/'.$vid, - 'title' => 'Context for ' .$vocab->name, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('taxonomy_context_vocabulary_settings_form', $vid), - 'access' => user_access('administer taxonomy context'), - 'type' => MENU_CALLBACK, - ); - } - } - } + ); + + $items[] = array('path' => 'admin/settings/taxonomy_context/vocabularies', + 'title' => t('Vocabularies'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -10, + ); + } + else { + if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'taxonomy_context') { + // define path to global settings form + $items[] = array( + 'path' => 'admin/settings/taxonomy_context/global', + 'title' => t('Global Settings'), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('taxonomy_context_global_settings_form'), + 'type' => MENU_LOCAL_TASK, + ); + // define path to vocabulary settings form + if (arg(3) == 'vocabulary' && is_numeric(arg(4))) { + $vid = arg(4); + $vocab = taxonomy_get_vocabulary($vid); + $items[] = array( + 'path' => 'admin/settings/taxonomy_context/vocabulary/'. $vid, + 'title' => 'Context for '. $vocab->name, + 'callback' => 'drupal_get_form', + 'callback arguments' => array('taxonomy_context_vocabulary_settings_form', $vid), + 'access' => user_access('administer taxonomy context'), + 'type' => MENU_CALLBACK, + ); + } + } + } return $items; } @@ -168,27 +168,27 @@ * Implementation of hook_block(). */ function taxonomy_context_block($op = 'list', $delta = 0, $edit = array()) { - switch ($op) { - case 'list': - // get only enabled vocabularies - $blocks = array(); - $vocabularies = taxonomy_context_get_vocabularies(TRUE); - foreach ($vocabularies as $vid => $vocabulary) { - $blocks[$vid]['info'] = t('Context for !vocabulary', array('!vocabulary' => check_plain($vocabulary->name))); - } - return $blocks; - - case 'view': - $context = taxonomy_context_get_context(); - if (taxonomy_context_variable_get('menu_display', $delta, TAXCON_MENU_DISPLAY_DEFAULT) == TAXCON_MENU_DISPLAY_CONTEXTUAL && $delta != $context->vid) { - return; - } - - $vocabulary = taxonomy_context_get_vocabulary($delta); - $block['subject'] = check_plain($vocabulary->name); - $block['content'] = theme('taxonomy_context_menu_tree', $delta) . "\n"; - return $block; - } + switch ($op) { + case 'list': + // get only enabled vocabularies + $blocks = array(); + $vocabularies = taxonomy_context_get_vocabularies(TRUE); + foreach ($vocabularies as $vid => $vocabulary) { + $blocks[$vid]['info'] = t('Context for !vocabulary', array('!vocabulary' => check_plain($vocabulary->name))); + } + return $blocks; + + case 'view': + $context = taxonomy_context_get_context(); + if (taxonomy_context_variable_get('menu_display', $delta, TAXCON_MENU_DISPLAY_DEFAULT) == TAXCON_MENU_DISPLAY_CONTEXTUAL && $delta != $context->vid) { + return; + } + + $vocabulary = taxonomy_context_get_vocabulary($delta); + $block['subject'] = check_plain($vocabulary->name); + $block['content'] = theme('taxonomy_context_menu_tree', $delta) ."\n"; + return $block; + } } /** @@ -198,7 +198,7 @@ $keys = array('term' => 'tid', 'vocabulary' => 'vid'); switch ($op) { case 'update': - db_query("DELETE FROM {taxonomy_context} WHERE type = '{$type}' AND id = '%d'", $object[$keys[$type]]); + db_query("DELETE FROM {taxonomy_context} WHERE type='%s' AND id='%d'", $type, $object[$keys[$type]]); // Fall through. case 'insert': db_query("INSERT INTO {taxonomy_context} (id, type, format) VALUES ('%d', '%s', '%d')", $object[$keys[$type]], $type, $object['format']); @@ -218,19 +218,19 @@ $links = array(); $keys = array('term' => 'tid', 'vocabulary' => 'vid'); if (in_array($type, array('term', 'vocabulary'))) { - if (! $teaser && user_access('administer taxonomy')) { - $links['administer_'. $type] = array( - 'title' => t('edit'), - 'href' => 'admin/content/taxonomy/edit/'. $type .'/'. $object->$keys[$type], - 'attributes' => array('title' => t('Edit this !type.', array('!type' => t($type)))) - ); - } - if ($teaser && $object->teaser != $object->body) { - $links['taxonomy_read_more'] = array( - 'title' => t('Read More'), - 'href' => taxonomy_term_path($object), - ); - } + if (! $teaser && user_access('administer taxonomy')) { + $links['administer_'. $type] = array( + 'title' => t('edit'), + 'href' => 'admin/content/taxonomy/edit/'. $type .'/'. $object->$keys[$type], + 'attributes' => array('title' => t('Edit this !type.', array('!type' => t($type)))) + ); + } + if ($teaser && $object->teaser != $object->body) { + $links['taxonomy_read_more'] = array( + 'title' => t('Read More'), + 'href' => taxonomy_term_path($object), + ); + } } return $links; } @@ -239,34 +239,33 @@ * Implementation of hook_perm(). */ function taxonomy_context_perm() { - return array('administer taxonomy context'); + return array('administer taxonomy context'); } /** - * Implementation of hook_nodeapi() + * Implementation of hook_nodeapi(). */ function taxonomy_context_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { - switch($op) { - case 'view': - case 'prepare': - if ((arg(0) == 'node')) { - // add taxonomy inline - if (taxonomy_context_variable_get('node_breadcrumb_display', $node->type, TAXCON_NODE_BREADCRUMB_DISPLAY_DEFAULT) == TAXCON_NODE_BREADCRUMB_DISPLAY_ENABLED) { - drupal_set_breadcrumb(taxonomy_context_get_breadcrumb(taxonomy_context_get_context())); - } - } - } + switch ($op) { + case 'view': + case 'prepare': + if ((arg(0) == 'node')) { + // add taxonomy inline + if (taxonomy_context_variable_get('node_breadcrumb_display', $node->type, TAXCON_NODE_BREADCRUMB_DISPLAY_DEFAULT) == TAXCON_NODE_BREADCRUMB_DISPLAY_ENABLED) { + drupal_set_breadcrumb(taxonomy_context_get_breadcrumb(taxonomy_context_get_context())); + } + } + } } - /** * Implementation of hook_init(). */ function taxonomy_context_init() { - if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && empty($_GET['from'])) { - // kludge: should probably have a setting here that allows you to prevent using taxcon breadcrumbs - drupal_set_breadcrumb(taxonomy_context_get_breadcrumb(taxonomy_context_get_context())); - } + if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && empty($_GET['from'])) { + // kludge: should probably have a setting here that allows you to prevent using taxcon breadcrumbs + drupal_set_breadcrumb(taxonomy_context_get_breadcrumb(taxonomy_context_get_context())); + } } /** @@ -276,12 +275,12 @@ // If we're on a 2nd or subsequent page, don't show taxonomy info. if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && empty($_GET['from'])) { $context = taxonomy_context_get_context(); - return taxonomy_context_term_page($context->tid); - } + return taxonomy_context_term_page($context->tid); + } switch ($section) { case 'admin/help#taxonomy_context': - $output .= '

'.t('This module can be used to enhance and customize the display of vocabularies, terms, and nodes that.').'

'; + $output .= '

'. t('This module can be used to enhance and customize the display of vocabularies, terms, and nodes that.') .'

'; break; } @@ -289,30 +288,26 @@ } /** - ****************************** - */ - -/** * Function for retrieving vocabularies. */ -function taxonomy_context_get_vocabularies($enabled_only = true) { - static $vocabularies; +function taxonomy_context_get_vocabularies($enabled_only = TRUE) { + static $vocabularies; - if (! isset($vocabularies)) { - // get all vocabularies exists - $vocabularies['all'] = taxonomy_get_vocabularies(); - - foreach (array_keys($vocabularies['all']) AS $vid) { - // determine whether or not another module is using a vocabulary - $vocabularies['all'][$vid]->context_able = ($vocabularies['all'][$vid]->module == 'taxonomy' || ! module_hook($vocabularies['all'][$vid]->module, 'term_path')); - - if ($vocabularies['all'][$vid]->context_able && taxonomy_context_variable_get('vocabulary', $vid, TAXCON_VOCABULARY_DEFAULT)) { - $vocabularies['enabled'] &= $vocabularies['all'][$vid]; - } - } - } + if (! isset($vocabularies)) { + // get all vocabularies exists + $vocabularies['all'] = taxonomy_get_vocabularies(); + + foreach (array_keys($vocabularies['all']) AS $vid) { + // determine whether or not another module is using a vocabulary + $vocabularies['all'][$vid]->context_able = ($vocabularies['all'][$vid]->module == 'taxonomy' || ! module_hook($vocabularies['all'][$vid]->module, 'term_path')); - return ($enabled) ? $vocabularies['enabled'] : $vocabularies['all']; + if ($vocabularies['all'][$vid]->context_able && taxonomy_context_variable_get('vocabulary', $vid, TAXCON_VOCABULARY_DEFAULT)) { + $vocabularies['enabled'] &= $vocabularies['all'][$vid]; + } + } + } + + return ($enabled) ? $vocabularies['enabled'] : $vocabularies['all']; } /** @@ -321,31 +316,31 @@ * static caching in taxonomy_context_get_vocabularies(). */ function taxonomy_context_get_vocabulary($vid) { - $vocabs = taxonomy_context_get_vocabularies($enabled_only); - return $vocabs[$vid]; + $vocabs = taxonomy_context_get_vocabularies($enabled_only); + return $vocabs[$vid]; } /** * Function for retrieving settings in a cascading manner. */ function taxonomy_context_variable_get($varname, $id = NULL, $default) { - if ($id !== NULL) { - // if we have an id check for the vocabulary specific setting - $res = variable_get('taxonomy_context_'.$varname.'_'.$id, NULL); + if ($id !== NULL) { + // if we have an id check for the vocabulary specific setting + $res = variable_get('taxonomy_context_'. $varname .'_'. $id, NULL); - if ($res == TAXCON_SETTING_USE_DEFAULT) return $default; - if ($res == TAXCON_SETTING_USE_GLOBAL) return variable_get($varname, $default); + if ($res == TAXCON_SETTING_USE_DEFAULT) return $default; + if ($res == TAXCON_SETTING_USE_GLOBAL) return variable_get($varname, $default); - return $res; - } + return $res; + } } /** * Return the breadcrumb of taxonomy terms ending with $tid. * Statically caches results to reduce processing in the case of identical calls. */ -function taxonomy_context_get_breadcrumb($context){ - static $breadcrumb; +function taxonomy_context_get_breadcrumb($context) { + static $breadcrumb; if (! isset($breadcrumb)) $breadcrumb = array(); // create unique index based on $context attributes @@ -354,15 +349,17 @@ if (! isset($breadcrumb[$cache_index])) { $breadcrumb[$cache_index][] = l(t('Home'), ''); $vocabulary = taxonomy_context_get_vocabulary($context->vid); - - // check setting to include vocabulary name in breadcrump - if (taxonomy_context_variable_get('breadcrumb_includes_vocabulary', $context->vid, FALSE, FALSE) || $redirect = taxonomy_context_variable_get('vocabulary_breadcrumb', $context->vid, TAXCON_VOCABULARY_BREADCRUMB_DEFAULT)) { - if ($redirect != TAXCON_VOCABULARY_REDIRECT_DEFAULT) { - list($path, $name) = split('\|', $redirect); - $breadcrumb[$cache_index][] = l($name, $path); - } else - $breadcrumb[$cache_index][] = l($vocabulary->name, 'taxonomy/vocabulary/' . $context->vid); - } + + // check setting to include vocabulary name in breadcrump + if (taxonomy_context_variable_get('breadcrumb_includes_vocabulary', $context->vid, FALSE, FALSE) || $redirect = taxonomy_context_variable_get('vocabulary_breadcrumb', $context->vid, TAXCON_VOCABULARY_BREADCRUMB_DEFAULT)) { + if ($redirect != TAXCON_VOCABULARY_REDIRECT_DEFAULT) { + list($path, $name) = split('\|', $redirect); + $breadcrumb[$cache_index][] = l($name, $path); + } + else { + $breadcrumb[$cache_index][] = l($vocabulary->name, 'taxonomy/vocabulary/'. $context->vid); + } + } $parents = taxonomy_get_parents_all($context->tid); if ($parents) { @@ -373,7 +370,7 @@ } } } - } + } return $breadcrumb[$cache_index]; } @@ -381,63 +378,63 @@ * Return context of the requested page. */ function taxonomy_context_get_context() { - static $context; - if (! isset($context)) { - $context = (object) array('tid' => NULL, 'nid' => NULL, "vid" => NULL); - switch (arg(0)) { - case 'taxonomy': - switch (arg(1)) { - // vocab page - case 'vocabulary': - $context->tid = 0; - $context->vid = ((int)arg(2)) ? arg(2) : 1; - break; - // term page - case 'term': - // get the term id from args (if multiple use the first) - list($context->tid) = preg_split('/[+ ,]/', arg(2)); - // get vocab id from term - $term = taxonomy_get_term($context->tid); - $context->vid = $term->vid; - break; - } - break; - // node page - case 'node': -// if (arg(2) == 'edit') { - $context->nid = arg(1); - $terms = taxonomy_node_get_terms($context->nid); - $term = array_pop($terms); - $context->tid = $term->tid; - $context->vid = $term->vid; -// } - break; - } - } - return $context; + static $context; + if (! isset($context)) { + $context = (object) array('tid' => NULL, 'nid' => NULL, "vid" => NULL); + switch (arg(0)) { + case 'taxonomy': + switch (arg(1)) { + // vocab page + case 'vocabulary': + $context->tid = 0; + $context->vid = ((int)arg(2)) ? arg(2) : 1; + break; + // term page + case 'term': + // get the term id from args (if multiple use the first) + list($context->tid) = preg_split('/[+ ,]/', arg(2)); + // get vocab id from term + $term = taxonomy_get_term($context->tid); + $context->vid = $term->vid; + break; + } + break; + // node page + case 'node': +// if (arg(2) == 'edit') { + $context->nid = arg(1); + $terms = taxonomy_node_get_terms($context->nid); + $term = array_pop($terms); + $context->tid = $term->tid; + $context->vid = $term->vid; +// } + break; + } + } + return $context; } /** * Load format data for a vocabulary or term. */ -function taxonomy_context_load($type, &$object, $teaser = false) { - if (! $object->taxonomy_context_loaded) { - $keys = array('term' => 'tid', 'vocabulary' => 'vid'); -// $object->format = db_result(db_query('SELECT format FROM {taxonomy_context_'. $type .'} WHERE '. $keys[$type] .' = %d', $object->$keys[$type])); - $object->format = $object->format ? $object->format : FILTER_FORMAT_DEFAULT; - $object->taxonomy_context_loaded = TRUE; - } +function taxonomy_context_load($type, &$object, $teaser = FALSE) { + if (! $object->taxonomy_context_loaded) { + $keys = array('term' => 'tid', 'vocabulary' => 'vid'); +// $object->format = db_result(db_query('SELECT format FROM {taxonomy_context_'. $type .'} WHERE '. $keys[$type] .' = %d', $object->$keys[$type])); + $object->format = $object->format ? $object->format : FILTER_FORMAT_DEFAULT; + $object->taxonomy_context_loaded = TRUE; + } } /** * Apply filters to a term or vocabulary in preparation for theming. */ function taxonomy_context_prepare($type, &$object, $teaser = FALSE, $description = FALSE) { - taxonomy_context_load($type, $object, $teaser); + taxonomy_context_load($type, $object, $teaser); $object->teaser = ($teaser) ? check_markup(node_teaser($object->description, $object->format), $object->format, FALSE) : NULL; $object->description = ($teaser === FALSE || $description) ? check_markup($object->description, $object->format, FALSE) : NULL; - // Get links. - taxonomy_context_get_links($type, $object, $teaser); + // Get links. + taxonomy_context_get_links($type, $object, $teaser); } /** @@ -451,44 +448,44 @@ * Pages & Forms */ function taxonomy_context_term_page($tid) { - $term_output = ''; - $term = taxonomy_get_term($tid); + $term_output = ''; + $term = taxonomy_get_term($tid); - $subterm_ouput = ''; - $subterm_display = taxonomy_context_variable_get('term_page_subterm_display', $term->vid, TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT); + $subterm_ouput = ''; + $subterm_display = taxonomy_context_variable_get('term_page_subterm_display', $term->vid, TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT); - if ($subterm_display != TAXCON_TERM_PAGE_SUBTERM_DISPLAY_NONE) { - if ($subterms = taxonomy_get_children($term->tid, $term->vid)) { - foreach ($subterms AS $subterm) { - switch ($subterm_display) { - case TAXCON_TERM_PAGE_SUBTERM_DISPLAY_FULL: - taxonomy_context_prepare('term', $subterm, FALSE); - $subterm_output .= theme('taxonomy_context_subterm', $subterm, FALSE); - break; - case TAXCON_TERM_PAGE_SUBTERM_DISPLAY_TEASER: - taxonomy_context_prepare('term', $subterm, TRUE); - $subterm_output .= theme('taxonomy_context_subterm', $subterm, TRUE); - break; - } - } - } - } - - switch (taxonomy_context_variable_get('term_page_term_display', $term->vid, TAXCON_TERM_PAGE_TERM_DISPLAY_DEFAULT)) { - // no additional output for current term - case TAXCON_TERM_PAGE_TERM_DISPLAY_NONE: - return theme('taxonomy_context_term_page', $subterm_output); - case TAXCON_TERM_PAGE_TERM_DISPLAY_TEASER: - taxonomy_context_prepare('term', $term, TRUE, TRUE); - $term_output .= theme('taxonomy_context_term', $term, TRUE, $subterm_output, $subterm_display); - break; - case TAXCON_TERM_PAGE_TERM_DISPLAY_FULL: - taxonomy_context_prepare('term', $term, FALSE); - $term_output .= theme('taxonomy_context_term', $term, FALSE, $subterm_output, $subterm_display); - break; - } + if ($subterm_display != TAXCON_TERM_PAGE_SUBTERM_DISPLAY_NONE) { + if ($subterms = taxonomy_get_children($term->tid, $term->vid)) { + foreach ($subterms AS $subterm) { + switch ($subterm_display) { + case TAXCON_TERM_PAGE_SUBTERM_DISPLAY_FULL: + taxonomy_context_prepare('term', $subterm, FALSE); + $subterm_output .= theme('taxonomy_context_subterm', $subterm, FALSE); + break; + case TAXCON_TERM_PAGE_SUBTERM_DISPLAY_TEASER: + taxonomy_context_prepare('term', $subterm, TRUE); + $subterm_output .= theme('taxonomy_context_subterm', $subterm, TRUE); + break; + } + } + } + } - return theme('taxonomy_context_term_page', $term_output); + switch (taxonomy_context_variable_get('term_page_term_display', $term->vid, TAXCON_TERM_PAGE_TERM_DISPLAY_DEFAULT)) { + // no additional output for current term + case TAXCON_TERM_PAGE_TERM_DISPLAY_NONE: + return theme('taxonomy_context_term_page', $subterm_output); + case TAXCON_TERM_PAGE_TERM_DISPLAY_TEASER: + taxonomy_context_prepare('term', $term, TRUE, TRUE); + $term_output .= theme('taxonomy_context_term', $term, TRUE, $subterm_output, $subterm_display); + break; + case TAXCON_TERM_PAGE_TERM_DISPLAY_FULL: + taxonomy_context_prepare('term', $term, FALSE); + $term_output .= theme('taxonomy_context_term', $term, FALSE, $subterm_output, $subterm_display); + break; + } + + return theme('taxonomy_context_term_page', $term_output); } /** @@ -497,132 +494,132 @@ */ function taxonomy_context_admin_page() { - // get vocabularies for display - $vocabularies = taxonomy_context_get_vocabularies(FALSE); + // get vocabularies for display + $vocabularies = taxonomy_context_get_vocabularies(FALSE); $header = array(t('Vocabulary'), t('Operations')); - $rows = array(); - foreach ($vocabularies AS $vid => $vocab) { - $rows[] = array('data' => array( - 'vocabulary' => $vocab->name, - 'operations' => $vocab->context_able ? l(t('configure'), 'admin/settings/taxonomy_context/vocabulary/'.$vid) - : ''.t('locked').'', - )); - } + $rows = array(); + foreach ($vocabularies AS $vid => $vocab) { + $rows[] = array('data' => array( + 'vocabulary' => $vocab->name, + 'operations' => $vocab->context_able ? l(t('configure'), 'admin/settings/taxonomy_context/vocabulary/'. $vid) + : ''. t('locked') .'', + )); + } - $output .= '

'.t('Vocabuarlies').'

'; + $output .= '

'. t('Vocabuarlies') .'

'; $output .= theme('table', $header, $rows, array('id' => 'taxonomy')); - - return $output; + + return $output; } /** * Form fields which can be used to set global settings and vocabulary specific settings. */ function _taxonomy_context_vocabulary_settings_fields($vid = NULL) { - $fields = array(); - $default_options = $vid ? array(TAXCON_SETTING_USE_DEFAULT => 'Use Default Setting', TAXCON_SETTING_USE_GLOBAL => 'Use Global Setting') : array(); - $suffix = ($vid) ? '_'.$vid : NULL; - $fields['taxonomy_context_term_page_term_display'.$suffix] = array( + $fields = array(); + $default_options = $vid ? array(TAXCON_SETTING_USE_DEFAULT => 'Use Default Setting', TAXCON_SETTING_USE_GLOBAL => 'Use Global Setting') : array(); + $suffix = ($vid) ? '_'. $vid : NULL; + $fields['taxonomy_context_term_page_term_display'. $suffix] = array( '#type' => 'select', '#title' => t('Show term info'), - '#default_value' => variable_get('taxonomy_context_term_page_term_display'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_TERM_PAGE_TERM_DISPLAY_DEFAULT)), + '#default_value' => variable_get('taxonomy_context_term_page_term_display'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_TERM_PAGE_TERM_DISPLAY_DEFAULT)), '#options' => $default_options + array( - TAXCON_TERM_PAGE_TERM_DISPLAY_FULL => t('Full description'), - TAXCON_TERM_PAGE_TERM_DISPLAY_TEASER => t('Description as teaser'), - TAXCON_TERM_PAGE_TERM_DISPLAY_NONE => t('Disabled (no description)'), - ), + TAXCON_TERM_PAGE_TERM_DISPLAY_FULL => t('Full description'), + TAXCON_TERM_PAGE_TERM_DISPLAY_TEASER => t('Description as teaser'), + TAXCON_TERM_PAGE_TERM_DISPLAY_NONE => t('Disabled (no description)'), + ), '#description' => t('Show additional information about current term (from description).'), ); - $fields['taxonomy_context_term_page_subterm_display'.$suffix] = array( + $fields['taxonomy_context_term_page_subterm_display'. $suffix] = array( '#type' => 'select', '#title' => t('Show subterm info'), - '#default_value' => variable_get('taxonomy_context_term_page_subterm_display'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT)), + '#default_value' => variable_get('taxonomy_context_term_page_subterm_display'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT)), '#options' => $default_options + array( - TAXCON_TERM_PAGE_SUBTERM_DISPLAY_TEASER => t('Description as teaser'), - TAXCON_TERM_PAGE_SUBTERM_DISPLAY_FULL => t('Full Descriptions'), - TAXCON_TERM_PAGE_SUBTERM_DISPLAY_NONE => t('Disabled'), - ), + TAXCON_TERM_PAGE_SUBTERM_DISPLAY_TEASER => t('Description as teaser'), + TAXCON_TERM_PAGE_SUBTERM_DISPLAY_FULL => t('Full Descriptions'), + TAXCON_TERM_PAGE_SUBTERM_DISPLAY_NONE => t('Disabled'), + ), '#description' => t('Show listings of subterms (sub-categories) for current term.'), ); - $fields['taxonomy_context_menu_include_nodes'.$suffix] = array( + $fields['taxonomy_context_menu_include_nodes'. $suffix] = array( '#type' => 'select', '#title' => t('Show nodes in block'), - '#default_value' => variable_get('taxonomy_context_menu_include_nodes'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_MENU_INCLUDE_NODES_DEFAULT)), + '#default_value' => variable_get('taxonomy_context_menu_include_nodes'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_MENU_INCLUDE_NODES_DEFAULT)), '#description' => t('What nodes do you wish to display in taxonomy menu blocks?'), '#options' => $default_options + array( - TAXCON_MENU_INCLUDE_NODES_NONE => t('None'), - TAXCON_MENU_INCLUDE_NODES_STICKY => t('Sticky'), - TAXCON_MENU_INCLUDE_NODES_PROMOTED => t('Promoted'), - TAXCON_MENU_INCLUDE_NODES_ALL => t('All'), - ), + TAXCON_MENU_INCLUDE_NODES_NONE => t('None'), + TAXCON_MENU_INCLUDE_NODES_STICKY => t('Sticky'), + TAXCON_MENU_INCLUDE_NODES_PROMOTED => t('Promoted'), + TAXCON_MENU_INCLUDE_NODES_ALL => t('All'), + ), ); - $fields['taxonomy_context_menu_expanded'.$suffix] = array( + $fields['taxonomy_context_menu_expanded'. $suffix] = array( '#type' => 'select', '#title' => t('Show block items'), - '#default_value' => variable_get('taxonomy_context_menu_expanded'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_MENU_EXPANDED_DEFAULT)), + '#default_value' => variable_get('taxonomy_context_menu_expanded'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_MENU_EXPANDED_DEFAULT)), '#options' => $default_options + array(TAXCON_MENU_COLLAPSED => t('Collapsed'), TAXCON_MENU_EXPANDED => t('Expanded')), '#description' => t('Do you want items on the menu expanded or collapsed by default?'), ); - /* - $fields['taxonomy_context_breadcrumb_includes_vocabulary'.$suffix] = array( - '#type' => 'checkbox', - '#title' => t('Include Vocabulary in Breadcrumbs'), - '#return_value' => TAXCON_BREADCRUMB_INCLUDES_VOCABULARY, - '#default_value' => variable_get('taxonomy_context_breadcrumb_includes_vocabulary'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_BREADCRUMB_INCLUDES_VOCABULARY_DEFAULT)), - '#description' => t('When checked, the Vocabulary name will appear as a link in the breadcrumbs'), - ); - */ - $fields['taxonomy_context_vocabulary_breadcrumb'.$suffix] = array( - '#type' => 'textfield', - '#disabled' => (variable_get('taxonomy_context_breadcrumb_includes_vocabulary'.$suffix, TAXCON_BREADCRUMB_INCLUDES_VOCABULARY_DEFAULT) == TAXCON_BREADCRMB_EXCLUDES_VOCABULARY), - '#title' => t('Custom Vocabulary Breadcrumb'), - '#description' => t('You can define a custom breadcrumb (path|title)'), - '#default_value' => variable_get('taxonomy_context_vocabulary_breadcrumb'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_VOCABULARY_REDIRECT_DEFAULT)), - ); - if (module_exists('views')) { - $fields['taxonomy_context_vocabulary_use_custom_view'.$suffix] = array( - '#type' => 'select', - '#title' => t('Display nodes using'), - '#default_value' => variable_get('taxonomy_context_vocabulary_use_custom_view'.$suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_VOCABUARLY_USE_CUSTOM_VIEW_DEFAUL)), - '#description' => t('Only use views that provide a page view'), - '#options' => $default_options + array('' => t('Default')) + _taxonomy_context_views_list(), - ); - } - return $fields; + /* + $fields['taxonomy_context_breadcrumb_includes_vocabulary'. $suffix] = array( + '#type' => 'checkbox', + '#title' => t('Include Vocabulary in Breadcrumbs'), + '#return_value' => TAXCON_BREADCRUMB_INCLUDES_VOCABULARY, + '#default_value' => variable_get('taxonomy_context_breadcrumb_includes_vocabulary'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_BREADCRUMB_INCLUDES_VOCABULARY_DEFAULT)), + '#description' => t('When checked, the Vocabulary name will appear as a link in the breadcrumbs'), + ); + */ + $fields['taxonomy_context_vocabulary_breadcrumb'. $suffix] = array( + '#type' => 'textfield', + '#disabled' => (variable_get('taxonomy_context_breadcrumb_includes_vocabulary'. $suffix, TAXCON_BREADCRUMB_INCLUDES_VOCABULARY_DEFAULT) == TAXCON_BREADCRMB_EXCLUDES_VOCABULARY), + '#title' => t('Custom Vocabulary Breadcrumb'), + '#description' => t('You can define a custom breadcrumb (path|title)'), + '#default_value' => variable_get('taxonomy_context_vocabulary_breadcrumb'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_VOCABULARY_REDIRECT_DEFAULT)), + ); + if (module_exists('views')) { + $fields['taxonomy_context_vocabulary_use_custom_view'. $suffix] = array( + '#type' => 'select', + '#title' => t('Display nodes using'), + '#default_value' => variable_get('taxonomy_context_vocabulary_use_custom_view'. $suffix, ($vid ? TAXCON_SETTING_USE_GLOBAL : TAXCON_VOCABUARLY_USE_CUSTOM_VIEW_DEFAUL)), + '#description' => t('Only use views that provide a page view'), + '#options' => $default_options + array('' => t('Default')) + _taxonomy_context_views_list(), + ); + } + return $fields; } function _taxonomy_context_views_list() { - static $view; - if (! isset($views)) { - $result = db_query("SELECT name, description FROM {view_view}"); - while ($view = db_fetch_object($result)) { - $views[$view->name] = $view->name . ': ' . $view->description; - } - - views_load_cache(); - $default_views = _views_get_default_views(); - $views_status = variable_get('views_defaults', array()); - foreach ($default_views as $view) { - if (!$views[$view->name] && - ($views_status[$view->name] == 'enabled' || (!$views_status[$view->name] && !$view->disabled))) { - $views[$view->name] = check_plain($view->name . ': ' . $view->description); - } - } - } - return $views; + static $view; + if (! isset($views)) { + $result = db_query("SELECT name, description FROM {view_view}"); + while ($view = db_fetch_object($result)) { + $views[$view->name] = $view->name .': '. $view->description; + } + + views_load_cache(); + $default_views = _views_get_default_views(); + $views_status = variable_get('views_defaults', array()); + foreach ($default_views as $view) { + if (!$views[$view->name] && + ($views_status[$view->name] == 'enabled' || (!$views_status[$view->name] && !$view->disabled))) { + $views[$view->name] = check_plain($view->name .': '. $view->description); + } + } + } + return $views; } /** * Global settings form for taxonomy context. */ function taxonomy_context_global_settings_form() { - $form = array(); - $form['settings'] = array( - '#type' => 'fieldset', - '#title' => t('Settings'), - '#collapsable' => true, - ); + $form = array(); + $form['settings'] = array( + '#type' => 'fieldset', + '#title' => t('Settings'), + '#collapsable' => TRUE, + ); - $form['settings']['taxonomy_context_use_style'] = array( + $form['settings']['taxonomy_context_use_style'] = array( '#type' => 'select', '#title' => t('Use style for term and subterm display'), '#default_value' => variable_get('taxonomy_context_use_style', TAXCON_MODULE_STYLES_DEFAULT), @@ -630,12 +627,12 @@ '#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['globals'] = array_merge(array( - '#type' => 'fieldset', - '#title' => t('Global Settings'), - '#description' => t('These are settings that can be overriden either at a vocabulary, or node type level.'), - ), _taxonomy_context_vocabulary_settings_fields(NULL)); - return system_settings_form($form); + $form['globals'] = array_merge(array( + '#type' => 'fieldset', + '#title' => t('Global Settings'), + '#description' => t('These are settings that can be overriden either at a vocabulary, or node type level.'), + ), _taxonomy_context_vocabulary_settings_fields(NULL)); + return system_settings_form($form); } @@ -643,8 +640,8 @@ * Vocabulary settings form for configuring individual categories. */ function taxonomy_context_vocabulary_settings_form($vid) { - $form = _taxonomy_context_vocabulary_settings_fields($vid); - return system_settings_form($form); + $form = _taxonomy_context_vocabulary_settings_fields($vid); + return system_settings_form($form); } /** @@ -656,17 +653,17 @@ function taxonomy_context_menu_tree($vid, $tid = NULL) { $terms = $tid ? taxonomy_get_children($tid, $vid) : taxonomy_get_tree($vid, 0, -1, 1); if ($terms) { - foreach ($terms as $term) { + foreach ($terms as $term) { $expand = (taxonomy_context_term_in_active_trail($term->tid) || taxonomy_context_variable_get('menu_expanded', $vid, TAXCON_MENU_EXPANDED_DEFAULT) == TAXCON_MENU_EXPANDED); - $children = ($expand) ? theme('taxonomy_context_menu_tree', $vid, $term->tid) : ''; - $tree .= theme('taxonomy_context_menu_item', $term->tid, 'term', $children, (!$children)); + $children = ($expand) ? theme('taxonomy_context_menu_tree', $vid, $term->tid) : ''; + $tree .= theme('taxonomy_context_menu_item', $term->tid, 'term', $children, (!$children)); } } - if ($nodes = taxonomy_context_menu_term_nodes($vid, $tid)) { - foreach ($nodes AS $node) { - $tree .= theme('taxonomy_context_menu_item', $node->nid, 'node'); - } - } + if ($nodes = taxonomy_context_menu_term_nodes($vid, $tid)) { + foreach ($nodes AS $node) { + $tree .= theme('taxonomy_context_menu_item', $node->nid, 'node'); + } + } return $tree; } @@ -674,128 +671,128 @@ * Determine whether or not a term is in the active trail to the current node or term. */ function taxonomy_context_term_in_active_trail($tid) { - static $active_trail; - if (! isset($active_trail)) { - $active_trail = array(); - $context = taxonomy_context_get_context(); - $parents = array_reverse(taxonomy_get_parents_all($context->tid)); - foreach ($parents as $term) { - $active_trail[] = $term->tid; - } - } + static $active_trail; + if (! isset($active_trail)) { + $active_trail = array(); + $context = taxonomy_context_get_context(); + $parents = array_reverse(taxonomy_get_parents_all($context->tid)); + foreach ($parents as $term) { + $active_trail[] = $term->tid; + } + } - return in_array($tid, $active_trail); + return in_array($tid, $active_trail); } /** * Return an array of nodes below the given term to display in the menu. */ function taxonomy_context_menu_term_nodes($vid, $tid) { - $where = array(); - switch (taxonomy_context_variable_get('menu_include_nodes', $vid, TAXCON_MENU_INCLUDE_NODES_DEFAULT)) { - case TAXCON_MENU_INCLUDE_NODES_NONE: - return FALSE; - case TAXCON_MENU_INCLUDE_NODES_STICKY: - $where[] = "AND n.sticky = '1'"; - break; - case TAXCON_MENU_INCLUDE_NODES_PROMOTED: - $where[] = "AND n.promote = '1'"; - break; - case TAXCON_MENU_INCLUDE_NODES_ALL: - break; - } - - array_unshift($where, 'WHERE tn.tid = %d', "AND n.status = '1'"); - $sql = 'SELECT DISTINCT(n.nid), n.title, r.teaser ' . - 'FROM {node} n ' . - 'LEFT JOIN {term_node} tn ON n.nid = tn.nid ' . - 'LEFT JOIN {users} u ON n.uid = u.uid ' . - 'INNER JOIN {node_revisions} r ON n.vid = r.vid ' . - implode(' ', $where) . - ' ORDER BY sticky DESC, n.created DESC'; - - - $nodes = array(); - $result = db_query(db_rewrite_sql($sql), $tid); - while ($node = db_fetch_object($result)) { - //if (node_access('view', $node)) - $nodes[] = $node; - } - return count($nodes) ? $nodes : false; + $where = array(); + switch (taxonomy_context_variable_get('menu_include_nodes', $vid, TAXCON_MENU_INCLUDE_NODES_DEFAULT)) { + case TAXCON_MENU_INCLUDE_NODES_NONE: + return FALSE; + case TAXCON_MENU_INCLUDE_NODES_STICKY: + $where[] = "AND n.sticky = '1'"; + break; + case TAXCON_MENU_INCLUDE_NODES_PROMOTED: + $where[] = "AND n.promote = '1'"; + break; + case TAXCON_MENU_INCLUDE_NODES_ALL: + break; + } + + array_unshift($where, 'WHERE tn.tid = %d', "AND n.status = '1'"); + $sql = 'SELECT DISTINCT(n.nid), n.title, r.teaser '. + 'FROM {node} n '. + 'LEFT JOIN {term_node} tn ON n.nid = tn.nid '. + 'LEFT JOIN {users} u ON n.uid = u.uid '. + 'INNER JOIN {node_revisions} r ON n.vid = r.vid '. + implode(' ', $where) . + ' ORDER BY sticky DESC, n.created DESC'; + + + $nodes = array(); + $result = db_query(db_rewrite_sql($sql), $tid); + while ($node = db_fetch_object($result)) { + //if (node_access('view', $node)) + $nodes[] = $node; + } + return count($nodes) ? $nodes : FALSE; } /** * Create a link (themed by default) to the given term or node. */ -function taxonomy_context_menu_item_link($id, $type = 'term', $theme = true) { - switch ($type) { - case 'node': - $node = node_load($id); - $item = array('title' => $node->title, 'path' => 'node/'.$node->nid, 'description' => check_markup($node->teaser, $node->format)); - break; - case 'term': - $term = taxonomy_get_term($id); - $item = array('title' => $term->name, 'path' => taxonomy_term_path($term), 'description' => $term->description ? strip_tags(node_teaser($term->description)) : t('View this section')); - break; - } - - if ($theme) return theme('menu_item_link', $item, $item); - else return array( - 'title' => $item['title'], - 'href' => $item['path'], - 'attributes' => ! empty($item['description']) ? array('title' => $item['description']) : array(), - ); +function taxonomy_context_menu_item_link($id, $type = 'term', $theme = TRUE) { + switch ($type) { + case 'node': + $node = node_load($id); + $item = array('title' => $node->title, 'path' => 'node/'. $node->nid, 'description' => check_markup($node->teaser, $node->format)); + break; + case 'term': + $term = taxonomy_get_term($id); + $item = array('title' => $term->name, 'path' => taxonomy_term_path($term), 'description' => $term->description ? strip_tags(node_teaser($term->description)) : t('View this section')); + break; + } + + if ($theme) return theme('menu_item_link', $item, $item); + else return array( + 'title' => $item['title'], + 'href' => $item['path'], + 'attributes' => ! empty($item['description']) ? array('title' => $item['description']) : array(), + ); } -function theme_taxonomy_context_term($term, $teaser = false, $subterms = '', $subterm_display = TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT) { +function theme_taxonomy_context_term($term, $teaser = FALSE, $subterms = '', $subterm_display = TAXCON_TERM_PAGE_SUBTERM_DISPLAY_DEFAULT) { $output = ''; $output .= "
\n"; - if ($teaser && $term->teaser == $term->description) $teaser = false; + if ($teaser && $term->teaser == $term->description) $teaser = FALSE; if ($teaser) { - // needs testing - $output .= '
'.$term->teaser; - $output .= ''.t('Read More').''; - $output .= "
"; + // needs testing + $output .= '
'. $term->teaser; + $output .= ''. t('Read More') .''; + $output .= "
"; } - $output .= '\n"; + $output .= '\n"; if ($term->links) { - $output .= ' \n"; + $output .= ' \n"; } $output .= "
\n"; - $output .= $subterms ? '
'.$subterms.'
' : ''; + $output .= $subterms ? '
'. $subterms .'
' : ''; return $output; } -function theme_taxonomy_context_subterm($subterm, $teaser = false) { +function theme_taxonomy_context_subterm($subterm, $teaser = FALSE) { $output .= "
\n"; - $output .= '

' . l($subterm->name, taxonomy_term_path($subterm)) . "

\n"; - $output .= ($teaser) ? '
'.$subterm->teaser.'
' : '
'.$subterm->description.'
'; + $output .= '

'. l($subterm->name, taxonomy_term_path($subterm)) ."

\n"; + $output .= ($teaser) ? '
'. $subterm->teaser .'
' : '
'. $subterm->description .'
'; if ($subterm->links) { - $output .= ' \n"; + $output .= ' \n"; } - $output .= "
"; - return $output; + $output .= ""; + return $output; } /** * Theme Functions */ function theme_taxonomy_context_term_page($output) { - return '
'.$output.'
'; + return '
'. $output .'
'; } /** * Return a themed taxonomy menu tree */ function theme_taxonomy_context_menu_tree($vid, $tid = NULL) { - if ($tree = taxonomy_context_menu_tree($vid, $tid)) - return ''; + if ($tree = taxonomy_context_menu_tree($vid, $tid)) + return ''; } function theme_taxonomy_context_menu_item($id, $type = 'term', $children = '', $leaf = TRUE) { - return '
  • '.taxonomy_context_menu_item_link($id, $type).$children.'
  • '; + return '
  • '. taxonomy_context_menu_item_link($id, $type) . $children .'
  • '; } /** @@ -805,92 +802,92 @@ function taxonomy_context_views_post_view(&$view) { if (arg(0) == 'taxonomy' && empty($_GET['from']) && arg(1) == 'term') { $context = taxonomy_context_get_context(); - drupal_set_breadcrumb(taxonomy_context_get_breadcrumb($context)); + drupal_set_breadcrumb(taxonomy_context_get_breadcrumb($context)); } } function taxonomy_context_view_controls(&$view) { - // invoke hook here :) (possible intercepting filter) - if (is_numeric(arg(2))) { - $term = taxonomy_get_term(arg(2)); - - $replace = taxonomy_context_variable_get('vocabulary_use_custom_view', $term->vid, TAXCON_VOCABULARY_USE_CUSTOM_VIEW_DEFAULT); - - if ($view->name == $replace) $replace = false; - - if ($replace) { - $view = views_get_view($replace); - if ($view->view_args_php) { - $result = eval($view->view_args_php); - return $result; - } - } - } + // invoke hook here :) (possible intercepting filter) + if (is_numeric(arg(2))) { + $term = taxonomy_get_term(arg(2)); + + $replace = taxonomy_context_variable_get('vocabulary_use_custom_view', $term->vid, TAXCON_VOCABULARY_USE_CUSTOM_VIEW_DEFAULT); + + if ($view->name == $replace) $replace = FALSE; + + if ($replace) { + $view = views_get_view($replace); + if ($view->view_args_php) { + $result = eval($view->view_args_php); + return $result; + } + } + } } function taxonomy_context_views_default_views() { - $views = taxonomy_views_default_views(); - $view = array_pop($views); + $views = taxonomy_views_default_views(); + $view = array_pop($views); $view->name = 'taxonomy_context_term'; - $view->no_cache = 'TRUE'; + $view->no_cache = 'TRUE'; $view->description = t('Taxonomy Context Term Page View.'); $view->view_args_php = 'return taxonomy_context_view_controls($view);'; return array($view->name => $view); } function taxonomy_context_views_style_plugins() { - return array(); + return array(); } /** * Implementation of hook_form_alter(). */ function taxonomy_context_form_alter($form_id, &$form) { - switch ($form_id) { - case 'node_type_form': - if (isset($form['identity']['type'])) { - $options = array(t('Disabled'), t('Enabled')); - $form['taxonomy_context'] = array('#type' => 'fieldset', '#title' => t('Taxonomy context'), '#weight' => 0); - $form['taxonomy_context']['taxonomy_context_inline'] = array( - '#type' => 'radios', - '#title' => t('Display taxonomy inline'), - '#default_value' => variable_get('taxonomy_context_inline_'. $form['#node_type']->type, 0), - '#options' => $options, - '#description' => t('Display taxonomy information in node body.'), - ); - $form['taxonomy_context']['taxonomy_context_breadcrumb'] = array( - '#type' => 'radios', - '#title' => t('Show taxonomy breadcrumb'), - '#default_value' => variable_get('taxonomy_context_breadcrumb_'. $form['#node_type']->type, 0), - '#options' => $options, - '#description' => t('Display a breadcrumb with full taxonomy context.'), - ); - } - break; - /* - case 'taxonomy_form_term': - case 'taxonomy_form_vocabulary': - $type = substr($form_id, 14, strlen($form_id)); - $keys = array('term' => 'tid', 'vocabulary' => 'vid'); - if ($form[$keys[$type]]) { - $object = new StdClass(); - $object->$keys[$type] = $form[$keys[$type]]['#value']; - taxonomy_context_load($type, $object); - } - $form['description'] = array('description' => $form['description']); - $form['description']['format'] = filter_form($object->format); - - $form['taxonomy_context'] = array('#type' => 'fieldset', '#title' => t('Taxonomy context'), '#weight' => 0); - $form['taxonomy_context']['taxonomy_context_term_use_custom_view'] = array( - '#type' => 'select', - '#title' => t('Display nodes using'), - '#default_value' => variable_get('taxonomy_context_vocabulary_use_custom_view'.$suffix, TAXCON_SETTING_USE_GLOBAL), - '#description' => t('Only use views that provide a page view'), - '#options' => array(TAXCON_SETTING_USE_DEFAULT => 'Use Default Setting', TAXCON_SETTING_USE_GLOBAL => 'Use Global Setting') + _taxonomy_context_views_list(), - ); - break; - */ - } + switch ($form_id) { + case 'node_type_form': + if (isset($form['identity']['type'])) { + $options = array(t('Disabled'), t('Enabled')); + $form['taxonomy_context'] = array('#type' => 'fieldset', '#title' => t('Taxonomy context'), '#weight' => 0); + $form['taxonomy_context']['taxonomy_context_inline'] = array( + '#type' => 'radios', + '#title' => t('Display taxonomy inline'), + '#default_value' => variable_get('taxonomy_context_inline_'. $form['#node_type']->type, 0), + '#options' => $options, + '#description' => t('Display taxonomy information in node body.'), + ); + $form['taxonomy_context']['taxonomy_context_breadcrumb'] = array( + '#type' => 'radios', + '#title' => t('Show taxonomy breadcrumb'), + '#default_value' => variable_get('taxonomy_context_breadcrumb_'. $form['#node_type']->type, 0), + '#options' => $options, + '#description' => t('Display a breadcrumb with full taxonomy context.'), + ); + } + break; + /* + case 'taxonomy_form_term': + case 'taxonomy_form_vocabulary': + $type = substr($form_id, 14, strlen($form_id)); + $keys = array('term' => 'tid', 'vocabulary' => 'vid'); + if ($form[$keys[$type]]) { + $object = new StdClass(); + $object->$keys[$type] = $form[$keys[$type]]['#value']; + taxonomy_context_load($type, $object); + } + $form['description'] = array('description' => $form['description']); + $form['description']['format'] = filter_form($object->format); + + $form['taxonomy_context'] = array('#type' => 'fieldset', '#title' => t('Taxonomy context'), '#weight' => 0); + $form['taxonomy_context']['taxonomy_context_term_use_custom_view'] = array( + '#type' => 'select', + '#title' => t('Display nodes using'), + '#default_value' => variable_get('taxonomy_context_vocabulary_use_custom_view'. $suffix, TAXCON_SETTING_USE_GLOBAL), + '#description' => t('Only use views that provide a page view'), + '#options' => array(TAXCON_SETTING_USE_DEFAULT => 'Use Default Setting', TAXCON_SETTING_USE_GLOBAL => 'Use Global Setting') + _taxonomy_context_views_list(), + ); + break; + */ + } } /** @@ -924,7 +921,7 @@ $vocabulary->terms = taxonomy_get_tree($vocabulary->vid, 0, -1, 1); } if (count($vocabulary->terms)) { - foreach(array_keys($vocabulary->terms) as $key){ + foreach (array_keys($vocabulary->terms) as $key) { $vocabulary->terms[$key]->description = node_teaser($vocabulary->terms[$key]->description); // Load the term to ensure it gets a format assigned. taxonomy_context_load('term', $vocabulary->terms[$key]); @@ -1034,19 +1031,19 @@ function theme_taxonomy_context_vocabulary($vocabulary) { $output .= "
    \n"; $output .= "
    \n"; - $output .= '
    ' . $vocabulary->description . "
    \n"; + $output .= '
    '. $vocabulary->description ."
    \n"; if ($vocabulary->links) { - $output .= ' \n"; + $output .= ' \n"; } if ($vocabulary->terms && is_array($vocabulary->terms)) { - foreach($vocabulary->terms as $term) { + foreach ($vocabulary->terms as $term) { $term->subterm = TRUE; $output .= theme('taxonomy_context_term', $term); } } $output .= "
    \n"; $output .= "
    \n"; - + return $output; } @@ -1054,10 +1051,10 @@ * Theme a list of vocabulary and term links. */ function theme_taxonomy_context_vocabulary_list($vocabulary) { - $output = '

    ' . l($vocabulary->name, "taxonomy/vocabulary/$vocabulary->vid") . "

    \n"; + $output = '

    '. l($vocabulary->name, "taxonomy/vocabulary/$vocabulary->vid") ."

    \n"; $output .= "\n"; return $output;