MediaSearch_Search
[ class tree: MediaSearch_Search ] [ index: MediaSearch_Search ] [ all elements ]

Source for file Query.php

Documentation is available at Query.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     MediaSearch_Search
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.   * @todo Write apidoc.
  23.   *
  24.   * @category   MediaSearch
  25.   * @package    MediaSearch_Search
  26.   * @copyright  Copyright (c) 2009 Sven Strittmatter
  27.   */
  28.     const TRACE_LELVEL 52;
  29.     
  30.     const ALLOWED_QUOTE     '"';
  31.     const DISALLOWED_QUOTE  "'";
  32.  
  33.     private $queryString;
  34.     private $preparedQuery;
  35.     
  36.     public function __construct($string{
  37.         $this->queryString trim($string);
  38.     }
  39.  
  40.     public function get({
  41.         if (!$this->isEmpty(&& null === $this->preparedQuery{
  42.             $this->preparedQuery $this->prepareQuery($this->queryString);
  43.         }
  44.  
  45.         return $this->preparedQuery;
  46.     }
  47.  
  48.     public function isEmpty({
  49.         return (strlen($this->queryString=== 0);
  50.     }
  51.     
  52.     private function prepareQuery($string{
  53.         $preparedQuery $this->split($string);
  54.  
  55.         return $preparedQuery;
  56.     }
  57.  
  58.  
  59.  
  60.     /*private function removeBadChars($string) {
  61.         return $string;
  62.     }
  63.  
  64.     private function replaceQuotes($string) {
  65.         return str_replace(self::DISALLOWED_QUOTE, self::ALLOWED_QUOTE, $string);
  66.     }
  67.  
  68.     private function hasQuotetParts($string) {
  69.         return (false === strpos(self::ALLOWED_QUOTE, $string) ? false : true);
  70.     }
  71.  
  72.     private function splitByQuotes($string) {
  73.  
  74.     }*/
  75.  
  76.     private function split($string{
  77.         $return  array();
  78.         $pattern '/[\s,._\-\/]+/';
  79.         
  80.         return preg_split($pattern$string-1PREG_SPLIT_NO_EMPTY);
  81.     }
  82. }

Documentation generated on Mon, 17 Aug 2009 14:53:46 +0200 by phpDocumentor 1.4.2