Exemplo n.º 1
0
 /**
  * Serialize a condition object into a query string.
  *
  * @param   object  $cond   Services_HyperEstraier_Condition
  *                          which is a condition object.
  * @param   int     $depth  Depth of meta search
  * @param   int     $wwidth Whole width of a snippet
  * @param   int     $hwidth Width of strings picked up from the beginning of the text
  * @param   int     $awidth Width of strings picked up around each highlighted word
  * @return  string  The serialized string.
  * @access  public
  * @static
  * @ignore
  */
 public static function conditionToQuery(Services_HyperEstraier_Condition $cond, $depth, $wwidth, $hwidth, $awidth)
 {
     $query = '';
     if ($phrase = $cond->getPhrase()) {
         $query .= '&phrase=' . urlencode($phrase);
     }
     if ($attrs = $cond->getAttributes()) {
         $i = 0;
         foreach ($attrs as $attr) {
             $query .= '&attr' . strval(++$i) . '=' . urlencode($attr);
         }
     }
     if (strlen($order = $cond->getOrder()) > 0) {
         $query .= '&order=' . urlencode($order);
     }
     $query .= '&max=' . strval(($max = $cond->getMax()) >= 0 ? $max : 1 << 30);
     if (($options = $cond->getOptions()) > 0) {
         $query .= '&options=' . strval($options);
     }
     $query .= '&auxiliary=' . strval($cond->getAuxiliary());
     if (strlen($distinct = $cond->getDistinct()) > 0) {
         $query .= '&distinct=' . urlencode($distinct);
     }
     if ($depth > 0) {
         $query .= '&depth=' . strval($depth);
     }
     $query .= '&wwidth=' . strval($wwidth);
     $query .= '&hwidth=' . strval($hwidth);
     $query .= '&awidth=' . strval($awidth);
     $query .= '&skip=' . strval($cond->getSkip());
     $query .= '&mask=' . strval($cond->getMask());
     return substr($query, 1);
 }