Added setting to configure pages' accessibility for search spiders
authorMarcel Werk <burntime@woltlab.com>
Fri, 17 Mar 2017 12:05:06 +0000 (13:05 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 17 Mar 2017 12:05:06 +0000 (13:05 +0100)
See #2204

20 files changed:
XSD/page.xsd
com.woltlab.wcf/page.xml
com.woltlab.wcf/templates/headInclude.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/files/lib/page/ArticleListPage.class.php
wcfsetup/install/files/lib/page/ArticlePage.class.php
wcfsetup/install/files/lib/page/CategoryArticleListPage.class.php
wcfsetup/install/files/lib/page/CmsPage.class.php
wcfsetup/install/files/lib/page/MembersListPage.class.php
wcfsetup/install/files/lib/page/RecentActivityListPage.class.php
wcfsetup/install/files/lib/page/TeamPage.class.php
wcfsetup/install/files/lib/page/UserPage.class.php
wcfsetup/install/files/lib/page/UsersOnlineListPage.class.php
wcfsetup/install/files/lib/system/package/plugin/PagePackageInstallationPlugin.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml
wcfsetup/setup/db/install.sql

index d325db595f365926b1cccfeeb4f737be767b7040..4f95efbc1206423cc37664cd20c9301959c586cd 100644 (file)
@@ -56,6 +56,7 @@
                                        <xs:element name="hasFixedParent" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="requireObjectID" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="availableDuringOfflineMode" type="woltlab_boolean" minOccurs="0" />
+                                       <xs:element name="allowSpidersToIndex" type="woltlab_boolean" minOccurs="0" />
                                        <xs:element name="cssClassName" type="woltlab_varchar" minOccurs="0" />
                                </xs:choice>
                        </xs:extension>
index 003fb25f3e3bdbf2f9526209764fc8d572a5989c..26a1028389d3c8c4f6f5e66eabdd89c4c55e4dfe 100644 (file)
@@ -9,6 +9,7 @@
                        <name language="en">Members</name>
                        <permissions>user.profile.canViewMembersList</permissions>
                        <options>module_members_list</options>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                        
                        <content language="en">
                                <title>Members</title>
@@ -23,6 +24,7 @@
                        <name language="de">Letzte Aktivitäten</name>
                        <name language="en">Recent Activities</name>
                        <parent>com.woltlab.wcf.MembersList</parent>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                        
                        <content language="en">
                                <title>Recent Activities</title>
@@ -39,6 +41,7 @@
                        <parent>com.woltlab.wcf.MembersList</parent>
                        <permissions>user.profile.canViewUsersOnlineList</permissions>
                        <options>module_users_online</options>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                        
                        <content language="en">
                                <title>Users Online</title>
@@ -55,6 +58,7 @@
                        <parent>com.woltlab.wcf.MembersList</parent>
                        <permissions>user.profile.canViewMembersList</permissions>
                        <options>module_team_page</options>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                        
                        <content language="en">
                                <title>Team</title>
                        <name language="en">User Profile</name>
                        <parent>com.woltlab.wcf.MembersList</parent>
                        <requireObjectID>1</requireObjectID>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                </page>
                <page identifier="com.woltlab.wcf.ArticleList">
                        <pageType>system</pageType>
                        <name language="de">Artikel-Liste</name>
                        <name language="en">Article List</name>
                        <options>module_article</options>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                        
                        <content language="en">
                                <title>Articles</title>
                        <options>module_article</options>
                        <parent>com.woltlab.wcf.ArticleList</parent>
                        <requireObjectID>1</requireObjectID>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                </page>
                <page identifier="com.woltlab.wcf.Article">
                        <pageType>system</pageType>
                        <parent>com.woltlab.wcf.CategoryArticleList</parent>
                        <hasFixedParent>1</hasFixedParent>
                        <requireObjectID>1</requireObjectID>
+                       <allowSpidersToIndex>1</allowSpidersToIndex>
                </page>
                
                <!-- static -->
index 3b82da25c152e7fc5c4bd62cacaf00a9e4f4e6e7..146d5b665f3519b591a370f0a4ccd52231390a54 100644 (file)
@@ -1,7 +1,7 @@
 <meta charset="utf-8">
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta name="format-detection" content="telephone=no">
-{if $allowSpidersToIndexThisPage|empty}<meta name="robots" content="noindex,nofollow">{/if}
+{if $allowSpidersToIndexThisPage|empty && ($__wcf->getActivePage() == null || !$__wcf->getActivePage()->allowSpidersToIndex)}<meta name="robots" content="noindex,nofollow">{/if}
 {implode from=$__wcf->getMetaTagHandler() item=__metaTag glue="\n"}{@$__metaTag}{/implode}
 {event name='metaTags'}
 
index dc453a460a6b9a4c0a3be0e24273252a4db69ce3..ac22caa14b6b8f50908b65f33fb7192d22166390 100644 (file)
                                        </dd>
                                </dl>
                                
+                               <dl>
+                                       <dt></dt>
+                                       <dd>
+                                               <label><input type="checkbox" id="allowSpidersToIndex" name="allowSpidersToIndex" value="1"{if $allowSpidersToIndex} checked{/if}> {lang}wcf.acp.page.allowSpidersToIndex{/lang}</label>
+                                       </dd>
+                               </dl>
+                               
                                {event name='dataFields'}
                        </div>
                </div>
index 480260aa6fefcb4167d7d94909651cfce2439704..02bcf7ec639028a9b370b382988601721242687e 100644 (file)
@@ -161,6 +161,12 @@ class PageAddForm extends AbstractForm {
         */
        public $availableDuringOfflineMode = 0;
        
+       /**
+        * true if the page is accessible for search spiders
+        * @var boolean
+        */
+       public $allowSpidersToIndex = 1;
+       
        /**
         * @inheritDoc
         */
@@ -213,12 +219,14 @@ class PageAddForm extends AbstractForm {
        public function readFormParameters() {
                parent::readFormParameters();
                
+               $this->allowSpidersToIndex = 0;
                if (isset($_POST['parentPageID'])) $this->parentPageID = intval($_POST['parentPageID']);
                if (isset($_POST['name'])) $this->name = StringUtil::trim($_POST['name']);
                if (isset($_POST['cssClassName'])) $this->cssClassName = StringUtil::trim($_POST['cssClassName']);
                if (isset($_POST['isDisabled'])) $this->isDisabled = 1;
                if (isset($_POST['isLandingPage'])) $this->isLandingPage = 1;
                if (isset($_POST['availableDuringOfflineMode'])) $this->availableDuringOfflineMode = 1;
+               if (isset($_POST['allowSpidersToIndex'])) $this->allowSpidersToIndex = 1;
                if (isset($_POST['applicationPackageID'])) $this->applicationPackageID = intval($_POST['applicationPackageID']);
                
                if (isset($_POST['customURL']) && is_array($_POST['customURL'])) $this->customURL = array_map('mb_strtolower', ArrayUtil::trim($_POST['customURL']));
@@ -454,6 +462,7 @@ class PageAddForm extends AbstractForm {
                        'isDisabled' => $this->isDisabled ? 1 : 0,
                        'isLandingPage' => 0,
                        'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
+                       'allowSpidersToIndex' => $this->allowSpidersToIndex,
                        'applicationPackageID' => $this->applicationPackageID,
                        'lastUpdateTime' => TIME_NOW,
                        'isMultilingual' => $this->isMultilingual,
@@ -519,6 +528,7 @@ class PageAddForm extends AbstractForm {
                        'isDisabled' => $this->isDisabled,
                        'isLandingPage' => $this->isLandingPage,
                        'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
+                       'allowSpidersToIndex' => $this->allowSpidersToIndex,
                        'isMultilingual' => $this->isMultilingual,
                        'applicationPackageID' => $this->applicationPackageID,
                        'customURL' => $this->customURL,
index 1fe2f5bdc4418f8f62eea1489dc92270818dd27b..9d2bbff2a0886dfaf6548146e8ea95a24403ae17 100644 (file)
@@ -139,7 +139,8 @@ class PageEditForm extends PageAddForm {
                        'lastUpdateTime' => TIME_NOW,
                        'parentPageID' => $this->parentPageID ?: null,
                        'applicationPackageID' => $this->applicationPackageID,
-                       'availableDuringOfflineMode' => $this->availableDuringOfflineMode
+                       'availableDuringOfflineMode' => $this->availableDuringOfflineMode,
+                       'allowSpidersToIndex' => $this->allowSpidersToIndex
                ];
                
                if ($this->pageType == 'system') {
@@ -227,6 +228,7 @@ class PageEditForm extends PageAddForm {
                        if ($this->page->isLandingPage) $this->isLandingPage = 1;
                        if ($this->page->isDisabled) $this->isDisabled = 1;
                        if ($this->page->availableDuringOfflineMode) $this->availableDuringOfflineMode = 1;
+                       if ($this->page->allowSpidersToIndex) $this->allowSpidersToIndex = 1;
                        
                        foreach ($this->page->getPageContents() as $languageID => $content) {
                                $this->title[$languageID] = $content->title;
index 6551a00662ed922bfeb6208148c34447abae8766..7715ce106223f485d9bd3784e734b9339c52f5d7 100644 (file)
@@ -43,6 +43,7 @@ use wcf\system\WCF;
  * @property-read      integer         $lastUpdateTime                 timestamp at which the page has been updated the last time
  * @property-read      string          $cssClassName                   css class name(s) of the page
  * @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          $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
  */
index 7ad07c08f23c9c52aa7dd3aa4cb433a7f2b52803..d137bf6b72173f404224fa71aca42c66747d5c81 100644 (file)
@@ -2,7 +2,6 @@
 namespace wcf\page;
 use wcf\data\article\AccessibleArticleList;
 use wcf\system\request\LinkHandler;
-use wcf\system\WCF;
 
 /**
  * Shows a list of cms articles.
@@ -47,15 +46,4 @@ class ArticleListPage extends MultipleLinkPage {
                
                $this->canonicalURL = LinkHandler::getInstance()->getLink('ArticleList', [], ($this->pageNo > 1 ? 'pageNo=' . $this->pageNo : ''));
        }
-       
-       /**
-        * @inheritDoc
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign([
-                       'allowSpidersToIndexThisPage' => true
-               ]);
-       }
 }
index aa1e21bacf1435cbfcb2f103d39d0fe7fa26949a..573a6100ca6d2b5a75e9437087eb1c3f4cbd7af0 100644 (file)
@@ -140,8 +140,7 @@ class ArticlePage extends AbstractArticlePage {
                        'commentObjectTypeID' => $this->commentObjectTypeID,
                        'lastCommentTime' => $this->commentList ? $this->commentList->getMinCommentTime() : 0,
                        'likeData' => (MODULE_LIKE && $this->commentList) ? $this->commentList->getLikeData() : [],
-                       'articleLikeData' => $this->articleLikeData,
-                       'allowSpidersToIndexThisPage' => true
+                       'articleLikeData' => $this->articleLikeData
                ]);
        }
 }
index f8b43c8f716d560c4da5c95d247f50292041810d..1e124dd272ec721bd3b67022141ba4e3d15acbce 100644 (file)
@@ -86,8 +86,7 @@ class CategoryArticleListPage extends ArticleListPage {
                
                WCF::getTPL()->assign([
                        'categoryID' => $this->categoryID,
-                       'category' => $this->category,
-                       'allowSpidersToIndexThisPage' => true
+                       'category' => $this->category
                ]);
        }
 }
index 42f3f75313c2a0a8fd8f5697695f7a1fe8613f98..553b222c0538c54232906e3481a5cec2387a85c3 100644 (file)
@@ -115,8 +115,7 @@ class CmsPage extends AbstractPage {
                        'contentLanguageID' => $this->languageID,
                        'page' => $this->page,
                        'pageID' => $this->pageID,
-                       'activePageLanguage' => $this->languageID ? LanguageFactory::getInstance()->getLanguage($this->languageID) : null,
-                       'allowSpidersToIndexThisPage' => true
+                       'activePageLanguage' => $this->languageID ? LanguageFactory::getInstance()->getLanguage($this->languageID) : null
                ]);
        }
 }
index c2fcfe8144374d138aedf9db747b386e161f6e26..95e6d36c80c52b38260c785719e2130bc431bd10 100644 (file)
@@ -154,8 +154,7 @@ class MembersListPage extends SortablePage {
                WCF::getTPL()->assign([
                        'letters' => str_split(self::$availableLetters),
                        'letter' => $this->letter,
-                       'searchID' => $this->searchID,
-                       'allowSpidersToIndexThisPage' => true
+                       'searchID' => $this->searchID
                ]);
                
                if (count($this->objectList) === 0) {
index 779708a142c08f7840d2a958d4a69d2bee90f346..0317066f63d38d4849577d836f6fe1bff934bf2d 100644 (file)
@@ -61,8 +61,7 @@ class RecentActivityListPage extends AbstractPage {
                
                WCF::getTPL()->assign([
                        'eventList' => $this->eventList,
-                       'lastEventTime' => $this->eventList->getLastEventTime(),
-                       'allowSpidersToIndexThisPage' => true
+                       'lastEventTime' => $this->eventList->getLastEventTime()
                ]);
        }
 }
index 895fb9678ea3650e5b5e77fb36d0e398fd837184..18ef514cab7ea7693edcbd17dda3321cf5101e39 100644 (file)
@@ -64,15 +64,4 @@ class TeamPage extends MultipleLinkPage {
                // add breadcrumbs
                if (MODULE_MEMBERS_LIST) PageLocationManager::getInstance()->addParentLocation('com.woltlab.wcf.MembersList');
        }
-       
-       /**
-        * @inheritDoc
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign([
-                       'allowSpidersToIndexThisPage' => true
-               ]);
-       }
 }
index 0424d779444da11d2a2be8a7753d115a52936537..eaae0ebfd9967581a4a18a8040a3cb4604c9a741 100644 (file)
@@ -161,7 +161,6 @@ class UserPage extends AbstractPage {
                        'followingCount' => $this->followingList->countObjects(),
                        'visitors' => $this->visitorList !== null ? $this->visitorList->getObjects() : [],
                        'visitorCount' => $this->visitorList !== null ? $this->visitorList->countObjects() : 0,
-                       'allowSpidersToIndexThisPage' => true,
                        'isAccessible' => UserGroup::isAccessibleGroup($this->user->getGroupIDs())
                ]);
        }
index 4724311794fcdfdc29a6c0ade54f6df5b670d585..69a6a71af16ab8396423edf19c1a3b13cf1d64db 100644 (file)
@@ -119,17 +119,6 @@ class UsersOnlineListPage extends SortablePage {
                }
        }
        
-       /**
-        * @inheritDoc
-        */
-       public function assignVariables() {
-               parent::assignVariables();
-               
-               WCF::getTPL()->assign([
-                       'allowSpidersToIndexThisPage' => true
-               ]);
-       }
-       
        /**
         * @inheritDoc
         */
index cf5740d28789edd0fc6aebd90e125784bfdd4af5..2472fb71c2f877dbe3b39f69408f2f7a4fb60e47 100644 (file)
@@ -221,7 +221,8 @@ class PagePackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin
                        'permissions' => isset($data['elements']['permissions']) ? $data['elements']['permissions'] : '',
                        'hasFixedParent' => ($pageType == 'system' && !empty($data['elements']['hasFixedParent'])) ? 1 : 0,
                        'cssClassName' => isset($data['elements']['cssClassName']) ? $data['elements']['cssClassName'] : '',
-                       'availableDuringOfflineMode' => (!empty($data['elements']['availableDuringOfflineMode'])) ? 1 : 0
+                       'availableDuringOfflineMode' => (!empty($data['elements']['availableDuringOfflineMode'])) ? 1 : 0,
+                       'allowSpidersToIndex' => (!empty($data['elements']['allowSpidersToIndex'])) ? 1 : 0
                ];
        }
        
index d9bf7e1d16ea7ddb79b7c53f5d3e709e99314391..8961afabc70d3baa5bc5370fb0fb96b41e604624 100644 (file)
@@ -1423,6 +1423,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.page.url"><![CDATA[URL]]></item>
                <item name="wcf.acp.page.cssClassName"><![CDATA[CSS-Klassen]]></item>
                <item name="wcf.acp.page.availableDuringOfflineMode"><![CDATA[Seite ist im Wartungsmodus aufrufbar]]></item>
+               <item name="wcf.acp.page.allowSpidersToIndex"><![CDATA[Seite darf von Suchmaschinen-Robotern indiziert werden]]></item>
        </category>
        
        <category name="wcf.acp.paidSubscription">
index 7c805528ddcc26602754c33610e518ffbc62bb29..507f92b50e43ab148f6dadd18fa2803c961b79f2 100644 (file)
@@ -2894,6 +2894,7 @@ Errors are:
                <item name="wcf.acp.page.url"><![CDATA[URL]]></item>
                <item name="wcf.acp.page.cssClassName"><![CDATA[CSS Class Name]]></item>
                <item name="wcf.acp.page.availableDuringOfflineMode"><![CDATA[Page is available during maintenance mode]]></item>
+               <item name="wcf.acp.page.allowSpidersToIndex"><![CDATA[Allow search spiders to index this page]]></item>
        </category>
        
        <category name="wcf.paidSubscription">
index 5e591e23ea9b5674490e235a69fb2b1a48665071..f017bf351f3f829255ce3a7c123cc7bc3346c2c4 100644 (file)
@@ -981,6 +981,7 @@ CREATE TABLE wcf1_page (
        lastUpdateTime INT(10) NOT NULL DEFAULT 0,
        cssClassName VARCHAR(255) NOT NULL DEFAULT '',
        availableDuringOfflineMode TINYINT(1) NOT NULL DEFAULT 0,
+       allowSpidersToIndex TINYINT(1) NOT NULL DEFAULT 0,
        permissions TEXT NULL,
        options TEXT NULL
 );