Add sitemap toggling function
authorJoshua Rüsweg <josh@bastelstu.be>
Mon, 16 Oct 2017 19:54:39 +0000 (21:54 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Mon, 16 Oct 2017 19:54:39 +0000 (21:54 +0200)
Closes #2439

wcfsetup/install/files/acp/templates/sitemapList.tpl
wcfsetup/install/files/acp/update_com.woltlab.wcf_beta1_to_beta2.php
wcfsetup/install/files/lib/data/object/type/SitemapObjectTypeAction.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 1ee8f5d821d70dede840643d8e8bf7f305cd1ac8..6ac57b31ae71f4983286d5444a0c97e7bfbcc99f 100755 (executable)
@@ -1,5 +1,11 @@
 {include file='header' pageTitle='wcf.acp.menu.link.maintenance.sitemap'}
 
+<script data-relocate="true">
+       $(function() {
+               new WCF.Action.Toggle('wcf\\data\\object\\type\\SitemapObjectTypeAction', '.sitemapObjectRow');
+       });
+</script>
+
 <header class="contentHeader">
        <div class="contentHeaderTitle">
                <h1 class="contentTitle">{lang}wcf.acp.menu.link.maintenance.sitemap{/lang}</h1>
@@ -34,7 +40,7 @@
                                {foreach from=$sitemapObjectTypes item=object}
                                        <tr class="sitemapObjectRow">
                                                <td class="columnIcon">
-                                                       <a href="{link controller="SitemapEdit"}objectType={$object->objectType}{/link}" title="{lang}wcf.acp.sitemap.{if $object->isDisabled}isDisabled{else}enabled{/if}{/lang}" class="jsTooltip"><span class="icon icon16 fa{if !$object->isDisabled}-check{/if}-square-o"></span></a>
+                                                       <span class="icon icon16 fa-{if !$object->isDisabled}check-{/if}square-o jsToggleButton jsTooltip pointer" title="{lang}wcf.global.button.{if !$object->isDisabled}disable{else}enable{/if}{/lang}" data-object-id="{@$object->objectTypeID}"></span>
                                                        <a href="{link controller="SitemapEdit"}objectType={$object->objectType}{/link}" title="{lang}wcf.global.button.edit{/lang}" class="jsTooltip"><span class="icon icon16 fa-pencil"></span></a>
                                                </td>
                                                <td class="columnTitle columnSitemap"><a href="{link controller="SitemapEdit"}objectType={$object->objectType}{/link}">{lang}wcf.acp.sitemap.objectType.{$object->objectType}{/lang}</a></td>
index 6c812ed0ceea743c2e5134d7856a6e918605694f..fd1c1e9bd10d910c7f38bb21a40dee253c2a5734 100644 (file)
@@ -35,4 +35,4 @@ foreach ($conditionList->getObjects() as $condition) {
        }
 }
 
-ConditionEditor::resetCache();
\ No newline at end of file
+ConditionEditor::resetCache();
diff --git a/wcfsetup/install/files/lib/data/object/type/SitemapObjectTypeAction.class.php b/wcfsetup/install/files/lib/data/object/type/SitemapObjectTypeAction.class.php
new file mode 100644 (file)
index 0000000..ee029bf
--- /dev/null
@@ -0,0 +1,58 @@
+<?php
+namespace wcf\data\object\type;
+use wcf\data\IToggleAction;
+use wcf\system\exception\IllegalLinkException;
+use wcf\system\WCF;
+
+/**
+ * Executes sitemap object type-related actions.
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\Data\Object\Type
+ * @since      3.1
+ *
+ * @method     ObjectType              create()
+ * @method     ObjectTypeEditor[]      getObjects()
+ * @method     ObjectTypeEditor        getSingleObject()
+ */
+class SitemapObjectTypeAction extends ObjectTypeAction implements IToggleAction {
+       /**
+        * @inheritDoc
+        */
+       protected $className = ObjectTypeEditor::class;
+       
+       /**
+        * @inheritDoc
+        */
+       protected $requireACP = ['toggle'];
+       
+       /**
+        * @inheritdoc
+        */
+       public function toggle() {
+               foreach ($this->getObjects() as $objectEditor) {
+                       $objectEditor->update([
+                               'additionalData' => serialize(array_merge($objectEditor->additionalData, ['isDisabled' => !$objectEditor->isDisabled ? 1 : 0]))
+                       ]);
+               }
+       }
+       
+       /**
+        * @inheritdoc
+        */
+       public function validateToggle() {
+               if (empty($this->objects)) {
+                       $this->readObjects();
+               }
+               
+               WCF::getSession()->checkPermissions(['admin.management.canRebuildData']);
+               
+               foreach ($this->getObjects() as $objectEditor) {
+                       if ($objectEditor->definitionID != ObjectTypeCache::getInstance()->getDefinitionByName('com.woltlab.wcf.sitemap.object')->definitionID) {
+                               throw new IllegalLinkException();
+                       }
+               }
+       }
+}
index 0ea06f4d780a1c5c2896e88b95cb0a59173661ff..3d4aa59cbcf3264643d123a1ac7870d4b9dc8db0 100644 (file)
@@ -1770,7 +1770,6 @@ Als Benachrichtigungs-URL in der Konfiguration der sofortigen Zahlungsbestätigu
                <item name="wcf.acp.sitemap.rebuildTime"><![CDATA[Erneuerungszeit]]></item>
                <item name="wcf.acp.sitemap.rebuildTime.description"><![CDATA[Die Zeit nachdem die Sitemap erneuert werden soll.]]></item>
                <item name="wcf.acp.sitemap.isDisabled"><![CDATA[Sitemap deaktivieren]]></item>
-               <item name="wcf.acp.sitemap.enabled"><![CDATA[Sitemap aktiviert]]></item>
                <item name="wcf.acp.sitemap.edit"><![CDATA[Sitemap bearbeiten]]></item>
                <item name="wcf.acp.sitemap.cliInfo"><![CDATA[Die Sitemap kann auch mittels CLI neu generiert werden. {if LANGUAGE_USE_INFORMAL_VARIANT}Führe{else}Führen Sie{/if} dafür <kbd>worker wcf\system\worker\SitemapRebuildWorker</kbd> in einer CLI Session aus.]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.user"><![CDATA[Benutzer]]></item>
index 6eb6767cc3db9e46fe677d8e71cae47d7008f85a..037ec808853c6c90a5e0f1c23443e2f79c4d6b84 100644 (file)
@@ -1712,7 +1712,6 @@ When prompted for the notification URL for the instant payment notifications, pl
                <item name="wcf.acp.sitemap.rebuildTime"><![CDATA[Rebuild Time]]></item>
                <item name="wcf.acp.sitemap.rebuildTime.description"><![CDATA[The time after the sitemap have to be rebuilt.]]></item>
                <item name="wcf.acp.sitemap.isDisabled"><![CDATA[Disable Sitemap]]></item>
-               <item name="wcf.acp.sitemap.enabled"><![CDATA[Sitemap enabled]]></item>
                <item name="wcf.acp.sitemap.edit"><![CDATA[Edit Sitemap]]></item>
                <item name="wcf.acp.sitemap.cliInfo"><![CDATA[You can rebuild the sitemap using CLI. For that, execute <kbd>worker wcf\system\worker\SitemapRebuildWorker</kbd> in a CLI session.]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.user"><![CDATA[User]]></item>