*/
protected $label = 'wcf.page.requestedPage';
+ /**
+ * is `true` if the logic should be reversed, thus all of the non-selected pages fulfill the
+ * condition
+ * @var bool
+ */
+ protected $reverseLogic = false;
+
+ /**
+ * @inheritDoc
+ */
+ public function getData() {
+ if (!empty($this->fieldValue)) {
+ return [
+ $this->fieldName => $this->fieldValue,
+ $this->fieldName . '_reverseLogic' => $this->reverseLogic
+ ];
+ }
+
+ return null;
+ }
+
/**
* @inheritDoc
*/
* @inheritDoc
*/
public function getHTML() {
- return AbstractSingleFieldCondition::getHTML();
+ return WCF::getTPL()->fetch('__multiPageCondition', 'wcf', [
+ 'condition' => $this,
+ 'conditionHtml' => AbstractSingleFieldCondition::getHTML(),
+ 'fieldName' => $this->fieldName,
+ 'reverseLogic' => $this->reverseLogic
+ ]);
}
/**
return [];
}
+ /**
+ * @inheritDoc
+ */
+ public function readFormParameters() {
+ parent::readFormParameters();
+
+ if (isset($_POST[$this->fieldName . '_reverseLogic'])) $this->reverseLogic = (bool)$this->fieldName . '_reverseLogic';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function reset() {
+ $this->fieldValue = [];
+ $this->reverseLogic = false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function setData(Condition $condition) {
+ parent::setData($condition);
+
+ // backwards compatibility: if the reverse logic condition entry does not exist,
+ // the logic is not reversed
+ $this->reverseLogic = $condition->conditionData[$this->fieldName . '_reverseLogic'] ?? false;
+ }
+
/**
* @inheritDoc
*/
$activeRequest = RequestHandler::getInstance()->getActiveRequest();
if ($activeRequest !== null) {
$pageID = $activeRequest->getPageID();
- if ($pageID && $condition->pageIDs && is_array($condition->pageIDs)) {
- return in_array($pageID, $condition->pageIDs);
+ $pageIDs = $condition->{$this->fieldName};
+
+ if ($pageID && $condition->pageIDs && is_array($pageIDs)) {
+ $matchingPageID = in_array($pageID, $pageIDs);
+
+ if ($condition->{$this->fieldName . '_reverseLogic'}) {
+ return !$matchingPageID;
+ }
+
+ return $matchingPageID;
}
}
<item name="wcf.page.sidebar.left"><![CDATA[Linke Seitenleiste]]></item>
<item name="wcf.page.sidebar.right"><![CDATA[Rechte Seitenleiste]]></item>
<item name="wcf.page.breadcrumb"><![CDATA[Verlaufsnavigation]]></item>
+ <item name="wcf.page.requestedPage.condition.reverseLogic"><![CDATA[„Aufgerufene Seite“-Auswahl umkehren]]></item>
+ <item name="wcf.page.requestedPage.condition.reverseLogic.description"><![CDATA[Wenn ausgewählt, darf die aufgerufene Seite <strong>keine</strong> keine der unter „Aufgerufene Seite“ ausgewählten Seiten sein.]]></item>
</category>
<category name="wcf.paidSubscription">
<item name="wcf.paidSubscription.availableSubscriptions"><![CDATA[Verfügbare Mitgliedschaften]]></item>
<item name="wcf.page.sidebar.left"><![CDATA[Left Sidebar]]></item>
<item name="wcf.page.sidebar.right"><![CDATA[Right Sidebar]]></item>
<item name="wcf.page.breadcrumb"><![CDATA[Breadcrumb]]></item>
+ <item name="wcf.page.requestedPage.condition.reverseLogic"><![CDATA[Reverse “Requested Page” selection]]></item>
+ <item name="wcf.page.requestedPage.condition.reverseLogic.description"><![CDATA[If selected, the requested page <strong>may not</strong> be one of the pages selected under “Requested Page”.]]></item>
</category>
<category name="wcf.acp.page">
<item name="wcf.acp.page.add"><![CDATA[Add Page]]></item>