Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
192 commits
Select commit Hold shift + click to select a range
32ce15e
ding2 -> ding2tal
ubcudvikler Aug 15, 2012
83d6383
tag -> branch
ubcudvikler Aug 27, 2012
85894f2
Updated search result to use display mode settings
cableman Sep 4, 2012
a16fd5e
Reverted changes to the make file
cableman Sep 4, 2012
499c324
Fixed merge conflict in make file
cableman Sep 4, 2012
1206d3e
Removed un-used display/view mode
cableman Sep 4, 2012
7e38989
Revert "Updated search result to use display mode settings"
cableman Sep 4, 2012
6399eb3
Updates search result pane to use ting_search_result theme function
cableman Sep 5, 2012
fc50d5f
Merge branch 'use_theme_function_for_search' into development
cableman Sep 5, 2012
b7e7a32
Bumping version to 7.x-0.26
Feb 9, 2012
8b990f2
Removed un-used display/view mode
cableman Sep 4, 2012
0a6d390
Merge pull request #3 from ding2tal/removed_unused_view_mode
kasperg Oct 2, 2012
65da42d
Removed stylesheet, nothing relevant in there and we should let the t…
zorp Jan 16, 2013
366d2ea
Change menu alter text strings into english from danish
cableman Mar 18, 2013
3988208
Fixed slash delimiter in search string, which failes inside regex quo…
cableman Mar 18, 2013
e1b6d28
Changed makefile to point to ding2 on github
cableman May 6, 2013
ac7b192
Merge pull request #5 from ding2tal/core-pr-3
kasperg Jul 3, 2013
153f4e9
Merge branch 'master' into release
cableman Jul 3, 2013
95a6b2b
Updated makefile to point to development branch and ding2tal
cableman Jul 3, 2013
38ef822
Merge branch 'release' into development
cableman Jul 3, 2013
9384102
Merge remote-tracking branch 'origin' into release
cableman Jul 3, 2013
e5d5909
Updated makefile to point to ding2tal
cableman Jul 4, 2013
77b4b1c
Merge remote-tracking branch 'origin' into release
cableman Jul 18, 2013
fd8438f
Added admin page. This enables the admin users to change the results …
jesper-b Oct 3, 2013
e795ee6
Added translation to the search result count plugin.
jesper-b Oct 4, 2013
633f3e5
Added comments and some changes to comply with coding standards
jesper-b Oct 4, 2013
bb32310
Added support for facet api intergration later on
cableman Oct 17, 2013
0c9e382
Updated comments
jesper-b Oct 25, 2013
8947b8f
Merge pull request #4 from jesper-b/B14Updates
cableman Oct 28, 2013
d16a22e
Updated coding style and move files into folder
cableman Oct 29, 2013
7e0d836
Fixed drupal static variable value, so it's not always NULL
cableman Oct 29, 2013
c3caab2
Merge branch 'b14' into development
cableman Oct 29, 2013
6fa78eb
Moved templates and js into folders
cableman Oct 29, 2013
d454b95
Removed old CVS tags from tpl files
cableman Oct 29, 2013
6b9e866
Fixed missing pages.inc file
cableman Oct 29, 2013
6803fe0
Added spinner to search form
cableman Oct 29, 2013
eea404d
Fixed search spinner on in all pages
cableman Oct 29, 2013
22e21c5
Added panels pane to show search backends as links
cableman Oct 29, 2013
2de1f8e
Changed backend links into radio input fields and added JS to handle …
cableman Oct 30, 2013
c9c4996
Added fieldset around backend search engines
cableman Oct 30, 2013
f310693
Removed 2 times t() functions
cableman Oct 30, 2013
d967bca
Updated coding style
cableman Nov 1, 2013
b30b570
Ensured that the search result is render fist, so static varibles wil…
cableman Nov 1, 2013
47d3444
Fixed results per page
cableman Nov 1, 2013
f9410e1
Added new plugin to handle "records per page"
cableman Nov 4, 2013
71c8b77
Merge remote-tracking branch 'origin' into release
cableman Nov 4, 2013
b21baa2
Updated makefile to point to tag 7.x-1.0-beta2
cableman Nov 4, 2013
ba0e36c
Added JS to handle results per page drop down
cableman Nov 5, 2013
4f4f047
Change records per page to use submit function
cableman Nov 5, 2013
5115a54
Moved sort search selector label and desciption into the field
cableman Nov 5, 2013
074acc5
Added helper message with large search results
cableman Nov 5, 2013
4e6c107
Added page title with result count panels plugin
cableman Nov 5, 2013
39ff75f
Merge branch 'search-ui-rewritten' into development
cableman Nov 5, 2013
4dbaf4b
Ensured that click event is trigger after spinner class is added
cableman Nov 5, 2013
9f2994c
Removed warning class from search count message
cableman Nov 5, 2013
a57f060
Added missing "." to search result default message
cableman Nov 5, 2013
a7363ee
Fixed debug info and classes
cableman Nov 5, 2013
8aa2c53
Added the new overlay for search
cableman Nov 6, 2013
0945fab
Removed #token false in sort forms as it throws errors if user is not…
cableman Nov 6, 2013
3349df3
Removed Acquisition date form sort order as it do not work corretly
cableman Nov 6, 2013
5e67f17
Fixed administration form with right input types
cableman Nov 7, 2013
f8fa93b
Fixed default value in admin ui
cableman Nov 7, 2013
88f3659
Added static search variable to ensure search is only executed once
cableman Nov 8, 2013
7eef676
Merge remote-tracking branch 'origin' into release
cableman Nov 25, 2013
52f8426
Updated makefile to point to tag 7.x-1.0-beta3
cableman Nov 26, 2013
b111b28
Fixed typo in theme array in search count plugin
cableman Nov 27, 2013
1531420
Added better support for search overlay on search result page
cableman Nov 29, 2013
800b1c3
Added the search overlay javascript file
cableman Nov 29, 2013
27da021
Added ting series setting from ting module
cableman Dec 5, 2013
9022365
Fixed undefined index errors if no search results are found
cableman Dec 5, 2013
4d31f04
Added a litte better search overlay
cableman Dec 10, 2013
9815ca3
Change close to cancel in search overlay
cableman Dec 10, 2013
389989b
Merge remote-tracking branch 'origin' into release
cableman Dec 12, 2013
395018a
Updated makefile to point to tag 7.x-1.0-beta4
cableman Dec 12, 2013
dc14057
Updated makefile to point to tag 7.x-1.0-beta5
cableman Dec 18, 2013
93dcd0c
Removed event trigger that made the event trigger it self
cableman Dec 18, 2013
aee4932
Merge branch 'development' into release
cableman Dec 18, 2013
6cb2ee8
Changed max lenght on the search input field
cableman Dec 19, 2013
aca0003
Merge remote-tracking branch 'origin' into release
cableman Dec 20, 2013
28c63ee
Updated makefile to point to tag 7.x-1.0-rc1
cableman Dec 20, 2013
42e7d68
Updated makefile to point to tag 7.x-1.0-rc2
cableman Jan 8, 2014
0056e2e
Override normal auto-complete submit behavior
cableman Jan 17, 2014
e447f5c
Merge branch 'development' into release
cableman Jan 20, 2014
0308e47
Updated makefile to point to tag 7.x-1.0-rc3
cableman Jan 20, 2014
a975b63
Updated makefile to point to ding2 master branches
cableman Feb 3, 2014
4b5293a
Fixed variable name in administration forms default value
cableman Feb 25, 2014
6c6e539
Updated ting series search registry default value
cableman Feb 28, 2014
5c6885a
Added unload event to remove search overlay, so it is not display whe…
cableman Mar 19, 2014
3325404
Fixed so overlay is not toggled on unload, but removed
cableman Mar 19, 2014
473c0c8
Updated default series register search string
cableman Mar 26, 2014
abfc241
Issue #372 cableman: Fixed search executed twice on search form submit
cableman May 15, 2014
1ef3588
Updated description in admin UI
cableman Jun 3, 2014
76bcf07
Updated comment in admin UI
cableman Jun 3, 2014
33fb821
Updated toggle class logic in JS search spinner
cableman Jun 3, 2014
cf01519
Updated toggle class logic in JS search spinner
cableman Jun 3, 2014
b56447d
Added comment to backends javascript
cableman Jun 3, 2014
fb94f52
Added comment to backends javascript
cableman Jun 3, 2014
4a92b1e
Renamed the input parameter to search overlay function
cableman Jun 3, 2014
0e0a8d0
Renamed the input parameter to search overlay function
cableman Jun 3, 2014
77bd5f6
Removed not need empty check in panels plugin
cableman Jun 3, 2014
2313515
Removed not need empty check in panels plugin
cableman Jun 3, 2014
0a0a8b9
Prefixed function with module name
cableman Jun 3, 2014
b479533
Prefixed function with module name
cableman Jun 3, 2014
6d476d2
Fixed usage of Q to current_path
cableman Jun 3, 2014
6b0b3b1
Fixed usage of Q to current_path
cableman Jun 3, 2014
5698396
Fixed usage of Q to current_path
cableman Jun 3, 2014
49008af
Fixed usage of Q to current_path
cableman Jun 3, 2014
4684d91
Removed requirement for search module to exists
cableman Jun 3, 2014
61e1014
Removed requirement for search module to exists
cableman Jun 3, 2014
a17b50d
Added missing t function to default value in admin ui
cableman Jun 3, 2014
1c04709
Added missing t function to default value in admin ui
cableman Jun 3, 2014
a12cde8
Fixed formatted plural in search-result_page
Jun 3, 2014
11b8ce4
Merge branch 'development' of github.com:ding2tal/ting_search into de…
Jun 3, 2014
f698a6d
Fixed formatted plural in search-result_page
Jun 3, 2014
aefd3bc
Added better comment regarding -result->more
Jun 3, 2014
0b8cc9c
Added better comment regarding -result->more
Jun 3, 2014
b247515
Renamed forms
Jun 3, 2014
6174233
Renamed forms
Jun 3, 2014
34a5c19
Added count to data attribute
Aug 19, 2014
94b2a4d
Fixed indexes for advanced search
cableman Aug 19, 2014
dd82808
Merge branch 'development' of github.com:ding2tal/ting_search into de…
cableman Aug 19, 2014
04006c3
Reviewed: Updated comment about search spinner overlay in JS
cableman Oct 22, 2014
919a777
Reviewed: Updated link in search backends to use l() function
cableman Oct 22, 2014
5030c56
Reviewed: Added extra comment about search input field length
cableman Oct 22, 2014
6e08a3c
Reviewed: Removed un-used class from pr-page form
cableman Oct 22, 2014
aa9f508
Reviewed: Updated comment about search spinner overlay in JS
cableman Oct 22, 2014
364daa8
Reviewed: Updated link in search backends to use l() function
cableman Oct 22, 2014
7180da2
Reviewed: Added extra comment about search input field length
cableman Oct 22, 2014
75b89eb
Reviewed: Removed un-used class from pr-page form
cableman Oct 22, 2014
a619dd8
Merge pull request #6 from ding2tal/core-pr-4
kasperg Nov 5, 2014
3dbe82a
Issue 635 by Pjohans: make whole phrase translatable
pjohans Nov 7, 2014
16eb54c
Merge pull request #7 from pjohans/Issue635
cableman Nov 14, 2014
fb50ad4
Resolved merge conflict with ding2 core
cableman Nov 17, 2014
bb728b9
Updated make file to match ding2 core
cableman Nov 17, 2014
2ab052e
Merge pull request #8 from ding2tal/core-pr-5
kasperg Nov 19, 2014
ac75f30
Issue 467 by Pjohans: make string strict cql for well 3.2
pjohans Nov 19, 2014
b3cf5cd
Issue 467 by Pjohans: additional comments on parameters
pjohans Jan 14, 2015
524abc9
Merge remote-tracking branch 'upstream/master' into Issue467
pjohans Feb 24, 2015
1a2dcf0
Issue 467 by Pjohans: maintain qouted phrases in searchstring"
pjohans Feb 24, 2015
6885b60
Merge pull request #9 from pjohans/Issue467
vibjerg Feb 24, 2015
adba180
case 4312 - Dont make overlay appear if new window.
guddo Jul 31, 2014
b47f88f
DDBEASY-251 - Dont make overlay appear if CTRL is clicked.
guddo Dec 5, 2014
0db1624
Issue #815 by JrgenGNielsen: Translate-function on search result limi…
JrgenGNielsen Mar 25, 2015
ca7b6da
remove ting_scan_url and ting_spell_url
JrgenGNielsen Mar 26, 2015
5980d33
Issue1113 by pjohans: show sort method in searchresult
pjohans Apr 10, 2015
8157b28
Make search form cachable
xendk Apr 17, 2015
85ba44c
Issue #815 by JrgenGNielsen: lowercase array()
JrgenGNielsen Apr 21, 2015
6a128c4
Issue #815 by JrgenGNielsen: redo ting_search_result_message as item …
JrgenGNielsen Apr 24, 2015
b50ce91
Merge pull request #16 from JrgenGNielsen/feature/bug815-search_resul…
kasperg Apr 27, 2015
02e6679
Issue429 by Pjohans: Class that makes an attempt to handle non strict…
pjohans Jun 8, 2015
b548475
Issue429 by Pjohans: Use a class to handle non strict cql
pjohans Jun 8, 2015
4474882
Issue429 by pjohans: newline
pjohans Jun 9, 2015
b51c8da
Issue429 by pjohans: remove dpm
pjohans Jun 9, 2015
2187fc3
Issue429 by pjohans: enable character escapes disabled for testpurpose
pjohans Jun 9, 2015
cf45b49
Merge pull request #17 from pjohans/Issue1113
kasperg Jun 9, 2015
b5f3890
Merge pull request #18 from JrgenGNielsen/feature/feature257-opensugg…
kasperg Jun 11, 2015
b63bd40
Issue #429 by pjohans: Changes due to review.
pjohans Jun 12, 2015
15697d1
Issue #429 by pjohans: changes due to review
pjohans Jun 12, 2015
cd1a0bd
Issue #429 by pjohans: changes due to review
pjohans Jun 17, 2015
c905a3a
Merge pull request #21 from pjohans/Issue429
cableman Jun 17, 2015
f0f6e20
Revert "Issue1113 by pjohans: show sort method in searchresult"
kasperg Jun 24, 2015
4af11cb
Merge pull request #22 from ding2/revert-17-Issue1113
kasperg Jun 24, 2015
c29d87b
Revert "Revert "Issue1113 by pjohans: show sort method in searchresult""
kasperg Jun 24, 2015
83c82ba
Revert "remove ting_scan_url and ting_spell_url"
kasperg Jun 24, 2015
9844a7a
Merge pull request #24 from ding2/revert-18-feature/feature257-opensu…
kasperg Jun 24, 2015
601e2cb
Revert "Revert "remove ting_scan_url and ting_spell_url""
kasperg Jun 24, 2015
300deb9
Merge pull request #25 from ding2/revert-24-revert-18-feature/feature…
kasperg Jul 8, 2015
0ac77b6
Merge pull request #23 from ding2/revert-22-revert-17-Issue1113
kasperg Jul 8, 2015
2989829
Bug #1324 by Pjohans: Make regular expression case insensitive to han…
pjohans Aug 10, 2015
b16dcc7
Issue 1215 by Pjohans: Some searches failed. Do thngs in the right or…
pjohans Aug 10, 2015
2b46704
This commit belong to another issue
pjohans Aug 12, 2015
8e2ae2f
Merge pull request #27 from pjohans/master
kasperg Aug 12, 2015
002f70d
Issue732 by Pjohans: Make input field in search form longer(1024)
pjohans Aug 14, 2015
e87310e
Issue 1324 by Pjohans: Fix the regexp for content between qoutes and …
pjohans Aug 31, 2015
ccfbac8
Issue 1324 by Pjohans: Handle nested qoutes and paranthesis
pjohans Sep 1, 2015
8b85a0f
Issue 1324 by Pjohans: Comments the right way
pjohans Sep 7, 2015
ad8dc92
Merge pull request #29 from pjohans/Issue1324
cableman Sep 7, 2015
244fc1e
DDBEASY-251 - Make it work on OSX too.
guddo Sep 10, 2015
8468f73
Issue 1324 by Pjohans: Updated test to use cqldoctor
pjohans Sep 11, 2015
94168d6
Issue 1324 by Pjohans: initialize variables to avoid warnings
pjohans Sep 11, 2015
37b97e1
Issue 1324 by Pjohans: Update test to use cql-doctor
pjohans Sep 11, 2015
2a80911
Issue 1324 by Pjohans: Moved test to folder
pjohans Sep 11, 2015
1d3b43b
Merge pull request #30 from pjohans/Issue1324
cableman Sep 14, 2015
3f391c3
Issue #1395 by xendk: Fix parsing of search string.
xendk Oct 2, 2015
ae823b8
Issue 1373+1400 by Pjohans: Fix cql doctor to handle rec.id + add to …
pjohans Oct 20, 2015
4cf89c6
Issue 1373+1400 by Pjohans: Added unit test for new cql
pjohans Oct 20, 2015
b611227
Merge pull request #33 from kasperg/1373-1400-fix-search-pid-cql
cableman Oct 20, 2015
0c33ff0
Merge pull request #20 from xendk/patch-1
cableman Oct 28, 2015
0a2d481
Merge pull request #13 from easyddb/DDBEASY-251
cableman Oct 28, 2015
02dbb4f
Merge pull request #15 from easyddb/DDBEASY-97
cableman Oct 28, 2015
53e5be1
Merge pull request #32 from xendk/parsing-fixes
cableman Nov 13, 2015
d531434
Merge pull request #28 from pjohans/Issue732
cableman Nov 25, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
282 changes: 282 additions & 0 deletions includes/TingSearchCqlDoctor.class.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,282 @@
<?php

/**
* @file
*
* File holds class to convert not valid searchphrases to valid cql.
* Private membet cql_string holds an internal reprensation of the original search string. All parts of the string
* is examined to check for healthy cql.
*
* Enqouted parts of the string stays the same. Parantheses are enqouted if content is not healthy. Blanks are
* replaced by 'and'. Mulitple whitespaces are removed. Reserved characters are enqouted.
*
* Examples not valid:
* portland (film) => portland and (film)
* henning mortensen (f. 1939) => henning and mortensen and "(f. 1939)"
* harry and (White night) = harry and "(White night)"
*
*
* Valid cql stays the same eg.
* dkcclterm.sf=v and dkcclterm.uu=nt and (term.type=bog) not term.literaryForm=fiktion
*/

/**
* Class TingSearchCqlDoctor.
*
* An attempt to convert non cql search phrases to valid cql.
*/
class TingSearchCqlDoctor {

/**
* @var string cql_string.
* Internael representation of the searchphtrase.
*/
private $cql_string;
/**
* @var array pattern.
* The pattern to replace in searchstring.
*/
private $pattern = array();
/**
* @var array replace.
* The string to replace with.
*/
private $replace=array();
/**
* @var int replace_key.
* Used to prepend key - @see $this->get_replace_key().
*/
private static $replace_key = 10;

/**
* Constructor,Escape reserved characters, remove multiple whitespaces
* and sets private member $cql_string with trimmed string.
*
* @param string $string
* The search phrase to cure.
*/
public function __construct($string) {
$this->cql_string = trim($string);
// Remove multiple whitespaces.
$this->cql_string = preg_replace('/\s+/', ' ', $this->cql_string);
}

/**
* Method to convert a string to strict cql.
*
* Basically this method adds quotes when needed.
*
* @param string $string
* The search query.
* @return string
* Cql compatible string.
*/
public function string_to_cql() {

// Handle qoutes.
$this->fix_qoutes();
// Hendle parantheses.
$this->fix_paranthesis();
// Handle reserved characters.
$this->escape_reserved_characters();
// Format the string.
return $this->format_cql_string();
}

/**
* Format cql string.
*
* Use private members $pattern and $replace to replace not valid cql phrases with valid.
*
* @return string
* string in valid cql (hopefully)
*
*/
private function format_cql_string() {
// Last check. All parts of cql string must be valid.
$valid = TRUE;
$parts = preg_split($this->get_cql_operators_regexp(), $this->cql_string);
foreach ($parts as $part) {
if (!$this->string_is_cql($part)) {
$valid = FALSE;
break;
}
}
// Explode string by whitespace.
$expressions = explode(' ', $this->cql_string);

// Replace keys with phrases,
if (!empty($this->pattern)) {
$expressions = preg_replace($this->pattern, $this->replace, $expressions);
}

$done = FALSE;
do {
$expressions = $this->replace_inline($expressions, $done);
}
while(!$done);

// Remove empty elements.
$empty_slots = array_keys($expressions,'');
foreach($empty_slots as $slot){
unset($expressions[$slot]);
}

if ($valid) {
// Implode by blank.
return implode(' ', $expressions);
}

// String is not valid; implode by and.
return implode(' and ', $expressions);
}


/**
* Some replacements are nested in paranthesis and/or qoutes
* eg. (hund and "("hest")") which is perfectly legal.
* Cql doctor first handles the qoutes and then the
* paranthesis ; thus (hund and "("hest")") becomes encoded multiple times.
* This method runs through all parts to fix it
*
* @param array $expressions;
* The parts of the searchquery to be cured.
* @param $done;
* Flag indicating whether all parts has been handled.
* @return array;
* Decoded expressions.
*/
private function replace_inline($expressions, &$done) {
foreach ($expressions as $key_exp => $expression) {
foreach ($this->pattern as $key_pat => $regexp) {
if (preg_match($regexp, $expression)) {
$expressions[$key_exp] = preg_replace($regexp, $this->replace[$key_pat], $expression);
return $expressions;
}
}
}
$done = TRUE;
return $expressions;
}


/**
* Enqoute forward slashes and '-'.
*
* @return nothing
* Alters private member cql_string.
*/
private function escape_reserved_characters() {
$this->cql_string = str_replace('/', ' "/" ', $this->cql_string);
}

/**
* Get a key for replacement in string.
*
* @return string
*/
private function get_replace_key() {
$key_prefix = 'zxcv';
return $key_prefix . self::$replace_key++;
}

/**
* Handle parantheses.
*
* Look lace parantheses in string. If any found and content is not
* strict cql; enqoute the lot.
*
* @return nothing.
* Alters private member cql_string.
*
*/
private function fix_paranthesis() {
//Grab content in paranthesis.
preg_match_all('$\(([^\(\)]*)\)$', $this->cql_string, $phrases);

if (empty($phrases[1])) {
// No matching paranthesis.
return;
}

foreach ($phrases[1] as $key => $phrase) {
if (!$this->string_is_cql($phrase)) {
$this->set_replace_pattern($phrases[0][$key], TRUE);
}
else{
$this->set_replace_pattern($phrase);
}
}
}

/**
* Handle qoutes.
*
* Look for qouted content. Qouted content is replaced in searchstring.
*/
private function fix_qoutes() {
// Greab qouted content.
preg_match_all('$"([^"]*)"$', $this->cql_string, $phrases);
;
if (!empty($phrases[0])) {
foreach ($phrases[0] as $phrase) {
$this->set_replace_pattern($phrase);
}
}
}

/**
* Helper function to set a single replacement key and phrase.
*
* Adds given phrase to private member $replace. Retrieve a key for the replacement and replace given phrase in
* internal representation of search string with the key.
*
* @param string $phrase.
* The phrase to add to private member $replace.
* @param bool $qoute_me.
* If TRUE phrase is enqouted.
* @return nothing
* Alters private member cql_string
*/
private function set_replace_pattern($phrase, $qoute_me = FALSE) {
if ($qoute_me) {
$this->replace[] = '"' . $phrase . '"';
}
else {
$this->replace[] = $phrase;
}
$replace_key = $this->get_replace_key();
$this->pattern[] = '/' . $replace_key . '/';

$this->cql_string = str_replace($phrase, $replace_key, $this->cql_string);
}


/**
* Tests if a string is cql.
*
* If string contains a cql operator it is assumed that an attempt to write cql is done.
*
* @param string $string
* The search query
* @return bool|int
* Whether the string is valid cql(TRUE) or not(FALSE)
*/
private function string_is_cql($string) {
// Single word is valid (no whitespaces).
if (strpos(trim($string), ' ') === FALSE) {
return TRUE;
}
return preg_match($this->get_cql_operators_regexp(), $string);
}

/**
* Get reqular expression to ideniify cql operators.
*
* @return string.
* Reqular expression to identify cql operators.
*/
private function get_cql_operators_regexp() {
return '@ and | any | all | adj | or | not |=|\(|\)@i';
}
}
79 changes: 79 additions & 0 deletions includes/ting_search.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?php
/**
* @file
* Admin page callback file for the ting search module.
*/

/**
* Configure ting search settings for this site.
*
* @ingroup forms
* @see system_settings_form()
*/
function ting_search_admin_settings($form_state) {
$form = array();

$display_message = 'Your search gave more than %s results. Try to search more specific or use the facets to filter the result.';

$form['ting_search'] = array(
'#type' => 'fieldset',
'#title' => t('Ting search settings'),
'#tree' => FALSE,
);

// Set ting search results per page. Used on the ting search page to determine
// the initial amount of search results to display.
$form['ting_search']['ting_search_results_per_page'] = array(
'#type' => 'textfield',
'#title' => t('Default results per page'),
'#description' => t('Enter the number of results desplayed on the search page by default.'),
'#default_value' => variable_get('ting_search_results_per_page', 10),
);

// Set ting search number of facets. Used on the ting search page to determine
// how many facets to display in the facet browser.
$form['ting_search']['ting_search_number_of_facets'] = array(
'#type' => 'textfield',
'#title' => t('Number of facets'),
'#description' => t('Enter the number of facets the search engine should show.'),
'#default_value' => variable_get('ting_search_number_of_facets', 25),
);

$form['ting_search']['ting_search_register_serie_title'] = array(
'#type' => 'textfield',
'#title' => t('Serie title'),
'#description' => t('Specify the searchstring to be used for searching against serie titles. Use @serietitle as a placeholder for the serietitle'),
'#default_value' => variable_get('ting_search_register_serie_title', 'phrase.titleSeries="@serietitle"'),
);

// The default sort option. Used by ting search execute to set the default
// sort option.
$form['ting_search']['ting_search_default_sort'] = array(
'#type' => 'select',
'#title' => t('Default sorting'),
'#options' => ting_search_sort_options(),
'#default_value' => variable_get('ting_search_default_sort', ''),
'#description' => t('Set the default sorting for search results.'),
);

$form['ting_search']['ting_search_result_message'] = array(
'#type' => 'item',
'#attributes' => array('class' => array('description')),
'#title' => t('Display message'),
'#markup' => t($display_message),
'#description' => t('Message to display when search has more than x results. The token %s will be substituted by the number choosen.'),
);

if ( t($display_message) != $display_message ) {
$form['ting_search']['ting_search_result_message']['#description'] .= '<br/>' . t('Translated from: %n.', array('%n' => $display_message));
}

$form['ting_search']['ting_search_result_message_limit'] = array(
'#type' => 'textfield',
'#title' => t('Display message at'),
'#default_value' => variable_get('ting_search_result_message_limit', 100),
'#description' => t('The limit at wich the message is to be displayed.'),
);

return system_settings_form($form);
}
Loading