Public Member Functions | Data Fields

ilQueryParser Class Reference

Public Member Functions

 ilQueryParser ($a_query_str)
 Constructor public.
 setMinWordLength ($a_length)
 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

Detailed Description

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


Member Function Documentation

ilQueryParser::__parseQuotation (  ) 

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

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

Referenced by parse().

        {
                if(!strlen($this->getQueryString()))
                {
                        $this->quoted_words[] = '';
                        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 85 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 98 of file class.ilQueryParser.php.

Referenced by getLuceneQueryString().

        {
                return $this->combination;
        }

Here is the caller graph for this function:

ilQueryParser::getLuceneQueryString (  ) 

Definition at line 128 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 81 of file class.ilQueryParser.php.

Referenced by appendMessage(), and validate().

        {
                return $this->message;
        }

Here is the caller graph for this function:

ilQueryParser::getMinWordLength (  ) 

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

Referenced by parse(), and validate().

        {
                return $this->min_word_length;
        }

Here is the caller graph for this function:

ilQueryParser::getQueryString (  ) 

Definition at line 103 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 112 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 107 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 54 of file class.ilQueryParser.php.

References $lng.

        {
                global $lng;

                define(MIN_WORD_LENGTH,3);

                $this->lng =& $lng;

                $this->query_str = $a_query_str;
                $this->message = '';

                $this->min_word_length = MIN_WORD_LENGTH;
        }

ilQueryParser::parse (  ) 

Definition at line 141 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);
                }

                // 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 94 of file class.ilQueryParser.php.

        {
                $this->combination = $a_combination;
        }

ilQueryParser::setMessage ( a_msg  ) 

Definition at line 77 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  ) 

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

        {
                $this->min_word_length = $a_length;
        }

ilQueryParser::validate (  ) 

Definition at line 198 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.

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.

ilQueryParser::$min_word_length = 0

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

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.


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