From: Alexander Ebert Date: Sun, 5 May 2013 17:57:44 +0000 (+0200) Subject: Supporting page object ids for clipboard actions X-Git-Tag: 2.0.0_Beta_1~252^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=607c1f326f9ed52561f0e4480cc09cc84bc9e1e9;p=GitHub%2FWoltLab%2FWCF.git Supporting page object ids for clipboard actions --- diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 42c00c876e..bf90b7dc46 100755 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -852,6 +852,12 @@ WCF.Clipboard = { */ _page: '', + /** + * current page's object id + * @var integer + */ + _pageObjectID: 0, + /** * proxy object * @var WCF.Action.Proxy @@ -866,16 +872,17 @@ WCF.Clipboard = { /** * Initializes the clipboard API. + * + * @param string page + * @param integer hasMarkedItems + * @param object actionObjects + * @param integer pageObjectID */ - init: function(page, hasMarkedItems, actionObjects) { + init: function(page, hasMarkedItems, actionObjects, pageObjectID) { this._page = page; - this._actionObjects = actionObjects; - if (!actionObjects) { - this._actionObjects = {}; - } - if (hasMarkedItems) { - this._hasMarkedItems = true; - } + this._actionObjects = actionObjects || { }; + this._hasMarkedItems = (hasMarkedItems > 0); + this._pageObjectID = parseInt(pageObjectID) || 0; this._actionProxy = new WCF.Action.Proxy({ success: $.proxy(this._actionSuccess, this), @@ -913,7 +920,8 @@ WCF.Clipboard = { autoSend: true, data: { containerData: this._containerData, - pageClassName: this._page + pageClassName: this._page, + pageObjectID: this._pageObjectID }, success: $.proxy(this._loadMarkedItemsSuccess, this), url: 'index.php/ClipboardLoadMarkedItems/?t=' + SECURITY_TOKEN + SID_ARG_2ND diff --git a/wcfsetup/install/files/lib/action/ClipboardAction.class.php b/wcfsetup/install/files/lib/action/ClipboardAction.class.php index d8dd4eb89f..37c42f83b0 100644 --- a/wcfsetup/install/files/lib/action/ClipboardAction.class.php +++ b/wcfsetup/install/files/lib/action/ClipboardAction.class.php @@ -48,6 +48,12 @@ class ClipboardAction extends AJAXInvokeAction { */ protected $pageClassName = ''; + /** + * page object id + * @var integer + */ + protected $pageObjectID = 0; + /** * object type * @var string @@ -70,6 +76,7 @@ class ClipboardAction extends AJAXInvokeAction { if (isset($_POST['containerData']) && is_array($_POST['containerData'])) $this->containerData = $_POST['containerData']; if (isset($_POST['objectIDs']) && is_array($_POST['objectIDs'])) $this->objectIDs = ArrayUtil::toIntegerArray($_POST['objectIDs']); if (isset($_POST['pageClassName'])) $this->pageClassName = StringUtil::trim($_POST['pageClassName']); + if (isset($_POST['pageObjectID'])) $this->pageObjectID = intval($_POST['pageObjectID']); if (isset($_POST['type'])) $this->type = StringUtil::trim($_POST['type']); } @@ -112,7 +119,7 @@ class ClipboardAction extends AJAXInvokeAction { * @return array */ protected function getEditorItems() { - $data = ClipboardHandler::getInstance()->getEditorItems($this->pageClassName, $this->containerData); + $data = ClipboardHandler::getInstance()->getEditorItems($this->pageClassName, $this->pageObjectID, $this->containerData); if ($data === null) { return array(); diff --git a/wcfsetup/install/files/lib/action/ClipboardLoadMarkedItemsAction.class.php b/wcfsetup/install/files/lib/action/ClipboardLoadMarkedItemsAction.class.php index ce2b75348f..9a4bc057ed 100644 --- a/wcfsetup/install/files/lib/action/ClipboardLoadMarkedItemsAction.class.php +++ b/wcfsetup/install/files/lib/action/ClipboardLoadMarkedItemsAction.class.php @@ -6,7 +6,7 @@ use wcf\system\clipboard\ClipboardHandler; * Handles marked clipboard items once DOM is loaded. * * @author Alexander Ebert - * @copyright 2001-2012 WoltLab GmbH + * @copyright 2001-2013 WoltLab GmbH * @license GNU Lesser General Public License * @package com.woltlab.wcf * @subpackage action diff --git a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php index 9a9c6415c9..62b594f058 100644 --- a/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php +++ b/wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php @@ -26,6 +26,12 @@ class ClipboardHandler extends SingletonFactory { */ protected $actionCache = null; + /** + * cached list of clipboard item types + * @var array + */ + protected $cache = null; + /** * list of marked items * @var array @@ -39,10 +45,10 @@ class ClipboardHandler extends SingletonFactory { protected $pageCache = null; /** - * cached list of clipboard item types - * @var array + * page object id + * @var integer */ - protected $cache = null; + protected $pageObjectID = 0; /** * @see wcf\system\SingletonFactory::init() @@ -282,10 +288,13 @@ class ClipboardHandler extends SingletonFactory { * Returns items for clipboard editor. * * @param string $page + * @param integer $pageObjectID * @param array $containerData * @return array */ - public function getEditorItems($page, $containerData) { + public function getEditorItems($page, $pageObjectID, $containerData) { + $this->pageObjectID = 0; + // ignore unknown pages if (!isset($this->pageCache[$page])) return null; @@ -293,6 +302,8 @@ class ClipboardHandler extends SingletonFactory { $this->loadMarkedItems(); if (empty($this->markedItems)) return null; + $this->pageObjectID = $pageObjectID; + // fetch action ids $this->loadActionCache(); $actionIDs = array(); @@ -403,4 +414,13 @@ class ClipboardHandler extends SingletonFactory { return 0; } + + /** + * Returns page object id. + * + * @return integer + */ + public function getPageObjectID() { + return $this->pageObjectID; + } }