Add simple page sitemap
authorJoshua Rüsweg <josh@bastelstu.be>
Sun, 11 Jun 2017 13:52:02 +0000 (15:52 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Sun, 11 Jun 2017 14:09:02 +0000 (16:09 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/sitemap/object/SimplePageSitemapObject.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index e3bfd4225970ab26272ebd79721311f93e673ea8..0d1234e0dcc30c154f020d59c32e9405e42c872e 100644 (file)
                        <changeFreq>monthly</changeFreq>
                        <rebuildTime>259200</rebuildTime>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.sitemap.object.simplePage</name>
+                       <definitionname>com.woltlab.wcf.sitemap.object</definitionname>
+                       <classname>wcf\system\sitemap\object\SimplePageSitemapObject</classname>
+                       <priority>0.5</priority>
+                       <changeFreq>monthly</changeFreq>
+                       <rebuildTime>604800</rebuildTime>
+               </type>
                <!-- /sitemap -->
                
                <!-- deprecated -->
diff --git a/wcfsetup/install/files/lib/system/sitemap/object/SimplePageSitemapObject.class.php b/wcfsetup/install/files/lib/system/sitemap/object/SimplePageSitemapObject.class.php
new file mode 100644 (file)
index 0000000..d65c277
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+namespace wcf\system\sitemap\object;
+use wcf\data\page\Page;
+use wcf\data\page\PageList;
+use wcf\data\DatabaseObject;
+use wcf\page\AbstractPage;
+use wcf\system\acl\simple\SimpleAclResolver;
+
+/**
+ * Simple page sitemap implementation.
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\Sitemap\Object
+ * @since      3.1
+ */
+class SimplePageSitemapObject extends AbstractSitemapObjectObjectType {
+       /**
+        * @inheritDoc
+        */
+       public function getObjectClass() {
+               return Page::class;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getObjectList() {
+               /** @var $classList PageList */
+               $classList = parent::getObjectList();
+               $classList->getConditionBuilder()->add('isMultilingual = ?', [0]);
+               
+               return $classList;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function canView(DatabaseObject $object) {
+               /** @var $object Page */
+               if ($object->isDisabled) {
+                       return false;
+               }
+               
+               if ($object->requireObjectID) {
+                       return false;
+               }
+               
+               if (!$object->validateOptions()) {
+                       return false;
+               }
+               
+               if ($object->permissions) {
+                       $permissions = explode(',', $object->permissions);
+                       foreach ($permissions as $permission) {
+                               if (!self::getGuestUserProfile()->getPermission($permission)) {
+                                       return false;
+                               }
+                       }
+               }
+               
+               if (!SimpleAclResolver::getInstance()->canAccess('com.woltlab.wcf.page', $object->pageID, self::getGuestUserProfile()->getDecoratedObject())) {
+                       return false;
+               }
+               
+               if (!empty($object->controller)) {
+                       /** @var $page AbstractPage */
+                       $page = new $object->controller;
+                       
+                       if ($page->loginRequired) {
+                               return false;
+                       }
+                       
+                       if ($page->neededPermissions) {
+                               foreach ($page->neededPermissions as $permission) {
+                                       if (!self::getGuestUserProfile()->getPermission($permission)) {
+                                               return false;
+                                       }
+                               }
+                       }
+                       
+                       if ($page->neededModules) {
+                               foreach ($page->neededModules as $module) {
+                                       if (!defined($module) || !constant($module)) {
+                                               return false;
+                                       }
+                               }
+                       }
+               }
+               
+               return true;
+       }
+}
index 136b02321a1c62c39a4a01ab2c785e04384efe60..7aadb8d9039c89cc4154c2efe3fdfd1911b16e93 100644 (file)
@@ -1601,6 +1601,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.user"><![CDATA[Benutzer]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.articleCategory"><![CDATA[Artikel-Kategorien]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.article"><![CDATA[Artikel]]></item>
+               <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.simplePage"><![CDATA[Einfache Seiten]]></item>
        </category>
        
        <category name="wcf.acp.stat">
index 076998359cd0fa823b0cacfc0c52198009549554..295491ed587a985f0e3cfafc86b7459a14baa459 100644 (file)
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.user"><![CDATA[User]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.articleCategory"><![CDATA[Article categories]]></item>
                <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.article"><![CDATA[Article]]></item>
+               <item name="wcf.acp.sitemap.objectType.com.woltlab.wcf.sitemap.object.simplePage"><![CDATA[Simple pages]]></item>
        </category>
        
        <category name="wcf.acp.stat">