security update core+modules

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-26 18:38:56 +02:00
parent 2f45ea820a
commit 7c96373038
1022 changed files with 30319 additions and 11259 deletions

View File

@@ -12,29 +12,22 @@
*
* To return:
* the complete search path
*
*/
function _custom_search_apachesolr_search($variables) {
// Set default path in case the core search page path isn't set yet.
$path = 'search/apachesolr_search';
$solr_info = apachesolr_search_page_load('core_search');
if (isset($solr_info['search_path'])) {
// Use the configured Solr search path instead of default path.
$path = $solr_info['search_path'];
}
$type = $path . '/' . $variables['keywords'];
function _custom_search_apachesolr_search($variables, &$keys, $fields) {
// Use the search info for the apachesolr module to get the search path.
$solr_info = apachesolr_search_search_info();
$type = 'search/' . $solr_info['path'] . '/' . $variables['keywords'];
$keys = array();
if (count($variables['types']) && !in_array('all', $variables['types'])) {
foreach ($variables['types'] as $t) {
$keys['f[' . count($keys) . ']'] = 'bundle:' . $t;
$keys['fq[' . count($keys) . ']'] = 'bundle:' . $t;
}
}
if (module_exists('taxonomy') && count($variables['terms'])) {
// get all fields info to get correct filter names
$fields = field_info_fields();
// Get all fields info to get correct filter names.
$taxonomy_fields = array();
foreach ($fields as $name => $settings) {
if ($settings['type'] == 'taxonomy_term_reference') {
@@ -42,12 +35,19 @@ function _custom_search_apachesolr_search($variables) {
$taxonomy_fields[$voc->vid] = $name;
}
}
// build keys for taxonomy
// Build keys for taxonomy.
foreach ($variables['terms'] as $t) {
$vocid = taxonomy_term_load($t)->vid;
$keys['f[' . count($keys) . ']'] = 'im_' . $taxonomy_fields[$vocid] . ':' . $t;
$keys['fq[' . count($keys) . ']'] = 'im_' . $taxonomy_fields[$vocid] . ':' . $t;
}
}
foreach (module_implements('custom_search_apachesolr_processing') as $module) {
$function = $module . '_custom_search_apachesolr_processing';
if (function_exists($function)) {
call_user_func_array($function, array(&$keys, $fields, $variables['other']));
}
}
return array('path' => $type, 'query' => $keys);
}
}

View File

@@ -8,7 +8,9 @@
* Default admin form.
*/
function _custom_search_default_admin_form($delta = '') {
if ($delta != '') $delta = 'blocks_' . $delta . '_';
if ($delta != '') {
$delta = 'blocks_' . $delta . '_';
}
// Labels & default text.
$form['search_box'] = array(
@@ -33,10 +35,28 @@ function _custom_search_default_admin_form($delta = '') {
);
$form['search_box']['custom_search_' . $delta . 'text'] = array(
'#type' => 'textfield',
'#title' => t('Search box default text'),
'#title' => t('Search box placeholder text'),
'#default_value' => variable_get('custom_search_' . $delta . 'text', ''),
'#description' => t('This will change the default text inside the search form. Leave blank for no text. This field is blank by default.'),
'#description' => t('This will change the default text inside the search form. This is the <a href="http://www.w3schools.com/tags/att_input_placeholder.asp" target="_blank">placeholder</a> attribute for the TextField. Leave blank for no text. This field is blank by default.'),
);
$form['search_box']['custom_search_' . $delta . 'hint_text'] = array(
'#type' => 'textfield',
'#title' => t('Search box hint text'),
'#default_value' => variable_get('custom_search_' . $delta . 'hint_text', CUSTOM_SEARCH_HINT_TEXT_DEFAULT),
'#description' => t('Enter the text that will be displayed when hovering the input field (HTML <em>title</em> attritube).'),
);
if (module_exists('elements')) {
$form['search_box']['custom_search_' . $delta . 'element'] = array(
'#type' => 'select',
'#title' => t('Search box input type'),
'#options' => array(
'textfield' => 'text',
'searchfield' => 'search (HTML5)',
),
'#default_value' => variable_get('custom_search_' . $delta . 'element', 'textfield'),
'#description' => t('The default value is "text".'),
);
}
$form['search_box']['custom_search_' . $delta . 'size'] = array(
'#type' => 'textfield',
'#title' => t('Search box size'),
@@ -73,7 +93,7 @@ function _custom_search_default_admin_form($delta = '') {
$form['submit_button']['custom_search_image'] = array(
'#type' => 'file',
'#title' => t('Submit image'),
'#description' => t('If you don\'t have direct file access to the server, use this field to upload your image.'),
'#description' => t("If you don't have direct file access to the server, use this field to upload your image."),
);
// Criteria.
@@ -144,11 +164,10 @@ function _custom_search_default_admin_form($delta = '') {
),
);
if (module_exists('search_api_page')) {
$search_api_pages = search_api_page_load_multiple();
$options[0] = t('None');
foreach($search_api_pages as $page) {
foreach ($search_api_pages as $page) {
$options[$page->id] = $page->name;
}
$form['searchapi'] = array(
@@ -172,12 +191,14 @@ function _custom_search_default_admin_form($delta = '') {
* Content admin form.
*/
function _custom_search_content_admin_form($delta = '') {
if ($delta != '') $delta = 'blocks_' . $delta . '_';
if ($delta != '') {
$delta = 'blocks_' . $delta . '_';
}
$form['content_selector'] = array(
'#type' => 'fieldset',
'#title' => t('Content selector'),
'#description' => t('Select the search types to present as search options in the search block. If none is selected, no selector will be displayed. <strong>Note</strong>: if there\'s only one type checked, the selector won\'t be displayed BUT only this type will be searched.'),
'#description' => t("Select the search types to present as search options in the search block. If none is selected, no selector will be displayed. <strong>Note</strong>: if there's only one type checked, the selector won't be displayed BUT only this type will be searched."),
);
$form['content_selector']['custom_search_' . $delta . 'node_types'] = array(
'#type' => 'checkboxes',
@@ -255,7 +276,7 @@ function _custom_search_content_admin_form($delta = '') {
$form['custom_search_' . $delta . 'node_types_excluded'] = array(
'#type' => 'checkboxes',
'#title' => t('Content exclusion'),
'#description' => t('Select the content types you don\'t want to be displayed as results.'),
'#description' => t("Select the content types you don't want to be displayed as results.<br/><strong>Notice</strong>: content exclusion only works with the core Search module."),
'#default_value' => variable_get('custom_search_' . $delta . 'node_types_excluded', array()),
'#options' => node_type_get_names(),
);
@@ -267,7 +288,9 @@ function _custom_search_content_admin_form($delta = '') {
* Custom paths admin form.
*/
function _custom_search_custom_paths_admin_form($delta = '') {
if ($delta != '') $delta = 'blocks_' . $delta . '_';
if ($delta != '') {
$delta = 'blocks_' . $delta . '_';
}
$form['custom_search_paths_admin'] = array(
'#type' => 'fieldset',
'#title' => t('Custom search paths'),
@@ -300,18 +323,20 @@ function _custom_search_custom_paths_admin_form($delta = '') {
'#title' => t('Paths'),
'#default_value' => variable_get('custom_search_' . $delta . 'paths', ''),
'#rows' => 3,
'#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. Ie: mysearch/[key]|My custom search label.'),
'#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. Ie: mysearch/[key]|My custom search label. The [current_path] token can be used to use the current URL path of the page beeing viewed.'),
);
return $form;
}
/**
* Ordering admin form
* Ordering admin form.
*/
function _custom_search_ordering_admin_form($delta = '') {
drupal_add_css(drupal_get_path('module', 'custom_search') . '/custom_search.css');
if ($delta != '') $delta = 'blocks_' . $delta . '_';
if ($delta != '') {
$delta = 'blocks_' . $delta . '_';
}
$form['order'] = array(
'#type' => 'fieldset',
'#title' => t('Elements ordering'),
@@ -330,8 +355,9 @@ function _custom_search_ordering_admin_form($delta = '') {
'custom_paths' => array('title' => t('Custom search paths'), 'default_weight' => 9),
'submit_button' => array('title' => t('Submit button'), 'default_weight' => 10),
);
if (count(array_filter(array_merge(variable_get('custom_search_' . $delta . 'node_types', array()), variable_get('custom_search_' . $delta . 'other', array())))))
if (count(array_filter(array_merge(variable_get('custom_search_' . $delta . 'node_types', array()), variable_get('custom_search_' . $delta . 'other', array()))))) {
$elements['content_types'] = array('title' => t('Content Types'), 'default_weight' => 0);
}
foreach ($elements as $element => $data) {
$form['order']['custom_search_' . $delta . 'order'][$element] = array(
@@ -341,17 +367,27 @@ function _custom_search_ordering_admin_form($delta = '') {
$form['order']['custom_search_' . $delta . 'order'][$element]['sort'] = array(
'#type' => 'weight',
'#default_value' => variable_get('custom_search_' . $delta . $element . '_weight', $data['default_weight']),
'#attributes' => array('class' => array('sort-select', 'sort-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'))),
'#attributes' => array(
'class' => array(
'sort-select',
'sort-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'),
),
),
);
$form['order']['custom_search_' . $delta . 'order'][$element]['region'] = array(
'#type' => 'select',
'#options' => array(
'block' => t('Block'),
'popup' => t('Popup')
'popup' => t('Popup'),
),
'#default_value' => variable_get('custom_search_' . $delta . $element . '_region', 'block'),
'#attributes' => array('class' => array('region-select', 'region-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'))),
'#attributes' => array(
'class' => array(
'region-select',
'region-select-' . variable_get('custom_search_' . $delta . $element . '_region', 'block'),
),
),
);
}
return $form;
}
}

View File

@@ -12,10 +12,9 @@
*
* To return:
* the complete search path
*
*/
function _custom_search_google_appliance_search($variables) {
$type = variable_get('google_appliance_default_search_path', 'google-appliance');
$type = variable_get('google_appliance_default_search_path', 'gsearch');
return array('path' => $type . '/' . $variables['keys'], 'query' => array());
}
}

View File

@@ -12,7 +12,6 @@
*
* To return:
* the complete search path
*
*/
function _custom_search_lucenapi_search($variables) {
@@ -20,12 +19,16 @@ function _custom_search_lucenapi_search($variables) {
$keys = array();
if (count($variables['types']) && !in_array('all', $variables['types'])) {
foreach ($variables['types'] as $t) $keys["type[$t]"] = $t;
foreach ($variables['types'] as $t) {
$keys["type[$t]"] = $t;
}
}
if (module_exists('taxonomy') && count($variables['terms'])) {
foreach ($variables['terms'] as $t) $keys["category[$t]"] = $t;
foreach ($variables['terms'] as $t) {
$keys["category[$t]"] = $t;
}
}
return array('path' => $type, 'query' => $keys);
}
}

View File

@@ -12,7 +12,6 @@
*
* To return:
* the complete search path
*
*/
function _custom_search_search_api_search($variables) {
@@ -21,11 +20,13 @@ function _custom_search_search_api_search($variables) {
$keys = array();
if (count($variables['types']) && !in_array('all', $variables['types'])) {
foreach ($variables['types'] as $key => $value) $keys["filter[type][$key]"] = "\"$value\"";
foreach ($variables['types'] as $key => $value) {
$keys["filter[type][$key]"] = "\"$value\"";
}
}
if (module_exists('taxonomy') && count($variables['terms'])) {
// Get index fields info, and keeps only the taxonomy ones
// Get index fields info, and keeps only the taxonomy ones.
$index = search_api_index_load($variables['page']->index_id);
$fields = array();
foreach ($index->options['fields'] as $field => $data) {
@@ -34,14 +35,15 @@ function _custom_search_search_api_search($variables) {
$fields[$field_info['settings']['allowed_values'][0]['vocabulary']] = $field;
}
}
// Adds terms
// Adds terms.
foreach ($variables['terms'] as $key => $value) {
$term = taxonomy_term_load($value);
if (array_key_exists($term->vocabulary_machine_name, $fields))
if (array_key_exists($term->vocabulary_machine_name, $fields)) {
$keys['filter[' . $fields[$term->vocabulary_machine_name] . '][' . $key . ']'] = "\"$value\"";
}
}
}
return array('path' => $type, 'query' => $keys);
}
}