Public Member Functions | |
| ilQueryParser ($a_query_str) | |
| Constructor public. | |
| 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 | |
| $query_str | |
| $quoted_words = array() | |
| $message | |
| $combination | |
Definition at line 35 of file class.ilQueryParser.php.
| ilQueryParser::__parseQuotation | ( | ) |
Definition at line 155 of file class.ilQueryParser.php.
References $query_str, getQueryString(), and ilUtil::prepareDBString().
Referenced by parse().
{
if(!strlen($this->getQueryString()))
{
return false;
}
$query_str = $this->getQueryString();
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 68 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 81 of file class.ilQueryParser.php.
Referenced by getLuceneQueryString().
{
return $this->combination;
}
Here is the caller graph for this function:| ilQueryParser::getLuceneQueryString | ( | ) |
Definition at line 111 of file class.ilQueryParser.php.
References $counter, 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 64 of file class.ilQueryParser.php.
Referenced by appendMessage(), and validate().
{
return $this->message;
}
Here is the caller graph for this function:| ilQueryParser::getQueryString | ( | ) |
Definition at line 86 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 95 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 90 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 49 of file class.ilQueryParser.php.
References $lng.
{
global $lng;
$this->lng =& $lng;
$this->query_str = $a_query_str;
$this->message = '';
}
| ilQueryParser::parse | ( | ) |
Definition at line 124 of file class.ilQueryParser.php.
References __parseQuotation(), 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)) < 3)
{
$this->setMessage($this->lng->txt('search_minimum_three'));
continue;
}
$this->words[] = ilUtil::prepareDBString($word);
}
// 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 77 of file class.ilQueryParser.php.
{
$this->combination = $a_combination;
}
| ilQueryParser::setMessage | ( | $ | a_msg | ) |
Definition at line 60 of file class.ilQueryParser.php.
Referenced by parse(), and validate().
{
$this->message = $a_msg;
}
Here is the caller graph for this function:| ilQueryParser::validate | ( | ) |
Definition at line 180 of file class.ilQueryParser.php.
References getMessage(), getWords(), and setMessage().
{
// Words with less than 3 characters
if(strlen($this->getMessage()))
{
return false;
}
// No search string given
if(!count($this->getWords()))
{
$this->setMessage($this->lng->txt('msg_no_search_string'));
return false;
}
return true;
}
Here is the call graph for this function:| ilQueryParser::$combination |
Definition at line 43 of file class.ilQueryParser.php.
| ilQueryParser::$lng = null |
Definition at line 37 of file class.ilQueryParser.php.
Referenced by ilQueryParser().
| ilQueryParser::$message |
Definition at line 42 of file class.ilQueryParser.php.
| ilQueryParser::$query_str |
Definition at line 40 of file class.ilQueryParser.php.
Referenced by __parseQuotation().
| ilQueryParser::$quoted_words = array() |
Definition at line 41 of file class.ilQueryParser.php.
1.7.1