ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilQueryParser Class Reference
+ Collaboration diagram for ilQueryParser:

Public Member Functions

 ilQueryParser ($a_query_str)
 Constructor public.
 setMinWordLength ($a_length, $a_force=false)
 getMinWordLength ()
 setMessage ($a_msg)
 getMessage ()
 appendMessage ($a_msg)
 setCombination ($a_combination)
 getCombination ()
 getQueryString ()
 getWords ()
 getQuotedWords ($with_quotation=false)
 getLuceneQueryString ()
 parse ()
 __parseQuotation ()
 validate ()

Data Fields

 $lng = null
 $min_word_length = 0
 $query_str
 $quoted_words = array()
 $message
 $combination

Protected Attributes

 $settings = null

Detailed Description

Definition at line 38 of file class.ilQueryParser.php.

Member Function Documentation

ilQueryParser::__parseQuotation ( )

Definition at line 195 of file class.ilQueryParser.php.

References $query_str, getQueryString(), and ilUtil\prepareDBString().

Referenced by parse().

{
if(!strlen($this->getQueryString()))
{
$this->quoted_words[] = '';
return false;
}
while(preg_match("/\".*?\"/",$query_str,$matches))
{
$query_str = str_replace($matches[0],'',$query_str);
$this->quoted_words[] = ilUtil::prepareDBString($matches[0]);
}
// Parse the rest
$words = explode(' ',trim($query_str));
foreach($words as $word)
{
if(!strlen(trim($word)))
{
continue;
}
$this->quoted_words[] = ilUtil::prepareDBString($word);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilQueryParser::appendMessage (   $a_msg)

Definition at line 101 of file class.ilQueryParser.php.

References getMessage().

{
if(strlen($this->getMessage()))
{
$this->message .= '<br />';
}
$this->message .= $a_msg;
}

+ Here is the call graph for this function:

ilQueryParser::getCombination ( )

Definition at line 114 of file class.ilQueryParser.php.

References $combination.

Referenced by getLuceneQueryString().

{
}

+ Here is the caller graph for this function:

ilQueryParser::getLuceneQueryString ( )

Definition at line 144 of file class.ilQueryParser.php.

References getCombination(), and getQuotedWords().

{
$counter = 0;
$tmp_str = "";
foreach($this->getQuotedWords(true) as $word) {
if($counter++)
{
$tmp_str .= (" ".strtoupper($this->getCombination())." ");
}
$tmp_str .= $word;
}
return $tmp_str;
}

+ Here is the call graph for this function:

ilQueryParser::getMessage ( )

Definition at line 97 of file class.ilQueryParser.php.

References $message.

Referenced by appendMessage(), and validate().

{
}

+ Here is the caller graph for this function:

ilQueryParser::getMinWordLength ( )

Definition at line 88 of file class.ilQueryParser.php.

References $min_word_length.

Referenced by parse(), and validate().

+ Here is the caller graph for this function:

ilQueryParser::getQueryString ( )

Definition at line 119 of file class.ilQueryParser.php.

Referenced by __parseQuotation(), and parse().

{
return trim($this->query_str);
}

+ Here is the caller graph for this function:

ilQueryParser::getQuotedWords (   $with_quotation = false)

Definition at line 128 of file class.ilQueryParser.php.

Referenced by getLuceneQueryString().

{
if($with_quotation)
{
return $this->quoted_words ? $this->quoted_words : array();
}
else
{
foreach($this->quoted_words as $word)
{
$tmp_word[] = str_replace('\"','',$word);
}
return $tmp_word ? $tmp_word : array();
}
}

+ Here is the caller graph for this function:

ilQueryParser::getWords ( )

Definition at line 123 of file class.ilQueryParser.php.

Referenced by validate().

{
return $this->words ? $this->words : array();
}

+ Here is the caller graph for this function:

ilQueryParser::ilQueryParser (   $a_query_str)

Constructor public.

Definition at line 55 of file class.ilQueryParser.php.

References $lng, ilSearchSettings\getInstance(), and setMinWordLength().

{
global $lng;
define(MIN_WORD_LENGTH,3);
$this->lng =& $lng;
$this->query_str = $a_query_str;
$this->message = '';
include_once './Services/Search/classes/class.ilSearchSettings.php';
$this->settings = ilSearchSettings::getInstance();
if(!$this->setMinWordLength(1))
{
$this->setMinWordLength(MIN_WORD_LENGTH);
}
}

+ Here is the call graph for this function:

ilQueryParser::parse ( )

Definition at line 157 of file class.ilQueryParser.php.

References __parseQuotation(), getMinWordLength(), getQueryString(), ilUtil\prepareDBString(), and setMessage().

{
$this->words = array();
#if(!strlen($this->getQueryString()))
#{
# return false;
#}
$words = explode(' ',trim($this->getQueryString()));
foreach($words as $word)
{
if(!strlen(trim($word)))
{
continue;
}
if(strlen(trim($word)) < $this->getMinWordLength())
{
$this->setMessage($this->lng->txt('search_minimum_three'));
continue;
}
$this->words[] = ilUtil::prepareDBString($word);
}
$fullstr = trim($this->getQueryString());
if (!in_array($fullstr, $this->words))
{
$this->words[] = ilUtil::prepareDBString($fullstr);
}
// Parse strings like && 'A "B C D" E' as 'A' && 'B C D' && 'E'
// Can be used in LIKE search or fulltext search > MYSQL 4.0
$this->__parseQuotation();
return true;
}

+ Here is the call graph for this function:

ilQueryParser::setCombination (   $a_combination)

Definition at line 110 of file class.ilQueryParser.php.

{
$this->combination = $a_combination;
}
ilQueryParser::setMessage (   $a_msg)

Definition at line 93 of file class.ilQueryParser.php.

Referenced by parse(), and validate().

{
$this->message = $a_msg;
}

+ Here is the caller graph for this function:

ilQueryParser::setMinWordLength (   $a_length,
  $a_force = false 
)

Definition at line 75 of file class.ilQueryParser.php.

References $GLOBALS.

Referenced by ilQueryParser(), ilLDAPSettingsGUI\loadRoleAssignmentRule(), ilAuthShibbolethSettingsGUI\loadRule(), and ilObjectCopyGUI\searchSource().

{
// Due to a bug in mysql fulltext search queries with min_word_legth < 3
// might freeze the system.
// Thus min_word_length cannot be set to values < 3 if the mysql fulltext is used.
if(!$a_force and $this->settings->enabledIndex() and $a_length < 3)
{
$GLOBALS['ilLog']->write(__METHOD__.': Disabled min word length');
return false;
}
$this->min_word_length = $a_length;
return true;
}

+ Here is the caller graph for this function:

ilQueryParser::validate ( )

Definition at line 222 of file class.ilQueryParser.php.

References getMessage(), getMinWordLength(), getWords(), and setMessage().

{
// Words with less than 3 characters
if(strlen($this->getMessage()))
{
return false;
}
// No search string given
if($this->getMinWordLength() and !count($this->getWords()))
{
$this->setMessage($this->lng->txt('msg_no_search_string'));
return false;
}
return true;
}

+ Here is the call graph for this function:

Field Documentation

ilQueryParser::$combination

Definition at line 48 of file class.ilQueryParser.php.

Referenced by getCombination().

ilQueryParser::$lng = null

Definition at line 40 of file class.ilQueryParser.php.

Referenced by ilQueryParser().

ilQueryParser::$message

Definition at line 47 of file class.ilQueryParser.php.

Referenced by getMessage().

ilQueryParser::$min_word_length = 0

Definition at line 42 of file class.ilQueryParser.php.

Referenced by getMinWordLength().

ilQueryParser::$query_str

Definition at line 45 of file class.ilQueryParser.php.

Referenced by __parseQuotation().

ilQueryParser::$quoted_words = array()

Definition at line 46 of file class.ilQueryParser.php.

ilQueryParser::$settings = null
protected

Definition at line 49 of file class.ilQueryParser.php.


The documentation for this class was generated from the following file: