Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions com.woltlab.wcf/objectType.xml
Original file line number Diff line number Diff line change
Expand Up @@ -970,14 +970,6 @@
<conditiongroup>general</conditiongroup>
</type>
<!-- /notice conditions -->
<!-- box conditions -->
<type>
<name>com.woltlab.wcf.page</name>
<definitionname>com.woltlab.wcf.condition.box</definitionname>
<classname>wcf\system\condition\page\MultiPageCondition</classname>
<conditionobject>com.woltlab.wcf.page</conditionobject>
</type>
<!-- /box conditions -->
<!-- ad locations -->
<type>
<name>com.woltlab.wcf.logo</name>
Expand Down Expand Up @@ -1831,5 +1823,8 @@
<type name="com.woltlab.wcf.searchEngineConvertInnoDb">
<definitionname>com.woltlab.wcf.rebuildData</definitionname>
</type>
<type name="com.woltlab.wcf.page">
<definitionname>com.woltlab.wcf.condition.box</definitionname>
</type>
</delete>
</data>
27 changes: 27 additions & 0 deletions wcfsetup/install/files/acp/templates/boxAdd.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,33 @@
<h2 class="sectionTitle">{lang}wcf.acp.box.conditions.page{/lang}</h2>
</header>

<dl>
<dt></dt>
<dd>
<label><input type="checkbox" id="visibleEverywhere" name="visibleEverywhere" value="1"{if $visibleEverywhere} checked{/if}> {lang}wcf.acp.box.visibleEverywhere{/lang}</label>
<script data-relocate="true">
(() => {
const visibilityExceptionHidden = document.getElementById('visibilityExceptionHidden');
const visibilityExceptionVisible = document.getElementById('visibilityExceptionVisible');
document.getElementById('visibleEverywhere').addEventListener('change', function () {
visibilityExceptionHidden.hidden = this.checked ? false : true;
visibilityExceptionVisible.hidden = this.checked ? true : false;
});
})();
</script>
</dd>
</dl>

<dl>
<dt>
<span id="visibilityExceptionVisible"{if $visibleEverywhere} hidden{/if}>{lang}wcf.acp.box.visibilityException.visible{/lang}</span>
<span id="visibilityExceptionHidden"{if !$visibleEverywhere} hidden{/if}>{lang}wcf.acp.box.visibilityException.hidden{/lang}</span>
</dt>
<dd>
{include file='scrollablePageCheckboxList' pageCheckboxListContainerID='boxVisibilitySettings' pageCheckboxID='pageIDs'}
</dd>
</dl>

{foreach from=$groupedConditionObjectTypes['com.woltlab.wcf.page'] item='pageConditionObjectType'}
{@$pageConditionObjectType->getProcessor()->getHtml()}
{/foreach}
Expand Down
35 changes: 6 additions & 29 deletions wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use wcf\system\box\IBoxController;
use wcf\system\box\IConditionBoxController;
use wcf\system\condition\ConditionHandler;
use wcf\system\condition\page\MultiPageCondition;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\UserInputException;
Expand Down Expand Up @@ -339,6 +338,9 @@ public function readFormParameters()
if (isset($_POST['showOrder'])) {
$this->showOrder = \intval($_POST['showOrder']);
}
if (isset($_POST['visibleEverywhere'])) {
$this->visibleEverywhere = \intval($_POST['visibleEverywhere']);
}
if (isset($_POST['cssClassName'])) {
$this->cssClassName = StringUtil::trim($_POST['cssClassName']);
}
Expand All @@ -348,6 +350,9 @@ public function readFormParameters()
if (isset($_POST['isDisabled'])) {
$this->isDisabled = 1;
}
if (isset($_POST['pageIDs']) && \is_array($_POST['pageIDs'])) {
$this->pageIDs = ArrayUtil::toIntegerArray($_POST['pageIDs']);
}
if (isset($_POST['linkType'])) {
$this->linkType = $_POST['linkType'];
}
Expand Down Expand Up @@ -399,36 +404,8 @@ public function readFormParameters()

private function readConditions(): void
{
$pageConditionObjectTypeID = ObjectTypeCache::getInstance()->getObjectTypeIDByName(
Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME,
'com.woltlab.wcf.page'
);

$this->pageIDs = $this->visibleEverywhere = null;
foreach ($this->toFlatList($this->groupedConditionObjectTypes) as $objectType) {
$objectType->getProcessor()->readFormParameters();
if ($objectType->objectTypeID == $pageConditionObjectTypeID) {
\assert($objectType->getProcessor() instanceof MultiPageCondition);

$data = $objectType->getProcessor()->getData();
if ($data !== null) {
$this->pageIDs = $data['pageIDs'];
$this->visibleEverywhere = $data['pageIDs_reverseLogic'] ? 1 : 0;
} else {
$this->pageIDs = [];
$this->visibleEverywhere = 1;
}
}
}

if ($this->pageIDs === null || $this->visibleEverywhere === null) {
throw new \LogicException(
\sprintf(
"The '%s' condition for the definition '%s' is missing.",
'com.woltlab.wcf.page',
Box::VISIBILITY_CONDITIONS_OBJECT_TYPE_NAME
)
);
}
}

Expand Down