diff --git a/app/Info.php b/app/Info.php index 87faa0213..fa6ddfc7c 100644 --- a/app/Info.php +++ b/app/Info.php @@ -228,44 +228,49 @@ class Info extends Model return 'desktop_windows'; } - public function hasFeature(string $feature) + public function hasFeature(string $feature): bool { return (in_array($feature, unserialize($this->attributes['features']))); } - public function isJingleAudio() + public function isGallery(): bool + { + return $this->type == 'urn:xmpp:pubsub-social-gallery:0'; + } + + public function isJingleAudio(): bool { return $this->hasFeature('urn:xmpp:jingle:apps:rtp:audio') && $this->hasFeature('urn:xmpp:jingle-message:0'); } - public function isJingleVideo() + public function isJingleVideo(): bool { return $this->hasFeature('urn:xmpp:jingle:apps:rtp:video') && $this->hasFeature('urn:xmpp:jingle-message:0'); } - public function isMAM() + public function isMAM(): bool { return $this->hasFeature('urn:xmpp:mam:1'); } - public function isMAM2() + public function isMAM2(): bool { return $this->hasFeature('urn:xmpp:mam:2'); } - public function hasMAM() + public function hasMAM(): bool { return $this->isMAM() || $this->isMAM2(); } - public function hasStanzaId() + public function hasStanzaId(): bool { return $this->hasFeature('urn:xmpp:sid:0'); } - public function hasExternalServices() + public function hasExternalServices(): bool { return $this->hasFeature('urn:xmpp:extdisco:2'); } @@ -354,6 +359,9 @@ class Info extends Model case 'pubsub#title': $this->name = (string)$field->value; break; + case 'pubsub#type': + $this->type = (string)$field->value; + break; case 'pubsub#creation_date': $this->created = toSQLDate($field->value); break; diff --git a/app/helpers/UtilsHelper.php b/app/helpers/UtilsHelper.php index 4c90b1f8f..4f8f0bb4a 100644 --- a/app/helpers/UtilsHelper.php +++ b/app/helpers/UtilsHelper.php @@ -153,25 +153,6 @@ function getClientTypes() ]; } -/** - * Check if Posts collection is gallery - */ -function isPostGallery($postCollection): bool -{ - // For now we detect if a node is a gallery if all the publications have an attached picture - // and if the post contents are short. - $shortCount = 0; - - $gallery = $postCollection->every(function ($post) use (&$shortCount) { - if ($post->isShort()) $shortCount++; - return $post->picture != null; - }); - - if ($gallery && $shortCount < $postCollection->count()/2) $gallery = false; - - return $gallery; -} - /** * Resolve infos from a Posts collection */ @@ -582,6 +563,7 @@ function varToIcons(string $var) 'pubsub#notify_delete' => 'delete', 'pubsub#notify_retract' => 'delete_sweep', 'pubsub#persist_items' => 'save', + 'pubsub#type' => 'space_dashboard', 'pubsub#deliver_notifications' => 'notifications_active', // Muc diff --git a/app/widgets/Blog/Blog.php b/app/widgets/Blog/Blog.php index eb2247d6d..84e9ae1b1 100644 --- a/app/widgets/Blog/Blog.php +++ b/app/widgets/Blog/Blog.php @@ -168,7 +168,7 @@ class Blog extends Base } if ($this->_posts !== null) { - $this->_gallery = isPostGallery($this->_posts); + $this->_gallery = $this->_item && $this->_item->isGallery(); } } diff --git a/app/widgets/CommunitiesServer/_communitiesserver.tpl b/app/widgets/CommunitiesServer/_communitiesserver.tpl index 8c90d593e..5690559fa 100644 --- a/app/widgets/CommunitiesServer/_communitiesserver.tpl +++ b/app/widgets/CommunitiesServer/_communitiesserver.tpl @@ -71,6 +71,10 @@
+ {if="$value->isGallery()"} + grid_view + ยท + {/if} {if="$value->published"} update {$value->published|strtotime|prepareDate:true} diff --git a/app/widgets/CommunityConfig/_communityconfig.tpl b/app/widgets/CommunityConfig/_communityconfig.tpl index b5a0be937..9997a1f6d 100644 --- a/app/widgets/CommunityConfig/_communityconfig.tpl +++ b/app/widgets/CommunityConfig/_communityconfig.tpl @@ -61,6 +61,45 @@ +
{$c->__('communityconfig.type_articles_title')}
+{$c->__('communityconfig.type_articles_text')}
+{$c->__('communityconfig.type_gallery_title')}
+{$c->__('communityconfig.type_gallery_text')}
+