From: Alexander Ebert Date: Tue, 10 Jul 2018 10:13:12 +0000 (+0200) Subject: Optional share buttons for CMS pages X-Git-Tag: 5.2.0_Alpha_1~364^2~128 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=95230ff4509857ea2b3b49fa0a19a472e9c1bc9c;p=GitHub%2FWoltLab%2FWCF.git Optional share buttons for CMS pages See #2595 --- diff --git a/com.woltlab.wcf/templates/cms.tpl b/com.woltlab.wcf/templates/cms.tpl index 4147ed57cb..cb359ab7fb 100644 --- a/com.woltlab.wcf/templates/cms.tpl +++ b/com.woltlab.wcf/templates/cms.tpl @@ -62,4 +62,16 @@ {/hascontent} +{if $page->showShareButtons()} + {capture assign='footerBoxes'} +
+

{lang}wcf.message.share{/lang}

+ +
+ {include file='shareButtons'} +
+
+ {/capture} +{/if} + {include file='footer'} diff --git a/wcfsetup/install/files/acp/templates/pageAdd.tpl b/wcfsetup/install/files/acp/templates/pageAdd.tpl index 5f01577119..3350cea03d 100644 --- a/wcfsetup/install/files/acp/templates/pageAdd.tpl +++ b/wcfsetup/install/files/acp/templates/pageAdd.tpl @@ -244,7 +244,7 @@ - {if $action == 'add'} + {if $action === 'add'}
@@ -286,6 +286,15 @@
{/if} + {if $pageType !== 'system'} +
+
+
+ +
+
+ {/if} + {event name='dataFields'} diff --git a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php index 98b0d036e4..e03f670276 100644 --- a/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageAddForm.class.php @@ -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 ]); } } diff --git a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php index 750b7d7a72..6d813a8a74 100644 --- a/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/PageEditForm.class.php @@ -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; diff --git a/wcfsetup/install/files/lib/data/page/Page.class.php b/wcfsetup/install/files/lib/data/page/Page.class.php index 0f08f03753..fe6ef7e632 100644 --- a/wcfsetup/install/files/lib/data/page/Page.class.php +++ b/wcfsetup/install/files/lib/data/page/Page.class.php @@ -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. * diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index df0cf1802f..27671b6a73 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1681,6 +1681,7 @@ Als Benachrichtigungs-URL in der Konfiguration der sofortigen Zahlungsbestätigu pageID}{/link}">vorherige Versionen dieser Seite, die letzte Änderung erfolgte durch {$lastVersion->username} ({@$lastVersion->time|time}).]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 73def6a048..96712a2562 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -3349,6 +3349,7 @@ Email: {@$emailAddress} {* this line ends with a space *} pageID}{/link}">previous versions of this page, the last change was by {$lastVersion->username} ({@$lastVersion->time|time}).]]> + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 83e79596e2..1e9cbaf46a 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -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 );