<!-- notice conditions -->
<type>
- <name>com.woltlab.wcf.page.controller</name>
+ <name>com.woltlab.wcf.page</name>
<definitionname>com.woltlab.wcf.condition.notice</definitionname>
- <classname><![CDATA[wcf\system\condition\MultiPageControllerCondition]]></classname>
+ <classname><![CDATA[wcf\system\condition\page\MultiPageCondition]]></classname>
<conditionobject>com.woltlab.wcf.page</conditionobject>
</type>
<!-- ad conditions -->
<type>
- <name>com.woltlab.wcf.page.controller</name>
+ <name>com.woltlab.wcf.page</name>
<definitionname>com.woltlab.wcf.condition.ad</definitionname>
- <classname><![CDATA[wcf\system\condition\MultiPageControllerCondition]]></classname>
+ <classname><![CDATA[wcf\system\condition\page\MultiPageCondition]]></classname>
<conditionobject>com.woltlab.wcf.page</conditionobject>
</type>
<conditiongroup>userOptions</conditiongroup>
</type>
<!-- /user search conditions -->
+
+ <!-- deprecated -->
+ <type>
+ <name>com.woltlab.wcf.page.controller</name>
+ <definitionname>com.woltlab.wcf.condition.notice</definitionname>
+ <classname><![CDATA[wcf\system\condition\MultiPageControllerCondition]]></classname>
+ <conditionobject>com.woltlab.wcf.page</conditionobject>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.page.controller</name>
+ <definitionname>com.woltlab.wcf.condition.ad</definitionname>
+ <classname><![CDATA[wcf\system\condition\MultiPageControllerCondition]]></classname>
+ <conditionobject>com.woltlab.wcf.page</conditionobject>
+ </type>
+ <!-- /deprecated -->
</import>
</data>
*/
abstract class AbstractMultiSelectCondition extends AbstractSelectCondition {
/**
- * @see \wcf\system\condition\AbstractSelectCondition::$fieldValue
+ * selected values
+ * @var mixed[]
*/
- protected $fieldValue = array();
+ protected $fieldValue = [];
/**
- * @see \wcf\system\condition\ICondition::getData()
+ * @inheritDoc
*/
public function getData() {
if (!empty($this->fieldValue)) {
- return array(
- $this->fieldName => $this->fieldValue
- );
+ return [$this->fieldName => $this->fieldValue];
}
return null;
}
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::getFieldElement()
+ * @inheritDoc
*/
protected function getFieldElement() {
$options = $this->getOptions();
}
/**
- * @see \wcf\system\condition\AbstractSelectCondition::getOptionCode()
+ * @inheritDoc
*/
protected function getOptionCode($value, $label) {
return '<option value="'.$value.'"'.(in_array($value, $this->fieldValue) ? ' selected="selected"' : '').'>'.WCF::getLanguage()->get($label).'</option>';
}
/**
- * @see \wcf\system\condition\ICondition::readFormParameters()
+ * @inheritDoc
*/
public function readFormParameters() {
if (isset($_POST[$this->fieldName]) && is_array($_POST[$this->fieldName])) $this->fieldValue = ArrayUtil::toIntegerArray($_POST[$this->fieldName]);
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function reset() {
$this->fieldValue = array();
}
/**
- * @see \wcf\system\condition\ICondition::validate()
+ * @inheritDoc
*/
public function validate() {
$options = $this->getOptions();
* Condition implementation for selecting multiple page controllers.
*
* @author Matthias Schmidt
- * @copyright 2001-2015 WoltLab GmbH
+ * @copyright 2001-2016 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.condition
* @category Community Framework
+ * @deprecated since 2.2
*/
class MultiPageControllerCondition extends AbstractMultiSelectCondition implements IContentCondition {
/**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
+ * @inheritDoc
*/
- protected $description = 'wcf.global.multiSelect';
-
- /**
- * @see \wcf\system\condition\AbstractSelectCondition::$fieldName
- */
- protected $fieldName = 'pageControllers';
-
- /**
- * @see \wcf\system\condition\AbstractSingleFieldCondition::$label
- */
- protected $label = 'wcf.page.requestedPage';
-
- /**
- * @see \wcf\system\condition\AbstractSelectCondition::getOptionCode()
- */
- protected function getOptionCode($value, $label) {
- return '<option value="'.$value.'" data-object-type="'.ObjectTypeCache::getInstance()->getObjectType($value)->objectType.'"'.(in_array($value, $this->fieldValue) ? ' selected="selected"' : '').'>'.WCF::getLanguage()->get($label).'</option>';
+ protected function getFieldElement() {
+ return '';
}
/**
- * @see \wcf\system\condition\AbstractSelectCondition::getOptions()
+ * @inheritDoc
*/
protected function getOptions() {
- return PageManager::getInstance()->getSelection();
+ return [];
}
/**
- * @see \wcf\system\condition\IContentCondition::showContent()
+ * @inheritDoc
*/
public function showContent(Condition $condition) {
- $requestClassName = RequestHandler::getInstance()->getActiveRequest()->getClassName();
- $requestClassName = ltrim($requestClassName, '\\'); // remove leading backslash
- $pageControllers = $condition->pageControllers;
- foreach ($pageControllers as $objectTypeID) {
- $objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
- if ($objectType === null) return false;
-
- if ($requestClassName == $objectType->className) {
- return true;
- }
- }
-
return false;
}
}
--- /dev/null
+<?php
+namespace wcf\system\condition\page;
+use wcf\data\condition\Condition;
+use wcf\data\page\PageCache;
+use wcf\data\page\PageNode;
+use wcf\data\page\PageNodeTree;
+use wcf\system\condition\AbstractMultiSelectCondition;
+use wcf\system\condition\IContentCondition;
+use wcf\system\exception\UserInputException;
+use wcf\system\request\RequestHandler;
+
+/**
+ * Condition implementation for selecting multiple pages.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package com.woltlab.wcf
+ * @subpackage system.condition.page
+ * @category Community Framework
+ * @deprecated since 2.2
+ */
+class MultiPageCondition extends AbstractMultiSelectCondition implements IContentCondition {
+ /**
+ * @inheritDoc
+ */
+ protected $description = 'wcf.global.multiSelect';
+
+ /**
+ * @inheritDoc
+ */
+ protected $fieldName = 'pageIDs';
+
+ /**
+ * @inheritDoc
+ */
+ protected $label = 'wcf.page.requestedPage';
+
+ /**
+ * @inheritDoc
+ */
+ protected function getFieldElement() {
+ $pageNodes = (new PageNodeTree())->getNodeList();
+
+ $fieldElement = '<select name="'.$this->fieldName.'[]" id="'.$this->fieldName.'" multiple="multiple" size="10">';
+ /** @var PageNode $pageNode */
+ foreach ($pageNodes as $pageNode) {
+ $fieldElement .= '<option value="'.$pageNode->getPage()->pageID.'">'.($pageNode->getDepth() > 1 ? str_repeat(" ", $pageNode->getDepth() - 1) : '').$pageNode->getPage()->name.'</option>';
+ }
+ $fieldElement .= "</select>";
+
+ return $fieldElement;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected function getOptions() {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function showContent(Condition $condition) {
+ $pageID = RequestHandler::getInstance()->getActiveRequest()->getPageID();
+ if ($pageID && $condition->pageIDs && is_array($condition->pageIDs)) {
+ return in_array($pageID, $condition->pageIDs);
+ }
+
+ return false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function validate() {
+ foreach ($this->fieldValue as $value) {
+ if (PageCache::getInstance()->getPage($value) === null) {
+ $this->errorMessage = 'wcf.global.form.error.noValidSelection';
+
+ throw new UserInputException($this->fieldName, 'noValidSelection');
+ }
+ }
+ }
+}
\ No newline at end of file
/**
* Returns the current page id.
*
- * @return integer current page id or `0` if unknown
+ * @return integer current page id or `0` if unknown
*/
public function getPageID() {
if ($this->pageID === null) {