add article sitemap
authorJoshua Rüsweg <josh@bastelstu.be>
Fri, 9 Jun 2017 10:42:17 +0000 (12:42 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Fri, 9 Jun 2017 10:42:40 +0000 (12:42 +0200)
See #2286

com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 22a7c9e4e8d17ef246abcdec1ea3197aff1f9360..e3bfd4225970ab26272ebd79721311f93e673ea8 100644 (file)
                        <changeFreq>weekly</changeFreq>
                        <rebuildTime>2592000</rebuildTime>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.sitemap.object.article</name>
+                       <definitionname>com.woltlab.wcf.sitemap.object</definitionname>
+                       <classname>wcf\system\sitemap\object\ArticleSitemapObject</classname>
+                       <priority>0.5</priority>
+                       <changeFreq>monthly</changeFreq>
+                       <rebuildTime>259200</rebuildTime>
+               </type>
                <!-- /sitemap -->
                
                <!-- deprecated -->
diff --git a/wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php b/wcfsetup/install/files/lib/system/sitemap/object/ArticleSitemapObject.class.php
new file mode 100644 (file)
index 0000000..77ed7c3
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+namespace wcf\system\sitemap\object;
+use wcf\data\article\content\ArticleContent;
+use wcf\data\article\Article;
+use wcf\data\DatabaseObject;
+
+/**
+ * Article 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 ArticleSitemapObject extends AbstractSitemapObjectObjectType {
+       /**
+        * @inheritDoc
+        */
+       public function getObjectClass() {
+               return ArticleContent::class;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function canView(DatabaseObject $object) {
+               /** @var $object ArticleContent */
+               if ($object->getArticle()->publicationStatus != Article::PUBLISHED) {
+                       return false; 
+               }
+               
+               if ($object->getArticle()->getCategory()) {
+                       return $object->getArticle()->getCategory()->isAccessible(self::getGuestUserProfile()->getDecoratedObject());
+               }
+               
+               return self::getGuestUserProfile()->getPermission('user.article.canRead');
+       }
+}
index 4590be15cc0171196667b2c32923aa36f15d97bc..7657abe5e07ed9b7ef7a451db52d0025629bf3d2 100644 (file)
@@ -1600,6 +1600,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]></item>
                <item name="wcf.acp.sitemap.edit"><![CDATA[Sitemap bearbeiten]]></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>
        </category>
        
        <category name="wcf.acp.stat">
index 0d4cd1b9cd7de482997cdc574f76a37f29f13946..70a8683d88bed1743d2e650a7cc4be61bd622c3f 100644 (file)
                <item name="wcf.acp.sitemap.edit"><![CDATA[Edit Sitemap]]></item>
                <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>
        </category>
        
        <category name="wcf.acp.stat">