Guest User

Untitled

a guest
Jan 13th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. <?php
  2.  
  3. $links = array();
  4. // it is a section
  5. if (arg(0)=='section' && arg(1)!=NULL) {
  6.  
  7. global $language;
  8. if ($language->language==language_default('language')) {
  9. $source_term = arg(1);
  10. }
  11. else $source_term = euractiv_section_translation(arg(1), $language->language);
  12. // get the taxonomy tid for the correct vocabulary
  13. $source_term_tid = euractiv_section_name_to_tid($source_term);
  14. // now let's translate links for each sections
  15. $current_term=taxonomy_get_term($source_term_tid);
  16.  
  17. $languages = language_list('enabled');
  18. foreach ($languages[1] as $language_section) {
  19.  
  20. $section_link = tt('taxonomy:term:'.$current_term->tid.':name',$current_term->name,$language_section->language);
  21. $path_section = 'section/'.$section_link;
  22. $links[$language_section->language] = array(
  23. 'href' => $path_section,
  24. 'title' => $language_section->language,
  25. 'language' => $language_section,
  26. 'attributes' => array('class' => 'language-link'),
  27. );
  28. }
  29. }
  30.  
  31.  
  32. if (drupal_is_front_page() || (arg(0)=='node' && is_numeric(arg(1)))) {
  33. $path = drupal_is_front_page() ? '<front>' : $_GET['q'];
  34. $languages = language_list('enabled');
  35. foreach ($languages[1] as $language_hp) {
  36. $links[$language_hp->language] = array(
  37. 'href' => $path,
  38. 'title' => $language_hp->language,
  39. 'language' => $language_hp,
  40. 'attributes' => array('class' => 'language-link'),
  41. );
  42. }
  43. drupal_alter('translation_link', $links, $path);
  44. }
  45. $output=theme('links', $links, array());
  46.  
  47. ?>
  48. -------------- in module -------------
  49. <?php
  50. function euractiv_section_translation ($taxonomy_string, $language_code) {
  51. $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));
  52. return $source_argument;
  53. }
  54.  
  55. function euractiv_section_name_to_tid ($source_argument) {
  56. $source_term_objects = taxonomy_get_term_by_name($source_argument);
  57. foreach($source_term_objects as $source_term_object) {
  58. if ($source_term_object->vid == 5) {
  59. $source_term_tid = $source_term_object->tid;
  60. break;
  61. }
  62. }
  63. return $source_term_tid;
  64. }
  65. ?>
  66.  
  67. -------- hook menu => t function -------
  68. function delivery_menu() { $items = array();
  69. // note: we can't dynamically append destination to querystring. do so at theme layer. fix in D7?
  70. $items['delivery/setstatus/%/%'] = array(
  71. 'title' => 'set orders status to deliver',
  72. 'title callback' => 't',
  73. 'page callback' => 'delivery_status',
  74. 'page arguments' => array(2,3), //delivery niddist
  75. 'description' => 'set default status as "deliver" for all clients at start of delivery.',
  76. 'access arguments' => array('edit delivery nodes'),
  77. );
Add Comment
Please, Sign In to add comment