use wcf\data\page\PageNodeTree;
use wcf\form\AbstractForm;
use wcf\system\acl\simple\SimpleAclHandler;
+use wcf\system\box\IBoxController;
use wcf\system\box\IConditionBoxController;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
*/
public $availableBoxControllers = [];
+ /**
+ * list of available positions per box handler
+ * @var array
+ */
+ public $availableBoxPositions = [];
+
/**
* @inheritDoc
*/
}
$this->availableBoxControllers = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.boxController');
+ $this->readBoxPositions();
+ }
+
+ /**
+ * Loads available box positions per box controller.
+ */
+ protected function readBoxPositions() {
+ foreach ($this->availableBoxControllers as $boxController) {
+ /** @var IBoxController $controller */
+ $controller = $boxController->getProcessor();
+ $this->availableBoxPositions[$boxController->objectTypeID] = $controller::getSupportedPositions();
+ }
}
/**
}
// validate box position
- if (!in_array($this->position, Box::$availablePositions)) {
- throw new UserInputException('position');
- }
+ $this->validateBoxPosition();
// validate link
if ($this->linkType == 'internal') {
}
}
+ /**
+ * Validates the selected box position.
+ */
+ protected function validateBoxPosition() {
+ if (!in_array($this->position, Box::$availablePositions)) {
+ throw new UserInputException('position');
+ }
+
+ if ($this->boxType == 'system') {
+ if (!in_array($this->position, $this->availableBoxPositions[$this->boxController->objectTypeID])) {
+ throw new UserInputException('position', 'invalid');
+ }
+ }
+ }
+
/**
* @inheritDoc
*/
'boxController' => $this->boxController,
'pageNodeList' => $this->pageNodeList,
'pageHandlers' => $this->pageHandlers,
- 'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues)
+ 'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues),
+ 'availableBoxPositions' => $this->availableBoxPositions
]);
}
}
*/
public $activeMenuItem = 'wcf.acp.menu.link.cms.box.list';
- /**
- * list of available positions per box handler
- * @var array
- */
- public $availableBoxPositions = [];
-
/**
* box id
* @var integer
throw new IllegalLinkException();
}
if ($this->box->isMultilingual) $this->isMultilingual = 1;
-
- $this->readBoxPositions();
- }
-
- /**
- * Loads available box positions per box controller.
- */
- protected function readBoxPositions() {
- foreach ($this->availableBoxControllers as $boxController) {
- /** @var IBoxController $controller */
- $controller = $boxController->getProcessor();
- $this->availableBoxPositions[$boxController->objectTypeID] = $controller::getSupportedPositions();
- }
}
/**
public function validate() {
parent::validate();
- $this->validateBoxPosition();
+
}
- /**
- * Validates the selected box position.
- */
- protected function validateBoxPosition() {
- if ($this->boxType == 'system') {
- if (!in_array($this->position, $this->availableBoxPositions[$this->boxController->objectTypeID])) {
- throw new UserInputException('position', 'invalid');
- }
- }
- }
+
/**
* @inheritDoc
WCF::getTPL()->assign([
'action' => 'edit',
- 'availableBoxPositions' => $this->availableBoxPositions,
'boxID' => $this->boxID,
'box' => $this->box
]);