template.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /**
  3. * Implementation of hook_theme().
  4. */
  5. function guibik_theme() {
  6. $items = array();
  7. // Content theming.
  8. $items['help'] =
  9. $items['node'] =
  10. $items['comment'] =
  11. $items['comment_wrapper'] = array(
  12. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  13. 'template' => 'object',
  14. );
  15. $items['node']['template'] = 'node';
  16. // Help pages really need help. See preprocess_page().
  17. $items['help_page'] = array(
  18. 'variables' => array('content' => array()),
  19. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  20. 'template' => 'object',
  21. 'preprocess functions' => array(
  22. 'template_preprocess',
  23. 'rubik_preprocess_help_page',
  24. ),
  25. 'process functions' => array('template_process'),
  26. );
  27. // Form layout: default (2 column).
  28. $items['block_add_block_form'] =
  29. $items['block_admin_configure'] =
  30. $items['comment_form'] =
  31. $items['contact_admin_edit'] =
  32. $items['contact_mail_page'] =
  33. $items['contact_mail_user'] =
  34. $items['filter_admin_format_form'] =
  35. $items['forum_form'] =
  36. $items['locale_languages_edit_form'] =
  37. $items['menu_edit_menu'] =
  38. $items['menu_edit_item'] =
  39. $items['node_type_form'] =
  40. $items['path_admin_form'] =
  41. $items['system_settings_form'] =
  42. $items['system_themes_form'] =
  43. $items['system_modules'] =
  44. $items['system_actions_configure'] =
  45. $items['taxonomy_form_term'] =
  46. $items['taxonomy_form_vocabulary'] =
  47. $items['user_profile_form'] =
  48. $items['user_admin_access_add_form'] = array(
  49. 'render element' => 'form',
  50. 'path' => drupal_get_path('theme', 'guibik') .'/templates',
  51. 'template' => 'form-default',
  52. 'preprocess functions' => array(
  53. 'rubik_preprocess_form_buttons',
  54. ),
  55. );
  56. // These forms require additional massaging.
  57. $items['confirm_form'] = array(
  58. 'render element' => 'form',
  59. 'path' => drupal_get_path('theme', 'rubik') .'/templates',
  60. 'template' => 'form-simple',
  61. 'preprocess functions' => array(
  62. 'rubik_preprocess_form_confirm'
  63. ),
  64. );
  65. $items['node_form'] = array(
  66. 'render element' => 'form',
  67. 'path' => drupal_get_path('theme', 'guibik') .'/templates',
  68. 'template' => 'form-default',
  69. 'preprocess functions' => array(
  70. 'rubik_preprocess_form_buttons',
  71. 'rubik_preprocess_form_node',
  72. ),
  73. );
  74. return $items;
  75. }
  76. /**
  77. * Preprocessor for theme('page').
  78. */
  79. function guibik_preprocess_page(&$vars) {
  80. // Show a warning if base theme is not present.
  81. if (!function_exists('rubik_theme') && user_access('administer site configuration')) {
  82. drupal_set_message(t('The Guibik theme requires the !rubik base theme in order to work properly.', array('!rubik' => l('Rubik', 'http://code.developmentseed.org/tao'))), 'warning');
  83. }
  84. // Process local tasks. Only do this processing if the current theme is
  85. // indeed Rubik. Subthemes must reimplement this call.
  86. global $theme;
  87. if ($theme === 'guibik')
  88. _rubik_local_tasks($vars);
  89. }
  90. function guibik_preprocess_html(&$vars){
  91. $heads['icon'] = array(
  92. '#tag' => 'link',
  93. '#attributes' => array(
  94. 'href' => base_path() . path_to_theme() .'/icon.png',
  95. 'rel' => 'shortcut icon',
  96. 'type' => 'image/png',
  97. ),
  98. );
  99. $heads['apple-touch-icon'] = array(
  100. '#tag' => 'link',
  101. '#attributes' => array(
  102. 'href' => base_path() . path_to_theme() .'/apple-touch-icon.png',
  103. 'rel' => 'apple-touch-icon',
  104. ),
  105. );
  106. foreach ($heads as $type=>$head)
  107. drupal_add_html_head($head, $type);
  108. }
  109. function guibik_preprocess_views_view_table(&$vars){
  110. if($vars['title'] != ''){
  111. $vars['classes_array'][] = 'has-caption';
  112. }
  113. // dsm($vars);
  114. }
  115. /**
  116. * Implements hook_form_node_form_alter().
  117. */
  118. function guibik_form_node_form_alter(&$form, &$form_state){
  119. // dsm($form, 'guibik_form_node_form_alter | $form');
  120. // dsm($form_state, '$form_state');
  121. if(!isset($form['language']['#description']))
  122. $form['language']['#description'] = t('Please consider to leave language in neutral state <strong>if you dont plan to translate this node</strong>, even if your content is (obviously) writed in some non neutral language. Then this node will always be visible.');
  123. }
  124. function guibik_image_field_widget_process($element, &$form_state, $form){
  125. $element['title']['#type'] = "textarea";
  126. return $element;
  127. }
  128. /**
  129. * Implements hook_field_widget_form_alter().
  130. */
  131. function guibik_field_widget_form_alter(&$element, &$form_state, $context) {
  132. // dsm($context['field']['type'], '$context[field][type]');
  133. if ($context['field']['type'] == 'image') {
  134. foreach ($element as $delta => $item) {
  135. if(!isset($element[$delta]['#process']) || !is_array($element[$delta]['#process']))
  136. continue;
  137. $element[$delta]['#process'][] = "guibik_image_field_widget_process";
  138. }
  139. }
  140. }