Index: taxonomy_title.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_title/taxonomy_title.info,v retrieving revision 1.4 diff -u -p -r1.4 taxonomy_title.info --- taxonomy_title.info 25 Dec 2009 21:15:20 -0000 1.4 +++ taxonomy_title.info 25 Jul 2010 20:31:41 -0000 @@ -2,4 +2,6 @@ name = Taxonomy title description = Enables control over the taxonomy page titles. dependencies[] = taxonomy -core = 6.x \ No newline at end of file +core = 7.x +files[] = taxonomy_title.install +files[] = taxonomy_title.module Index: taxonomy_title.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_title/taxonomy_title.install,v retrieving revision 1.3 diff -u -p -r1.3 taxonomy_title.install --- taxonomy_title.install 18 Dec 2009 22:15:58 -0000 1.3 +++ taxonomy_title.install 25 Jul 2010 20:31:41 -0000 @@ -1,24 +1,13 @@ - '255', 'default' => '', 'not null' => TRUE, - ), + ), ), 'primary key' => array('tid'), ); - + return $schema; -} \ No newline at end of file +} Index: taxonomy_title.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_title/taxonomy_title.module,v retrieving revision 1.11 diff -u -p -r1.11 taxonomy_title.module --- taxonomy_title.module 1 Jul 2010 15:37:55 -0000 1.11 +++ taxonomy_title.module 25 Jul 2010 20:31:41 -0000 @@ -2,11 +2,11 @@ // $Id: taxonomy_title.module,v 1.11 2010/07/01 15:37:55 jenlampton Exp $ /** - * Implementation of hook_help(). + * Implements hook_help(). */ function taxonomy_title_help($path, $arg) { switch ($path) { - case 'admin/content/taxonomy': + case 'admin/structure/taxonomy': return '

' . t('Set the page title on your Taxonomy Term pages.') . '

'; case 'admin/help#quiz': return '

' . t('Set the page title on your Taxonomy Term pages.') . '

'; @@ -14,7 +14,7 @@ function taxonomy_title_help($path, $arg } /** - * Implementation of hook_form_FORM_ID_alter(). + * Implements hook_form_FORM_ID_alter(). */ function taxonomy_title_form_taxonomy_form_term_alter(&$form, &$form_state) { if (!(isset($_POST['op']) && $_POST['op'] == t('Delete')) || isset($_POST['confirm'])) { @@ -30,29 +30,29 @@ function taxonomy_title_form_taxonomy_fo } /** - * Implementation of hook_taxonomy(). + * Implements hook_taxonomy_term_delete(). */ -function taxonomy_title_taxonomy($op, $type, $array = NULL) { - if ($type == 'term') { - switch($op) { - case 'delete': - _taxonomy_title_delete_title($array['tid']); - break; - - case 'update': - _taxonomy_title_delete_title($array['tid']); - _taxonomy_title_insert_title($array['tid'], $array['taxonomy_title']); - break; - - case 'insert': - _taxonomy_title_insert_title($array['tid'], $array['taxonomy_title']); - break; - } - } +function taxonomy_title_taxonomy_term_delete($op, $type, $array = NULL) { + _taxonomy_title_delete_title($term->tid); } /** - * Implementation of hook_preprocess_page(). + * Implements hook_taxonomy_term_update(). + */ +function taxonomy_title_taxonomy_term_update() { + _taxonomy_title_delete_title($term->tid); + _taxonomy_title_insert_title($term->tid, $term->taxonomy_title); +} + +/** + * Implements hook_taxonomy_term_insert(). + */ +function taxonomy_title_taxonomy_term_insert($term) { + _taxonomy_title_insert_title($term->tid, $term->taxonomy_title); +} + +/** + * Implements hook_preprocess_page(). * * Overrides variables sent to template_preprocess. */ @@ -60,17 +60,17 @@ function taxonomy_title_preprocess_page( if (arg(0) == 'taxonomy' && arg(1) == 'term' && is_numeric(arg(2)) && arg(2) > 0) { $title = _taxonomy_title_get_title(arg(2)); } - + // Add support for Ubercart catalog too. if (module_exists('uc_catalog') && arg(0) == 'catalog') { - $tids = explode(' ', arg(1)); - if (is_numeric($tids[0]) && $tids[0] > 0) { - $tid = $tids[0]; - $title = _taxonomy_title_get_title($tid); - } - } - - if (!empty($title)){ + $tids = explode(' ', arg(1)); + if (is_numeric($tids[0]) && $tids[0] > 0) { + $tid = $tids[0]; + $title = _taxonomy_title_get_title($tid); + } + } + + if (!empty($title)) { drupal_set_title($title); if ($new_title = drupal_get_title()) { @@ -78,7 +78,7 @@ function taxonomy_title_preprocess_page( $variables['title'] = $new_title; // Sets the meta title. - if (!module_exists('page_title')){ + if (!module_exists('page_title')) { $head_title = array(strip_tags($new_title), variable_get('site_name', 'Drupal')); $variables['head_title'] = implode(' | ', $head_title); } @@ -87,8 +87,8 @@ function taxonomy_title_preprocess_page( } /** -* Implementation of hook_token_list(). -*/ + * Implements hook_token_list(). + */ function taxonomy_title_token_list($type = 'all') { if ($type == 'taxonomy' || $type == 'all') { $tokens['taxonomy']['term-title'] = t("The term's title, defaults to term name (same as [term])."); @@ -97,15 +97,15 @@ function taxonomy_title_token_list($type } /** -* Implementation of hook_token_values(). -*/ + * Implements hook_token_values(). + */ function taxonomy_title_token_values($type, $object = NULL, $options = array()) { $values = array(); if ($type == 'taxonomy') { - $category = $object; - // Use taxonomy title if it exists, else the category name. - $token = _taxonomy_title_get_title($category->tid); - $values['term-title'] = ($token) ? $token : $category->name; + $category = $object; + // Use taxonomy title if it exists, else the category name. + $token = _taxonomy_title_get_title($category->tid); + $values['term-title'] = ($token) ? $token : $category->name; } return $values; } @@ -118,9 +118,14 @@ function taxonomy_title_token_values($ty * @param $title * The taxonomy term title to use for this term. */ -function _taxonomy_title_insert_title($tid, $title){ +function _taxonomy_title_insert_title($tid, $title) { if (!empty($title)) { - db_query("INSERT INTO {taxonomy_title} (tid, title) VALUES (%d, '%s')", $tid, $title); + $id = db_insert('taxonomy_title') + ->fields(array( + 'tid' => $tid, + 'title' => $title, + )) + ->execute(); } } @@ -130,8 +135,10 @@ function _taxonomy_title_insert_title($t * @param $tid * The taxonomy term id of the term to delete. */ -function _taxonomy_title_delete_title($tid){ - db_query("DELETE FROM {taxonomy_title} WHERE tid = %d", $tid); +function _taxonomy_title_delete_title($tid) { + db_delete('taxonomy_title') + ->condition('tid', $tid) + ->execute(); } /** @@ -142,7 +149,7 @@ function _taxonomy_title_delete_title($t * @return * The taxonomy term title for the term. */ -function _taxonomy_title_get_title($tid){ - $title = db_result(db_query("SELECT title FROM {taxonomy_title} WHERE tid = %d", $tid)); +function _taxonomy_title_get_title($tid) { + $title = db_query("SELECT title FROM {taxonomy_title} WHERE tid = :tid", array(':tid' => $tid))->fetchField(); return $title; }