From 3f640b79c938908c893f493092c9ce37b98e9c8c Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Thu, 3 Oct 2024 13:48:31 +0200 Subject: [PATCH 1/2] Use PHP CS Fixer --- .github/workflows/php-cs-fixer.yml | 7 +++++++ docs/CHANGELOG.md | 1 + 2 files changed, 8 insertions(+) create mode 100644 .github/workflows/php-cs-fixer.yml diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..2d37e13 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,7 @@ +name: PHP CS Fixer + +on: push + +jobs: + fixers: + uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9da1b66..d57c1ac 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ Changelog - Fix #135: Fix gallery comment URL from notifications - Fix: Add autofocus on edit (for HumHub 1.17 - see https://github.com/humhub/humhub/issues/7136) - Enh #140: Replace theme variables with CSS variables +- Enh #141: Use PHP CS Fixer 1.5.5 (December 22, 2023) ------------------------- From 44440742716b18f57cfc28a7c6c3bf6828d5c50e Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Thu, 3 Oct 2024 11:48:53 +0000 Subject: [PATCH 2/2] Autocommit PHP CS Fixer --- Events.php | 3 +- Module.php | 9 ++-- assets/Assets.php | 11 ++--- assets/WallEntryAssets.php | 1 - config.php | 9 ++-- controllers/BaseController.php | 28 +++++------ controllers/CustomGalleryController.php | 47 +++++++++---------- controllers/ListController.php | 10 ++-- controllers/MediaController.php | 18 +++---- controllers/SettingController.php | 8 ++-- controllers/StreamGalleryController.php | 10 ++-- libs/FileUtils.php | 16 +++---- migrations/m160321_163801_initial.php | 5 +- migrations/uninstall.php | 3 +- models/BaseGallery.php | 37 ++++++++------- models/CustomGallery.php | 4 +- models/Media.php | 11 ++--- models/MediaUpload.php | 6 +-- models/SquarePreviewImage.php | 7 ++- models/StreamGallery.php | 16 +++---- models/forms/ContainerSettings.php | 37 ++++++++------- models/forms/GalleryEditForm.php | 18 +++---- permissions/WriteAccess.php | 9 ++-- tests/codeception/_bootstrap.php | 2 +- .../codeception/_support/AcceptanceTester.php | 9 ++-- .../codeception/_support/FunctionalTester.php | 7 +-- tests/codeception/_support/UnitTester.php | 7 +-- tests/codeception/acceptance/_bootstrap.php | 2 +- tests/codeception/config/unit.php | 2 +- tests/codeception/fixtures/GalleryFixture.php | 2 +- tests/codeception/fixtures/data/gallery.php | 1 - tests/codeception/fixtures/data/media.php | 1 - tests/codeception/functional/_bootstrap.php | 2 +- tests/codeception/unit/CustomGalleryTest.php | 10 ++-- tests/codeception/unit/_bootstrap.php | 2 +- tests/config/test.php | 7 +-- widgets/GalleryList.php | 5 +- widgets/GalleryListEntry.php | 13 +++-- widgets/GalleryListEntryAdd.php | 45 +++++++++--------- widgets/GalleryMenu.php | 13 +++-- widgets/GallerySnippet.php | 11 ++--- widgets/WallEntryMedia.php | 1 - 42 files changed, 224 insertions(+), 241 deletions(-) diff --git a/Events.php b/Events.php index 5b7af53..a40e8b4 100644 --- a/Events.php +++ b/Events.php @@ -22,7 +22,6 @@ */ class Events { - public static function onSpaceMenuInit($event) { try { @@ -63,7 +62,7 @@ public static function onProfileMenuInit($event) 'label' => Yii::t('GalleryModule.base', 'Gallery'), 'url' => Url::toGalleryOverview($event->sender->user), 'icon' => '', - 'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'gallery') + 'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'gallery'), ]); } } catch (\Throwable $e) { diff --git a/Module.php b/Module.php index 66e1705..4129713 100644 --- a/Module.php +++ b/Module.php @@ -17,7 +17,6 @@ class Module extends ContentContainerModule { - public $galleryMaxImages = 50; public $snippetMaxImages = 20; public $debug = false; @@ -29,7 +28,7 @@ public function getContentContainerTypes() { return [ Space::class, - User::class + User::class, ]; } @@ -43,8 +42,8 @@ public function getContentClasses(): array public function getContainerPermissions($contentContainer = null) { - return [ - new WriteAccess() + return [ + new WriteAccess(), ]; } @@ -82,7 +81,7 @@ public function enableContentContainer(ContentContainerActiveRecord $container) { $streamGallery = new StreamGallery($container, Content::VISIBILITY_PUBLIC, [ 'title' => Yii::t('GalleryModule.base', 'Posted pictures'), - 'description' => Yii::t('GalleryModule.base', 'This gallery contains all posted pictures.') + 'description' => Yii::t('GalleryModule.base', 'This gallery contains all posted pictures.'), ]); $streamGallery->save(); diff --git a/assets/Assets.php b/assets/Assets.php index 73ee270..93bf4ba 100644 --- a/assets/Assets.php +++ b/assets/Assets.php @@ -22,7 +22,6 @@ */ class Assets extends AssetBundle { - /** * v1.5 compatibility defer script loading * @@ -33,7 +32,7 @@ class Assets extends AssetBundle public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; public $css = [ @@ -43,9 +42,9 @@ class Assets extends AssetBundle public $js = [ 'js/gallery.js', ]; - + public $jsOptions = [ - 'position' => \yii\web\View::POS_END + 'position' => \yii\web\View::POS_END, ]; /** @@ -62,8 +61,8 @@ public static function register($view) $view->registerJsConfig('gallery', [ 'fallbackImageUrl' => Media::getFallbackPreviewImageUrl(), 'text' => [ - 'error.loadImageError' => Yii::t('GalleryModule.base', 'Image could not be loaded') - ] + 'error.loadImageError' => Yii::t('GalleryModule.base', 'Image could not be loaded'), + ], ]); return parent::register($view); diff --git a/assets/WallEntryAssets.php b/assets/WallEntryAssets.php index bd55b09..adc152d 100644 --- a/assets/WallEntryAssets.php +++ b/assets/WallEntryAssets.php @@ -14,7 +14,6 @@ */ class WallEntryAssets extends AssetBundle { - /** * @inheritdoc */ diff --git a/config.php b/config.php index 5b1c16f..ade2e1f 100644 --- a/config.php +++ b/config.php @@ -1,10 +1,10 @@ 'gallery', @@ -15,6 +15,5 @@ ['class' => ProfileMenu::class,'event' => ProfileMenu::EVENT_INIT, 'callback' => [Events::class,'onProfileMenuInit']], ['class' => SpaceSidebar::class, 'event' => SpaceSidebar::EVENT_INIT, 'callback' => [Events::class, 'onSpaceSidebarInit']], ['class' => ProfileSidebar::class, 'event' => ProfileSidebar::EVENT_INIT, 'callback' => [Events::class, 'onProfileSidebarInit']], - ] + ], ]; - diff --git a/controllers/BaseController.php b/controllers/BaseController.php index 95c81da..76fe4b6 100644 --- a/controllers/BaseController.php +++ b/controllers/BaseController.php @@ -10,20 +10,20 @@ use humhub\modules\content\components\ActiveQueryContent; use humhub\modules\content\components\ContentActiveRecord; -use \humhub\modules\content\components\ContentContainerController; +use humhub\modules\content\components\ContentContainerController; use humhub\modules\gallery\models\BaseGallery; use humhub\modules\gallery\models\forms\ContainerSettings; use humhub\modules\gallery\models\Media; -use \humhub\modules\gallery\Module; +use humhub\modules\gallery\Module; use humhub\modules\gallery\widgets\GalleryList; use humhub\modules\space\models\Space; -use \humhub\modules\user\models\User; -use \Yii; +use humhub\modules\user\models\User; +use Yii; use yii\base\Exception; -use \yii\base\Model; +use yii\base\Model; use yii\data\ActiveDataProvider; use yii\data\BaseDataProvider; -use \yii\web\HttpException; +use yii\web\HttpException; use yii\web\NotFoundHttpException; /** @@ -71,7 +71,7 @@ protected function prepareInitialItems($items) protected function loadPage($page = 0) { $query = $this->getPaginationQuery(); - if(!$query) { + if (!$query) { throw new NotFoundHttpException(); } @@ -79,8 +79,8 @@ protected function loadPage($page = 0) 'query' => $query, 'pagination' => [ 'page' => $page, - 'pageSize' => $this->getPageSize() - ] + 'pageSize' => $this->getPageSize(), + ], ]); } @@ -95,11 +95,11 @@ abstract protected function getGallery(); final protected function isAdmin() { - if(Yii::$app->user->isGuest) { + if (Yii::$app->user->isGuest) { return false; } - if($this->contentContainer instanceof Space) { + if ($this->contentContainer instanceof Space) { return $this->contentContainer->isAdmin(); } @@ -114,13 +114,13 @@ public function actionLoadPage($page) return $this->asJson([ 'html' => GalleryList::widget(['entryList' => $models, 'entriesOnly' => true, 'parentGallery' => $this->getGallery()]), - 'isLast' => $this->isLastPage($page) + 'isLast' => $this->isLastPage($page), ]); } protected function isLastPage($page = 0) { - if(!$this->dataProvider || !$this->dataProvider->getPagination()) { + if (!$this->dataProvider || !$this->dataProvider->getPagination()) { return true; } @@ -135,7 +135,7 @@ protected function getPageSize() protected function getSettings() { return new ContainerSettings([ - 'contentContainer' => $this->contentContainer + 'contentContainer' => $this->contentContainer, ]); } } diff --git a/controllers/CustomGalleryController.php b/controllers/CustomGalleryController.php index 44b91a8..aeacfe6 100644 --- a/controllers/CustomGalleryController.php +++ b/controllers/CustomGalleryController.php @@ -12,18 +12,18 @@ use humhub\modules\file\libs\FileHelper; use humhub\modules\gallery\helpers\Url; use humhub\modules\gallery\models\BaseGallery; -use \humhub\modules\gallery\models\CustomGallery; +use humhub\modules\gallery\models\CustomGallery; use humhub\modules\gallery\models\forms\GalleryEditForm; -use \humhub\modules\gallery\models\Media; +use humhub\modules\gallery\models\Media; use humhub\modules\gallery\permissions\WriteAccess; -use \Yii; +use Yii; use yii\base\Exception; use yii\web\BadRequestHttpException; use yii\web\ForbiddenHttpException; -use \yii\web\HttpException; +use yii\web\HttpException; use yii\web\NotFoundHttpException; use yii\web\Response; -use \yii\web\UploadedFile; +use yii\web\UploadedFile; /** * Description of a Custom Gallery Controller for the gallery module. @@ -34,7 +34,6 @@ */ class CustomGalleryController extends BaseController { - /** * @var CustomGallery */ @@ -55,15 +54,15 @@ protected function renderGallery($items) { $gallery = $this->getGallery(); - if(!$gallery->content->canView()) { + if (!$gallery->content->canView()) { throw new ForbiddenHttpException(); } return $this->render("gallery_view", [ - 'gallery'=> $gallery, + 'gallery' => $gallery, 'media' => $items, 'container' => $this->contentContainer, - 'showMore' => !$this->isLastPage() ? Url::toShowMoreMedia($this->contentContainer, $gallery->id) : false + 'showMore' => !$this->isLastPage() ? Url::toShowMoreMedia($this->contentContainer, $gallery->id) : false, ]); } @@ -76,19 +75,19 @@ protected function renderGallery($items) */ protected function getGallery() { - if($this->gallery) { + if ($this->gallery) { return $this->gallery; } $gid = Yii::$app->request->get('gid'); - if(!$gid) { + if (!$gid) { throw new BadRequestHttpException(); } $this->gallery = CustomGallery::find()->contentContainer($this->contentContainer)->where(['gallery_gallery.id' => $gid])->one(); - if(!$this->gallery) { + if (!$this->gallery) { throw new NotFoundHttpException(); } @@ -104,13 +103,13 @@ protected function getGallery() */ public function actionEdit($gid = null) { - if(!$gid && !$this->contentContainer->can(WriteAccess::class)) { + if (!$gid && !$this->contentContainer->can(WriteAccess::class)) { throw new ForbiddenHttpException(); } $gallery = $gid ? $this->getGallery($gid) : null; - if($gallery && !$gallery->content->canEdit()) { + if ($gallery && !$gallery->content->canEdit()) { throw new ForbiddenHttpException(); } @@ -121,10 +120,10 @@ public function actionEdit($gid = null) } return $this->renderPartial('modal_gallery_edit', [ - 'galleryForm' => $form, - 'contentContainer' => $this->contentContainer, - 'sortByCreated' => $this->getSettings()->sortByCreated, - 'createdAt' => isset($this->gallery) ? $this->gallery->getCreatedAt() : null + 'galleryForm' => $form, + 'contentContainer' => $this->contentContainer, + 'sortByCreated' => $this->getSettings()->sortByCreated, + 'createdAt' => isset($this->gallery) ? $this->gallery->getCreatedAt() : null, ]); } @@ -140,15 +139,15 @@ public function actionDelete($gid) $gallery = CustomGallery::findOne(['id' => $gid]); - if(!$gallery) { + if (!$gallery) { throw new NotFoundHttpException(); } - if(!$gallery->content->canEdit()) { + if (!$gallery->content->canEdit()) { throw new ForbiddenHttpException(); } - if($gallery->delete()) { + if ($gallery->delete()) { $this->view->success(Yii::t('GalleryModule.base', 'Deleted')); } else { $this->view->error(Yii::t('GalleryModule.base', 'Item could not be deleted!')); @@ -161,7 +160,7 @@ public function actionUpload() { $gallery = $this->getGallery(); - if(!$gallery->content->canEdit()) { + if (!$gallery->content->canEdit()) { throw new HttpException(404); } @@ -188,7 +187,7 @@ protected function handleMediaUpload(BaseGallery $gallery, UploadedFile $cfile) return [ 'name' => $mediaUpload->file_name, 'error' => true, - 'errors' => implode(', ', $mediaUpload->getErrorSummary(true)) + 'errors' => implode(', ', $mediaUpload->getErrorSummary(true)), ]; } @@ -208,7 +207,7 @@ protected function getOpenGallery($gid = null) { $id = $gid == null ? Yii::$app->request->get('gid') : $gid; - if(!$id) { + if (!$id) { throw new HttpException(404); } diff --git a/controllers/ListController.php b/controllers/ListController.php index 93797cd..1949095 100644 --- a/controllers/ListController.php +++ b/controllers/ListController.php @@ -3,10 +3,10 @@ namespace humhub\modules\gallery\controllers; use humhub\modules\gallery\helpers\Url; -use \humhub\modules\gallery\models\CustomGallery; -use \humhub\modules\gallery\models\StreamGallery; +use humhub\modules\gallery\models\CustomGallery; +use humhub\modules\gallery\models\StreamGallery; use humhub\modules\gallery\permissions\WriteAccess; -use \Yii; +use Yii; use yii\web\HttpException; /** @@ -25,7 +25,7 @@ protected function renderGallery($items) 'galleries' => $items, 'canWrite' => $this->contentContainer->can(WriteAccess::class), 'isAdmin' => $this->isAdmin(), - 'showMore' => !$this->isLastPage() + 'showMore' => !$this->isLastPage(), ]); } @@ -48,7 +48,7 @@ protected function getPaginationQuery() // Using sortByCreated we add this additional orderBy $pageQuery ->orderBy([ - 'content.created_at' => SORT_DESC + 'content.created_at' => SORT_DESC, ]); } else { $pageQuery diff --git a/controllers/MediaController.php b/controllers/MediaController.php index 3e64cb2..ce0e23b 100644 --- a/controllers/MediaController.php +++ b/controllers/MediaController.php @@ -9,10 +9,10 @@ namespace humhub\modules\gallery\controllers; use humhub\modules\gallery\helpers\Url; -use \humhub\modules\gallery\models\Media; -use \Yii; +use humhub\modules\gallery\models\Media; +use Yii; use yii\web\ForbiddenHttpException; -use \yii\web\HttpException; +use yii\web\HttpException; use yii\web\NotFoundHttpException; /** @@ -32,7 +32,7 @@ public function actionEdit($id = null, $fromWall = false) throw new HttpException(404); } - if(!$media->content->canEdit()) { + if (!$media->content->canEdit()) { throw new ForbiddenHttpException(); } @@ -49,7 +49,7 @@ public function actionEdit($id = null, $fromWall = false) 'gid' => $media->gallery_id, 'media' => $media, 'contentContainer' => $this->contentContainer, - 'fromWall' => $fromWall + 'fromWall' => $fromWall, ]); } @@ -59,15 +59,15 @@ public function actionDelete($id = null, $fromWall = false) $media = Media::findOne(['id' => $id]); - if(!$media) { + if (!$media) { throw new NotFoundHttpException(); } - if(!$media->content->canEdit()) { + if (!$media->content->canEdit()) { throw new ForbiddenHttpException(); } - if($media->delete()) { + if ($media->delete()) { $this->view->success(Yii::t('GalleryModule.base', 'Deleted')); } else { $this->view->error(Yii::t('GalleryModule.base', 'Item could not be deleted!')); @@ -76,7 +76,7 @@ public function actionDelete($id = null, $fromWall = false) return !$fromWall ? $this->htmlRedirect(Url::toCustomGallery($this->contentContainer, $media->gallery_id)) : $this->asJson([ - 'success' => false + 'success' => false, ]); } diff --git a/controllers/SettingController.php b/controllers/SettingController.php index 0d92e71..79d973d 100644 --- a/controllers/SettingController.php +++ b/controllers/SettingController.php @@ -27,23 +27,23 @@ class SettingController extends ContentContainerController protected function getAccessRules() { return [ - [ContentContainerControllerAccess::RULE_USER_GROUP_ONLY => [Space::USERGROUP_ADMIN, User::USERGROUP_SELF]] + [ContentContainerControllerAccess::RULE_USER_GROUP_ONLY => [Space::USERGROUP_ADMIN, User::USERGROUP_SELF]], ]; } public function actionIndex() { $settings = new ContainerSettings([ - 'contentContainer' => $this->contentContainer + 'contentContainer' => $this->contentContainer, ]); - if($settings->load(Yii::$app->request->post()) && $settings->save()) { + if ($settings->load(Yii::$app->request->post()) && $settings->save()) { $this->view->saved(); } return $this->render('index', [ 'settings' => $settings, - 'contentContainer' => $this->contentContainer + 'contentContainer' => $this->contentContainer, ]); } diff --git a/controllers/StreamGalleryController.php b/controllers/StreamGalleryController.php index 5731048..5d9ab0d 100644 --- a/controllers/StreamGalleryController.php +++ b/controllers/StreamGalleryController.php @@ -8,10 +8,10 @@ namespace humhub\modules\gallery\controllers; -use \humhub\modules\gallery\models\StreamGallery; +use humhub\modules\gallery\models\StreamGallery; use humhub\modules\stream\actions\Stream; -use \Yii; -use \yii\web\HttpException; +use Yii; +use yii\web\HttpException; use yii\web\NotFoundHttpException; use yii\web\Response; @@ -46,7 +46,7 @@ public function beforeAction($action) } $this->streamGallery = StreamGallery::findForContainer($this->contentContainer); - if(!$this->streamGallery) { + if (!$this->streamGallery) { throw new NotFoundHttpException(); } @@ -71,7 +71,7 @@ protected function renderGallery($items) 'files' => $items, 'gallery' => $this->streamGallery, 'container' => $this->contentContainer, - 'showMore' => !$this->isLastPage() + 'showMore' => !$this->isLastPage(), ]); } diff --git a/libs/FileUtils.php b/libs/FileUtils.php index 1263499..5f16ef9 100644 --- a/libs/FileUtils.php +++ b/libs/FileUtils.php @@ -2,19 +2,19 @@ namespace humhub\modules\gallery\libs; -use \humhub\modules\comment\models\Comment; -use \humhub\modules\content\models\Content; -use \humhub\modules\file\models\File; +use humhub\modules\comment\models\Comment; +use humhub\modules\content\models\Content; +use humhub\modules\file\models\File; /** * This is a utility lib for files. - * + * * @package humhub.modules.gallery.libs * @since 1.0 * @author Sebastian Stumpf */ class FileUtils -{ +{ /** * Get the content model the file is connected to. * @param File $file the file. @@ -28,13 +28,13 @@ public static function getBaseContent($file = null) // if the item is connected to a Comment, we have to search for the corresponding Post if ($file->object_model === Comment::class) { $searchItem = Comment::findOne([ - 'id' => $file->object_id + 'id' => $file->object_id, ]); } $query = Content::find(); $query->andWhere([ 'content.object_id' => $searchItem->object_id, - 'content.object_model' => $searchItem->object_model + 'content.object_model' => $searchItem->object_model, ]); return $query->one(); } @@ -49,7 +49,7 @@ public static function getBaseObject($file = null) return null; } $object = call_user_func([$file->object_model, 'findOne'], [ - 'id' => $file->object_id + 'id' => $file->object_id, ]); return $object; diff --git a/migrations/m160321_163801_initial.php b/migrations/m160321_163801_initial.php index c517862..e08a51e 100644 --- a/migrations/m160321_163801_initial.php +++ b/migrations/m160321_163801_initial.php @@ -1,10 +1,9 @@ createTable('gallery_media', [ @@ -12,7 +11,7 @@ public function up() 'title' => $this->string(255), 'gallery_id' => $this->integer(11), 'description' => $this->string(1000), - 'sort_order' => $this->integer(11)->defaultValue(0) + 'sort_order' => $this->integer(11)->defaultValue(0), ], ''); $this->createTable('gallery_gallery', [ diff --git a/migrations/uninstall.php b/migrations/uninstall.php index bee4363..e3627b1 100644 --- a/migrations/uninstall.php +++ b/migrations/uninstall.php @@ -1,10 +1,9 @@ dropTable('gallery_media'); diff --git a/models/BaseGallery.php b/models/BaseGallery.php index 00ace35..143359e 100644 --- a/models/BaseGallery.php +++ b/models/BaseGallery.php @@ -2,22 +2,22 @@ namespace humhub\modules\gallery\models; -use \humhub\modules\content\components\ContentActiveRecord; -use \humhub\modules\file\models\File; +use humhub\modules\content\components\ContentActiveRecord; +use humhub\modules\file\models\File; use humhub\modules\gallery\permissions\WriteAccess; -use \humhub\modules\user\models\User; +use humhub\modules\user\models\User; use humhub\modules\gallery\Module; -use \Yii; +use Yii; /** * This is the abstract model class for table "gallery_gallery". * - * @property integer $id + * @property int $id * @property string $title * @property string $description - * @property integer $sort_order - * @property integer $thumb_file_id - * @property integer $type + * @property int $sort_order + * @property int $thumb_file_id + * @property int $type * * @package humhub.modules.gallery.models * @since 1.0 @@ -54,7 +54,7 @@ public function rules() ['description', 'string', 'max' => 1000], [['thumb_file_id', 'type'], 'safe'], [['sort_order'], 'integer'], - [['sort_order'], 'default', 'value' => 0] + [['sort_order'], 'default', 'value' => 0], ]; } @@ -65,7 +65,7 @@ public function attributeLabels() { return [ 'title' => Yii::t('GalleryModule.base', 'Title'), - 'description' => Yii::t('GalleryModule.base', 'Description') + 'description' => Yii::t('GalleryModule.base', 'Description'), ]; } @@ -87,15 +87,18 @@ public function getContentName() return Yii::t('GalleryModule.base', "Gallery"); } - public function getTitle() { + public function getTitle() + { return $this->title; } - public function getUrl() { + public function getUrl() + { return null; } - public function getCreatedAt() { + public function getCreatedAt() + { return $this->content->created_at; } @@ -130,13 +133,13 @@ public function getMetaData() 'contentObject' => $this, 'footerOverwrite' => false, 'alwaysShowHeading' => true, - 'imagePadding' => '' + 'imagePadding' => '', ]; } public static function findOne($condition) { - if(static::class !== BaseGallery::class) { + if (static::class !== BaseGallery::class) { $condition = $condition ? $condition : []; $condition['type'] = isset($condition['type']) ? $condition['type'] : static::class; return parent::findOne($condition); @@ -147,7 +150,7 @@ public static function findOne($condition) public static function findAll($condition) { - if(static::class !== BaseGallery::class) { + if (static::class !== BaseGallery::class) { $condition = $condition ? $condition : []; $condition['type'] = isset($condition['type']) ? $condition['type'] : static::class; return parent::findAll($condition); @@ -161,7 +164,7 @@ public static function findAll($condition) */ public function beforeSave($insert) { - if($insert) { + if ($insert) { $this->type = static::class; } return parent::beforeSave($insert); diff --git a/models/CustomGallery.php b/models/CustomGallery.php index 540ffc0..0f931cf 100644 --- a/models/CustomGallery.php +++ b/models/CustomGallery.php @@ -54,7 +54,7 @@ public function getPreviewImageUrl() // get preview image from the file list $media = $this->mediaListQuery() ->orderBy([ - 'sort_order' => SORT_ASC + 'sort_order' => SORT_ASC, ]) ->one(); if ($media != null && !empty($media->getSquarePreviewImageUrl())) { @@ -75,7 +75,7 @@ public function afterSoftDelete() public function getItemId() { - if($this->id != null) { + if ($this->id != null) { return 'custom-gallery_' . $this->id; } diff --git a/models/Media.php b/models/Media.php index 049bd4e..180ec96 100644 --- a/models/Media.php +++ b/models/Media.php @@ -17,11 +17,11 @@ /** * This is the model class for table "gallery_media". * - * @property integer $id - * @property integer $gallery_id + * @property int $id + * @property int $gallery_id * @property string $description * @property string $title - * @property integer $sort_order + * @property int $sort_order * @property File $baseFile * @property CustomGallery $parentGallery * @@ -31,7 +31,6 @@ */ class Media extends ContentActiveRecord implements Searchable { - /** * @var BaseGallery used for instantiation */ @@ -92,7 +91,7 @@ public function rules() [['gallery_id', 'sort_order'], 'integer'], ['title', 'string', 'max' => 255], ['description', 'string', 'max' => 1000], - ['hidden', 'boolean'] + ['hidden', 'boolean'], ]; } @@ -105,7 +104,7 @@ public function attributeLabels() 'id' => 'ID', 'gallery_id' => 'Gallery ID', 'description' => 'Description', - 'sort_order' => 'Sort Order' + 'sort_order' => 'Sort Order', ]; } diff --git a/models/MediaUpload.php b/models/MediaUpload.php index 59d4cfd..9353611 100644 --- a/models/MediaUpload.php +++ b/models/MediaUpload.php @@ -6,12 +6,11 @@ /** * MediaUpload - * + * * @author Sebastian Stumpf */ class MediaUpload extends FileUpload { - /** * The supported extensions */ @@ -22,10 +21,9 @@ class MediaUpload extends FileUpload */ public function rules() { - return array_merge(parent::rules(), [ + return array_merge(parent::rules(), [ ['uploadedFile', 'file', 'extensions' => $this->validExtensions], ]); } } - diff --git a/models/SquarePreviewImage.php b/models/SquarePreviewImage.php index cb08517..0350fae 100644 --- a/models/SquarePreviewImage.php +++ b/models/SquarePreviewImage.php @@ -8,10 +8,10 @@ namespace humhub\modules\gallery\models; -use \humhub\modules\file\converter\PreviewImage; +use humhub\modules\file\converter\PreviewImage; use Imagine\Image\Box; use Imagine\Image\ManipulatorInterface; -use \Yii; +use Yii; use yii\imagine\Image; /** @@ -22,8 +22,7 @@ */ class SquarePreviewImage extends PreviewImage { - - const DEFAULT_GALLERY_PREVIEW_IMAGE_MAX_DIM = 400; + public const DEFAULT_GALLERY_PREVIEW_IMAGE_MAX_DIM = 400; /** * @inheritdoc diff --git a/models/StreamGallery.php b/models/StreamGallery.php index 3254528..e842777 100644 --- a/models/StreamGallery.php +++ b/models/StreamGallery.php @@ -2,17 +2,17 @@ namespace humhub\modules\gallery\models; -use \humhub\modules\comment\models\Comment; +use humhub\modules\comment\models\Comment; use humhub\modules\content\components\ContentContainerActiveRecord; use humhub\modules\content\models\Content; use humhub\modules\content\widgets\Stream; -use \humhub\modules\file\models\File; +use humhub\modules\file\models\File; use humhub\modules\gallery\helpers\Url; -use \humhub\modules\post\models\Post; +use humhub\modules\post\models\Post; use humhub\modules\stream\actions\ContentContainerStream; use humhub\modules\stream\models\StreamQuery; use humhub\modules\stream\models\WallStreamQuery; -use \Yii; +use Yii; use yii\data\Pagination; use yii\db\ActiveQuery; @@ -42,10 +42,10 @@ public static function findForContainer(ContentContainerActiveRecord $container, { $result = static::find()->contentContainer($container)->where(['type' => StreamGallery::class])->one(); - if(!$result && $init) { + if (!$result && $init) { $result = new StreamGallery($container, Content::VISIBILITY_PUBLIC, [ 'title' => Yii::t('GalleryModule.base', 'Posted pictures'), - 'description' => Yii::t('GalleryModule.base', 'This gallery contains all posted pictures.') + 'description' => Yii::t('GalleryModule.base', 'This gallery contains all posted pictures.'), ]); $result->save(); } @@ -68,7 +68,7 @@ public function getPreviewImageUrl() // get first image from the complete filelist as fallback $file = $this->fileListQuery()->one(); - if(!$file) { + if (!$file) { return $this->getDefaultPreviewImageUrl(); } @@ -98,7 +98,7 @@ public function fileListQuery() ->andWhere('show_in_stream = 1') ->orderBy(['file.updated_at' => SORT_DESC]); - if(!$container->canAccessPrivateContent()) { + if (!$container->canAccessPrivateContent()) { $query->andWhere('content.visibility = :visibility', [':visibility' => Content::VISIBILITY_PUBLIC]); } diff --git a/models/forms/ContainerSettings.php b/models/forms/ContainerSettings.php index 339c692..524937d 100644 --- a/models/forms/ContainerSettings.php +++ b/models/forms/ContainerSettings.php @@ -24,13 +24,13 @@ */ class ContainerSettings extends Model { - const SETTING_HIDE_SNIPPET = 'hideSnippet'; - const SETTING_GALLERY_ID = 'galleryId'; - const SETTING_SORT_ORDER= 'snippetSortOrder'; - const SETTING_SORT_BY_CREATED = 'sortByCreated'; - const SETTING_CONTENT_HIDDEN_DEFAULT = 'contentHiddenDefault'; - const SORT_MIN = 0; - const SORT_MAX = 32000; + public const SETTING_HIDE_SNIPPET = 'hideSnippet'; + public const SETTING_GALLERY_ID = 'galleryId'; + public const SETTING_SORT_ORDER = 'snippetSortOrder'; + public const SETTING_SORT_BY_CREATED = 'sortByCreated'; + public const SETTING_CONTENT_HIDDEN_DEFAULT = 'contentHiddenDefault'; + public const SORT_MIN = 0; + public const SORT_MAX = 32000; /** * @var ContentContainerActiveRecord $contentContainer of this snippet */ @@ -47,7 +47,7 @@ class ContainerSettings extends Model public $hideSnippet; /** - * @var integer defines the sort order snippet for the gallery; + * @var int defines the sort order snippet for the gallery; */ public $snippetSortOrder; @@ -89,17 +89,18 @@ public function rules() [['snippetGallery'], 'containerGallery'], [['snippetSortOrder'], 'number', 'min' => static::SORT_MIN, 'max' => static::SORT_MAX], ['sortByCreated', 'integer'], - [['contentHiddenDefault'], 'boolean'] + [['contentHiddenDefault'], 'boolean'], ]; } - public function containerGallery($attribute, $params) { - if(!$this->snippetGallery) { + public function containerGallery($attribute, $params) + { + if (!$this->snippetGallery) { return; } $gallery = CustomGallery::findOne(['id' => $this->snippetGallery]); - if(!$gallery->content->contentcontainer_id === $this->contentContainer->contentContainerRecord->id) { + if (!$gallery->content->contentcontainer_id === $this->contentContainer->contentContainerRecord->id) { $this->addError($attribute, 'Invalid gallery selection.'); } } @@ -120,7 +121,7 @@ public function attributeLabels() public function attributeHints() { return [ - 'snippetGallery' => Yii::t('GalleryModule.base', 'In case the gallery is not visible for the current user, the snippet will use the latest accessible gallery instead.') + 'snippetGallery' => Yii::t('GalleryModule.base', 'In case the gallery is not visible for the current user, the snippet will use the latest accessible gallery instead.'), ]; } @@ -132,12 +133,12 @@ public function getGallerySelection() $visibility = $latest->content->isPublic() ? Yii::t('base', 'Public') : Yii::t('base', 'Private'); $result = ['0' => Yii::t('GalleryModule.base', 'Latest Gallery - {title} ({visibility})', [ 'title' => Html::encode($latest->title), - 'visibility' => $visibility + 'visibility' => $visibility, ])]; foreach ($galleries as $gallery) { $visibility = $gallery->content->isPublic() ? Yii::t('base', 'Public') : Yii::t('base', 'Private'); - $result[$gallery->id] = Html::encode($gallery->title).' ('.$visibility.')'; + $result[$gallery->id] = Html::encode($gallery->title) . ' (' . $visibility . ')'; } return $result; @@ -145,7 +146,7 @@ public function getGallerySelection() public function save() { - if(!$this->validate()) { + if (!$this->validate()) { return false; } @@ -204,13 +205,13 @@ public function getSnippetGallery() { $galleryId = $this->getSnippetId(); - if(!$galleryId) { + if (!$galleryId) { $gallery = CustomGallery::findLatest($this->contentContainer); } else { $gallery = CustomGallery::findOne(['id' => $galleryId]); } - if($gallery && !$gallery->content->canView()) { + if ($gallery && !$gallery->content->canView()) { $gallery = CustomGallery::find()->contentContainer($this->contentContainer)->readable()->one(); } diff --git a/models/forms/GalleryEditForm.php b/models/forms/GalleryEditForm.php index 5dd4379..7e577e3 100644 --- a/models/forms/GalleryEditForm.php +++ b/models/forms/GalleryEditForm.php @@ -52,16 +52,16 @@ public function init() { parent::init(); - if(!$this->instance) { + if (!$this->instance) { $this->visibility = $this->getDefaultVisibility(); $this->instance = new CustomGallery(); $this->instance->content->container = $this->contentContainer; $this->instance->content->visibility = $this->visibility; - } else if(!($this->instance instanceof CustomGallery)) { + } elseif (!($this->instance instanceof CustomGallery)) { throw new HttpException(404); - } else if($this->instance->content->container->id != $this->contentContainer->id) { + } elseif ($this->instance->content->container->id != $this->contentContainer->id) { throw new HttpException(404); - } else if(!$this->instance->content->canEdit()) { + } elseif (!$this->instance->content->canEdit()) { throw new HttpException(403); } else { $this->visibility = $this->instance->content->visibility; @@ -82,7 +82,7 @@ public function attributeLabels() */ private function getDefaultVisibility() { - if($this->contentContainer instanceof Space) { + if ($this->contentContainer instanceof Space) { return $this->contentContainer->getDefaultContentVisibility(); } else { return Content::VISIBILITY_PUBLIC; @@ -115,11 +115,11 @@ public function rules() */ public function save() { - if(!$this->validate()) { + if (!$this->validate()) { return false; } - return CustomGallery::getDb()->transaction(function() { + return CustomGallery::getDb()->transaction(function () { $this->updateVisibility(); return $this->instance->save(); }); @@ -131,7 +131,7 @@ public function save() */ protected function updateVisibility() { - if($this->visibility === null) { + if ($this->visibility === null) { return; } @@ -139,7 +139,7 @@ protected function updateVisibility() $this->instance->content->visibility = $this->visibility; $contentIds = []; - foreach($this->instance->mediaList as $media) { + foreach ($this->instance->mediaList as $media) { $contentIds[] = $media->content->id; } diff --git a/permissions/WriteAccess.php b/permissions/WriteAccess.php index a95713e..a0034be 100644 --- a/permissions/WriteAccess.php +++ b/permissions/WriteAccess.php @@ -10,8 +10,8 @@ use humhub\modules\user\models\User; use Yii; -use \humhub\libs\BasePermission; -use \humhub\modules\space\models\Space; +use humhub\libs\BasePermission; +use humhub\modules\space\models\Space; /** * WriteAccess Permission @@ -22,7 +22,6 @@ */ class WriteAccess extends BasePermission { - /** * @inheritdoc */ @@ -31,7 +30,7 @@ class WriteAccess extends BasePermission Space::USERGROUP_OWNER, Space::USERGROUP_ADMIN, Space::USERGROUP_MODERATOR, - Space::USERGROUP_MEMBER + Space::USERGROUP_MEMBER, ]; /** @@ -42,7 +41,7 @@ class WriteAccess extends BasePermission User::USERGROUP_GUEST, User::USERGROUP_USER, Space::USERGROUP_USER, - Space::USERGROUP_GUEST + Space::USERGROUP_GUEST, ]; public function getTitle() diff --git a/tests/codeception/_bootstrap.php b/tests/codeception/_bootstrap.php index d95583f..8ece297 100644 --- a/tests/codeception/_bootstrap.php +++ b/tests/codeception/_bootstrap.php @@ -32,4 +32,4 @@ $globalConfig = require $humhubPath . '/protected/humhub/tests/codeception/_loadConfig.php'; // Load default test bootstrap (initialize Yii...) -require $globalConfig['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'; \ No newline at end of file +require $globalConfig['humhub_root'] . '/protected/humhub/tests/codeception/_bootstrap.php'; diff --git a/tests/codeception/_support/AcceptanceTester.php b/tests/codeception/_support/AcceptanceTester.php index 548a9db..adc225f 100644 --- a/tests/codeception/_support/AcceptanceTester.php +++ b/tests/codeception/_support/AcceptanceTester.php @@ -1,4 +1,5 @@ amOnSpace($guid, '/space/manage/module'); - $this->seeElement('.enable-module-'.$moduleId); - $this->jsClick('.enable-module-'.$moduleId); - $this->waitForElement('.disable-module-'.$moduleId); + $this->seeElement('.enable-module-' . $moduleId); + $this->jsClick('.enable-module-' . $moduleId); + $this->waitForElement('.disable-module-' . $moduleId); $this->amOnSpace($guid); } @@ -66,7 +67,7 @@ public function createGallery($title = 'Test gallery', $description = 'My test g } $this->click('Save', '#globalModal'); - $this->waitForText('Gallery '.$title, null, '#gallery-container .panel-heading'); + $this->waitForText('Gallery ' . $title, null, '#gallery-container .panel-heading'); if ($public) { $this->see('Public'); diff --git a/tests/codeception/_support/FunctionalTester.php b/tests/codeception/_support/FunctionalTester.php index e0f3eb5..1d452bb 100644 --- a/tests/codeception/_support/FunctionalTester.php +++ b/tests/codeception/_support/FunctionalTester.php @@ -1,4 +1,5 @@ becomeUser('User1'); $gallery = new CustomGallery(Space::findOne(1), [ 'title' => 'Test Gallery', - 'description' => 'Test Gallery Description' + 'description' => 'Test Gallery Description', ]); $this->assertTrue($gallery->save()); @@ -24,7 +24,7 @@ public function testCreateGallery() $media = new Media($space, [ 'gallery' => $gallery, 'title' => 'My media', - 'description' => 'My test media' + 'description' => 'My test media', ]); $this->assertTrue($media->save()); @@ -42,7 +42,7 @@ public function testDeleteGallery() $this->becomeUser('User1'); $gallery = new CustomGallery(Space::findOne(1), [ 'title' => 'Test Gallery', - 'description' => 'Test Gallery Description' + 'description' => 'Test Gallery Description', ]); $this->assertTrue($gallery->save()); @@ -50,7 +50,7 @@ public function testDeleteGallery() $media = new Media($space, [ 'gallery' => $gallery, 'title' => 'My media', - 'description' => 'My test media' + 'description' => 'My test media', ]); $this->assertTrue($media->save()); @@ -60,4 +60,4 @@ public function testDeleteGallery() $this->assertCount(0, Media::find()->readable(User::findOne(['username' => 'User1']))->all()); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/_bootstrap.php b/tests/codeception/unit/_bootstrap.php index 1d20d03..fd21dc5 100644 --- a/tests/codeception/unit/_bootstrap.php +++ b/tests/codeception/unit/_bootstrap.php @@ -3,4 +3,4 @@ * Initialize the HumHub Application for functional testing. The default application configuration for this suite can be overwritten * in @tests/config/functional.php */ -require(Yii::getAlias('@humhubTests/codeception/unit/_bootstrap.php')); \ No newline at end of file +require(Yii::getAlias('@humhubTests/codeception/unit/_bootstrap.php')); diff --git a/tests/config/test.php b/tests/config/test.php index 9e93c0e..d81f69e 100644 --- a/tests/config/test.php +++ b/tests/config/test.php @@ -10,9 +10,6 @@ 'modules' => ['gallery'], 'fixtures' => [ 'default', - 'task' => \humhub\modules\gallery\tests\codeception\fixtures\GalleryFixture::class - ] + 'task' => \humhub\modules\gallery\tests\codeception\fixtures\GalleryFixture::class, + ], ]; - - - diff --git a/widgets/GalleryList.php b/widgets/GalleryList.php index 83c8922..f503923 100644 --- a/widgets/GalleryList.php +++ b/widgets/GalleryList.php @@ -8,7 +8,7 @@ namespace humhub\modules\gallery\widgets; -use \yii\base\Widget; +use yii\base\Widget; /** * Widget that renders a list of entries in the gallery module. @@ -19,7 +19,6 @@ */ class GalleryList extends Widget { - public $entryList; public $parentGallery; public $entriesOnly = false; @@ -31,7 +30,7 @@ public function run() 'entryList' => $this->entryList, 'entriesOnly' => $this->entriesOnly, 'parentGallery' => $this->parentGallery, - 'showMore' => $this->showMore + 'showMore' => $this->showMore, ]); } } diff --git a/widgets/GalleryListEntry.php b/widgets/GalleryListEntry.php index 7fc2aa0..7a9f68f 100644 --- a/widgets/GalleryListEntry.php +++ b/widgets/GalleryListEntry.php @@ -16,8 +16,8 @@ use humhub\modules\gallery\models\BaseGallery; use humhub\modules\gallery\models\Media; use humhub\modules\gallery\models\SquarePreviewImage; -use \yii\base\Widget; -use \Yii; +use yii\base\Widget; +use Yii; /** * Widget that renders an entry inside a list in the gallery module @@ -28,7 +28,6 @@ */ class GalleryListEntry extends Widget { - public $entryObject; public $parentGallery; @@ -48,7 +47,7 @@ public function run() } $metaData['creatorUrl'] = !empty($metaData['creator']) ? $metaData['creator']->createUrl() : ''; - $metaData['creatorThumbnailUrl'] = !empty($metaData['creator']) ? $metaData['creator']->getProfileImage()->getUrl() : ''; + $metaData['creatorThumbnailUrl'] = !empty($metaData['creator']) ? $metaData['creator']->getProfileImage()->getUrl() : ''; $metaData['uiGalleryId'] = $this->parentGallery ? "GalleryModule-Gallery-" . $this->parentGallery->id : ''; return $this->render('galleryListEntry', $metaData); @@ -64,14 +63,14 @@ private function getMediaMetaData(Media $media) 'wallUrl' => $media->getWallUrl(), 'deleteUrl' => Url::toDeleteMedia($contentContainer, $media->id), 'editUrl' => Url::toEditMedia($contentContainer, $media), - 'downloadUrl' =>$media->getFileUrl(true), + 'downloadUrl' => $media->getFileUrl(true), 'fileUrl' => $media->getFileUrl(), 'thumbnailUrl' => $media->getSquarePreviewImageUrl(), 'writeAccess' => $media->content->canEdit(), 'contentObject' => $media, 'footerOverwrite' => false, 'alwaysShowHeading' => false, - 'imagePadding' => '' + 'imagePadding' => '', ]; } @@ -94,7 +93,7 @@ private function getFileMetaData($model) 'contentObject' => $contentObject, 'footerOverwrite' => false, 'alwaysShowHeading' => false, - 'imagePadding' => '' + 'imagePadding' => '', ]; } } diff --git a/widgets/GalleryListEntryAdd.php b/widgets/GalleryListEntryAdd.php index 3cf0bd7..a38f98f 100644 --- a/widgets/GalleryListEntryAdd.php +++ b/widgets/GalleryListEntryAdd.php @@ -8,14 +8,14 @@ namespace humhub\modules\gallery\widgets; -use \humhub\modules\file\handler\FileHandlerCollection; -use \humhub\modules\file\widgets\FileHandlerButtonDropdown; -use \humhub\modules\file\widgets\UploadButton; +use humhub\modules\file\handler\FileHandlerCollection; +use humhub\modules\file\widgets\FileHandlerButtonDropdown; +use humhub\modules\file\widgets\UploadButton; use humhub\modules\gallery\helpers\Url; -use \humhub\modules\gallery\models\StreamGallery; +use humhub\modules\gallery\models\StreamGallery; use humhub\modules\gallery\permissions\WriteAccess; -use \Yii; -use \yii\base\Widget; +use Yii; +use yii\base\Widget; /** * Widget that renders an entry inside a list in the gallery module @@ -26,14 +26,13 @@ */ class GalleryListEntryAdd extends Widget { - public $parentGallery; public function run() { $contentContainer = Yii::$app->controller->contentContainer; - if(!$contentContainer->can(WriteAccess::class)) { + if (!$contentContainer->can(WriteAccess::class)) { return ''; } @@ -44,24 +43,24 @@ public function run() if ($this->parentGallery) { return $this->render('galleryListEntryAdd', [ - 'title' => Yii::t('GalleryModule.base', 'Click or drop files here'), - 'addActionUrl' => '#', - 'htmlOptions' => [ - 'data' => [ - 'action-click' => "file.upload", - 'action-target' => '#gallery-media-upload' - ] - ] + 'title' => Yii::t('GalleryModule.base', 'Click or drop files here'), + 'addActionUrl' => '#', + 'htmlOptions' => [ + 'data' => [ + 'action-click' => "file.upload", + 'action-target' => '#gallery-media-upload', + ], + ], ]); } else { return $this->render('galleryListEntryAdd', [ - 'title' => Yii::t('GalleryModule.base', 'Click here to add new Gallery'), - 'addActionUrl' => Url::toCreateCustomGallery($contentContainer), - 'htmlOptions' => [ - 'data' => [ - 'target' => "#globalModal", - ] - ] + 'title' => Yii::t('GalleryModule.base', 'Click here to add new Gallery'), + 'addActionUrl' => Url::toCreateCustomGallery($contentContainer), + 'htmlOptions' => [ + 'data' => [ + 'target' => "#globalModal", + ], + ], ]); } } diff --git a/widgets/GalleryMenu.php b/widgets/GalleryMenu.php index 6583e0c..50debf6 100644 --- a/widgets/GalleryMenu.php +++ b/widgets/GalleryMenu.php @@ -14,7 +14,6 @@ */ class GalleryMenu extends \yii\base\Widget { - /** * var humhub\modules\gallery\models\BaseGallery Current gallery model instance. */ @@ -26,12 +25,12 @@ class GalleryMenu extends \yii\base\Widget public $contentContainer; /** - * @var boolean Determines if the user has write permissions. + * @var bool Determines if the user has write permissions. */ public $canWrite; /** - * @var integer FileList item count. + * @var int FileList item count. */ public $itemCount; @@ -40,14 +39,14 @@ class GalleryMenu extends \yii\base\Widget */ public function run() { - if(!$this->canWrite) { + if (!$this->canWrite) { return; } return $this->render('galleryMenuDropdown', [ - 'deleteUrl' => Url::toDeleteCustomGallery($this->contentContainer, $this->gallery->id), - 'editUrl' => Url::toEditCustomGallery($this->contentContainer, $this->gallery->id), - 'uploadUrl' => Url::toUploadMedia($this->contentContainer, $this->gallery->id), + 'deleteUrl' => Url::toDeleteCustomGallery($this->contentContainer, $this->gallery->id), + 'editUrl' => Url::toEditCustomGallery($this->contentContainer, $this->gallery->id), + 'uploadUrl' => Url::toUploadMedia($this->contentContainer, $this->gallery->id), ]); } diff --git a/widgets/GallerySnippet.php b/widgets/GallerySnippet.php index 41a8fc6..9cdb924 100644 --- a/widgets/GallerySnippet.php +++ b/widgets/GallerySnippet.php @@ -15,7 +15,6 @@ namespace humhub\modules\gallery\widgets; - use humhub\modules\gallery\permissions\WriteAccess; use Yii; use humhub\components\Widget; @@ -38,19 +37,19 @@ public function run() { $settings = new ContainerSettings(['contentContainer' => $this->contentContainer]); - if($settings->hideSnippet) { + if ($settings->hideSnippet) { return; } $gallery = $settings->getSnippetGallery(); - if(!$gallery) { + if (!$gallery) { return; } $images = $gallery->getMediaList(Yii::$app->getModule('gallery')->snippetMaxImages); - if(!count($images)) { + if (!count($images)) { return; } @@ -59,7 +58,7 @@ public function run() 'settingsUrl' => $this->contentContainer->createUrl('/gallery/setting'), 'galleryUrl' => $gallery->getUrl(), 'isAdmin' => $this->contentContainer instanceof Space ? $this->contentContainer->isAdmin() : $this->contentContainer->isCurrentUser(), - 'canWrite' => $this->contentContainer->permissionManager->can(new WriteAccess()) + 'canWrite' => $this->contentContainer->permissionManager->can(new WriteAccess()), ]); } -} \ No newline at end of file +} diff --git a/widgets/WallEntryMedia.php b/widgets/WallEntryMedia.php index 58985fd..2031053 100644 --- a/widgets/WallEntryMedia.php +++ b/widgets/WallEntryMedia.php @@ -21,7 +21,6 @@ */ class WallEntryMedia extends WallStreamModuleEntryWidget { - /** * @inheritdoc */