
first ajax geed results + 2 different custom autocomplete func (not used for now) - deselect - searchapi Signed-off-by: bachy <git@g-u-i.net>
177 lines
4.8 KiB
Plaintext
177 lines
4.8 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/dbselect'] = array(
|
|
'title' => 'Autocomplete materiobase search',
|
|
'page callback' => 'materiobase_search_autocomplete_dbselect',
|
|
'access arguments' => array('access content'),
|
|
'type' => MENU_CALLBACK,
|
|
'file' => 'materiobasemod.pages.inc',
|
|
);
|
|
$items['materiobase/search/autocomplete/searchapi'] = array(
|
|
'title' => 'Autocomplete materiobase search',
|
|
'page callback' => 'materiobase_search_autocomplete_searchapi',
|
|
'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;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_block_view_alter().
|
|
*/
|
|
function materiobasemod_block_view_alter(&$data, $block) {
|
|
if ($block->module == 'search_api_page') {
|
|
$page = search_api_page_load($block->delta);
|
|
$item = menu_get_item();
|
|
|
|
if (isset($page->path) && $page->path == $item['path']) {
|
|
$keys = arg(count(arg(NULL, $page->path)));
|
|
if ($keys) {
|
|
$data['content']['keys_' . $page->id]['#default_value'] = $keys;
|
|
$data['content']['keys_' . $page->id]['#value'] = $keys;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements hook_entity_info_alter().
|
|
*/
|
|
function materiobasemod_entity_info_alter(&$entity_info) {
|
|
$entity_info['node']['view modes']['cardsmall'] = array(
|
|
'label' => t('Small card for the grid'),
|
|
'custom settings' => TRUE,
|
|
);
|
|
|
|
$entity_info['node']['view modes']['cardmedium'] = array(
|
|
'label' => t('Medium card for the grid'),
|
|
'custom settings' => TRUE,
|
|
);
|
|
|
|
$entity_info['node']['view modes']['cardbig'] = array(
|
|
'label' => t('Big card for the grid'),
|
|
'custom settings' => TRUE,
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_preprocess_node().
|
|
*/
|
|
function materiobasemod_preprocess_node(&$vars) {
|
|
$vars['theme_hook_suggestions'][] = 'node__'.$vars['view_mode'];
|
|
$vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__' . $vars['view_mode'];
|
|
// dsm($vars, '$vars');
|
|
}
|
|
|
|
function materiobasemod_preprocess_field(&$vars) {
|
|
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#view_mode'];
|
|
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_type'] . '__' . $vars['element']['#view_mode'];
|
|
$vars['theme_hook_suggestions'][] = 'field__' . $vars['element']['#field_name'] . '__' . $vars['element']['#view_mode'];
|
|
// dsm($vars, '$vars');
|
|
}
|
|
|
|
|
|
/**
|
|
* materiobase_search_form()
|
|
*/
|
|
function materiobase_search_form(){
|
|
$form = array();
|
|
$form['searchfield'] = array(
|
|
'#type' => 'textfield',
|
|
'#default_value' => '',
|
|
// '#autocomplete_path' => 'materiobase/search/autocomplete/searchapi',
|
|
'#autocomplete_path' => 'materiobase/search/autocomplete/dbselect',
|
|
'#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");
|
|
|
|
|
|
}
|