From: Alexander Ebert Date: Fri, 3 May 2013 23:33:47 +0000 (+0200) Subject: Updated clipboard API to properly handle show order X-Git-Tag: 2.0.0_Beta_1~259^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9e9e4854b6b9f8e37ee0a4f63beb47563dd4e429;p=GitHub%2FWoltLab%2FWCF.git Updated clipboard API to properly handle show order --- diff --git a/wcfsetup/install/files/lib/action/ClipboardAction.class.php b/wcfsetup/install/files/lib/action/ClipboardAction.class.php index 328c345cb9..d8dd4eb89f 100644 --- a/wcfsetup/install/files/lib/action/ClipboardAction.class.php +++ b/wcfsetup/install/files/lib/action/ClipboardAction.class.php @@ -125,8 +125,8 @@ class ClipboardAction extends AJAXInvokeAction { 'items' => array() ); - foreach ($itemData['items'] as $item) { - $items['items'][] = array( + foreach ($itemData['items'] as $showOrder => $item) { + $items['items'][$showOrder] = array( 'actionName' => $item->getName(), 'internalData' => $item->getInternalData(), 'parameters' => $item->getParameters(), diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 18b38bb7c0..9a9c6415c9 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -306,8 +306,8 @@ class ClipboardHandler extends SingletonFactory { // load actions $actions = array(); foreach ($actionIDs as $actionID) { - $actionClassName = $this->actionCache[$actionID]->actionClassName; - $actionName = $this->actionCache[$actionID]->actionName; + $actionObject = $this->actionCache[$actionID]; + $actionClassName = $actionObject->actionClassName; if (!isset($actions[$actionClassName])) { // validate class if (!ClassUtil::isInstanceOf($actionClassName, 'wcf\system\clipboard\action\IClipboardAction')) { @@ -320,7 +320,7 @@ class ClipboardHandler extends SingletonFactory { ); } - $actions[$actionClassName]['actions'][] = $actionName; + $actions[$actionClassName]['actions'][] = $actionObject; } // execute actions @@ -346,13 +346,13 @@ class ClipboardHandler extends SingletonFactory { ); } - foreach ($actionData['actions'] as $action) { - $data = $actionData['object']->execute($objects, $action); + foreach ($actionData['actions'] as $actionObject) { + $data = $actionData['object']->execute($objects, $actionObject); if ($data === null) { continue; } - $editorData[$typeName]['items'][$action] = $data; + $editorData[$typeName]['items'][$actionObject->showOrder] = $data; } } diff --git a/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php index ab8765f0d4..d7eaa84c22 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/AbstractClipboardAction.class.php @@ -1,5 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.clipboard.action @@ -36,24 +37,24 @@ abstract class AbstractClipboardAction implements IClipboardAction { /** * @see wcf\system\clipboard\action\IClipboardAction::execute() */ - public function execute(array $objects, $actionName) { - if (!in_array($actionName, $this->supportedActions)) { - throw new SystemException("Unknown clipboard action '".$actionName."'"); + public function execute(array $objects, ClipboardAction $action) { + if (!in_array($action->actionName, $this->supportedActions)) { + throw new SystemException("Unknown clipboard action '".$action->actionName."'"); } $this->objects = $objects; $item = new ClipboardEditorItem(); - $item->setName($this->getTypeName().'.'.$actionName); + $item->setName($this->getTypeName().'.'.$action->actionName); // set action class-related data - if (in_array($actionName, $this->actionClassActions)) { - $item->addParameter('actionName', $actionName); + if (in_array($action->actionName, $this->actionClassActions)) { + $item->addParameter('actionName', $action->actionName); $item->addParameter('className', $this->getClassName()); } // validate objects if relevant method exists and set valid object ids - $methodName = 'validate'.ucfirst($actionName); + $methodName = 'validate'.ucfirst($action->actionName); if (method_exists($this, $methodName)) { $objectIDs = $this->$methodName(); if (empty($objectIDs)) { diff --git a/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php index a431b10296..d6e52c826d 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/IClipboardAction.class.php @@ -1,11 +1,12 @@ * @package com.woltlab.wcf * @subpackage system.clipboard.action @@ -23,11 +24,11 @@ interface IClipboardAction { * Returns editor item for the clipboard action with the given name or null * if the action is not applicable to the given objects. * - * @param array $objects - * @param string $actionName + * @param array $objects + * @param wcf\data\clipboard\action\ClipboardAction $action * @return wcf\system\clipboard\ClipboardEditorItem */ - public function execute(array $objects, $actionName); + public function execute(array $objects, ClipboardAction $action); /** * Filters the given objects by the given type data and returns the filtered diff --git a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php index e3acc40444..61e0f3532f 100644 --- a/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/action/UserClipboardAction.class.php @@ -1,5 +1,6 @@ * @package com.woltlab.wcf * @subpackage system.clipboard.action @@ -29,15 +30,15 @@ class UserClipboardAction extends AbstractClipboardAction { /** * @see wcf\system\clipboard\action\IClipboardAction::execute() */ - public function execute(array $objects, $actionName) { - $item = parent::execute($objects, $actionName); + public function execute(array $objects, ClipboardAction $action) { + $item = parent::execute($objects, $action); if ($item === null) { return null; } // handle actions - switch ($actionName) { + switch ($action->actionName) { case 'assignToGroup': $item->setURL(LinkHandler::getInstance()->getLink('UserAssignToGroup')); break;