Index: vocabindex.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/vocabindex/vocabindex.module,v retrieving revision 1.1.2.5.2.82 diff -u -r1.1.2.5.2.82 vocabindex.module --- vocabindex.module 5 Mar 2009 15:28:43 -0000 1.1.2.5.2.82 +++ vocabindex.module 1 Apr 2009 21:28:44 -0000 @@ -45,15 +45,15 @@ * A VI page. */ define('VOCABINDEX_VI_PAGE', 2); - -/** - * Implementation of hook_perm(). - */ -function vocabindex_perm() { + +/** + * Implementation of hook_perm(). + */ +function vocabindex_perm() { return array( 'administer vocabulary index', 'view vocabulary index pages', - ); + ); } /** @@ -64,74 +64,74 @@ $path = base_path() . 'update.php'; drupal_set_message(t("Please proceed to !update.php to update your database to Vocabulary Index 2.", array('!update.php' => 'update.php')), 'error'); } -} - -/** - * Implementation of hook_menu(). - */ +} + +/** + * Implementation of hook_menu(). + */ function vocabindex_menu() { if (vocabindex_update_status() == FALSE) { return array(); } - $items[_vocabindex_menu_paths('admin_main')] = array( + $items[_vocabindex_menu_paths('admin_main')] = array( 'title' => 'Vocabulary Index', - 'description' => 'Create index pages for vocabularies.', - 'access arguments' => array('administer vocabulary index'), + 'description' => 'Create index pages for vocabularies.', + 'access arguments' => array('administer vocabulary index'), 'page callback' => 'vocabindex_admin_vi', 'page arguments' => array((string) VOCABINDEX_VI_PAGE), - 'file' => 'vocabindex.admin.inc', - ); + 'file' => 'vocabindex.admin.inc', + ); $items[_vocabindex_menu_paths('admin_pages')] = array( - 'title' => 'Pages', + 'title' => 'Pages', 'access arguments' => array('administer vocabulary index'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'vocabindex.admin.inc', 'weight' => 0, - ); + ); $items[_vocabindex_menu_paths('admin_blocks')] = array( 'title' => 'Blocks', - 'description' => 'Create index blocks for vocabularies.', - 'access arguments' => array('administer vocabulary index'), + 'description' => 'Create index blocks for vocabularies.', + 'access arguments' => array('administer vocabulary index'), 'page callback' => 'vocabindex_admin_vi', 'page arguments' => array((string) VOCABINDEX_VI_BLOCK), 'type' => MENU_LOCAL_TASK, 'file' => 'vocabindex.admin.inc', 'weight' => 1, - ); + ); - $items[_vocabindex_menu_paths('admin_settings')] = array( + $items[_vocabindex_menu_paths('admin_settings')] = array( 'title' => 'Settings', - 'description' => 'General settings.', + 'description' => 'General settings.', 'access arguments' => array('administer vocabulary index'), - 'page callback' => 'drupal_get_form', + 'page callback' => 'drupal_get_form', 'page arguments' => array('vocabindex_admin'), 'type' => MENU_LOCAL_TASK, 'file' => 'vocabindex.admin.inc', - 'weight' => 2, + 'weight' => 2, ); // VI pages. - $vis = vocabindex_vi_load(VOCABINDEX_VI_PAGE); + $vis = vocabindex_vi_load(VOCABINDEX_VI_PAGE); foreach ($vis as $vi) { $item = vocabindex_menu_base() + array( - 'title' => $vi->name, - 'description' => check_plain($vi->description), + 'title' => vocabindex_t($vi, 'name'), + 'description' => check_plain(vocabindex_t($vi, 'description')), // We need to cast out the constant to a string, because the integer will - // otherwise be replaced with the corresponding part of the menu path. - 'page arguments' => array($vi->vid, (string) VOCABINDEX_VOC), + // otherwise be replaced with the corresponding part of the menu path. + 'page arguments' => array($vi->vid, (string) VOCABINDEX_VOC), ); // The menu item for alphabetical VIs using the letter wildcard. if ($vi->view == VOCABINDEX_VIEW_ALPHABETICAL) { $arg = (int) substr_count($vi->path, '/') + 1; $path = $vi->path . '/%vocabindex_letter'; $item['page arguments'][2] = $arg; - } - $items[$vi->path] = $item; + } + $items[$vi->path] = $item; } - + return $items; } @@ -142,7 +142,7 @@ * index pages. */ function vocabindex_menu_alter(&$items) { - $vis = vocabindex_vi_load(VOCABINDEX_VI_PAGE); + $vis = vocabindex_vi_load(VOCABINDEX_VI_PAGE); foreach ($vis as $vi) { if ($vi->view == VOCABINDEX_VIEW_FLAT) { $tree = taxonomy_get_tree($vi->vid); @@ -151,13 +151,14 @@ // Check if the current term is a parent. if (isset($children[$term->tid])) { $items['taxonomy/term/' . $term->tid] = vocabindex_menu_base() + array( - 'title' => $term->name, - 'description' => check_plain($term->description), + 'title' => vocanindex_t($term, 'name'), + 'description' => check_plain(vocabindex_t($term, 'description')), // We need to cast our integer constant to a string, because the // integer will otherwise be replaced with the corresponding part // of the menu path. 'page arguments' => array($term->tid, (string) VOCABINDEX_TERM), - 'file path' => drupal_get_path('module', 'vocabindex'), ); + 'file path' => drupal_get_path('module', 'vocabindex'), + ); } } } @@ -180,7 +181,7 @@ elseif ($op == 'view') { module_load_include('inc', 'vocabindex', 'vocabindex.view'); $vi = vocabindex_vi_load(VOCABINDEX_VI_BLOCK, $delta); - return array('subject' => check_plain($vi->name), 'content' => vocabindex_view_block($vi->vid)); + return array('subject' => check_plain(vocabindex_t($vi, 'name')), 'content' => vocabindex_view_block($vi->vid)); } } @@ -368,10 +369,10 @@ */ function vocabindex_menu_base() { return array( - 'access arguments' => array('view vocabulary index pages'), - 'page callback' => 'vocabindex_view_page', + 'access arguments' => array('view vocabulary index pages'), + 'page callback' => 'vocabindex_view_page', 'type' => MENU_CALLBACK, - 'file' => 'vocabindex.view.inc', + 'file' => 'vocabindex.view.inc', ); } @@ -573,4 +574,25 @@ */ function vocabindex_screenshot_link($view, $title) { return l(theme_image(drupal_get_path('module', 'vocabindex') . '/images/thumb_' . $view . '.gif', $title, $title), 'http://drupal.org/files/images/screenshot_' . $view . '.preview.png', array('html' => TRUE)); -} \ No newline at end of file +} + +/** +* Translate Taxonomy data. +* +* @param $object +* The term or vocabulary object to translate a property from. +* @param $property +* What property to translate. Either 'name' or 'description'. +*/ +function vocabindex_t($object, $property) { + $text = $object->$property; + if (module_exists('i18nstrings')) { + if (isset($object->tid)) { + return tt("taxonomy:term:$object->tid:$property", $text); + } else { + return tt("taxonomy:vocabulary:$object->vid:$property", $text); + } + } else { + return t($text); + } +} Index: vocabindex.view.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/vocabindex/vocabindex.view.inc,v retrieving revision 1.1.2.2.2.80 diff -u -r1.1.2.2.2.80 vocabindex.view.inc --- vocabindex.view.inc 5 Mar 2009 15:36:19 -0000 1.1.2.2.2.80 +++ vocabindex.view.inc 1 Apr 2009 21:28:28 -0000 @@ -232,7 +232,7 @@ function vocabindex_view_page($id, $type, $letter = '') { vocabindex_letter_set($letter); $parent = vocabindex_parent_load($id, $type); - $parent->description = check_plain($parent->description); + $parent->description = check_plain(vocabindex_t($parent, 'description')); $vi = vocabindex_vi_load(VOCABINDEX_VI_PAGE, $parent->vid); $output = vocabindex_vi_view($id, $type, $vi, $parent); @@ -327,10 +327,11 @@ // Processes that cannot be cached. if ($vi->view == VOCABINDEX_VIEW_ALPHABETICAL && isset($output['letter'])) { - drupal_set_title(check_plain($vi->name) . ' » ' . drupal_strtoupper($output['letter'])); + drupal_set_title(check_plain(vocabindex_t($vi, 'name')) . ' » ' . drupal_strtoupper($output['letter'])); } - return $output; + return $output; + } /** @@ -362,7 +363,8 @@ vocabindex_pager_query($tree); } - $items = array(); + $items = array(); + for ($i = 0, $len_i = count($tree); $i < $len_i; $i++) { $term = $tree[$i]; $zebra = ($i % 2 == 0 ? 'even' : 'odd'); @@ -584,8 +586,8 @@ */ function vocabindex_term_link($term, $vi) { $term->path = taxonomy_term_path($term); - $term->name = check_plain(t($term->name)); - $term->description = check_plain($term->description); + $term->name = check_plain(vocabindex_t($term, 'name')); + $term->description = check_plain(vocabindex_t($term, 'description')); return theme('vocabindex_link', $term, $vi, vocabindex_text_dir()); } \ No newline at end of file