add sitemap object type definition
authorJoshua Rüsweg <josh@bastelstu.be>
Fri, 2 Jun 2017 11:55:41 +0000 (13:55 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Fri, 2 Jun 2017 11:55:41 +0000 (13:55 +0200)
See #2286

com.woltlab.wcf/objectTypeDefinition.xml
wcfsetup/install/files/lib/system/sitemap/object/AbstractSitemapObjectObjectType.class.php [new file with mode: 0755]
wcfsetup/install/files/lib/system/sitemap/object/ISitemapObjectObjectType.class.php [new file with mode: 0755]

index a3319e251ad710127496780407707f164cb4602f..1ba57b67c7fb770f7d69fd80a9f4fe3f7b390fa4 100644 (file)
                        <interfacename>wcf\system\condition\IObjectListCondition</interfacename>
                </definition>
                <!-- /box conditions -->
+               
+               <definition>
+                       <name>com.woltlab.wcf.sitemap.object</name>
+                       <interfacename><![CDATA[wcf\system\sitemap\object\ISitemapObjectObjectType]]></interfacename>
+               </definition>
        </import>
        
        <delete>
diff --git a/wcfsetup/install/files/lib/system/sitemap/object/AbstractSitemapObjectObjectType.class.php b/wcfsetup/install/files/lib/system/sitemap/object/AbstractSitemapObjectObjectType.class.php
new file mode 100755 (executable)
index 0000000..749af4d
--- /dev/null
@@ -0,0 +1,66 @@
+<?php
+namespace wcf\system\sitemap\object;
+use wcf\data\user\User;
+use wcf\data\user\UserProfile;
+use wcf\data\DatabaseObject;
+
+/**
+ * Abstract implementation of a sitemap object.
+ * 
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Sitemap\Object
+ * @since      3.1
+ */
+abstract class AbstractSitemapObjectObjectType implements ISitemapObjectObjectType {
+       /**
+        * A guest user profile.
+        *
+        * @var UserProfile
+        */
+       protected static $userProfile = null;
+       
+       /**
+        * @inheritDoc
+        */
+       public function getObjectListClass() {
+               return $this->getObjectClass() . 'List';
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getObjectList() {
+               $className = $this->getObjectListClass();
+               return new $className;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getLastModifiedColumn() {
+               return false;
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function canView(DatabaseObject $object) {
+               return true;
+       }
+
+       /**
+        * Returns a guest user profile.
+        *
+        * @return      UserProfile
+        */
+       public static function getGuestUserProfile() {
+               if (self::$userProfile === null) {
+                       $user = new User(null, []);
+                       self::$userProfile = new UserProfile($user);
+               }
+
+               return self::$userProfile;
+       }
+}
diff --git a/wcfsetup/install/files/lib/system/sitemap/object/ISitemapObjectObjectType.class.php b/wcfsetup/install/files/lib/system/sitemap/object/ISitemapObjectObjectType.class.php
new file mode 100755 (executable)
index 0000000..654c4f2
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+namespace wcf\system\sitemap\object;
+use wcf\data\DatabaseObject;
+
+/**
+ * Interface for sitemap objects.
+ * 
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Sitemap\Object
+ * @since      3.1
+ */
+interface ISitemapObjectObjectType {
+       /**
+        * Returns the DatabaseObject class name for the sitemap object.
+        *
+        * @return      string
+        */
+       public function getObjectClass();
+
+       /**
+        * Returns the DatabaseObjectList class name for the sitemap object.
+        *
+        * @return      string
+        */
+       public function getObjectListClass();
+
+       /**
+        * Returns the DatabaseObjectList for the sitemap object.
+        *
+        * @return      string
+        */
+       public function getObjectList();
+
+       /**
+        * Returns the database column, which represents the last modified date.
+        * If there isn't any column, this method should return false.
+        *
+        * @return      string|null
+        */
+       public function getLastModifiedColumn();
+
+       /**
+        * Returns the permission for a guest to view a certain object for this object type. 
+        *
+        * @param       DatabaseObject  $object
+        * @return      boolean
+        */
+       public function canView(DatabaseObject $object);
+}