materiobasemod.module 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /**
  3. * @file
  4. * This is the file description for Materiobasemod 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. /**
  11. * Implements hook_permission().
  12. */
  13. function materiobasemod_permission() {
  14. return array(
  15. 'use materiobase search' => array(
  16. 'title' => t('Materio base search'),
  17. 'description' => t('Use materiobasemod search.'),
  18. ),
  19. );
  20. }
  21. /**
  22. * Implements hook_menu().
  23. */
  24. function materiobasemod_menu() {
  25. $items = array();
  26. $items['materiobase/search/autocomplete'] = array(
  27. 'title' => 'Autocomplete materiobase search',
  28. 'page callback' => 'materiobase_search_autocomplete',
  29. 'access arguments' => array('access content'),
  30. 'type' => MENU_CALLBACK,
  31. 'file' => 'materiobasemod.pages.inc',
  32. );
  33. return $items;
  34. }
  35. /**
  36. * Implements hook_block_info().
  37. */
  38. function materiobasemod_block_info() {
  39. // This example comes from node.module.
  40. $blocks['base_search'] = array(
  41. 'info' => t('Materio base search'),
  42. 'cache' => DRUPAL_NO_CACHE
  43. );
  44. return $blocks;
  45. }
  46. /**
  47. * Implements hook_theme().
  48. */
  49. function materiobasemod_theme($existing, $type, $theme, $path) {
  50. return array(
  51. 'materiobase_search_block' => array(
  52. 'arguments' => array(),
  53. 'template' => 'materiobase-search-block',
  54. 'path' => drupal_get_path('module', 'materiobasemod').'/templates',
  55. ),
  56. );
  57. }
  58. /**
  59. * Implements hook_block_view().
  60. */
  61. function materiobasemod_block_view($delta = '') {
  62. // This example comes from node.module. Note that you can also return a
  63. // renderable array rather than rendered HTML for 'content'.
  64. $block = array();
  65. switch ($delta) {
  66. case 'base_search':
  67. if (user_access('use materiobase search')) {
  68. $block['subject'] = t('Search');
  69. $block['content'] = theme('materiobase_search_block', array());
  70. }
  71. break;
  72. }
  73. return $block;
  74. }
  75. /**
  76. * materiobase_search_form()
  77. */
  78. function materiobase_search_form(){
  79. $form = array();
  80. $form['searchfield'] = array(
  81. '#type' => 'textfield',
  82. '#default_value' => '',
  83. '#autocomplete_path' => 'materiobase/search/autocomplete',
  84. '#size' => 30,
  85. '#maxlength' => 1024,
  86. // '#element_validate' => array('taxonomy_autocomplete_validate'),
  87. );
  88. $form['create'] = array(
  89. '#type' => 'submit',
  90. '#value' => t('Search'),
  91. );
  92. return $form;
  93. }
  94. /**
  95. * template_preprocess_materiobase_search_block();
  96. */
  97. function template_preprocess_materiobase_search_block(&$vars){
  98. $vars['searchform'] = drupal_get_form("materiobase_search_form");
  99. }