2 namespace wcf\system\search
;
3 use wcf\data\
object\type\ObjectTypeCache
;
4 use wcf\data\page\content\SearchResultPageContent
;
5 use wcf\data\page\content\SearchResultPageContentList
;
7 use wcf\system\database\util\PreparedStatementConditionBuilder
;
11 * An implementation of ISearchableObjectType for searching in cms pages.
14 * @copyright 2001-2017 WoltLab GmbH
15 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
16 * @package WoltLabSuite\Core\System\Search
19 class PageSearch
extends AbstractSearchableObjectType
{
22 * @var SearchResultPageContent[]
24 public $messageCache = [];
29 public function cacheObjects(array $objectIDs, array $additionalData = null) {
30 $list = new SearchResultPageContentList();
31 $list->setObjectIDs($objectIDs);
33 foreach ($list->getObjects() as $content) {
34 $this->messageCache
[$content->pageContentID
] = $content;
41 public function getObject($objectID) {
42 if (isset($this->messageCache
[$objectID])) {
43 return $this->messageCache
[$objectID];
52 public function getTableName() {
53 return 'wcf'.WCF_N
.'_page_content';
59 public function getIDFieldName() {
60 return $this->getTableName().'.pageContentID';
66 public function getSubjectFieldName() {
67 return $this->getTableName().'.title';
73 public function getUsernameFieldName() {
80 public function getTimeFieldName() {
81 return 'wcf'.WCF_N
.'_page_content.pageContentID';
84 /** @noinspection PhpMissingParentCallCommonInspection */
88 public function getConditions(IForm
$form = null) {
89 $conditionBuilder = new PreparedStatementConditionBuilder();
90 $conditionBuilder->add('wcf'.WCF_N
.'_page.pageType IN (?) AND wcf'.WCF_N
.'_page.isDisabled = ?', [['text', 'html'], 0]);
93 $objectTypeID = ObjectTypeCache
::getInstance()->getObjectTypeIDByName('com.woltlab.wcf.acl.simple', 'com.woltlab.wcf.page');
94 $conditionBuilder->add('(
95 wcf'.WCF_N
.'_page_content.pageID NOT IN (
96 SELECT objectID FROM wcf' . WCF_N
. '_acl_simple_to_group WHERE objectTypeID = ?
98 SELECT objectID FROM wcf' . WCF_N
. '_acl_simple_to_user WHERE objectTypeID = ?
101 wcf'.WCF_N
.'_page_content.pageID IN (
102 SELECT objectID FROM wcf' . WCF_N
. '_acl_simple_to_group WHERE objectTypeID = ? AND groupID IN (?)
104 SELECT objectID FROM wcf' . WCF_N
. '_acl_simple_to_user WHERE objectTypeID = ? AND userID = ?
106 )', [$objectTypeID, $objectTypeID, $objectTypeID, WCF
::getUser()->getGroupIDs(), $objectTypeID, WCF
::getUser()->userID
]);
108 return $conditionBuilder;
111 /** @noinspection PhpMissingParentCallCommonInspection */
115 public function getJoins() {
116 return 'INNER JOIN wcf'.WCF_N
.'_page ON (wcf'.WCF_N
.'_page.pageID = '.$this->getTableName().'.pageID)';