Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $links = array();
- // it is a section
- if (arg(0)=='section' && arg(1)!=NULL) {
- global $language;
- if ($language->language==language_default('language')) {
- $source_term = arg(1);
- }
- else $source_term = euractiv_section_translation(arg(1), $language->language);
- // get the taxonomy tid for the correct vocabulary
- $source_term_tid = euractiv_section_name_to_tid($source_term);
- // now let's translate links for each sections
- $current_term=taxonomy_get_term($source_term_tid);
- $languages = language_list('enabled');
- foreach ($languages[1] as $language_section) {
- $section_link = tt('taxonomy:term:'.$current_term->tid.':name',$current_term->name,$language_section->language);
- $path_section = 'section/'.$section_link;
- $links[$language_section->language] = array(
- 'href' => $path_section,
- 'title' => $language_section->language,
- 'language' => $language_section,
- 'attributes' => array('class' => 'language-link'),
- );
- }
- }
- if (drupal_is_front_page() || (arg(0)=='node' && is_numeric(arg(1)))) {
- $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
- $languages = language_list('enabled');
- foreach ($languages[1] as $language_hp) {
- $links[$language_hp->language] = array(
- 'href' => $path,
- 'title' => $language_hp->language,
- 'language' => $language_hp,
- 'attributes' => array('class' => 'language-link'),
- );
- }
- drupal_alter('translation_link', $links, $path);
- }
- $output=theme('links', $links, array());
- ?>
- -------------- in module -------------
- <?php
- function euractiv_section_translation ($taxonomy_string, $language_code) {
- $source_argument=db_result(db_query("SELECT s.source FROM {locales_target} t INNER JOIN {locales_source} s ON s.lid = t.lid WHERE t.translation ='%s' AND t.language='%s' AND s.textgroup='taxonomy'",$taxonomy_string,$language_code));
- return $source_argument;
- }
- function euractiv_section_name_to_tid ($source_argument) {
- $source_term_objects = taxonomy_get_term_by_name($source_argument);
- foreach($source_term_objects as $source_term_object) {
- if ($source_term_object->vid == 5) {
- $source_term_tid = $source_term_object->tid;
- break;
- }
- }
- return $source_term_tid;
- }
- ?>
- -------- hook menu => t function -------
- function delivery_menu() { $items = array();
- // note: we can't dynamically append destination to querystring. do so at theme layer. fix in D7?
- $items['delivery/setstatus/%/%'] = array(
- 'title' => 'set orders status to deliver',
- 'title callback' => 't',
- 'page callback' => 'delivery_status',
- 'page arguments' => array(2,3), //delivery niddist
- 'description' => 'set default status as "deliver" for all clients at start of delivery.',
- 'access arguments' => array('edit delivery nodes'),
- );
Add Comment
Please, Sign In to add comment