template.theme-overrides.inc 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. function perfarttimeline_links__locale_block(&$vars) {
  3. // global $language;
  4. // foreach ($vars['links'] as $lang => $link) {
  5. // $vars['links'][$lang]['title'] = $lang;
  6. // // if($lang == $language->language)
  7. // // unset($vars['link'][$lang]);
  8. // }
  9. $content = theme_links($vars);
  10. return $content;
  11. }
  12. /**
  13. * Returns HTML for an image using a specific image style.
  14. *
  15. * @param $variables
  16. * An associative array containing:
  17. * - style_name: The name of the style to be used to alter the original image.
  18. * - path: The path of the image file relative to the Drupal files directory.
  19. * This function does not work with images outside the files directory nor
  20. * with remotely hosted images. This should be in a format such as
  21. * 'images/image.jpg', or using a stream wrapper such as
  22. * 'public://images/image.jpg'.
  23. * - width: The width of the source image (if known).
  24. * - height: The height of the source image (if known).
  25. * - alt: The alternative text for text-based browsers.
  26. * - title: The title text is displayed when the image is hovered in some
  27. * popular browsers.
  28. * - attributes: Associative array of attributes to be placed in the img tag.
  29. *
  30. * @ingroup themeable
  31. */
  32. function perfarttimeline_image_style($vars) {
  33. // dsm($vars);
  34. $real_path = $vars['path'];
  35. _perfarttimeline_getImageStyleDimensions($vars);
  36. $figure = '<figure style="width:'.$vars['width'].'px;height:'.$vars['height'].'px;">';
  37. $styles = array('grid_small', 'grid_medium', 'grid_large');
  38. if(in_array($vars['style_name'], $styles)){
  39. foreach ($styles as $style) {
  40. $vars['attributes']['class'] = 'image '.$style;
  41. if($style == $vars['style_name']){
  42. $vars['path'] = image_style_url($vars['style_name'], $real_path);
  43. $figure .= theme('image', $vars);
  44. }else{
  45. $hidden_vars = array_merge(array(), $vars);
  46. $hidden_vars['style_name'] = $style;
  47. _perfarttimeline_getImageStyleDimensions($hidden_vars);
  48. $hidden_vars['attributes']['path'] = image_style_url($style, $real_path);
  49. $hidden_vars['path'] = "";
  50. $figure .= theme('image', $hidden_vars);
  51. }
  52. }
  53. }else{
  54. $vars['attributes']['class'] = 'image '.$vars['style_name'];
  55. $vars['path'] = image_style_url($vars['style_name'], $real_path);
  56. $figure .= theme('image', $vars);
  57. }
  58. #gif
  59. $gifvariables = array_merge(array(), $vars);
  60. $gifvariables['path'] = '/'. drupal_get_path("theme", "perfarttimeline") .'/images/blank.gif';
  61. $gifvariables['attributes']['class'] = 'blank';
  62. $gifvariables['title'] = $gifvariables['alt'] = '';
  63. $figure .= theme('image', $gifvariables);
  64. #figcaption
  65. $figure .= '<figcaption>'.$vars['title'].'</figcaption>';
  66. $figure .= '</figure>';
  67. return $figure;
  68. }
  69. function _perfarttimeline_getImageStyleDimensions(&$vars){
  70. $dimensions = array(
  71. 'width' => $vars['width'],
  72. 'height' => $vars['height'],
  73. );
  74. image_style_transform_dimensions($vars['style_name'], $dimensions);
  75. $vars['width'] = $dimensions['width'];
  76. $vars['height'] = $dimensions['height'];
  77. }
  78. function perfarttimeline_menu_tree__main_menu($variables) {
  79. // dsm($variables);
  80. global $language;
  81. preg_match_all('/<li[^>]+><a[^>]+>/', $variables['tree'], $links);
  82. // dsm($links, 'links');
  83. if(isset($links[0])){
  84. foreach ($links[0] as $link) {
  85. preg_match('/href="([^"]+)"/', $link, $path);
  86. $normal_path = drupal_get_normal_path( preg_replace('/^\/fr\/|\/en\//', '', $path[1]) );
  87. // dsm($normal_path, 'normal_path');
  88. preg_match('/node\/([0-9]+)/', $normal_path, $matches);
  89. // dsm($matches2, 'matches2');
  90. if(isset($matches[1])){
  91. $node = node_load($matches[1]);
  92. if(in_array($node->type, array('temoignage', 'biographie', 'document_video'))){
  93. $prenom = field_get_items('node', $node, 'field_prenom', $language->language);
  94. $nom = field_get_items('node', $node, 'field_nom', $language->language);
  95. // dsm($nom, 'nom');
  96. // dsm($prenom, 'prenom');
  97. $new_link = preg_replace('/(<li[^>]+)>/', '${1} prenom="'.$prenom[0]['value'].'" nom="'.$nom[0]['value'].'">', $link);
  98. // dsm($new_link, 'new_link');
  99. $variables['tree'] = str_replace($link, $new_link, $variables['tree']);
  100. }
  101. }
  102. }
  103. }
  104. return '<ul class="menu main-menu">' . $variables['tree'] . '</ul>';
  105. }