diff options
Diffstat (limited to 'modules/taxonomy')
-rw-r--r-- | modules/taxonomy/taxonomy-term.tpl.php | 1 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.admin.inc | 35 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.api.php | 1 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.css | 1 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.info | 1 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.install | 9 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.js | 1 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 28 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.pages.inc | 15 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 17 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.tokens.inc | 1 |
11 files changed, 67 insertions, 43 deletions
diff --git a/modules/taxonomy/taxonomy-term.tpl.php b/modules/taxonomy/taxonomy-term.tpl.php index f48452c29..b515a9be1 100644 --- a/modules/taxonomy/taxonomy-term.tpl.php +++ b/modules/taxonomy/taxonomy-term.tpl.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc index 63729fbb1..d83f5d367 100644 --- a/modules/taxonomy/taxonomy.admin.inc +++ b/modules/taxonomy/taxonomy.admin.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -100,10 +99,11 @@ function theme_taxonomy_overview_vocabularies($variables) { } /** - * Display form for adding and editing vocabularies. + * Form builder for the vocabulary editing form. * * @ingroup forms * @see taxonomy_form_vocabulary_submit() + * @see taxonomy_form_vocabulary_validate() */ function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) { // During initial form build, add the entity to the form state for use @@ -147,7 +147,7 @@ function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) { $form['machine_name'] = array( '#type' => 'machine_name', '#default_value' => $vocabulary->machine_name, - '#maxlength' => 21, + '#maxlength' => 255, '#machine_name' => array( 'exists' => 'taxonomy_vocabulary_machine_name_load', ), @@ -175,11 +175,38 @@ function taxonomy_form_vocabulary($form, &$form_state, $edit = array()) { $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->vid); $form['module'] = array('#type' => 'value', '#value' => $vocabulary->module); } + $form['#validate'][] = 'taxonomy_form_vocabulary_validate'; + return $form; } /** - * Accept the form submission for a vocabulary and save the results. + * Form validation handler for taxonomy_form_vocabulary(). + * + * Makes sure that the machine name of the vocabulary is not in the + * disallowed list (names that conflict with menu items, such as 'list' + * and 'add'). + * + * @see taxonomy_form_vocabulary() + * @see taxonomy_form_vocabulary_submit() + */ +function taxonomy_form_vocabulary_validate($form, &$form_state) { + // During the deletion there is no 'machine_name' key + if (isset($form_state['values']['machine_name'])) { + // Do not allow machine names to conflict with taxonomy path arguments. + $machine_name = $form_state['values']['machine_name']; + $disallowed = array('add', 'list'); + if (in_array($machine_name, $disallowed)) { + form_set_error('machine_name', t('The machine-readable name cannot be "add" or "list".')); + } + } +} + +/** + * Form submission handler for taxonomy_form_vocabulary(). + * + * @see taxonomy_form_vocabulary() + * @see taxonomy_form_vocabulary_validate() */ function taxonomy_form_vocabulary_submit($form, &$form_state) { if ($form_state['clicked_button']['#value'] == t('Delete')) { diff --git a/modules/taxonomy/taxonomy.api.php b/modules/taxonomy/taxonomy.api.php index 1527e487c..cb778c9a7 100644 --- a/modules/taxonomy/taxonomy.api.php +++ b/modules/taxonomy/taxonomy.api.php @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file diff --git a/modules/taxonomy/taxonomy.css b/modules/taxonomy/taxonomy.css index 5fdd2b0eb..36cd641be 100644 --- a/modules/taxonomy/taxonomy.css +++ b/modules/taxonomy/taxonomy.css @@ -1,4 +1,3 @@ -/* $Id$ */ tr.taxonomy-term-preview { background-color: #EEE; diff --git a/modules/taxonomy/taxonomy.info b/modules/taxonomy/taxonomy.info index 88e51e34b..44d4ebcd1 100644 --- a/modules/taxonomy/taxonomy.info +++ b/modules/taxonomy/taxonomy.info @@ -1,4 +1,3 @@ -; $Id$ name = Taxonomy description = Enables the categorization of content. package = Core diff --git a/modules/taxonomy/taxonomy.install b/modules/taxonomy/taxonomy.install index 73c115aa2..f28ffedf4 100644 --- a/modules/taxonomy/taxonomy.install +++ b/modules/taxonomy/taxonomy.install @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -567,8 +566,12 @@ function taxonomy_update_7005(&$sandbox) { // of term references stored so far for the current revision, which // provides the delta value for each term reference data insert. The // deltas are reset for each new revision. - - $field_info = _update_7000_field_read_fields(); + + $conditions = array( + 'type' => 'taxonomy_term_reference', + 'deleted' => 0, + ); + $field_info = _update_7000_field_read_fields($conditions, 'field_name'); // This is a multi-pass update. On the first call we need to initialize some // variables. diff --git a/modules/taxonomy/taxonomy.js b/modules/taxonomy/taxonomy.js index 6a304f6d1..cc9cdf7a6 100644 --- a/modules/taxonomy/taxonomy.js +++ b/modules/taxonomy/taxonomy.js @@ -1,4 +1,3 @@ -// $Id$ (function ($) { /** diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 9a1228a37..50d2fd608 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -683,8 +682,8 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) { $langcode = $GLOBALS['language_content']->language; } - field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode); - entity_prepare_view('taxonomy_term', array($term->tid => $term)); + field_attach_prepare_view('taxonomy_term', array($term->tid => $term), $view_mode, $langcode); + entity_prepare_view('taxonomy_term', array($term->tid => $term), $langcode); $build = array( '#theme' => 'taxonomy_term', @@ -695,12 +694,15 @@ function taxonomy_term_view($term, $view_mode = 'full', $langcode = NULL) { $build += field_attach_view('taxonomy_term', $term, $view_mode, $langcode); - $build['description'] = array( - '#markup' => check_markup($term->description, $term->format, '', TRUE), - '#weight' => 0, - '#prefix' => '<div class="taxonomy-term-description">', - '#suffix' => '</div>', - ); + // Add term description if the term has one. + if (!empty($term->description)) { + $build['description'] = array( + '#markup' => check_markup($term->description, $term->format, '', TRUE), + '#weight' => 0, + '#prefix' => '<div class="taxonomy-term-description">', + '#suffix' => '</div>', + ); + } $build['#attached']['css'][] = drupal_get_path('module', 'taxonomy') . '/taxonomy.css'; @@ -728,6 +730,7 @@ function template_preprocess_taxonomy_term(&$variables) { $variables = array_merge((array) $term, $variables); // Helpful $content variable for templates. + $variables['content'] = array(); foreach (element_children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; } @@ -747,7 +750,7 @@ function template_preprocess_taxonomy_term(&$variables) { } /** - * Returns whether the current page is the page of the passed in term. + * Returns whether the current page is the page of the passed-in term. * * @param $term * A term object. @@ -1313,7 +1316,7 @@ function taxonomy_field_validate($entity_type, $entity, $field, $instance, $lang if (!$validate) { $errors[$field['field_name']][$langcode][$delta][] = array( 'error' => 'taxonomy_term_reference_illegal_value', - 'message' => t('%name: illegal value.', array('%name' => t($instance['label']))), + 'message' => t('%name: illegal value.', array('%name' => $instance['label'])), ); } } @@ -1467,11 +1470,12 @@ function taxonomy_field_formatter_prepare_view($entity_type, $entities, $field, * * @param $term * A term object. + * * @return * The term name to be used as the page title. */ function taxonomy_term_title($term) { - return check_plain($term->name); + return $term->name; } /** diff --git a/modules/taxonomy/taxonomy.pages.inc b/modules/taxonomy/taxonomy.pages.inc index baa9776df..3aed29011 100644 --- a/modules/taxonomy/taxonomy.pages.inc +++ b/modules/taxonomy/taxonomy.pages.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file @@ -32,14 +31,12 @@ function taxonomy_term_page($term) { drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name); $build = array(); - // Add term heading if the term has a description - if (!empty($term->description)) { - $build['term_heading'] = array( - '#prefix' => '<div class="term-listing-heading">', - '#suffix' => '</div>', - 'term' => taxonomy_term_view($term, 'full'), - ); - } + + $build['term_heading'] = array( + '#prefix' => '<div class="term-listing-heading">', + '#suffix' => '</div>', + 'term' => taxonomy_term_view($term, 'full'), + ); if ($nids = taxonomy_select_nodes($term->tid, TRUE, variable_get('default_nodes_main', 10))) { $nodes = node_load_multiple($nids); diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 0664c523a..1fd47f5ea 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -1,9 +1,8 @@ <?php -// $Id$ /** * @file - * Tests for Taxonomy module. + * Tests for taxonomy.module. */ /** @@ -649,12 +648,12 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertText($edit['description[value]'], t('The randomly generated term description is present.')); // Did this page request display a 'term-listing-heading'? - $this->assertPattern('|class="term-listing-heading"|', 'Term page displayed the term description element.'); + $this->assertPattern('|class="taxonomy-term-description"|', 'Term page displayed the term description element.'); // Check that it does NOT show a description when description is blank. $term->description = ''; taxonomy_term_save($term); $this->drupalGet('taxonomy/term/' . $term->tid); - $this->assertNoPattern('|class="term-listing-heading"|', 'Term page did not display the term description when description was blank.'); + $this->assertNoPattern('|class="taxonomy-term-description"|', 'Term page did not display the term description when description was blank.'); // Check that the term feed page is working. $this->drupalGet('taxonomy/term/' . $term->tid . '/feed'); @@ -1108,7 +1107,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term1), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test sanitized tokens for term2. @@ -1128,7 +1127,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term2), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1139,7 +1138,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('term' => $term2), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized taxonomy term token %token replaced.', array('%token' => $input))); } // Generate and test sanitized tokens. @@ -1155,7 +1154,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language)); - $this->assertFalse(strcmp($output, $expected), t('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Sanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. @@ -1164,7 +1163,7 @@ class TaxonomyTokenReplaceTestCase extends TaxonomyWebTestCase { foreach ($tests as $input => $expected) { $output = token_replace($input, array('vocabulary' => $this->vocabulary), array('language' => $language, 'sanitize' => FALSE)); - $this->assertFalse(strcmp($output, $expected), t('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); + $this->assertEqual($output, $expected, t('Unsanitized taxonomy vocabulary token %token replaced.', array('%token' => $input))); } } } diff --git a/modules/taxonomy/taxonomy.tokens.inc b/modules/taxonomy/taxonomy.tokens.inc index 225d3e5a2..f8ae4576d 100644 --- a/modules/taxonomy/taxonomy.tokens.inc +++ b/modules/taxonomy/taxonomy.tokens.inc @@ -1,5 +1,4 @@ <?php -// $Id$ /** * @file |