perfart.module 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. /**
  3. * @file
  4. * This is the file description for Perfart module.
  5. *
  6. * In this more verbose, multi-line description, you can specify what this
  7. * file does exactly. Make sure to wrap your documentation in column 78 so
  8. * that the file can be displayed nicely in default-sized consoles.
  9. */
  10. define('PERFART_ELMTS_BY_PAGE', 100);
  11. /**
  12. * Implements hook_menu().
  13. */
  14. function perfart_menu() {
  15. $items = array();
  16. $base = array(
  17. 'access arguments' => array('access content'),
  18. 'type' => MENU_CALLBACK,
  19. 'file' => 'perfart.pages.inc',
  20. );
  21. $items['perfart/ajax/dates'] = $base+array(
  22. 'title' => 'List of dates',
  23. 'page callback' => 'perfart_get_dates',
  24. 'page arguments' => array(3),
  25. );
  26. $items['perfart/ajax/perf'] = $base+array(
  27. 'title' => 'content of one perf',
  28. 'page callback' => 'perfart_get_perf',
  29. 'page arguments' => array(3),
  30. );
  31. $items['perfart/ajax/home'] = $base+array(
  32. 'title' => 'content of home page',
  33. 'page callback' => 'perfart_get_home',
  34. 'page arguments' => array(),
  35. );
  36. $items['perfart/performances'] = $base+array(
  37. 'title' => 'List of performances',
  38. 'page callback' => 'perfart_get_performances',
  39. 'page arguments' => array(),
  40. );
  41. $items['perfart/search'] = $base+array(
  42. 'title' => 'search performances',
  43. 'page callback' => 'perfart_search',
  44. 'page arguments' => array(),
  45. );
  46. $items['perfart/search_api'] = $base+array(
  47. 'title' => 'search performances (through search_api)',
  48. 'page callback' => 'perfart_search_api',
  49. 'page arguments' => array(),
  50. );
  51. // $items['perfart/ajax/filters'] = array(
  52. // 'title' => 'List of filters blocks (taxonomy terms)',
  53. // 'page callback' => 'perfart_get_filters',
  54. // 'access callback' => TRUE,
  55. // 'file' => 'perfart.pages.inc',
  56. // 'page arguments' => array(),
  57. // );
  58. // $items['perfart/update_cer'] = array(
  59. // 'title' => 'Updating Corresponding entity reference',
  60. // 'page callback' => 'perfart_update_cer',
  61. // 'access callback' => TRUE,
  62. // 'file' => 'perfart.pages.inc',
  63. // 'page arguments' => array(2),
  64. // );
  65. return $items;
  66. }
  67. /**
  68. * Implements hook_ctools_plugin_directory -
  69. * This lets ctools know to scan my module for a content_type plugin file
  70. * Detailed docks in ctools/ctools.api.php
  71. */
  72. function perfart_ctools_plugin_directory($owner, $plugin_type) {
  73. // we'll be nice and limit scandir() calls
  74. if ($owner == 'ctools' && $plugin_type == 'content_types') {
  75. return 'plugins/content_types';
  76. }
  77. }
  78. /**
  79. * Implements hook_entity_info_alter().
  80. */
  81. function perfart_entity_info_alter(&$entity_info) {
  82. // Set the controller class for nodes to an alternate implementation of the
  83. // DrupalEntityController interface.
  84. // dsm($entity_info, '$entity_info');
  85. $entity_info['node']['view modes']['short_infos'] = array(
  86. 'label' => t('Short infos'),
  87. 'custom settings' => TRUE,
  88. );
  89. $entity_info['node']['view modes']['views_table_cel'] = array(
  90. 'label' => t('Views table cel'),
  91. 'custom settings' => TRUE,
  92. );
  93. $entity_info['node']['view modes']['gridready'] = array(
  94. 'label' => t('Grid ready (timeline)'),
  95. 'custom settings' => TRUE,
  96. );
  97. }
  98. /**
  99. * Implements hook_preprocess_node().
  100. */
  101. function perfart_preprocess_node(&$vars) {
  102. // dsm($vars, '$vars node');
  103. // if($vars['view_mode'] == 'short_infos') {
  104. // $vars['theme_hook_suggestions'][] = 'node__short_infos';
  105. // $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__short_infos';
  106. // }
  107. // if($vars['view_mode'] == 'views_table_cel') {
  108. // $vars['theme_hook_suggestions'][] = 'node__cel';
  109. // $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__cel';
  110. // }
  111. $vars['theme_hook_suggestions'][] = 'node__'.$vars['view_mode'];
  112. $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
  113. }
  114. function perfart_preprocess_field(&$vars) {
  115. // dsm($vars, '$vars field');
  116. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
  117. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
  118. $vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];
  119. }
  120. /**
  121. * Implements hook_theme().
  122. */
  123. function perfart_theme($existing, $type, $theme, $path) {
  124. $items = array();
  125. $path = drupal_get_path('module', 'perfart') .'/templates';
  126. $items['node__document__short_infos'] = array(
  127. 'render element' => 'form',
  128. 'path' => $path,
  129. 'template' => 'node--document--short_infos',
  130. // 'preprocess functions' => array(
  131. // 'rubik_preprocess_form_confirm'
  132. // ),
  133. );
  134. $items['node__document__cel'] = array(
  135. 'render element' => 'form',
  136. 'path' => $path,
  137. 'template' => 'node--document--cel',
  138. );
  139. /*
  140. TODO themable timeline item content
  141. */
  142. // $items['timeline__item_content'] = array(
  143. // 'render element' => 'form',
  144. // 'path' => $path,
  145. // 'template' => 'timeline--item-content',
  146. // );
  147. // $items['perfart_performances'] = array(
  148. // 'path' => $path,
  149. // 'template' => 'perfart-performances',
  150. // );
  151. return $items;
  152. }
  153. /**
  154. * Implements hook_init().
  155. */
  156. function perfart_init() {
  157. $query = new EffectuationEntityFieldQuery;
  158. $count = $query->count()->execute();
  159. $pages = ceil($count / PERFART_ELMTS_BY_PAGE);
  160. // drupal_set_message("pages : ".$pages);
  161. drupal_add_js(array('perfart' => array(
  162. 'effectuations_pages' => $pages,
  163. 'strings'=>array(
  164. 'topologies'=> t('topologies'),
  165. 'places'=> t('places'),
  166. 'peoples' => t('peoples'),
  167. ),
  168. )), 'setting');
  169. }
  170. /**
  171. * Implements hook_menu_get_item_alter().
  172. */
  173. // function perfart_menu_get_item_alter(&$router_item, $path, $original_map){
  174. // dsm($router_item, 'router_item');
  175. // dsm($path, 'path');
  176. // dsm($original_map, 'original_map');
  177. // }