Supporting page object ids for clipboard actions
authorAlexander Ebert <ebert@woltlab.com>
Sun, 5 May 2013 17:57:44 +0000 (19:57 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 5 May 2013 17:57:44 +0000 (19:57 +0200)
wcfsetup/install/files/js/WCF.js
wcfsetup/install/files/lib/action/ClipboardAction.class.php
wcfsetup/install/files/lib/action/ClipboardLoadMarkedItemsAction.class.php
wcfsetup/install/files/lib/system/clipboard/ClipboardHandler.class.php

index 42c00c876e2f715018d15166207be2f58874696e..bf90b7dc465104551c74e7221da59952bd2f6fb6 100755 (executable)
@@ -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
index d8dd4eb89fa674742b4e7e6c5aabbd4c2f61e349..37c42f83b07386e265283fcd16b1481d5db3456a 100644 (file)
@@ -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<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();
index ce2b75348fa0dbbddc5f3c75236f3626101a5bbf..9a4bc057ed6a06193256779ba813839b3bd06155 100644 (file)
@@ -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 <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage action
index 9a9c6415c9c71472a75ab8bd9a9a06a11a5d55ee..62b594f05822a35dd5c0a07904e6ded1ffeaf063 100644 (file)
@@ -26,6 +26,12 @@ class ClipboardHandler extends SingletonFactory {
         */
        protected $actionCache = null;
        
+       /**
+        * cached list of clipboard item types
+        * @var array<array>
+        */
+       protected $cache = null;
+       
        /**
         * list of marked items
         * @var array<array>
@@ -39,10 +45,10 @@ class ClipboardHandler extends SingletonFactory {
        protected $pageCache = null;
        
        /**
-        * cached list of clipboard item types
-        * @var array<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<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;
+       }
 }