From a39d8cc415c1525b0af9eff18073bb754543d833 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Sun, 11 Jun 2017 15:52:02 +0200 Subject: [PATCH] Add simple page sitemap --- com.woltlab.wcf/objectType.xml | 8 ++ .../object/SimplePageSitemapObject.class.php | 94 +++++++++++++++++++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + 4 files changed, 104 insertions(+) create mode 100644 wcfsetup/install/files/lib/system/sitemap/object/SimplePageSitemapObject.class.php diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index e3bfd42259..0d1234e0dc 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1275,6 +1275,14 @@ monthly 259200 + + com.woltlab.wcf.sitemap.object.simplePage + com.woltlab.wcf.sitemap.object + wcf\system\sitemap\object\SimplePageSitemapObject + 0.5 + monthly + 604800 + 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 index 0000000000..d65c277b9d --- /dev/null +++ b/wcfsetup/install/files/lib/system/sitemap/object/SimplePageSitemapObject.class.php @@ -0,0 +1,94 @@ + + * @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; + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 136b02321a..7aadb8d903 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1601,6 +1601,7 @@ GmbH=Gesellschaft mit beschränkter Haftung]]> + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 076998359c..295491ed58 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1552,6 +1552,7 @@ + -- 2.20.1