ds_search.admin.inc

  1. cis7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  2. cle7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  3. ecd7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  4. elmsmedia7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  5. harmony7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  6. icor7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
  8. mooc7 sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc

Administrative functions for Display Suite search.

Functions

Namesort descending Description
ds_search_settings Menu callback: Display Suite search settings.
ds_search_settings_submit Submit callback: Search settings submit.
theme_ds_search_group_by_type_settings Returns HTML for the Group by type settings.

File

sites/all/modules/ulmus/ds/modules/ds_search/includes/ds_search.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Administrative functions for Display Suite search.
  5. */
  6. /**
  7. * Menu callback: Display Suite search settings.
  8. */
  9. function ds_search_settings($form, $form_state) {
  10. $form['general'] = array(
  11. '#type' => 'fieldset',
  12. '#title' => t('General'),
  13. );
  14. $engine_options = array();
  15. foreach (module_implements('search_info') as $module) {
  16. if ($module != 'ds_search' && $module != 'user') {
  17. $engine_options[$module] = drupal_ucfirst(str_replace('_', ' ', $module));
  18. }
  19. }
  20. $form['general']['ds_search_type'] = array(
  21. '#type' => 'select',
  22. '#title' => t('Search engine'),
  23. '#description' => t('Select the search engine as the query backend.'),
  24. '#options' => $engine_options,
  25. '#default_value' => variable_get('ds_search_type', 'node'),
  26. );
  27. $form['general']['ds_search_path'] = array(
  28. '#type' => 'textfield',
  29. '#title' => t('Search path'),
  30. '#field_prefix' => 'search/',
  31. '#description' => t('Make sure you don\'t override an existing search path.'),
  32. '#default_value' => variable_get('ds_search_path', 'content'),
  33. '#required' => TRUE,
  34. );
  35. $entity_view_modes = ds_entity_view_modes('node');
  36. foreach ($entity_view_modes as $key => $view_mode) {
  37. $view_mode_options[$key] = $view_mode['label'];
  38. }
  39. $form['general']['ds_search_view_mode'] = array(
  40. '#type' => 'select',
  41. '#title' => t('View mode'),
  42. '#description' => 'Select another view mode in favor of the default search view mode.',
  43. '#default_value' => variable_get('ds_search_view_mode', 'search_result'),
  44. '#options' => $view_mode_options,
  45. );
  46. $form['general']['ds_search_file_render'] = array(
  47. '#type' => 'checkbox',
  48. '#title' => t('Use default search theming for files'),
  49. '#description' => t('File/attachment results are best supported when the file entity module is enabled. Toggle the checkbox in case it is not available or you want to use default search theming.'),
  50. '#default_value' => variable_get('ds_search_file_render', FALSE),
  51. );
  52. $form['general']['ds_search_variables'] = array(
  53. '#type' => 'radios',
  54. '#options' => array(
  55. 'none' => t('None'),
  56. 'search_totals' => t('Total results'),
  57. 'search_totals_plus_keywords' => t('Total results + keywords'),
  58. 'search_totals_from_to_end' => t('Totals + start to end')
  59. ),
  60. '#title' => t('Extra variables'),
  61. '#description' => t('Choose an extra variable to display on the results screen.'),
  62. '#default_value' => variable_get('ds_search_variables', 'none'),
  63. );
  64. $form['general']['ds_search_show_title'] = array(
  65. '#type' => 'checkbox',
  66. '#title' => t('Show title'),
  67. '#description' => t('Display the "Search results" title.'),
  68. '#default_value' => variable_get('ds_search_show_title'),
  69. );
  70. $form['general']['ds_search_language'] = array(
  71. '#type' => 'checkbox',
  72. '#title' => t('Language'),
  73. '#description' => t('Search in the language the site is currently in. Enable this if you have at least 2 languages.'),
  74. '#default_value' => variable_get('ds_search_language'),
  75. );
  76. $form['general']['ds_search_highlight'] = array(
  77. '#type' => 'checkbox',
  78. '#title' => t('Highlight search word'),
  79. '#description' => t('Use jQuery to highlight the word in the results.'),
  80. '#default_value' => variable_get('ds_search_highlight'),
  81. );
  82. $form['general']['ds_search_highlight_selector'] = array(
  83. '#type' => 'textfield',
  84. '#title' => t('HTML selector'),
  85. '#description' => t('Enter the css selector, if not sure, leave this by default.'),
  86. '#default_value' => variable_get('ds_search_highlight_selector', '.view-mode-search_result'),
  87. '#states' => array(
  88. 'visible' => array(
  89. 'input[name="ds_search_highlight"]' => array('checked' => TRUE),
  90. ),
  91. ),
  92. );
  93. $form['general']['ds_search_group_by_type'] = array(
  94. '#type' => 'checkbox',
  95. '#title' => t('Group by type.'),
  96. '#description' => t('Group the search results per page by type. Note that this only works if you only display nodes on the search result page.'),
  97. '#default_value' => variable_get('ds_search_group_by_type'),
  98. );
  99. // Group by type order.
  100. $form['ds_search_group_by_type_settings'] = array(
  101. '#type' => 'fieldset',
  102. '#title' => t('Group by type settings'),
  103. '#description' => t('Set the order of the node types which can be grouped. Node types which are not enabled will be showed into a "Other group". Note that this does not work with Apache Solr multisite support.'),
  104. '#theme' => 'ds_search_group_by_type_settings',
  105. '#states' => array(
  106. 'visible' => array(
  107. 'input[name="ds_search_group_by_type"]' => array('checked' => TRUE),
  108. ),
  109. ),
  110. );
  111. $node_types = node_type_get_names();
  112. $ds_search_group_by_type_settings = variable_get('ds_search_group_by_type_settings');
  113. foreach ($node_types as $name => $label) {
  114. $form['ds_search_group_by_type_settings'][$name]['name'] = array(
  115. '#markup' => check_plain($label),
  116. );
  117. $form['ds_search_group_by_type_settings'][$name]['status'] = array(
  118. '#type' => 'checkbox',
  119. '#title' => t('Weight for @title', array('@title' => $label)),
  120. '#title_display' => 'invisible',
  121. '#default_value' => isset($ds_search_group_by_type_settings[$name]) ? $ds_search_group_by_type_settings[$name]['status'] : TRUE,
  122. '#parents' => array('ds_search_group_by_type_settings', $name, 'status'),
  123. );
  124. $form['ds_search_group_by_type_settings'][$name]['label'] = array(
  125. '#type' => 'textfield',
  126. '#size' => 30,
  127. '#title' => t('Group label for @title', array('@title' => $label)),
  128. '#title_display' => 'invisible',
  129. '#description' => t('Group label. The label will be translatable. Leave empty for no label.'),
  130. '#default_value' => isset($ds_search_group_by_type_settings[$name]) ? $ds_search_group_by_type_settings[$name]['label'] : t('Results for @type', array('@type' => drupal_strtolower($node_types[$name]))),
  131. '#parents' => array('ds_search_group_by_type_settings', $name, 'label'),
  132. );
  133. $wrapper_options = array(
  134. 'fieldset' => t('Fieldset'),
  135. 'markup' => t('Div with H3 headline'),
  136. );
  137. $form['ds_search_group_by_type_settings'][$name]['wrapper'] = array(
  138. '#type' => 'select',
  139. '#options' => $wrapper_options,
  140. '#title' => t('Wrapper for @title', array('@title' => $label)),
  141. '#title_display' => 'invisible',
  142. '#default_value' => isset($ds_search_group_by_type_settings[$name]) ? $ds_search_group_by_type_settings[$name]['wrapper'] : 'fieldset',
  143. '#parents' => array('ds_search_group_by_type_settings', $name, 'wrapper'),
  144. );
  145. $weight = isset($ds_search_group_by_type_settings[$name]) ? $ds_search_group_by_type_settings[$name]['weight'] : 0;
  146. $form['ds_search_group_by_type_settings'][$name]['weight'] = array(
  147. '#type' => 'weight',
  148. '#title' => t('Weight for @title', array('@title' => $label)),
  149. '#title_display' => 'invisible',
  150. '#delta' => 30,
  151. '#default_value' => $weight,
  152. '#parents' => array('ds_search_group_by_type_settings', $name, 'weight'),
  153. );
  154. $form['ds_search_group_by_type_settings'][$name]['#weight'] = $weight;
  155. }
  156. $form['ds_search_group_by_type_settings']['ds_search_group_by_type_other'] = array(
  157. '#type' => 'textfield',
  158. '#title' => t('Other label'),
  159. '#description' => t('The label of the other group. Leave empty for no label.'),
  160. '#default_value' => variable_get('ds_search_group_by_type_other', 'Other'),
  161. '#states' => array(
  162. 'visible' => array(
  163. 'input[name="ds_search_group_by_type"]' => array('checked' => TRUE),
  164. ),
  165. ),
  166. );
  167. $form['ds_search_group_by_type_settings']['ds_search_group_by_type_other_wrapper'] = array(
  168. '#type' => 'select',
  169. '#options' => $wrapper_options,
  170. '#title' => t('Other wrapper'),
  171. '#description' => t('The wrapper of the other group.'),
  172. '#default_value' => variable_get('ds_search_group_by_type_other_wrapper', 'fieldset'),
  173. '#states' => array(
  174. 'visible' => array(
  175. 'input[name="ds_search_group_by_type"]' => array('checked' => TRUE),
  176. ),
  177. ),
  178. );
  179. $form['node'] = array(
  180. '#type' => 'fieldset',
  181. '#title' => t('Drupal core'),
  182. '#states' => array(
  183. 'visible' => array(
  184. 'select[name="ds_search_type"]' => array('value' => 'node'),
  185. ),
  186. ),
  187. );
  188. $form['node']['ds_search_node_form_alter'] = array(
  189. '#type' => 'checkbox',
  190. '#title' => t('Advanced'),
  191. '#description' => t('Enable the advanced search form.'),
  192. '#default_value' => variable_get('ds_search_node_form_alter'),
  193. );
  194. $form['node']['ds_search_node_limit'] = array(
  195. '#type' => 'textfield',
  196. '#default_value' => variable_get('ds_search_node_limit', 10),
  197. '#title' => t('Node search limit'),
  198. '#description' => t('The number of items to display per page. Enter 0 for no limit.'),
  199. );
  200. if (module_exists('apachesolr')) {
  201. $form['apachesolr_search'] = array(
  202. '#type' => 'fieldset',
  203. '#title' => t('Apache Solr'),
  204. '#states' => array(
  205. 'visible' => array(
  206. 'select[name="ds_search_type"]' => array('value' => 'apachesolr_search'),
  207. ),
  208. ),
  209. );
  210. $form['apachesolr_search']['ds_search_apachesolr_hide_current_filters'] = array(
  211. '#type' => 'checkbox',
  212. '#title' => t('Hide Retain filters'),
  213. '#description' => t('Hide the "Retain current filters" checkbox on search results.'),
  214. '#default_value' => variable_get('ds_search_apachesolr_hide_current_filters'),
  215. );
  216. $form['apachesolr_search']['ds_search_apachesolr_current_filters_default'] = array(
  217. '#type' => 'checkbox',
  218. '#title' => t('Remember filters'),
  219. '#description' => t('Remember the filters when you hide the "Retain current filters" checkbox.'),
  220. '#default_value' => variable_get('ds_search_apachesolr_current_filters_default'),
  221. '#states' => array(
  222. 'visible' => array(
  223. 'input[name="ds_search_apachesolr_hide_current_filters"]' => array('checked' => TRUE),
  224. ),
  225. ),
  226. );
  227. $form['apachesolr_search']['ds_search_apachesolr_multisite'] = array(
  228. '#type' => 'checkbox',
  229. '#title' => t('Multisite support'),
  230. '#description' => t('Enable this in case multiple sites share one index. Note that sometimes you need to make sure that your formatters are creating absolute paths for links or images. Implementing hook_url_outbound_alter() is a good option in which you can set $options[\'absolute\'] to TRUE.'),
  231. '#default_value' => variable_get('ds_search_apachesolr_multisite'),
  232. );
  233. $form['apachesolr_search']['ds_search_apachesolr_multisite_boost'] = array(
  234. '#type' => 'checkbox',
  235. '#title' => t('Sort by site'),
  236. '#description' => t('Enable this to rank the results of the current site first, than all the rest.'),
  237. '#default_value' => variable_get('ds_search_apachesolr_multisite_boost'),
  238. '#states' => array(
  239. 'visible' => array(
  240. 'input[name="ds_search_apachesolr_multisite"]' => array('checked' => TRUE),
  241. ),
  242. ),
  243. );
  244. $form['apachesolr_search']['ds_search_apachesolr_multisite_group'] = array(
  245. '#type' => 'checkbox',
  246. '#title' => t('Group results by site'),
  247. '#default_value' => variable_get('ds_search_apachesolr_multisite_group'),
  248. '#states' => array(
  249. 'visible' => array(
  250. 'input[name="ds_search_apachesolr_multisite"]' => array('checked' => TRUE),
  251. ),
  252. ),
  253. );
  254. $form['apachesolr_search']['ds_search_apachesolr_multisite_group_config'] = array(
  255. '#type' => 'textarea',
  256. '#title' => t('Group by site configuration'),
  257. '#default_value' => variable_get('ds_search_apachesolr_multisite_group_config'),
  258. '#description' => t('Enter sites line by line with following configuration: site-hash|label|wrapper. The <em>site-hash</em> is per site which you can get from Solr. The <em>label</em> is translatable per site. Use !total_per_site in this label for number of results per site. Depending on the number, you will either get "1 result" or "x results" which are translatable. The <em>wrapper</em> can either be "fieldset" or "div".'),
  259. '#states' => array(
  260. 'visible' => array(
  261. 'input[name="ds_search_apachesolr_multisite_group"]' => array('checked' => TRUE),
  262. 'input[name="ds_search_apachesolr_multisite"]' => array('checked' => TRUE),
  263. ),
  264. ),
  265. );
  266. }
  267. $active = variable_get('search_active_modules', array('node', 'user'));
  268. if (isset($active['user']) && $active['user'] !== 0) {
  269. $form['user'] = array(
  270. '#type' => 'fieldset',
  271. '#title' => t('User search'),
  272. );
  273. $form['user']['ds_user_override_search_page'] = array(
  274. '#type' => 'checkbox',
  275. '#title' => t('Override user search page'),
  276. '#description' => t('Toggle this checkbox if you want Display Suite to render user search results.'),
  277. '#default_value' => variable_get('ds_user_override_search_page'),
  278. );
  279. }
  280. $form = system_settings_form($form);
  281. $form['#submit'][] = 'ds_search_settings_submit';
  282. return $form;
  283. }
  284. /**
  285. * Submit callback: Search settings submit.
  286. */
  287. function ds_search_settings_submit($form, $form_state) {
  288. // Rebuild the menu.
  289. variable_set('menu_rebuild_needed', TRUE);
  290. }
  291. /**
  292. * Returns HTML for the Group by type settings.
  293. */
  294. function theme_ds_search_group_by_type_settings($variables) {
  295. $element = $variables['element'];
  296. // Type order (tabledrag).
  297. $rows = array();
  298. foreach (element_children($element, TRUE) as $name) {
  299. if (!isset($element[$name]['name'])) {
  300. continue;
  301. }
  302. $element[$name]['weight']['#attributes']['class'][] = 'type-order-weight';
  303. $rows[] = array(
  304. 'data' => array(
  305. drupal_render($element[$name]['name']),
  306. drupal_render($element[$name]['status']),
  307. drupal_render($element[$name]['label']),
  308. drupal_render($element[$name]['wrapper']),
  309. drupal_render($element[$name]['weight']),
  310. ),
  311. 'class' => array('draggable'),
  312. );
  313. }
  314. $header = array(t('Type'), t('Status'), t('Group label'), t('Wrapper'), t('Weight'));
  315. $output = drupal_render_children($element);
  316. $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'group-by-order')));
  317. drupal_add_tabledrag('group-by-order', 'order', 'sibling', 'type-order-weight', NULL, NULL, TRUE);
  318. return $output;
  319. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.