From 80c214514ac4eb1795d1e70255bc6a6497bdfe72 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Mon, 25 May 2015 08:41:49 +0200 Subject: [PATCH] Add missing files from previous commit --- .../files/acp/templates/tagSetAsSynonyms.tpl | 13 +++ .../action/TagClipboardAction.class.php | 98 +++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 wcfsetup/install/files/acp/templates/tagSetAsSynonyms.tpl create mode 100644 wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php diff --git a/wcfsetup/install/files/acp/templates/tagSetAsSynonyms.tpl b/wcfsetup/install/files/acp/templates/tagSetAsSynonyms.tpl new file mode 100644 index 0000000000..3b4d88e530 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/tagSetAsSynonyms.tpl @@ -0,0 +1,13 @@ +

{lang}wcf.acp.tag.setAsSynonyms.description{/lang}

+ + + +
+ +
diff --git a/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php b/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php new file mode 100644 index 0000000000..2c43c077f7 --- /dev/null +++ b/wcfsetup/install/files/lib/system/clipboard/action/TagClipboardAction.class.php @@ -0,0 +1,98 @@ + + * @package com.woltlab.wcf + * @subpackage system.clipboard.action + * @category Community Framework + */ +class TagClipboardAction extends AbstractClipboardAction { + /** + * @see \wcf\system\clipboard\action\AbstractClipboardAction::$actionClassActions + */ + protected $actionClassActions = array('delete'); + + /** + * @see \wcf\system\clipboard\action\AbstractClipboardAction::$supportedActions + */ + protected $supportedActions = array('delete', 'setAsSynonyms'); + + /** + * @see \wcf\system\clipboard\action\IClipboardAction::execute() + */ + public function execute(array $objects, ClipboardAction $action) { + $item = parent::execute($objects, $action); + + if ($item === null) { + return null; + } + + // handle actions + switch ($action->actionName) { + case 'delete': + $item->addInternalData('confirmMessage', WCF::getLanguage()->getDynamicVariable('wcf.clipboard.item.com.woltlab.wcf.tag.delete.confirmMessage', [ + 'count' => $item->getCount() + ])); + break; + + case 'setAsSynonyms': + $item->addParameter('template', WCF::getTPL()->fetch('tagSetAsSynonyms', 'wcf', [ + 'tags' => $this->objects + ])); + break; + } + + return $item; + } + + /** + * @see \wcf\system\clipboard\action\IClipboardAction::getClassName() + */ + public function getClassName() { + return 'wcf\data\tag\TagAction'; + } + + /** + * @see \wcf\system\clipboard\action\IClipboardAction::getTypeName() + */ + public function getTypeName() { + return 'com.woltlab.wcf.tag'; + } + + /** + * Returns the ids of the tags which can be deleted. + * + * @return array + */ + protected function validateDelete() { + if (!WCF::getSession()->getPermission('admin.content.tag.canManageTag')) { + return [ ]; + } + + return array_keys($this->objects); + } + + /** + * Returns the ids of the tags which can be set as synonyms. + * + * @return array + */ + protected function validateSetAsSynonyms() { + if (!WCF::getSession()->getPermission('admin.content.tag.canManageTag')) { + return [ ]; + } + + if (count($this->objects) < 2) { + return [ ]; + } + + return array_keys($this->objects); + } +} -- 2.20.1