protected function searchPhotos() { $keywords = $this->ui->getWidget('search_keywords')->value; $this->join_clause = ''; $this->order_by_clause = 'PinholePhoto.publish_date desc, PinholePhoto.photo_date asc, PinholePhoto.id'; if (trim($keywords) != '') { $query = new NateGoSearchQuery($this->app->db); $query->addDocumentType('photo'); $query->addBlockedWords(NateGoSearchQuery::getDefaultBlockedWords()); $result = $query->query($keywords); $type = NateGoSearch::getDocumentType($this->app->db, 'photo'); $this->join_clause = sprintf('inner join %1$s on %1$s.document_id = PinholePhoto.id and %1$s.unique_id = %2$s and %1$s.document_type = %3$s', $result->getResultTable(), $this->app->db->quote($result->getUniqueId(), 'text'), $this->app->db->quote($type, 'integer')); $this->order_by_clause = sprintf('%1$s.displayorder1, %1$s.displayorder2, %2$s', $result->getResultTable(), $this->order_by_clause); } }
/** * Gets the SQL join clauses for this search tag * * If the NateGoSearch feature is enabled, this returns a unique join * statement for the given keyword search results. * * @return array an array of join clauses used by this search tag. */ public function getJoinClauses() { // Ensure joined NateGoSearchResult table is unique even if we have // multiple keyword search tags. static $results_table_id = 1; switch ($this->name) { case 'keywords': $join_clauses = parent::getJoinClauses(); if ($this->value !== null && $this->getPhotoSearchType() !== null) { $query = new NateGoSearchQuery($this->db); $query->addDocumentType($this->getPhotoSearchType()); $query->addBlockedWords(NateGoSearchQuery::getDefaultBlockedWords()); $result = $query->query($this->value); $type = NateGoSearch::getDocumentType($this->db, 'photo'); $join_clauses[] = sprintf('inner join %1$s as %4$s on %4$s.document_id = PinholePhoto.id and %4$s.unique_id = %2$s and %4$s.document_type = %3$s', $result->getResultTable(), $this->db->quote($result->getUniqueId(), 'text'), $this->db->quote($type, 'integer'), $result->getResultTable() . $results_table_id); } $results_table_id++; break; default: $join_clauses = parent::getJoinClauses(); break; } return $join_clauses; }