119 lines
2.6 KiB
Plaintext
119 lines
2.6 KiB
Plaintext
<?php
|
|
/**
|
|
* @file
|
|
* This is the file description for Materiobasemod module.
|
|
*
|
|
* In this more verbose, multi-line description, you can specify what this
|
|
* file does exactly. Make sure to wrap your documentation in column 78 so
|
|
* that the file can be displayed nicely in default-sized consoles.
|
|
*/
|
|
|
|
|
|
/**
|
|
* Implements hook_permission().
|
|
*/
|
|
function materiobasemod_permission() {
|
|
return array(
|
|
'use materiobase search' => array(
|
|
'title' => t('Materio base search'),
|
|
'description' => t('Use materiobasemod search.'),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_menu().
|
|
*/
|
|
function materiobasemod_menu() {
|
|
$items = array();
|
|
$items['materiobase/search/autocomplete'] = array(
|
|
'title' => 'Autocomplete materiobase search',
|
|
'page callback' => 'materiobase_search_autocomplete',
|
|
'access arguments' => array('access content'),
|
|
'type' => MENU_CALLBACK,
|
|
'file' => 'materiobasemod.pages.inc',
|
|
);
|
|
return $items;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_block_info().
|
|
*/
|
|
function materiobasemod_block_info() {
|
|
// This example comes from node.module.
|
|
$blocks['base_search'] = array(
|
|
'info' => t('Materio base search'),
|
|
'cache' => DRUPAL_NO_CACHE
|
|
);
|
|
|
|
return $blocks;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_theme().
|
|
*/
|
|
function materiobasemod_theme($existing, $type, $theme, $path) {
|
|
return array(
|
|
'materiobase_search_block' => array(
|
|
'arguments' => array(),
|
|
'template' => 'materiobase-search-block',
|
|
'path' => drupal_get_path('module', 'materiobasemod').'/templates',
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_block_view().
|
|
*/
|
|
function materiobasemod_block_view($delta = '') {
|
|
// This example comes from node.module. Note that you can also return a
|
|
// renderable array rather than rendered HTML for 'content'.
|
|
$block = array();
|
|
|
|
switch ($delta) {
|
|
case 'base_search':
|
|
if (user_access('use materiobase search')) {
|
|
$block['subject'] = t('Search');
|
|
$block['content'] = theme('materiobase_search_block', array());
|
|
}
|
|
break;
|
|
}
|
|
return $block;
|
|
}
|
|
|
|
|
|
/**
|
|
* materiobase_search_form()
|
|
*/
|
|
function materiobase_search_form(){
|
|
|
|
$form = array();
|
|
|
|
$form['searchfield'] = array(
|
|
'#type' => 'textfield',
|
|
'#default_value' => '',
|
|
'#autocomplete_path' => 'materiobase/search/autocomplete',
|
|
'#size' => 30,
|
|
'#maxlength' => 1024,
|
|
// '#element_validate' => array('taxonomy_autocomplete_validate'),
|
|
);
|
|
|
|
$form['create'] = array(
|
|
'#type' => 'submit',
|
|
'#value' => t('Search'),
|
|
);
|
|
|
|
return $form;
|
|
}
|
|
|
|
/**
|
|
* template_preprocess_materiobase_search_block();
|
|
*/
|
|
function template_preprocess_materiobase_search_block(&$vars){
|
|
|
|
$vars['searchform'] = drupal_get_form("materiobase_search_form");
|
|
|
|
|
|
}
|
|
|