Now all modules are in core modules folder
This commit is contained in:
parent
5ba1cdfa0b
commit
05b6a91b0c
1907 changed files with 0 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin settings for custom search
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_help().
|
||||
*/
|
||||
function custom_search_blocks_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/settings/custom_search/blocks':
|
||||
$output = t('If you want custom search blocks, enable them here. Then go to the <a href="@link">block page</a> to place them in a region.', array('@link' => url('admin/build/block')));
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function custom_search_blocks_admin() {
|
||||
$form['custom_search_blocks_number'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Number of blocks'),
|
||||
'#size' => 2,
|
||||
'#default_value' => variable_get('custom_search_blocks_number', 1),
|
||||
);
|
||||
return system_settings_form($form);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
name = Custom Search Blocks
|
||||
description = Provides additional search blocks.
|
||||
core = 6.x
|
||||
package = Custom Search
|
||||
dependencies[] = custom_search
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "6.x-1.13"
|
||||
core = "6.x"
|
||||
project = "custom_search"
|
||||
datestamp = "1398258531"
|
||||
|
|
@ -0,0 +1,84 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for the custom search module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function custom_search_blocks_install() {
|
||||
db_query("UPDATE {system} SET weight = 99 WHERE name = 'custom_search_blocks'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function custom_search_blocks_uninstall() {
|
||||
$blocks = variable_get('custom_search_blocks_number', 1);
|
||||
for ($delta=1 ; $delta<=$blocks ; $delta++) {
|
||||
variable_del('custom_search_blocks_' . $delta . '_label_visibility');
|
||||
variable_del('custom_search_blocks_' . $delta . '_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_text');
|
||||
variable_del('custom_search_blocks_' . $delta . '_size');
|
||||
variable_del('custom_search_blocks_' . $delta . '_max_length');
|
||||
variable_del('custom_search_blocks_' . $delta . '_submit_text');
|
||||
variable_del('custom_search_blocks_' . $delta . '_image_path');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_or_display');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_or_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_phrase_display');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_phrase_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_negative_display');
|
||||
variable_del('custom_search_blocks_' . $delta . '_criteria_negative_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_search_box_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_content_types_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_custom_paths_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_submit_button_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_search_box_region');
|
||||
variable_del('custom_search_blocks_' . $delta . '_content_types_region');
|
||||
variable_del('custom_search_blocks_' . $delta . '_custom_paths_region');
|
||||
variable_del('custom_search_blocks_' . $delta . '_submit_button_region');
|
||||
variable_del('custom_search_blocks_' . $delta . '_node_types');
|
||||
variable_del('custom_search_blocks_' . $delta . '_node_types_excluded');
|
||||
variable_del('custom_search_blocks_' . $delta . '_other');
|
||||
variable_del('custom_search_blocks_' . $delta . '_type_selector');
|
||||
variable_del('custom_search_blocks_' . $delta . '_type_selector_label_visibility');
|
||||
variable_del('custom_search_blocks_' . $delta . '_type_selector_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_type_selector_all');
|
||||
variable_del('custom_search_blocks_' . $delta . '_any_restricts');
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths');
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths_selector');
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths_selector_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths_selector_label_visibility');
|
||||
if (module_exists('custom_search_taxonomy')) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label_visibility');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_all');
|
||||
variable_del('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_region');
|
||||
}
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths_terms_separator');
|
||||
}
|
||||
}
|
||||
variable_del('custom_search_blocks_number');
|
||||
}
|
||||
|
||||
function custom_search_blocks_update_6100() {
|
||||
$ret = array();
|
||||
$blocks = variable_get('custom_search_blocks_number', 1);
|
||||
for ($delta=1 ; $delta<=$blocks ; $delta++) {
|
||||
variable_set('custom_search_blocks_' . $delta . '_submit_text', variable_get('custom_search_submit_text', CUSTOM_SEARCH_SUBMIT_TEXT_DEFAULT));
|
||||
variable_set('custom_search_blocks_' . $delta . '_image_path', variable_get('custom_search_image_path', ''));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_or_display', variable_get('custom_search_criteria_or_display', FALSE));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_or_label', variable_get('custom_search_criteria_or_label', CUSTOM_SEARCH_CRITERIA_OR_LABEL_DEFAULT));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_phrase_display', variable_get('custom_search_criteria_phrase_display', FALSE));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_phrase_label', variable_get('custom_search_criteria_phrase_label', CUSTOM_SEARCH_CRITERIA_PHRASE_LABEL_DEFAULT));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_negative_display', variable_get('custom_search_criteria_negative_display', FALSE));
|
||||
variable_set('custom_search_blocks_' . $delta . '_criteria_negative_label', variable_get('custom_search_criteria_negative_label', CUSTOM_SEARCH_CRITERIA_NEGATIVE_LABEL_DEFAULT));
|
||||
}
|
||||
return $ret;
|
||||
}
|
|
@ -0,0 +1,147 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Bring additional search blocks
|
||||
*
|
||||
* Adds node types and taxonomy options to the search form
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function custom_search_blocks_menu() {
|
||||
$items['admin/settings/custom_search/blocks'] = array(
|
||||
'title' => 'Search Blocks',
|
||||
'description' => 'Provide additional search blocks by content type.',
|
||||
'page arguments' => array('custom_search_blocks_admin'),
|
||||
'access arguments' => array('administer custom search blocks'),
|
||||
'file' => 'custom_search_blocks.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 3,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_perm().
|
||||
*/
|
||||
function custom_search_blocks_perm() {
|
||||
return array('administer custom search blocks', 'use custom search blocks');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter().
|
||||
*/
|
||||
function custom_search_blocks_form_alter(&$form, $form_state, $form_id) {
|
||||
if ($form_id == 'block_admin_configure' && $form['module']['#value'] == 'custom_search_blocks') {
|
||||
// Needed to upload of file.
|
||||
$form['#attributes'] = array('enctype' => 'multipart/form-data');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_block() to provide additional blocks.
|
||||
*/
|
||||
function custom_search_blocks_block($op = 'list', $delta = 0, $edit = array()) {
|
||||
switch ($op) {
|
||||
|
||||
case 'configure':
|
||||
// Basic settings.
|
||||
$form = _custom_search_default_admin_form($delta);
|
||||
// Content.
|
||||
$form['content'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Content'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
$form['content'] = array_merge($form['content'], _custom_search_content_admin_form($delta));
|
||||
// Custom search paths
|
||||
$form = array_merge($form, _custom_search_custom_paths_admin_form($delta));
|
||||
// Ordering
|
||||
$form = array_merge($form, _custom_search_ordering_admin_form($delta));
|
||||
$form['order']['#weight'] = 50;
|
||||
|
||||
return $form;
|
||||
break;
|
||||
|
||||
case 'save':
|
||||
foreach ($edit as $key => $value) {
|
||||
if (drupal_substr($key, 0, 20) == 'custom_search_blocks') variable_set($key, $value);
|
||||
}
|
||||
foreach ($edit['custom_search_blocks_' . $delta . '_order'] as $key => $data) {
|
||||
variable_set('custom_search_blocks_' . $delta . '_' . $key . '_weight', $data['sort']);
|
||||
variable_set('custom_search_blocks_' . $delta . '_' . $key . '_region', $data['region']);
|
||||
}
|
||||
// Submit image?
|
||||
$directory_path = file_directory_path() . '/custom_search';
|
||||
file_check_directory($directory_path, FILE_CREATE_DIRECTORY);
|
||||
// Check for a new uploaded image.
|
||||
if ($file = file_save_upload('custom_search_image', array('file_validate_is_image' => array()))) {
|
||||
if (file_copy($file, $directory_path)) {
|
||||
variable_set('custom_search_blocks_' . $delta . '_image_path', $file->filepath);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'list':
|
||||
$blocks = array();
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
$blocks[$a]['info'] = "Custom Search $a";
|
||||
$blocks[$a]['cache'] = BLOCK_NO_CACHE;
|
||||
}
|
||||
return $blocks;
|
||||
break;
|
||||
|
||||
case 'view':
|
||||
if (user_access('use custom search blocks')) {
|
||||
$block['content'] = drupal_get_form('custom_search_blocks_form_' . $delta, $delta);
|
||||
$block['subject'] = "Custom Search $delta";
|
||||
return $block;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_forms() to generate a unique form_id with the same form builder function
|
||||
*/
|
||||
function custom_search_blocks_forms($form_id, $args) {
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
$forms['custom_search_blocks_form_' . $a] = array(
|
||||
'callback' => 'custom_search_blocks_form',
|
||||
'callback arguments' => array($a),
|
||||
);
|
||||
}
|
||||
return $forms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder; Output a search form for the additional search blocks.
|
||||
*/
|
||||
function custom_search_blocks_form(&$form_state, $delta) {
|
||||
$form['custom_search_blocks_form_' . $delta] = array(
|
||||
'#type' => 'textfield',
|
||||
'#size' => 15,
|
||||
'#default_value' => '',
|
||||
'#attributes' => array('title' => t('Enter the terms you wish to search for.')),
|
||||
);
|
||||
|
||||
$form['delta'] = array('#type' => 'hidden', '#value' => $delta);
|
||||
$form['submit'] = array('#type' => 'submit', '#value' => t('Search'));
|
||||
$form['#submit'][] = 'search_box_form_submit';
|
||||
|
||||
if (function_exists('apachesolr_autocomplete_variable_get_widget')) {
|
||||
// support for apachesolr_autocomplete module
|
||||
if (apachesolr_autocomplete_variable_get_widget() == 'custom') {
|
||||
$form['custom_search_blocks_form_' . $delta]['#attributes']['class'] = 'apachesolr-autocomplete unprocessed';
|
||||
}
|
||||
else {
|
||||
$form['custom_search_blocks_form_' . $delta]['#autocomplete_path'] = 'apachesolr_autocomplete';
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
name = Custom Search Internationalization
|
||||
description = Provides Internationalization to Custom Search.
|
||||
core = 6.x
|
||||
package = Custom Search
|
||||
dependencies[] = custom_search
|
||||
dependencies[] = i18nstrings
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "6.x-1.13"
|
||||
core = "6.x"
|
||||
project = "custom_search"
|
||||
datestamp = "1398258531"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for the custom search module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function custom_search_i18n_install() {
|
||||
db_query("UPDATE {system} SET weight = 110 WHERE name = 'custom_search_i18n'");
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Brings Internationalization to Custom Search
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter().
|
||||
*/
|
||||
function custom_search_i18n_form_alter(&$form, $form_state, $form_id) {
|
||||
|
||||
// Filter the form_id value to identify all the custom blocks
|
||||
$form_id_processed = $form_id;
|
||||
$delta = '';
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
if ($form_id == 'custom_search_blocks_form_' . $a) {
|
||||
$form_id_processed = 'custom_search_blocks_form';
|
||||
$delta = 'blocks_' . $a . '_';
|
||||
}
|
||||
}
|
||||
|
||||
switch ($form_id_processed) {
|
||||
case 'search_theme_form':
|
||||
case 'search_block_form':
|
||||
case 'custom_search_blocks_form':
|
||||
|
||||
if (user_access('use custom search')) {
|
||||
// Criteria
|
||||
$criteria = array('or', 'phrase', 'negative');
|
||||
foreach ($criteria as $c) {
|
||||
if (variable_get('custom_search_' . $delta . 'criteria_' . $c . '_display', FALSE)) {
|
||||
if (variable_get('custom_search_' . $delta . 'criteria_' . $c . '_region', 'block') == 'popup') {
|
||||
$form['popup']['custom_search_criteria_' . $c]['#title'] = i18nstrings('custom_search:criterion:1:' . $delta . $c .'_label', variable_get('custom_search_' . $delta . 'criteria_' . $c . '_label', constant('CUSTOM_SEARCH_CRITERIA_' . strtoupper($c) . '_LABEL_DEFAULT')));
|
||||
}
|
||||
else {
|
||||
$form['custom_search_criteria_' . $c]['#title'] = i18nstrings('custom_search:criterion:1:' . $delta . $c .'_label', variable_get('custom_search_' . $delta . 'criteria_' . $c . '_label', constant('CUSTOM_SEARCH_CRITERIA_' . strtoupper($c) . '_LABEL_DEFAULT')));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Title
|
||||
$form[$form_id]['#title'] = i18nstrings('custom_search:common:1:' . $delta . 'label', variable_get('custom_search_' . $delta . 'label', CUSTOM_SEARCH_LABEL_DEFAULT));
|
||||
|
||||
// Default text
|
||||
$form[$form_id]['#default_value'] = i18nstrings('custom_search:common:1:' . $delta . 'text', variable_get('custom_search_' . $delta . 'text', ''));
|
||||
$form['default_text']['#default_value'] = i18nstrings('custom_search:common:1:' . $delta . 'text', variable_get('custom_search_' . $delta . 'text', ''));
|
||||
|
||||
// Submit button
|
||||
$form['submit']['#value'] = i18nstrings('custom_search:common:1:' . $delta . 'submit_text', variable_get('custom_search_' . $delta . 'submit_text', CUSTOM_SEARCH_SUBMIT_TEXT_DEFAULT));
|
||||
if ($form['submit']['#value'] == '') $form['submit']['#attributes'] = array('style' => 'display:none;');
|
||||
|
||||
// Type selector
|
||||
if ((!empty($form['custom_search_types']) && is_array($form['custom_search_types'])) || (!empty($form['popup']['custom_search_types']) && is_array($form['popup']['custom_search_types']))) {
|
||||
if (variable_get('custom_search_' . $delta . 'content_types_region', 'block') == 'popup') {
|
||||
$form['popup']['custom_search_types']['#title'] = i18nstrings('custom_search:content_types:1:' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'type_selector_label', CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT));
|
||||
if (array_key_exists('c-all', $form['popup']['custom_search_types']['#options'])) {
|
||||
$form['popup']['custom_search_types']['#options']['c-all'] = i18nstrings('custom_search:content_types:1:' . $delta . 'selector_all', variable_get('custom_search_' . $delta . 'type_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$form['custom_search_types']['#title'] = i18nstrings('custom_search:content_types:1:' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'type_selector_label', CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT));
|
||||
if (array_key_exists('c-all', $form['custom_search_types']['#options'])) {
|
||||
$form['custom_search_types']['#options']['c-all'] = i18nstrings('custom_search:content_types:1:' . $delta . 'selector_all', variable_get('custom_search_' . $delta . 'type_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Taxonomy
|
||||
if (module_exists('custom_search_taxonomy')) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
// Translate label and -all-
|
||||
foreach ($vocabularies as $voc) {
|
||||
if ((!empty($form['custom_search_vocabulary_' . $voc->vid]) && is_array($form['custom_search_vocabulary_' . $voc->vid])) || (!empty($form['popup']['custom_search_vocabulary_' . $voc->vid]) && is_array($form['popup']['custom_search_vocabulary_' . $voc->vid]))) {
|
||||
if (variable_get('custom_search_' . $delta . 'taxonomy'. $voc->vid . '_region', 'block') == 'popup') {
|
||||
$form['popup']['custom_search_vocabulary_' . $voc->vid]['#title'] = i18nstrings('custom_search:vocabulary:' . $voc->vid . ':' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_label', $voc->name));
|
||||
if (is_array($form['popup']['custom_search_vocabulary_' . $voc->vid]['#options']) && array_key_exists('c-all', $form['popup']['custom_search_vocabulary_' . $voc->vid]['#options'])) {
|
||||
$form['popup']['custom_search_vocabulary_' . $voc->vid]['#options']['c-all'] = i18nstrings('custom_search:vocabulary:' . $voc->vid . ':' . $delta . 'selector_all', variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$form['custom_search_vocabulary_' . $voc->vid]['#title'] = i18nstrings('custom_search:vocabulary:' . $voc->vid . ':' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_label', $voc->name));
|
||||
if (is_array($form['custom_search_vocabulary_' . $voc->vid]['#options']) && array_key_exists('c-all', $form['custom_search_vocabulary_' . $voc->vid]['#options'])) {
|
||||
$form['custom_search_vocabulary_' . $voc->vid]['#options']['c-all'] = i18nstrings('custom_search:vocabulary:' . $voc->vid . ':' . $delta . 'selector_all', variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Translate terms
|
||||
if (module_exists('i18ntaxonomy')) {
|
||||
foreach ($vocabularies as $voc) {
|
||||
if ((!empty($form['custom_search_vocabulary_' . $voc->vid]) && is_array($form['custom_search_vocabulary_' . $voc->vid]['#options'])) || (!empty($form['popup']['custom_search_vocabulary_' . $voc->vid]) && is_array($form['popup']['custom_search_vocabulary_' . $voc->vid]['#options']))) {
|
||||
if (variable_get('custom_search_' . $delta . 'taxonomy'. $voc->vid . '_region', 'block') == 'popup') {
|
||||
foreach ($form['popup']['custom_search_vocabulary_' . $voc->vid]['#options'] as $tid => $name) {
|
||||
if ($tid != 'c-all') {
|
||||
$real_tid = substr($tid, 2);
|
||||
$translated_term = i18nstrings('taxonomy:term:' . $real_tid . ':name', $name);
|
||||
$form['popup']['custom_search_vocabulary_' . $voc->vid]['#options'][$tid] = ($translated_term[0] != '-') ? str_repeat('-', _custom_search_i18n_term_depth($real_tid)) . ' ' . $translated_term : $translated_term ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($form['custom_search_vocabulary_' . $voc->vid]['#options'] as $tid => $name) {
|
||||
if ($tid != 'c-all') {
|
||||
$real_tid = substr($tid, 2);
|
||||
$translated_term = i18nstrings('taxonomy:term:' . $real_tid . ':name', $name);
|
||||
$form['custom_search_vocabulary_' . $voc->vid]['#options'][$tid] = ($translated_term[0] != '-') ? str_repeat('-', _custom_search_i18n_term_depth($real_tid)) . ' ' . $translated_term : $translated_term ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Custom Paths
|
||||
if ((!empty($form['custom_search_paths']) && is_array($form['custom_search_paths'])) || (!empty($form['popup']['custom_search_paths']) && is_array($form['popup']['custom_search_paths']))) {
|
||||
if (variable_get('custom_search_' . $delta . 'custom_paths_region', 'block') == 'popup') {
|
||||
$form['popup']['custom_search_paths']['#title'] = i18nstrings('custom_search:paths:1:' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'paths_selector_label', CUSTOM_SEARCH_PATHS_SELECTOR_LABEL_DEFAULT));
|
||||
}
|
||||
else {
|
||||
$form['custom_search_paths']['#title'] = i18nstrings('custom_search:paths:1:' . $delta . 'selector_label', variable_get('custom_search_' . $delta . 'paths_selector_label', CUSTOM_SEARCH_PATHS_SELECTOR_LABEL_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'custom_search_admin': $form['#submit'][] = 'custom_search_i18n_admin_submit'; break;
|
||||
case 'custom_search_content_admin': $form['#submit'][] = 'custom_search_i18n_content_admin_submit'; break;
|
||||
case 'custom_search_taxonomy_admin': $form['#submit'][] = 'custom_search_i18n_taxonomy_admin_submit'; break;
|
||||
case 'custom_search_results_admin': $form['#submit'][] = 'custom_search_i18n_results_admin_submit'; break;
|
||||
case 'block_admin_configure': $form['#submit'][] = 'custom_search_i18n_block_admin_configure_submit'; break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function custom_search_i18n_preprocess_search_results(&$variables) {
|
||||
if (user_access('use custom search') && variable_get('custom_search_filter', 'disabled') != 'disabled') {
|
||||
$variables['filter-title'] = i18nstrings('custom_search:filter:1:label', variable_get('custom_search_filter_label', CUSTOM_SEARCH_FILTER_LABEL_DEFAULT));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callbacks for updating translations.
|
||||
*/
|
||||
function custom_search_i18n_admin_submit($form, &$form_state) {
|
||||
i18nstrings_update('custom_search:common:1:label', $form_state['values']['custom_search_label']);
|
||||
i18nstrings_update('custom_search:common:1:text', $form_state['values']['custom_search_text']);
|
||||
i18nstrings_update('custom_search:common:1:submit_text', $form_state['values']['custom_search_submit_text']);
|
||||
i18nstrings_update('custom_search:criterion:1:or_label', $form_state['values']['custom_search_criteria_or_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:phrase_label', $form_state['values']['custom_search_criteria_phrase_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:negative_label', $form_state['values']['custom_search_criteria_negative_label']);
|
||||
i18nstrings_update('custom_search:paths:1:selector_label', $form_state['values']['custom_search_paths_selector_label']);
|
||||
}
|
||||
|
||||
function custom_search_i18n_content_admin_submit($form, &$form_state) {
|
||||
i18nstrings_update('custom_search:content_types:1:selector_label', $form_state['values']['custom_search_type_selector_label']);
|
||||
i18nstrings_update('custom_search:content_types:1:selector_all', $form_state['values']['custom_search_type_selector_all']);
|
||||
}
|
||||
|
||||
function custom_search_i18n_taxonomy_admin_submit($form, &$form_state) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':selector_label', $form_state['values']['custom_search_voc' . $voc->vid . '_selector_label']);
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':selector_all', $form_state['values']['custom_search_voc' . $voc->vid . '_selector_all']);
|
||||
}
|
||||
}
|
||||
|
||||
function custom_search_i18n_results_admin_submit($form, &$form_state) {
|
||||
i18nstrings_update('custom_search:filter:1:label', $form_state['values']['custom_search_filter_label']);
|
||||
}
|
||||
|
||||
function custom_search_i18n_block_admin_configure_submit($form, &$form_state) {
|
||||
$delta = $form_state['values']['delta'];
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $delta . '_label', $form_state['values']['custom_search_blocks_' . $delta . '_label']);
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $delta . '_text', $form_state['values']['custom_search_blocks_' . $delta . '_text']);
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $delta . '_submit_text', $form_state['values']['custom_search_blocks_' . $delta . '_submit_text']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $delta . '_or_label', $form_state['values']['custom_search_blocks_' . $delta . '_criteria_or_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $delta . '_phrase_label', $form_state['values']['custom_search_blocks_' . $delta . '_criteria_phrase_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $delta . '_negative_label', $form_state['values']['custom_search_blocks_' . $delta . '_criteria_negative_label']);
|
||||
i18nstrings_update('custom_search:content_types:1:blocks_' . $delta . '_selector_label', $form_state['values']['custom_search_blocks_' . $delta . '_type_selector_label']);
|
||||
i18nstrings_update('custom_search:content_types:1:blocks_' . $delta . '_selector_all', $form_state['values']['custom_search_blocks_' . $delta . '_type_selector_all']);
|
||||
i18nstrings_update('custom_search:paths:1:blocks_' . $delta . '_selector_label', $form_state['values']['custom_search_blocks_' . $delta . '_paths_selector_label']);
|
||||
if (module_exists('custom_search_taxonomy')) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':blocks_' . $delta . '_selector_label', $form_state['values']['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label']);
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':blocks_' . $delta . '_selector_all', $form_state['values']['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_all']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_locale().
|
||||
*/
|
||||
function custom_search_i18n_locale($op = 'groups', $group = NULL) {
|
||||
switch ($op) {
|
||||
case 'groups':
|
||||
return array('custom_search' => t('Custom Search'));
|
||||
break;
|
||||
case 'info':
|
||||
$info['custom_search']['refresh callback'] = 'custom_search_i18n_locale_refresh';
|
||||
return $info;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function custom_search_i18n_locale_refresh() {
|
||||
i18nstrings_update('custom_search:common:1:label', variable_get('custom_search_label', CUSTOM_SEARCH_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:common:1:text', variable_get('custom_search_text', ''));
|
||||
i18nstrings_update('custom_search:common:1:submit_text', variable_get('custom_search_submit_text', CUSTOM_SEARCH_SUBMIT_TEXT_DEFAULT));
|
||||
i18nstrings_update('custom_search:content_types:1:selector_label', variable_get('custom_search_type_selector_label', CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:content_types:1:selector_all', variable_get('custom_search_type_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
i18nstrings_update('custom_search:paths:1:selector_label', variable_get('custom_search_paths_selector_label', CUSTOM_SEARCH_PATHS_SELECTOR_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:criterion:1:or_label', variable_get('custom_search_criteria_or_label', CUSTOM_SEARCH_CRITERIA_OR_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:criterion:1:phrase_label', variable_get('custom_search_criteria_phrase_label', CUSTOM_SEARCH_CRITERIA_PHRASE_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:criterion:1:negative_label', variable_get('custom_search_criteria_negative_label', CUSTOM_SEARCH_CRITERIA_NEGATIVE_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:filter:1:label', variable_get('custom_search_filter_label', CUSTOM_SEARCH_FILTER_LABEL_DEFAULT));
|
||||
if (module_exists('custom_search_taxonomy')) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':selector_label', variable_get('custom_search_voc' . $voc->vid . '_selector_label', $voc->name));
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':selector_all', variable_get('custom_search_voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
if (module_exists('custom_search_blocks')) {
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':blocks_' . $a . '_selector_label', variable_get('custom_search_blocks_' . $a . '_voc' . $voc->vid . '_selector_label', $voc->name));
|
||||
i18nstrings_update('custom_search:vocabulary:' . $voc->vid . ':blocks_' . $a . '_selector_all', variable_get('custom_search_blocks_' . $a . '_voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (module_exists('custom_search_blocks')) {
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $a . '_label', variable_get('custom_search_blocks_' . $a . '_label', CUSTOM_SEARCH_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $a . '_text', $form_state['values']['custom_search_blocks_' . $a . '_text']);
|
||||
i18nstrings_update('custom_search:common:1:blocks_' . $a . '_submit_text', $form_state['values']['custom_search_blocks_' . $a . '_submit_text']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $a . '_or_label', $form_state['values']['custom_search_blocks_' . $a . '_criteria_or_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $a . '_phrase_label', $form_state['values']['custom_search_blocks_' . $a . '_criteria_phrase_label']);
|
||||
i18nstrings_update('custom_search:criterion:1:blocks_' . $a . '_negative_label', $form_state['values']['custom_search_blocks_' . $a . '_criteria_negative_label']);
|
||||
i18nstrings_update('custom_search:content_types:1:blocks_' . $a . '_selector_label', variable_get('custom_search_blocks_' . $a . '_type_selector_label', CUSTOM_SEARCH_TYPE_SELECTOR_LABEL_DEFAULT));
|
||||
i18nstrings_update('custom_search:content_types:1:blocks_' . $a . '_selector_all', variable_get('custom_search_blocks_' . $a . '_type_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT));
|
||||
i18nstrings_update('custom_search:paths:1:blocks_' . $a . '_selector_label', variable_get('custom_search_blocks_' . $a . '_paths_selector_label', CUSTOM_SEARCH_PATHS_SELECTOR_LABEL_DEFAULT));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function _custom_search_i18n_term_depth($tid) {
|
||||
$limit = 99;
|
||||
$depth = 0;
|
||||
while ($parent = db_result(db_query("SELECT parent FROM {term_hierarchy} WHERE tid=%d", $tid))) {
|
||||
$depth++;
|
||||
$tid = $parent;
|
||||
if ($depth > $limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $depth;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin settings for custom search taxonomy
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_help().
|
||||
*/
|
||||
function custom_search_taxonomy_help($path, $arg) {
|
||||
switch ($path) {
|
||||
case 'admin/settings/custom_search/taxonomy':
|
||||
$output = t('Select the vocabularies to present as search options in the search block. If none is selected, no selector will be displayed.');
|
||||
break;
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
function custom_search_taxonomy_admin() {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
if (count($vocabularies)) {
|
||||
$options = array();
|
||||
foreach ($vocabularies as $voc) {
|
||||
$form[$voc->name] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => $voc->name,
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => (variable_get('custom_search_voc' . $voc->vid . '_selector', 'disabled') == 'disabled') ? TRUE : FALSE,
|
||||
);
|
||||
$form[$voc->name]['custom_search_voc' . $voc->vid . '_selector'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Selector type'),
|
||||
'#options' => array(
|
||||
'disabled' => t('Disabled'),
|
||||
'select' => t('Drop-down list'),
|
||||
'selectmultiple' => t('Drop-down list with multiple choices'),
|
||||
'radios' => t('Radio buttons'),
|
||||
'checkboxes' => t('Checkboxes'),
|
||||
),
|
||||
'#description' => t('Choose which selector type to use.'),
|
||||
'#default_value' => variable_get('custom_search_voc' . $voc->vid . '_selector', 'disabled'),
|
||||
);
|
||||
if (module_exists('hs_taxonomy')) $form[$voc->name]['custom_search_voc' . $voc->vid . '_selector']['#options']['hierarchical_select'] = t('Hierarchical selector');
|
||||
$form[$voc->name]['custom_search_voc' . $voc->vid . '_selector_depth'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Depth'),
|
||||
'#size' => 2,
|
||||
'#default_value' => variable_get('custom_search_voc' . $voc->vid . '_selector_depth', 0),
|
||||
'#description' => t('Define the maximum depth of terms being displayed. The default value is "0" which disables the limit.'),
|
||||
);
|
||||
$form[$voc->name]['custom_search_voc' . $voc->vid . '_selector_label_visibility'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display label'),
|
||||
'#default_value' => variable_get('custom_search_voc' . $voc->vid . '_selector_label_visibility', TRUE),
|
||||
);
|
||||
$form[$voc->name]['custom_search_voc' . $voc->vid . '_selector_label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Label text'),
|
||||
'#default_value' => variable_get('custom_search_voc' . $voc->vid . '_selector_label', $voc->name),
|
||||
'#description' => t('Enter the label text for the selector. The default value is "!default".', array('!default' => $voc->name)),
|
||||
);
|
||||
$form[$voc->name]['custom_search_voc' . $voc->vid . '_selector_all'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('-Any- text'),
|
||||
'#default_value' => variable_get('custom_search_voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT),
|
||||
'#required' => TRUE,
|
||||
'#description' => t('Enter the text for "any term" choice. The default value is "!default".', array('!default' => CUSTOM_SEARCH_ALL_TEXT_DEFAULT)),
|
||||
);
|
||||
}
|
||||
}
|
||||
return system_settings_form($form);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
name = Custom Search Taxonomy
|
||||
description = Adds taxonomy selectors to Custom Search.
|
||||
core = 6.x
|
||||
package = Custom Search
|
||||
dependencies[] = custom_search
|
||||
dependencies[] = taxonomy
|
||||
; Information added by Drupal.org packaging script on 2014-04-23
|
||||
version = "6.x-1.13"
|
||||
core = "6.x"
|
||||
project = "custom_search"
|
||||
datestamp = "1398258531"
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for the custom search module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_install().
|
||||
*/
|
||||
function custom_search_taxonomy_install() {
|
||||
db_query("UPDATE {system} SET weight = 101 WHERE name = 'custom_search_taxonomy'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_uninstall().
|
||||
*/
|
||||
function custom_search_taxonomy_uninstall() {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
variable_del('custom_search_voc' . $voc->vid . '_selector');
|
||||
variable_del('custom_search_voc' . $voc->vid . '_selector_depth');
|
||||
variable_del('custom_search_voc' . $voc->vid . '_selector_label_visibility');
|
||||
variable_del('custom_search_voc' . $voc->vid . '_selector_label');
|
||||
variable_del('custom_search_voc' . $voc->vid . '_selector_all');
|
||||
variable_del('custom_search_taxonomy' . $voc->vid . '_weight');
|
||||
variable_del('custom_search_taxonomy' . $voc->vid . '_region');
|
||||
if (module_exists('custom_search_blocks')) {
|
||||
$blocks = variable_get('custom_search_blocks_number', 1);
|
||||
for ($delta=1 ; $delta<=$blocks ; $delta++) {
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_depth');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label_visibility');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label');
|
||||
variable_del('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_all');
|
||||
variable_del('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_weight');
|
||||
variable_del('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_region');
|
||||
variable_del('custom_search_blocks_' . $delta . '_paths_terms_separator');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Bring customizations to the default search box
|
||||
*
|
||||
* Adds taxonomy options to the search form
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of hook_menu().
|
||||
*/
|
||||
function custom_search_taxonomy_menu() {
|
||||
$items['admin/settings/custom_search/taxonomy'] = array(
|
||||
'title' => 'Taxonomy',
|
||||
'description' => 'Select the vocabularies to present as search options in the search block.',
|
||||
'page arguments' => array('custom_search_taxonomy_admin'),
|
||||
'access arguments' => array('administer custom search'),
|
||||
'file' => 'custom_search_taxonomy.admin.inc',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => 2,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_form_alter().
|
||||
*/
|
||||
function custom_search_taxonomy_form_alter(&$form, $form_state, $form_id) {
|
||||
|
||||
// Filter the form_id value to identify all the custom blocks
|
||||
$form_id_processed = $form_id;
|
||||
$delta = '';
|
||||
for ($a = 1 ; $a <= variable_get('custom_search_blocks_number', 1) ; $a++) {
|
||||
if ($form_id == 'custom_search_blocks_form_' . $a) {
|
||||
$form_id_processed = 'custom_search_blocks_form';
|
||||
$delta = 'blocks_' . $a . '_';
|
||||
}
|
||||
}
|
||||
|
||||
switch ($form_id_processed) {
|
||||
|
||||
case 'search_theme_form':
|
||||
case 'search_block_form':
|
||||
case 'custom_search_blocks_form':
|
||||
|
||||
if (user_access('use custom search')) {
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
foreach ($vocabularies as $voc) {
|
||||
if (variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector', 'disabled') != 'disabled') {
|
||||
$options = array();
|
||||
$options['c-all'] = variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT);
|
||||
$vocabulary_depth = (!variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_depth', 0)) ? NULL : variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_depth', 0);
|
||||
$terms = taxonomy_get_tree($voc->vid, 0, -1, $vocabulary_depth);
|
||||
foreach ($terms as $term) {
|
||||
$options['c-' . $term->tid] = (drupal_substr(variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector', 'disabled'), 0, 6) == 'select') ? str_repeat('-', $term->depth) . ' ' . $term->name : $term->name ;
|
||||
}
|
||||
$selector_type = variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector', 'select');
|
||||
if ($selector_type == 'selectmultiple') {
|
||||
$selector_type = 'select';
|
||||
$multiple = TRUE;
|
||||
}
|
||||
else $multiple = FALSE;
|
||||
$form['custom_search_vocabulary_' . $voc->vid] = array(
|
||||
'#type' => $selector_type,
|
||||
'#multiple' => $multiple,
|
||||
'#title' => variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_label', $voc->name),
|
||||
'#options' => $options,
|
||||
'#default_value' => ($selector_type == 'checkboxes') ? array('c-all') : 'c-all',
|
||||
'#attributes' => ($selector_type != 'radios' && $selector_type != 'checkboxes') ? array('class' => 'custom-search-selector custom-search-vocabulary custom-search-vocabulary-' . $voc->vid) : array(),
|
||||
'#prefix' => ($selector_type == 'radios' || $selector_type == 'checkboxes') ? '<div class="custom-search-selector custom-search-vocabulary custom-search-vocabulary-' . $voc->vid . '">' : '',
|
||||
'#suffix' => ($selector_type == 'radios' || $selector_type == 'checkboxes') ? '</div>' : '',
|
||||
'#weight' => variable_get('custom_search_' . $delta . 'taxonomy' . $voc->vid . '_weight', 2),
|
||||
);
|
||||
|
||||
if ($selector_type == "hierarchical_select") {
|
||||
$form['custom_search_vocabulary_' . $voc->vid]['#config'] = array (
|
||||
'module' => 'hs_taxonomy',
|
||||
'params' => array('vid' => $voc->vid),
|
||||
);
|
||||
unset($form['custom_search_vocabulary_' . $voc->vid]['#options']);
|
||||
$form['#after_build'][] = 'hierarchical_select_after_build';
|
||||
}
|
||||
|
||||
if (variable_get('custom_search_' . $delta . 'taxonomy' . $voc->vid . '_region', 'block') == 'popup') {
|
||||
$form['popup']['custom_search_vocabulary_' . $voc->vid] = $form['custom_search_vocabulary_' . $voc->vid];
|
||||
unset($form['custom_search_vocabulary_' . $voc->vid]);
|
||||
}
|
||||
if (!variable_get('custom_search_' . $delta . 'voc' . $voc->vid . '_selector_label_visibility', TRUE)) $form['custom_search_vocabulary_' . $voc->vid]['#post_render'] = array('_custom_search_hide_label');
|
||||
}
|
||||
}
|
||||
|
||||
// Custom paths
|
||||
if (variable_get('custom_search_' . $delta . 'paths', '') != '') {
|
||||
$form['custom_search_paths_terms_separator'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#default_value' => variable_get('custom_search_' . $delta . 'paths_terms_separator', CUSTOM_SEARCH_PATHS_TERMS_SEPARATOR_DEFAULT),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'block_admin_configure':
|
||||
if (isset($form['module']) && $form['module']['#value'] == 'custom_search_blocks') {
|
||||
|
||||
$delta = $form['delta']['#value'];
|
||||
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
if (count($vocabularies)) {
|
||||
$form['block_settings']['taxonomy'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Taxonomy'),
|
||||
'#description' => t('Select the vocabularies to present as search options in the search block. If none is selected, no selector will be displayed.'),
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$w = 1;
|
||||
$collapsed = TRUE;
|
||||
foreach ($vocabularies as $voc) {
|
||||
// Selectors
|
||||
if (variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector', 'disabled') != 'disabled') {
|
||||
$collapsed = FALSE;
|
||||
$voc_collapsed = FALSE;
|
||||
}
|
||||
else $voc_collapsed = TRUE;
|
||||
$form['block_settings']['taxonomy'][$voc->name] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => check_plain($voc->name),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => $voc_collapsed,
|
||||
);
|
||||
$form['block_settings']['taxonomy'][$voc->name]['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Selector type'),
|
||||
'#options' => array(
|
||||
'disabled' => t('Disabled'),
|
||||
'select' => t('Drop-down list'),
|
||||
'selectmultiple' => t('Drop-down list with multiple choices'),
|
||||
'radios' => t('Radio buttons'),
|
||||
'checkboxes' => t('Checkboxes'),
|
||||
),
|
||||
'#description' => t('Choose which selector type to use.'),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector', 'disabled'),
|
||||
);
|
||||
$form['block_settings']['taxonomy'][$voc->name]['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_depth'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Depth'),
|
||||
'#size' => 2,
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_depth', 0),
|
||||
'#description' => t('Define the maximum depth of terms being displayed. The default value is "0" which disables the limit.'),
|
||||
);
|
||||
$form['block_settings']['taxonomy'][$voc->name]['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label_visibility'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Display label'),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label_visibility', TRUE),
|
||||
);
|
||||
$form['block_settings']['taxonomy'][$voc->name]['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Label text'),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_label', $voc->name),
|
||||
'#description' => t('Enter the label text for the selector. The default value is "@default".', array('@default' => $voc->name)),
|
||||
);
|
||||
$form['block_settings']['taxonomy'][$voc->name]['custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_all'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('-Any- text'),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_voc' . $voc->vid . '_selector_all', CUSTOM_SEARCH_ALL_TEXT_DEFAULT),
|
||||
'#required' => TRUE,
|
||||
'#description' => t('Enter the text for "any term" choice. The default value is "!default".', array('!default' => CUSTOM_SEARCH_ALL_TEXT_DEFAULT)),
|
||||
);
|
||||
// Ordering
|
||||
$form['block_settings']['order']['custom_search_blocks_' . $delta . '_order']['taxonomy' . $voc->vid] = array(
|
||||
'#title' => t('Taxonomy') . ': ' . $voc->name,
|
||||
'#weight' => variable_get('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_weight', $w),
|
||||
);
|
||||
$form['block_settings']['order']['custom_search_blocks_' . $delta . '_order']['taxonomy' . $voc->vid]['sort'] = array(
|
||||
'#type' => 'weight',
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_weight', $w),
|
||||
'#attributes' => array('class' => 'sort-select sort-select-' . variable_get('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_region', 'block')),
|
||||
);
|
||||
$form['block_settings']['order']['custom_search_blocks_' . $delta . '_order']['taxonomy' . $voc->vid]['region'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'block' => t('Block'),
|
||||
'popup' => t('Popup')
|
||||
),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_region', 'block'),
|
||||
'#attributes' => array('class' => 'region-select region-select-' . variable_get('custom_search_blocks_' . $delta . '_taxonomy' . $voc->vid . '_region', 'block')),
|
||||
);
|
||||
$w++;
|
||||
}
|
||||
$form['block_settings']['taxonomy']['#collapsed'] = $collapsed;
|
||||
}
|
||||
|
||||
$form['block_settings']['custom_search_paths_admin']['custom_search_blocks_' . $delta . '_paths']['#description'] = t('If you want to use custom search paths, enter them here in the form <em>path</em>|<em>label</em>, one per line (if only one path is specified, the selector will be hidden). The [key] token will be replaced by what is entered in the search box, and the [terms] token will be replaced by the selected taxonomy term id(s). Ie: mysearch/[key]/[terms]|My custom search label.');
|
||||
$form['block_settings']['custom_search_paths_admin']['custom_search_blocks_' . $delta . '_paths_terms_separator'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Taxonomy terms separator'),
|
||||
'#default_value' => variable_get('custom_search_blocks_' . $delta . '_paths_terms_separator', CUSTOM_SEARCH_PATHS_TERMS_SEPARATOR_DEFAULT),
|
||||
'#size' => 2
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'custom_search_admin':
|
||||
$vocabularies = taxonomy_get_vocabularies();
|
||||
$w = 1;
|
||||
foreach ($vocabularies as $voc) {
|
||||
$form['order']['custom_search_order']['taxonomy' . $voc->vid] = array(
|
||||
'#title' => t('Taxonomy') . ': ' . check_plain($voc->name),
|
||||
'#weight' => variable_get('custom_search_taxonomy' . $voc->vid . '_weight', $w),
|
||||
);
|
||||
$form['order']['custom_search_order']['taxonomy' . $voc->vid]['sort'] = array(
|
||||
'#type' => 'weight',
|
||||
'#default_value' => variable_get('custom_search_taxonomy' . $voc->vid . '_weight', $w),
|
||||
'#attributes' => array('class' => 'sort-select sort-select-' . variable_get('custom_search_taxonomy' . $voc->vid . '_region', 'block')),
|
||||
);
|
||||
$form['order']['custom_search_order']['taxonomy' . $voc->vid]['region'] = array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'block' => t('Block'),
|
||||
'popup' => t('Popup')
|
||||
),
|
||||
'#default_value' => variable_get('custom_search_taxonomy' . $voc->vid . '_region', 'block'),
|
||||
'#attributes' => array('class' => 'region-select region-select-' . variable_get('custom_search_taxonomy' . $voc->vid . '_region', 'block')),
|
||||
);
|
||||
$w++;
|
||||
}
|
||||
$form['custom_search_paths_admin']['custom_search_paths']['#description'] = t('If you want to use custom search paths, enter them here in the form <em>path</em>|<em>label</em>, one per line (if only one path is specified, the selector will be hidden). The [key] token will be replaced by what is entered in the search box, and the [terms] token will be replaced by the selected taxonomy term id(s). Ie: mysearch/[key]/[terms]|My custom search label.');
|
||||
$form['custom_search_paths_admin']['custom_search_paths_terms_separator'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Taxonomy terms separator'),
|
||||
'#default_value' => variable_get('custom_search_paths_terms_separator', CUSTOM_SEARCH_PATHS_TERMS_SEPARATOR_DEFAULT),
|
||||
'#size' => 2
|
||||
);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue