示例#1
0
 /**
  * Filter links according to parameters.
  *
  * @param string $type          Type of filter (eg. tags, permalink, etc.).
  * @param mixed  $request       Filter content.
  * @param bool   $casesensitive Optional: Perform case sensitive filter if true.
  * @param bool   $privateonly   Optional: Only returns private links if true.
  *
  * @return array filtered link list.
  */
 public function filter($type, $request, $casesensitive = false, $privateonly = false)
 {
     switch ($type) {
         case self::$FILTER_HASH:
             return $this->filterSmallHash($request);
         case self::$FILTER_TAG | self::$FILTER_TEXT:
             if (!empty($request)) {
                 $filtered = $this->links;
                 if (isset($request[0])) {
                     $filtered = $this->filterTags($request[0], $casesensitive, $privateonly);
                 }
                 if (isset($request[1])) {
                     $lf = new LinkFilter($filtered);
                     $filtered = $lf->filterFulltext($request[1], $privateonly);
                 }
                 return $filtered;
             }
             return $this->noFilter($privateonly);
         case self::$FILTER_TEXT:
             return $this->filterFulltext($request, $privateonly);
         case self::$FILTER_TAG:
             return $this->filterTags($request, $casesensitive, $privateonly);
         case self::$FILTER_DAY:
             return $this->filterDay($request);
         default:
             return $this->noFilter($privateonly);
     }
 }