Esempio n. 1
0
	/** 
	 * Filters by "keywords" (which searches everything including filenames, title, tags, users who uploaded the file, tags)
	 */
	public function filterByKeywords($keywords, $simple = false) {
		$db = Loader::db();
		$kw = $db->quote($keywords);
		$qk = $db->quote('%' . $keywords . '%');
		Loader::model('attribute/categories/collection');		
		$keys = CollectionAttributeKey::getSearchableIndexedList();
		$attribsStr = '';
		foreach ($keys as $ak) {
			$cnt = $ak->getController();			
			$attribsStr.=' OR ' . $cnt->searchKeywords($keywords);
		}

		if ($simple || $this->indexModeSimple) { // $this->indexModeSimple is set by the IndexedPageList class
			$this->filter(false, "(psi.cName like $qk or psi.cDescription like $qk or psi.content like $qk {$attribsStr})");		
		} else {
			$this->indexedSearch = true;
			$this->indexedKeywords = $keywords;
			$this->autoSortColumns[] = 'cIndexScore';
			$this->filter(false, "((match(psi.cName, psi.cDescription, psi.content) against ({$kw})) {$attribsStr})");
		}
	}
Esempio n. 2
0
 /**
  * Filters keyword fields by keywords (including name, description, content, and attributes.
  *
  * @param $keywords
  */
 public function filterByKeywords($keywords)
 {
     $expressions = array($this->query->expr()->like('psi.cName', ':keywords'), $this->query->expr()->like('psi.cDescription', ':keywords'), $this->query->expr()->like('psi.content', ':keywords'));
     $keys = \CollectionAttributeKey::getSearchableIndexedList();
     foreach ($keys as $ak) {
         $cnt = $ak->getController();
         $expressions[] = $cnt->searchKeywords($keywords, $this->query);
     }
     $expr = $this->query->expr();
     $this->query->andWhere(call_user_func_array(array($expr, 'orX'), $expressions));
     $this->query->setParameter('keywords', '%' . $keywords . '%');
 }