From cce5f6a62c8af4e4b880f81b341f514810d7cb4b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Fri, 2 Jun 2017 13:55:41 +0200 Subject: [PATCH] add sitemap object type definition See #2286 --- com.woltlab.wcf/objectTypeDefinition.xml | 5 ++ .../AbstractSitemapObjectObjectType.class.php | 66 +++++++++++++++++++ .../object/ISitemapObjectObjectType.class.php | 51 ++++++++++++++ 3 files changed, 122 insertions(+) create mode 100755 wcfsetup/install/files/lib/system/sitemap/object/AbstractSitemapObjectObjectType.class.php create mode 100755 wcfsetup/install/files/lib/system/sitemap/object/ISitemapObjectObjectType.class.php diff --git a/com.woltlab.wcf/objectTypeDefinition.xml b/com.woltlab.wcf/objectTypeDefinition.xml index a3319e251a..1ba57b67c7 100644 --- a/com.woltlab.wcf/objectTypeDefinition.xml +++ b/com.woltlab.wcf/objectTypeDefinition.xml @@ -227,6 +227,11 @@ wcf\system\condition\IObjectListCondition + + + com.woltlab.wcf.sitemap.object + + 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 index 0000000000..749af4d81a --- /dev/null +++ b/wcfsetup/install/files/lib/system/sitemap/object/AbstractSitemapObjectObjectType.class.php @@ -0,0 +1,66 @@ + + * @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 index 0000000000..654c4f2e60 --- /dev/null +++ b/wcfsetup/install/files/lib/system/sitemap/object/ISitemapObjectObjectType.class.php @@ -0,0 +1,51 @@ + + * @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); +} -- 2.20.1