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 @@ +

+ + +
{else} {autoescape="off"} {$form} diff --git a/app/widgets/CommunityConfig/locales.ini b/app/widgets/CommunityConfig/locales.ini index 4602cc3a9..832f18e67 100644 --- a/app/widgets/CommunityConfig/locales.ini +++ b/app/widgets/CommunityConfig/locales.ini @@ -7,3 +7,8 @@ publish_model_publishers_title = Publishers publish_model_publishers_text = The publishers can publish publish_model_subscribers_title = Subscribers publish_model_subscribers_text = The subscribers can publish +type = Community type +type_articles_title = Articles +type_articles_text = Publish and read articles +type_gallery_title = Gallery +type_gallery_text = Publish and browser pictures \ No newline at end of file diff --git a/app/widgets/CommunityData/_communitydata_card.tpl b/app/widgets/CommunityData/_communitydata_card.tpl index ad1763fe6..5c060e918 100644 --- a/app/widgets/CommunityData/_communitydata_card.tpl +++ b/app/widgets/CommunityData/_communitydata_card.tpl @@ -57,6 +57,12 @@ assignment_turned_in {$c->__('communitydata.publishmodel_subscribers')} {/if} + {if="$info->isGallery()"} +
+ grid_view + {$c->__('communityconfig.type_gallery_title')} + {/if} +

diff --git a/app/widgets/CommunityPosts/CommunityPosts.php b/app/widgets/CommunityPosts/CommunityPosts.php index 61a191402..7f6885cca 100644 --- a/app/widgets/CommunityPosts/CommunityPosts.php +++ b/app/widgets/CommunityPosts/CommunityPosts.php @@ -165,6 +165,10 @@ class CommunityPosts extends Base } } + $info = \App\Info::where('server', $origin) + ->where('node', $node) + ->first(); + $view = $this->tpl(); $view->assign('server', $origin); @@ -174,16 +178,14 @@ class CommunityPosts extends Base $view->assign('posts', $postsWithKeys); $view->assign('before', $before); $view->assign('after', $after); - $view->assign('info', \App\Info::where('server', $origin) - ->where('node', $node) - ->first()); + $view->assign('info', $info); $view->assign('subscription', $this->user->subscriptions() ->where('server', $origin) ->where('node', $node) ->first()); $view->assign('paging', $this->_paging); - $view->assign('gallery', isPostGallery($posts)); + $view->assign('gallery', $info && $info->isGallery()); $view->assign('publicposts', ($ids == false) ? \App\Post::where('server', $origin) diff --git a/database/migrations/20230303224825_add_type_to_infos_table.php b/database/migrations/20230303224825_add_type_to_infos_table.php new file mode 100644 index 000000000..875877986 --- /dev/null +++ b/database/migrations/20230303224825_add_type_to_infos_table.php @@ -0,0 +1,21 @@ +schema->table('infos', function (Blueprint $table) { + $table->string('type', 256)->nullable()->index(); + }); + } + + public function down() + { + $this->schema->table('infos', function (Blueprint $table) { + $table->dropColumn('type'); + }); + } +} diff --git a/doap.xml b/doap.xml index 40b8398e7..128b6880e 100644 --- a/doap.xml +++ b/doap.xml @@ -466,6 +466,13 @@ 0.2.0 + + + + complete + 0.3.0 + + @@ -480,6 +487,13 @@ 0.1.0 + + + + partial + 0.1.1 + +