'__daysShort': [ '{lang}wcf.date.day.sun{/lang}', '{lang}wcf.date.day.mon{/lang}', '{lang}wcf.date.day.tue{/lang}', '{lang}wcf.date.day.wed{/lang}', '{lang}wcf.date.day.thu{/lang}', '{lang}wcf.date.day.fri{/lang}', '{lang}wcf.date.day.sat{/lang}' ],
'__months': [ '{lang}wcf.date.month.january{/lang}', '{lang}wcf.date.month.february{/lang}', '{lang}wcf.date.month.march{/lang}', '{lang}wcf.date.month.april{/lang}', '{lang}wcf.date.month.may{/lang}', '{lang}wcf.date.month.june{/lang}', '{lang}wcf.date.month.july{/lang}', '{lang}wcf.date.month.august{/lang}', '{lang}wcf.date.month.september{/lang}', '{lang}wcf.date.month.october{/lang}', '{lang}wcf.date.month.november{/lang}', '{lang}wcf.date.month.december{/lang}' ],
'__monthsShort': [ '{lang}wcf.date.month.jan{/lang}', '{lang}wcf.date.month.feb{/lang}', '{lang}wcf.date.month.mar{/lang}', '{lang}wcf.date.month.apr{/lang}', '{lang}wcf.date.month.may{/lang}', '{lang}wcf.date.month.jun{/lang}', '{lang}wcf.date.month.jul{/lang}', '{lang}wcf.date.month.aug{/lang}', '{lang}wcf.date.month.sep{/lang}', '{lang}wcf.date.month.oct{/lang}', '{lang}wcf.date.month.nov{/lang}', '{lang}wcf.date.month.dec{/lang}' ],
+ 'wcf.clipboard.item.unmarkAll': '{lang}wcf.clipboard.item.unmarkAll{/lang}',
'wcf.date.relative.now': '{lang}wcf.date.relative.now{/lang}',
'wcf.date.relative.minutes': '{capture assign=relativeMinutes}{lang}wcf.date.relative.minutes{/lang}{/capture}{@$relativeMinutes|encodeJS}',
'wcf.date.relative.hours': '{capture assign=relativeHours}{lang}wcf.date.relative.hours{/lang}{/capture}{@$relativeHours|encodeJS}',
for (var $itemIndex in $editor.items) {
var $item = $editor.items[$itemIndex];
- if ($item.actionName === 'unmarkAll') {
- $('<li class="dropdownDivider" />').appendTo($itemList);
- }
-
var $listItem = $('<li><span>' + $item.label + '</span></li>').appendTo($itemList);
$listItem.data('objectType', $typeName);
$listItem.data('actionName', $item.actionName).data('parameters', $item.parameters);
$listItem.click($.proxy(this._executeAction, this));
}
+ // add 'unmark all'
+ $('<li class="dropdownDivider" />').appendTo($itemList);
+ $('<li><span>' + WCF.Language.get('wcf.clipboard.item.unmarkAll') + '</span></li>').appendTo($itemList).click($.proxy(function() {
+ this._proxy.setOption('data', {
+ action: 'unmarkAll',
+ type: $typeName
+ });
+ this._proxy.setOption('success', $.proxy(function(data, textStatus, jqXHR) {
+ for (var $__containerID in this._containers) {
+ var $__container = $(this._containers[$__containerID]);
+ if ($__container.data('type') == $typeName) {
+ $__container.find('.jsClipboardMarkAll, .jsClipboardItem').removeAttr('checked');
+ break;
+ }
+ }
+
+ // call and restore success method
+ this._success(data, textStatus, jqXHR);
+ this._proxy.setOption('success', $.proxy(this._success, this));
+ }, this));
+ this._proxy.sendRequest();
+ }, this));
+
// block click event
$container.click(function(event) {
event.stopPropagation();
* Handles clipboard items.
*
* @author Alexander Ebert
- * @copyright 2001-2012 WoltLab GmbH
+ * @copyright 2001-2013 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage action
*/
protected $action = '';
+ /**
+ * list of allowed action methods
+ * @var array<string>
+ */
+ protected $allowedActions = array('mark', 'unmark', 'unmarkAll');
+
/**
* container data
* @var array
$this->validate();
// execute action
- ClipboardHandler::getInstance()->{$this->action}($this->objectIDs, $this->objectTypeID);
+ if ($this->action == 'unmarkAll') {
+ ClipboardHandler::getInstance()->unmarkAll($this->objectTypeID);
+ }
+ else {
+ ClipboardHandler::getInstance()->{$this->action}($this->objectIDs, $this->objectTypeID);
+ }
}
/**
}
return array(
+ 'action' => $this->action,
'items' => $editorItems
);
}
* Validates parameters.
*/
protected function validate() {
- if (empty($this->objectIDs)) {
- throw new UserInputException('objectIDs');
- }
-
- if (empty($this->pageClassName)) {
- throw new UserInputException('pageClassName');
+ if (!in_array($this->action, $this->allowedActions)) {
+ throw new UserInputException('action');
}
- if ($this->action != 'mark' && $this->action != 'unmark') {
- throw new UserInputException('action');
+ if ($this->action != 'unmarkAll') {
+ if (empty($this->objectIDs)) {
+ throw new UserInputException('objectIDs');
+ }
+
+ if (empty($this->pageClassName)) {
+ throw new UserInputException('pageClassName');
+ }
}
$this->objectTypeID = (!empty($this->type)) ? ClipboardHandler::getInstance()->getObjectTypeID($this->type) : null;
$statement->execute($conditions->getParameters());
}
+ /**
+ * Unmarks all items of given type.
+ *
+ * @param integer $objectTypeID
+ */
+ public function unmarkAll($objectTypeID) {
+ $sql = "DELETE FROM wcf".WCF_N."_clipboard_item
+ WHERE objectTypeID = ?
+ AND userID = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(array(
+ $objectTypeID,
+ WCF::getUser()->userID
+ ));
+ }
+
/**
* Returns a type id by name.
*
$objects = $actionData['object']->filterObjects($this->markedItems[$typeName], $typeData);
if (empty($objects)) continue;
- $editorData[$typeName] = array(
- 'label' => $actionData['object']->getEditorLabel($objects),
- 'items' => array()
- );
+ if (!isset($editorData[$typeName])) {
+ $editorData[$typeName] = array(
+ 'label' => $actionData['object']->getEditorLabel($objects),
+ 'items' => array()
+ );
+ }
foreach ($actionData['actions'] as $action) {
$data = $actionData['object']->execute($objects, $action);
$editorData[$typeName]['items'][$action] = $data;
}
-
- // append 'unmark all' item
- if (!ClassUtil::isInstanceOf($actionData['object']->getClassName(), 'wcf\data\IClipboardAction')) {
- throw new SystemException("'".$actionData['object']->getClassName()."' does not implement 'wcf\data\IClipboardAction'");
- }
-
- $unmarkAll = new ClipboardEditorItem();
- $unmarkAll->setName('unmarkAll');
- $unmarkAll->addParameter('actionName', 'unmarkAll');
- $unmarkAll->addParameter('className', $actionData['object']->getClassName());
-
- $editorData[$typeName]['items'][] = $unmarkAll;
}
return $editorData;