Optional share buttons for CMS pages
authorAlexander Ebert <ebert@woltlab.com>
Tue, 10 Jul 2018 10:13:12 +0000 (12:13 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 10 Jul 2018 10:13:12 +0000 (12:13 +0200)
See #2595

com.woltlab.wcf/templates/cms.tpl
wcfsetup/install/files/acp/templates/pageAdd.tpl
wcfsetup/install/files/lib/acp/form/PageAddForm.class.php
wcfsetup/install/files/lib/acp/form/PageEditForm.class.php
wcfsetup/install/files/lib/data/page/Page.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index 4147ed57cb3ab2f9a129dfda9154aea083d83f4c..cb359ab7fb2257c7e85b1ddf69162f15cfdc9cbd 100644 (file)
        {/hascontent}
 </footer>
 
+{if $page->showShareButtons()}
+       {capture assign='footerBoxes'}
+               <section class="box boxFullWidth jsOnly">
+                       <h2 class="boxTitle">{lang}wcf.message.share{/lang}</h2>
+                       
+                       <div class="boxContent">
+                               {include file='shareButtons'}
+                       </div>
+               </section>
+       {/capture}
+{/if}
+
 {include file='footer'}
index 5f0157711953f045a373c2db757d613372a155d0..3350cea03d290843f3b6fc060598bd555233dcda 100644 (file)
                                        </dd>
                                </dl>
                                
-                               {if $action == 'add'}
+                               {if $action === 'add'}
                                        <dl>
                                                <dt></dt>
                                                <dd>
                                        </dl>
                                {/if}
                                
+                               {if $pageType !== 'system'}
+                                       <dl>
+                                               <dt></dt>
+                                               <dd>
+                                                       <label><input type="checkbox" id="enableShareButtons" name="enableShareButtons" value="1"{if $enableShareButtons} checked{/if}> {lang}wcf.acp.page.enableShareButtons{/lang}</label>
+                                               </dd>
+                                       </dl>
+                               {/if}
+                               
                                {event name='dataFields'}
                        </div>
                </div>
index 98b0d036e48fde9cc3f8271831f396d3d4e06e2c..e03f6702765468b3d893a7595cff5a45f3eda84c 100644 (file)
@@ -184,13 +184,19 @@ class PageAddForm extends AbstractForm {
         * parent menu item id
         * @var integer
         */
-       public $parentMenuItemID = null;
+       public $parentMenuItemID;
        
        /**
         * menu item node tree
         * @var MenuItemNodeTree
         */
-       public $menuItems = null;
+       public $menuItems;
+       
+       /**
+        * @var bool
+        * @since 3.2
+        */
+       public $enableShareButtons = 0;
        
        /**
         * @inheritDoc
@@ -255,6 +261,7 @@ class PageAddForm extends AbstractForm {
                if (isset($_POST['addPageToMainMenu'])) $this->addPageToMainMenu = 1;
                if (isset($_POST['applicationPackageID'])) $this->applicationPackageID = intval($_POST['applicationPackageID']);
                if (!empty($_POST['parentMenuItemID'])) $this->parentMenuItemID = intval($_POST['parentMenuItemID']);
+               if (isset($_POST['enableShareButtons'])) $this->enableShareButtons = 1;
                
                if (isset($_POST['customURL']) && is_array($_POST['customURL'])) $this->customURL = array_map('mb_strtolower', ArrayUtil::trim($_POST['customURL']));
                if (isset($_POST['title']) && is_array($_POST['title'])) $this->title = ArrayUtil::trim($_POST['title']);
@@ -290,7 +297,7 @@ class PageAddForm extends AbstractForm {
                
                $this->validateBoxIDs();
                
-               if ($this->pageType == 'text') {
+               if ($this->pageType === 'text') {
                        if ($this->isMultilingual) {
                                foreach (LanguageFactory::getInstance()->getLanguages() as $language) {
                                        $this->htmlInputProcessors[$language->languageID] = new HtmlInputProcessor();
@@ -530,6 +537,7 @@ class PageAddForm extends AbstractForm {
                        'isLandingPage' => 0,
                        'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
                        'allowSpidersToIndex' => $this->allowSpidersToIndex,
+                       'enableShareButtons' => $this->enableShareButtons,
                        'applicationPackageID' => $this->applicationPackageID,
                        'lastUpdateTime' => TIME_NOW,
                        'isMultilingual' => $this->isMultilingual,
@@ -587,7 +595,7 @@ class PageAddForm extends AbstractForm {
                WCF::getTPL()->assign('success', true);
                
                // reset variables
-               $this->parentPageID = $this->isDisabled = $this->isLandingPage = $this->availableDuringOfflineMode = 0;
+               $this->parentPageID = $this->isDisabled = $this->isLandingPage = $this->availableDuringOfflineMode = $this->enableShareButtons = 0;
                $this->applicationPackageID = 1;
                $this->cssClassName = $this->name = '';
                $this->customURL = $this->title = $this->content = $this->metaDescription = $this->metaKeywords = $this->aclValues = [];
@@ -652,7 +660,8 @@ class PageAddForm extends AbstractForm {
                        'aclValues' => SimpleAclHandler::getInstance()->getOutputValues($this->aclValues),
                        'addPageToMainMenu' => $this->addPageToMainMenu,
                        'parentMenuItemID' => $this->parentMenuItemID,
-                       'menuItemNodeList' => $this->menuItems->getNodeList()
+                       'menuItemNodeList' => $this->menuItems->getNodeList(),
+                       'enableShareButtons' => $this->enableShareButtons
                ]);
        }
 }
index 750b7d7a729b5f0b98a468dcd83987096431cdfe..6d813a8a74c3b5bac4d4dec8259f1b9ba965bc18 100644 (file)
@@ -157,7 +157,8 @@ class PageEditForm extends PageAddForm {
                        'parentPageID' => $this->parentPageID ?: null,
                        'applicationPackageID' => $this->applicationPackageID,
                        'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
-                       'allowSpidersToIndex' => $this->allowSpidersToIndex
+                       'allowSpidersToIndex' => $this->allowSpidersToIndex,
+                       'enableShareButtons' => $this->enableShareButtons
                ];
                
                if ($this->pageType == 'system') {
@@ -247,6 +248,7 @@ class PageEditForm extends PageAddForm {
                        if ($this->page->availableDuringOfflineMode) $this->availableDuringOfflineMode = 1;
                        if ($this->page->allowSpidersToIndex) $this->allowSpidersToIndex = 1;
                        else $this->allowSpidersToIndex = 0;
+                       $this->enableShareButtons = $this->page->enableShareButtons;
                        
                        foreach ($this->page->getPageContents() as $languageID => $content) {
                                $this->title[$languageID] = $content->title;
index 0f08f0375307e1aff713eae8220821a2bea7034b..fe6ef7e632a3a8a40f2247a866e0de7e65620a93 100644 (file)
@@ -46,6 +46,7 @@ use wcf\system\WCF;
  * @property-read      string          $availableDuringOfflineMode     is `1` if the page is available during offline mode, otherwise `0`
  * @property-read      string          $allowSpidersToIndex            is `1` if the page is accessible for search spiders, otherwise `0`
  * @property-read      string          $excludeFromLandingPage         is `1` if the page can never be set as landing page, otherwise `0`
+ * @property-read      string          $enableShareButtons             is `1` if the page should display share buttons, otherwise `0`
  * @property-read      string          $permissions                    comma separated list of user group permissions of which the active user needs to have at least one to access the page
  * @property-read      string          $options                        comma separated list of options of which at least one needs to be enabled for the page to be accessible
  */
@@ -353,6 +354,16 @@ class Page extends DatabaseObject implements ILinkableObject, ITitledObject {
                return $pageLanguages;
        }
        
+       /**
+        * Returns true if the share buttons are enabled and this is not a system-type page.
+        * 
+        * @return      bool
+        * @since       3.2
+        */
+       public function showShareButtons(): bool {
+               return $this->enableShareButtons && $this->pageType !== 'system';
+       }
+       
        /**
         * Returns the page with the given identifier.
         * 
index df0cf1802f0e0b34691aca978d5dfe445d647c62..27671b6a73a6e6419ed7cdcb2bba51a7eb8ad09d 100644 (file)
@@ -1681,6 +1681,7 @@ Als Benachrichtigungs-URL in der Konfiguration der sofortigen Zahlungsbestätigu
                <item name="wcf.acp.page.addPageToMainMenu"><![CDATA[Seite automatisch in das Hauptmenü aufnehmen]]></item>
                <item name="wcf.acp.page.lastVersion"><![CDATA[Es gibt <a href="{link controller='VersionTrackerList' objectType='com.woltlab.wcf.page' objectID=$page->pageID}{/link}">vorherige Versionen</a> dieser Seite, die letzte Änderung erfolgte durch <a href="{link controller='UserEdit' id=$lastVersion->userID}{/link}">{$lastVersion->username}</a> ({@$lastVersion->time|time}).]]></item>
                <item name="wcf.acp.page.originIsNotSystem"><![CDATA[Eigene Seiten]]></item>
+               <item name="wcf.acp.page.enableShareButtons"><![CDATA[Teilen-Buttons für diese Seite aktivieren]]></item>
        </category>
        
        <category name="wcf.acp.paidSubscription">
index 73def6a048b49cded9f1deff7d07879b83b3fed2..96712a256238da94cda772635c503966c4ac9833 100644 (file)
@@ -3349,6 +3349,7 @@ Email: {@$emailAddress} {* this line ends with a space *}
                <item name="wcf.acp.page.addPageToMainMenu"><![CDATA[Add page to main menu]]></item>
                <item name="wcf.acp.page.lastVersion"><![CDATA[There are <a href="{link controller='VersionTrackerList' objectType='com.woltlab.wcf.page' objectID=$page->pageID}{/link}">previous versions</a> of this page, the last change was by <a href="{link controller='UserEdit' id=$lastVersion->userID}{/link}">{$lastVersion->username}</a> ({@$lastVersion->time|time}).]]></item>
                <item name="wcf.acp.page.originIsNotSystem"><![CDATA[Custom pages only]]></item>
+               <item name="wcf.acp.page.enableShareButtons"><![CDATA[Enable the share buttons for this page]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
index 83e79596e2bb6e0e520af8bb3616fce8cb06955e..1e9cbaf46a73c3ba7729962742537a9ee221c86e 100644 (file)
@@ -1050,6 +1050,7 @@ CREATE TABLE wcf1_page (
        availableDuringOfflineMode TINYINT(1) NOT NULL DEFAULT 0,
        allowSpidersToIndex TINYINT(1) NOT NULL DEFAULT 0,
        excludeFromLandingPage TINYINT(1) NOT NULL DEFAULT 0,
+       enableShareButtons TINYINT(1) NOT NULL DEFAULT 0,
        permissions TEXT NULL,
        options TEXT NULL
 );