* Overhauled style editor
* Added replacements for WCF.Like, WCF.User.List and $.ui.wcfPages
* Added update support for styles
+* `\wcf\system\condition\MultiPageControllerCondition` has been replaced by `wcf\system\condition\page\MultiPageCondition`
#### CMS
* Renamed `.pageNavigation` to `.pagination`
* Renamed `.navigation`/`.navigationIcons` to `.pageNavigation`/`.pageNavigationIcons`
+#### Deprecated Code
+
+* Object type definition `com.woltlab.wcf.user.online.location` deprecated.
+* Object type definition `com.woltlab.wcf.page` deprecated.
+
#### Removed Code
* `wcf\system\clipboard\action\UserExtendedClipboardAction` removed.
* Version system removed.
* Support for query string based sessions in Frontend removed.
* Language server system removed.
-* Object type definition `com.woltlab.wcf.user.online.location` deprecated.
-* Object type definition `com.woltlab.wcf.page` deprecated.
* Deprecated methods in `wcf\util\StringUtil` removed.
* Option `message_sidebar_enable_message_group_starter_icon` removed.
* Option `module_privacy_policy_page` removed.
<script data-relocate="true">
//<![CDATA[
$(function() {
- WCF.TabMenu.init();
-
$('input[name=cssClassName]').change(function() {
var $val = $('input[name=cssClassName]:checked').val();
if (!$val || $val === 'custom') {
</header>
{include file='userConditions' groupedObjectTypes=$groupedConditionObjectTypes['com.woltlab.wcf.user']}
- </section>
-
+ </section>
+
{event name='conditionContainers'}
<div class="formSubmit">
*/
WCF.Condition = { };
-/**
- * Handles displaying the a form element whose visibility depends on the selected
- * page controllers.
- */
-WCF.Condition.PageControllerDependence = Class.extend({
- /**
- * select list with the available page controllers
- * @var jQuery
- */
- _pageControllerSelection: null,
-
- /**
- * ids of page object types that support the form element
- * @var array<integer>
- */
- _supportedPageObjectTypeIDs: [],
-
- /**
- * Initializes a new WCF.Condition.PageControllerDependence object.
- *
- * @param string inputIdentifier
- * @param array<integer> supportedPageObjectTypeIDs
- */
- init: function(inputIdentifier, supportedPageObjectTypeIDs) {
- this._supportedPageObjectTypeIDs = supportedPageObjectTypeIDs;
-
- this._pageControllerSelection = $('#pageControllers').change($.proxy(this._checkVisibility, this));
- this._pageControllerContainer = this._pageControllerSelection.parents('dl:eq(0)');
- this._fieldset = this._pageControllerContainer.parent('fieldset');
- this._nextFieldset = this._fieldset.next('fieldset');
- if (this._nextFieldset) {
- this._nextFieldset.data('margin-top', this._nextFieldset.css('margin-top'));
- }
-
- this._input = $('#' + inputIdentifier);
- this._inputContainer = this._input.parents('dl:eq(0)');
-
- this._checkVisibility();
- },
-
- /**
- * Checks the visibility based on the selected page controllers.
- */
- _checkVisibility: function() {
- var $selectedPageIDs = this._pageControllerSelection.val() || [ ];
-
- var $display = true;
- if ($selectedPageIDs.length) {
- for (var $i = 0, $length = $selectedPageIDs.length; $i < $length; $i++) {
- if (this._supportedPageObjectTypeIDs.indexOf(parseInt($selectedPageIDs[$i])) == -1) {
- $display = false;
- break;
- }
- }
- }
- else {
- $display = false;
- }
-
- if ($display) {
- this._inputContainer.show();
- this._input.enable();
- this._fieldset.show();
-
- if (this._nextFieldset) {
- this._nextFieldset.css('margin-top', this._nextFieldset.data('margin-top'));
- }
- }
- else {
- this._inputContainer.hide();
- this._input.disable();
-
- if (!this._fieldset.children('dl:visible').length) {
- this._fieldset.hide();
-
- if (this._nextFieldset) {
- this._nextFieldset.css('margin-top', 0);
- }
- }
- }
- }
-});
-
/**
* Initialize WCF.Notice namespace.
*/
--- /dev/null
+/**
+ * Shows and hides an element that dependes on certain selected pages when setting up conditions.
+ *
+ * @author Matthias Schmidt
+ * @copyright 2001-2016 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @module WoltLab/WCF/Controller/Condition/Page/Dependence
+ */
+define(['Dom/Traverse'], function(DomTraverse) {
+ "use strict";
+
+ var _pages = elBySelAll('input[name="pageIDs[]"]');
+
+ /**
+ * @constructor
+ */
+ function ControllerConditionPageDependence(dependentElement, pageIds) {
+ this._dependentElement = dependentElement;
+ this._pageIds = pageIds;
+
+ for (var i = 0, length = _pages.length; i < length; i++) {
+ _pages[i].addEventListener('change', this._checkVisibility.bind(this));
+ }
+
+ // remove the dependent element before submit if it is hidden
+ DomTraverse.parentByTag(this._dependentElement, 'FORM').addEventListener('submit', function() {
+ if (this._dependentElement.style.getPropertyValue('display') === 'none') {
+ this._dependentElement.remove();
+ }
+ }.bind(this));
+
+ this._checkVisibility();
+ };
+ ControllerConditionPageDependence.prototype = {
+ /**
+ * Checks if any of the relevant pages is selected. If that is the case, the dependent
+ * element is shown, otherwise it is hidden.
+ *
+ * @private
+ */
+ _checkVisibility: function() {
+ var page;
+ for (var i = 0, length = _pages.length; i < length; i++) {
+ page = _pages[i];
+
+ if (page.checked && this._pageIds.indexOf(~~page.value) !== -1) {
+ elShow(this._dependentElement);
+ return;
+ }
+ }
+
+ elHide(this._dependentElement);
+ }
+ };
+
+ return ControllerConditionPageDependence;
+});
$this->cache = PageCacheBuilder::getInstance()->getData();
}
+ /**
+ * Returns all available pages.
+ *
+ * @return Page[]
+ */
+ public function getPages() {
+ return $this->cache['pages'];
+ }
+
/**
* Returns a page by page id or null.
*
use wcf\data\page\PageNode;
use wcf\data\page\PageNodeTree;
use wcf\system\condition\AbstractMultiSelectCondition;
+use wcf\system\condition\AbstractSingleFieldCondition;
use wcf\system\condition\IContentCondition;
use wcf\system\exception\UserInputException;
use wcf\system\request\RequestHandler;
* @package com.woltlab.wcf
* @subpackage system.condition.page
* @category Community Framework
- * @deprecated since 2.2
+ * @since 2.2
*/
class MultiPageCondition extends AbstractMultiSelectCondition implements IContentCondition {
- /**
- * @inheritDoc
- */
- protected $description = 'wcf.global.multiSelect';
-
/**
* @inheritDoc
*/
protected function getFieldElement() {
$pageNodes = (new PageNodeTree())->getNodeList();
- $fieldElement = '<select name="'.$this->fieldName.'[]" id="'.$this->fieldName.'" multiple="multiple" size="10">';
+ $fieldElement = '<ul class="scrollableCheckboxList">';
/** @var PageNode $pageNode */
foreach ($pageNodes as $pageNode) {
- $fieldElement .= '<option value="'.$pageNode->pageID.'">'.($pageNode->getDepth() > 1 ? str_repeat(" ", $pageNode->getDepth() - 1) : '').$pageNode->name.'</option>';
+ $fieldElement .= '<li';
+ if ($pageNode->getDepth() > 1) {
+ $fieldElement .= ' style="padding-left: '.($pageNode->getDepth()*20-20).'px"';
+ }
+ $fieldElement .= '><label><input type="checkbox" name="'.$this->fieldName.'[]" value="'.$pageNode->pageID.'"';
+ if (in_array($pageNode->pageID, $this->fieldValue)) {
+ $fieldElement .= ' checked="checked"';
+ }
+ $fieldElement .= ' />'.$pageNode->name.'</label></li>';
}
- $fieldElement .= "</select>";
+ $fieldElement .= "</ul>";
return $fieldElement;
}
+ /**
+ * @inheritDoc
+ */
+ public function getHTML() {
+ return AbstractSingleFieldCondition::getHTML();
+ }
+
/**
* @inheritDoc
*/