From 3b58e7a10660ad288b3ded5c05b9d51e951b9f76 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Sun, 4 Nov 2018 17:13:07 +0900 Subject: [PATCH 01/59] Update slide.ctp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix: アップロードファイルディレクトリ変更に対応 https://github.com/NetCommons3/NetCommons3/issues/1365 --- View/PhotoAlbumPhotos/slide.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/PhotoAlbumPhotos/slide.ctp b/View/PhotoAlbumPhotos/slide.ctp index af9a601..a711394 100644 --- a/View/PhotoAlbumPhotos/slide.ctp +++ b/View/PhotoAlbumPhotos/slide.ctp @@ -88,7 +88,7 @@ $srcPrefix = $this->Html->url( if ($frameSetting['PhotoAlbumFrameSetting']['slide_height'] >= 1) { echo 'height:' . $frameSetting['PhotoAlbumFrameSetting']['slide_height'] . 'px'; } else { - list($width, $height) = getimagesize( WWW_ROOT . $photo['UploadFile']['photo']['path'] . $photo['UploadFile']['photo']['id'] . DS . $photo['UploadFile']['photo']['real_file_name']); + list($width, $height) = getimagesize( UPLOADS_ROOT . $photo['UploadFile']['photo']['path'] . $photo['UploadFile']['photo']['id'] . DS . $photo['UploadFile']['photo']['real_file_name']); echo 'padding-top:' . ($height / $width * 100) . '%;'; } } From 967bd73edebe24bdb90b6d2437bbf68628b5a602 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Tue, 27 Nov 2018 17:07:00 +0900 Subject: [PATCH 02/59] =?UTF-8?q?fix:=202=E3=81=A4=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=83=AB=E3=83=90=E3=83=A0=E3=82=92=E5=88=A5=E3=80=85=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0=E3=81=A7=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=81=9B=E3=82=8B=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1351?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/PhotoAlbumsController.php | 7 ++-- Model/PhotoAlbumDisplayAlbum.php | 32 +++++++++---------- .../GetDisplayListTest.php | 16 +++++----- 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Controller/PhotoAlbumsController.php b/Controller/PhotoAlbumsController.php index 96ec822..bd6ac57 100644 --- a/Controller/PhotoAlbumsController.php +++ b/Controller/PhotoAlbumsController.php @@ -90,11 +90,14 @@ public function index() { $frameSetting = $this->PhotoAlbumFrameSetting->getFrameSetting(); $this->set('frameSetting', $frameSetting); - $displayAlbum = $this->PhotoAlbumDisplayAlbum->getDisplayList(); + // PhotoAlbumDisplayAlbumはフレームキー毎にアルバムを管理している。 + // 本来アルバムはルーム単位で管理するもののため、PhotoAlbumDisplayAlbumは利用しない。 + // ここ以外でPhotoAlbumDisplayAlbum->getDisplayList()は利用されていない。 + //$displayAlbum = $this->PhotoAlbumDisplayAlbum->getDisplayList(); $conditions = $this->PhotoAlbum->getWorkflowConditions(); $conditions['PhotoAlbum.block_id'] = Current::read('Block.id'); - $conditions['PhotoAlbum.key'] = $displayAlbum; + //$conditions['PhotoAlbum.key'] = $displayAlbum; $this->Paginator->settings = array( 'PhotoAlbum' => array( diff --git a/Model/PhotoAlbumDisplayAlbum.php b/Model/PhotoAlbumDisplayAlbum.php index bd05096..e332f9e 100644 --- a/Model/PhotoAlbumDisplayAlbum.php +++ b/Model/PhotoAlbumDisplayAlbum.php @@ -49,20 +49,20 @@ public function beforeValidate($options = array()) { return parent::beforeValidate($options); } -/** - * Get display album key list - * - * @return display album key list - */ - public function getDisplayList() { - $query = array( - 'fields' => array('PhotoAlbumDisplayAlbum.album_key'), - 'conditions' => array( - 'frame_key' => Current::read('Frame.key') - ), - 'recursive' => -1 - ); - - return $this->find('list', $query); - } + ///** + // * Get display album key list + // * + // * @return display album key list + // */ + // public function getDisplayList() { + // $query = array( + // 'fields' => array('PhotoAlbumDisplayAlbum.album_key'), + // 'conditions' => array( + // 'frame_key' => Current::read('Frame.key') + // ), + // 'recursive' => -1 + // ); + // + // return $this->find('list', $query); + // } } diff --git a/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php b/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php index 654277f..5077179 100644 --- a/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php +++ b/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php @@ -53,13 +53,13 @@ public function tearDown() { * @return void */ public function testGetDisplayList() { - $currentValue['Frame']['key'] = 'Lorem ipsum dolor sit amet'; - PhotoAlbumTestCurrentUtility::setValue($currentValue); - - $expected[1] = 'Lorem ipsum dolor sit amet'; - $actual = $this->PhotoAlbumDisplayAlbum->getDisplayList(); - - $this->assertEquals($expected, $actual); - PhotoAlbumTestCurrentUtility::setOriginValue(); + // $currentValue['Frame']['key'] = 'Lorem ipsum dolor sit amet'; + // PhotoAlbumTestCurrentUtility::setValue($currentValue); + // + // $expected[1] = 'Lorem ipsum dolor sit amet'; + // $actual = $this->PhotoAlbumDisplayAlbum->getDisplayList(); + // + // $this->assertEquals($expected, $actual); + // PhotoAlbumTestCurrentUtility::setOriginValue(); } } From 3d1c7567902ac4a50893bb8b1110e4b8a86c062b Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Tue, 27 Nov 2018 18:35:30 +0900 Subject: [PATCH 03/59] =?UTF-8?q?fix:=202=E3=81=A4=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=83=AB=E3=83=90=E3=83=A0=E3=82=92=E5=88=A5=E3=80=85=E3=81=AE?= =?UTF-8?q?=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0=E3=81=A7=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=95=E3=81=9B=E3=82=8B=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1351?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/PhotoAlbumsController.php | 7 ++-- Model/PhotoAlbumDisplayAlbum.php | 32 +++++++++---------- Model/PhotoAlbumFrameSetting.php | 3 +- .../GetDisplayListTest.php | 16 +++++----- 4 files changed, 28 insertions(+), 30 deletions(-) diff --git a/Controller/PhotoAlbumsController.php b/Controller/PhotoAlbumsController.php index bd6ac57..96ec822 100644 --- a/Controller/PhotoAlbumsController.php +++ b/Controller/PhotoAlbumsController.php @@ -90,14 +90,11 @@ public function index() { $frameSetting = $this->PhotoAlbumFrameSetting->getFrameSetting(); $this->set('frameSetting', $frameSetting); - // PhotoAlbumDisplayAlbumはフレームキー毎にアルバムを管理している。 - // 本来アルバムはルーム単位で管理するもののため、PhotoAlbumDisplayAlbumは利用しない。 - // ここ以外でPhotoAlbumDisplayAlbum->getDisplayList()は利用されていない。 - //$displayAlbum = $this->PhotoAlbumDisplayAlbum->getDisplayList(); + $displayAlbum = $this->PhotoAlbumDisplayAlbum->getDisplayList(); $conditions = $this->PhotoAlbum->getWorkflowConditions(); $conditions['PhotoAlbum.block_id'] = Current::read('Block.id'); - //$conditions['PhotoAlbum.key'] = $displayAlbum; + $conditions['PhotoAlbum.key'] = $displayAlbum; $this->Paginator->settings = array( 'PhotoAlbum' => array( diff --git a/Model/PhotoAlbumDisplayAlbum.php b/Model/PhotoAlbumDisplayAlbum.php index e332f9e..bd05096 100644 --- a/Model/PhotoAlbumDisplayAlbum.php +++ b/Model/PhotoAlbumDisplayAlbum.php @@ -49,20 +49,20 @@ public function beforeValidate($options = array()) { return parent::beforeValidate($options); } - ///** - // * Get display album key list - // * - // * @return display album key list - // */ - // public function getDisplayList() { - // $query = array( - // 'fields' => array('PhotoAlbumDisplayAlbum.album_key'), - // 'conditions' => array( - // 'frame_key' => Current::read('Frame.key') - // ), - // 'recursive' => -1 - // ); - // - // return $this->find('list', $query); - // } +/** + * Get display album key list + * + * @return display album key list + */ + public function getDisplayList() { + $query = array( + 'fields' => array('PhotoAlbumDisplayAlbum.album_key'), + 'conditions' => array( + 'frame_key' => Current::read('Frame.key') + ), + 'recursive' => -1 + ); + + return $this->find('list', $query); + } } diff --git a/Model/PhotoAlbumFrameSetting.php b/Model/PhotoAlbumFrameSetting.php index 565bf06..97a955d 100644 --- a/Model/PhotoAlbumFrameSetting.php +++ b/Model/PhotoAlbumFrameSetting.php @@ -162,7 +162,8 @@ public function savePhotoAlbumFrameSetting($data) { foreach ($data['PhotoAlbumDisplayAlbum'] as $displayAlbumData) { $displayAlbumData = $DisplayAlbum->create($displayAlbumData); - $displayAlbumData['frame_key'] = $data['PhotoAlbumFrameSetting']['frame_key']; + $displayAlbumData['PhotoAlbumDisplayAlbum']['frame_key'] = + $data['PhotoAlbumFrameSetting']['frame_key']; if (!$DisplayAlbum->save($displayAlbumData)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } diff --git a/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php b/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php index 5077179..654277f 100644 --- a/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php +++ b/Test/Case/Model/PhotoAlbumDisplayAlbum/GetDisplayListTest.php @@ -53,13 +53,13 @@ public function tearDown() { * @return void */ public function testGetDisplayList() { - // $currentValue['Frame']['key'] = 'Lorem ipsum dolor sit amet'; - // PhotoAlbumTestCurrentUtility::setValue($currentValue); - // - // $expected[1] = 'Lorem ipsum dolor sit amet'; - // $actual = $this->PhotoAlbumDisplayAlbum->getDisplayList(); - // - // $this->assertEquals($expected, $actual); - // PhotoAlbumTestCurrentUtility::setOriginValue(); + $currentValue['Frame']['key'] = 'Lorem ipsum dolor sit amet'; + PhotoAlbumTestCurrentUtility::setValue($currentValue); + + $expected[1] = 'Lorem ipsum dolor sit amet'; + $actual = $this->PhotoAlbumDisplayAlbum->getDisplayList(); + + $this->assertEquals($expected, $actual); + PhotoAlbumTestCurrentUtility::setOriginValue(); } } From f6419c31bbf56c77d774e0507e1da72609c3a64a Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Sun, 6 Jan 2019 11:39:57 +0900 Subject: [PATCH 04/59] =?UTF-8?q?feat:=20=E3=82=B9=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=80=E3=83=BC=E9=AB=98=E3=81=95=E6=8C=87=E5=AE=9A=E6=99=82?= =?UTF-8?q?=E3=81=A7=E3=82=82=E7=B8=A6=E6=A8=AA=E6=AF=94=E3=82=92=E7=B6=AD?= =?UTF-8?q?=E6=8C=81=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit slide.ctpのみの修正 --- View/PhotoAlbumPhotos/slide.ctp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/View/PhotoAlbumPhotos/slide.ctp b/View/PhotoAlbumPhotos/slide.ctp index a711394..026c738 100644 --- a/View/PhotoAlbumPhotos/slide.ctp +++ b/View/PhotoAlbumPhotos/slide.ctp @@ -54,6 +54,7 @@ $srcPrefix = $this->Html->url( > + $photo) : ?>
Html->url( isset($frameSetting['PhotoAlbumFrameSetting']['slide_height']) ) { if ($frameSetting['PhotoAlbumFrameSetting']['slide_height'] >= 1) { - echo 'height:' . $frameSetting['PhotoAlbumFrameSetting']['slide_height'] . 'px'; + echo 'height:' . $frameSetting['PhotoAlbumFrameSetting']['slide_height'] . 'px; background-size:contain;'; } else { - list($width, $height) = getimagesize( UPLOADS_ROOT . $photo['UploadFile']['photo']['path'] . $photo['UploadFile']['photo']['id'] . DS . $photo['UploadFile']['photo']['real_file_name']); - echo 'padding-top:' . ($height / $width * 100) . '%;'; + if ( empty( $height ) ) { + list($width, $height) = getimagesize( UPLOADS_ROOT . $photo['UploadFile']['photo']['path'] . $photo['UploadFile']['photo']['id'] . DS . $photo['UploadFile']['photo']['real_file_name']); + } + echo 'padding-top:' . ($height / $width * 100) . '%; background-size:contain;'; } } ?> From 8a942397eb51946a3417cd440e1a6ccc7b00c150 Mon Sep 17 00:00:00 2001 From: Mitsuru Mutaguchi Date: Sun, 6 Jan 2019 13:23:02 +0900 Subject: [PATCH 05/59] fix: phpcs fix --- View/PhotoAlbumPhotos/slide.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/PhotoAlbumPhotos/slide.ctp b/View/PhotoAlbumPhotos/slide.ctp index 026c738..314cb5d 100644 --- a/View/PhotoAlbumPhotos/slide.ctp +++ b/View/PhotoAlbumPhotos/slide.ctp @@ -89,7 +89,7 @@ $srcPrefix = $this->Html->url( if ($frameSetting['PhotoAlbumFrameSetting']['slide_height'] >= 1) { echo 'height:' . $frameSetting['PhotoAlbumFrameSetting']['slide_height'] . 'px; background-size:contain;'; } else { - if ( empty( $height ) ) { + if (empty($height)) { list($width, $height) = getimagesize( UPLOADS_ROOT . $photo['UploadFile']['photo']['path'] . $photo['UploadFile']['photo']['id'] . DS . $photo['UploadFile']['photo']['real_file_name']); } echo 'padding-top:' . ($height / $width * 100) . '%; background-size:contain;'; From 198feda94feb5f6812fdbd08d3e91d4296ccd675 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Fri, 13 Sep 2019 20:43:21 +0900 Subject: [PATCH 06/59] =?UTF-8?q?fix:=20test:=20=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=A6=E3=81=9F=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GetWorkflowConditionsTest.php | 100 +++++++++++++++--- .../Model/PhotoAlbumPhoto/PublishTest.php | 42 ++++++-- 2 files changed, 118 insertions(+), 24 deletions(-) diff --git a/Test/Case/Model/PhotoAlbumPhoto/GetWorkflowConditionsTest.php b/Test/Case/Model/PhotoAlbumPhoto/GetWorkflowConditionsTest.php index 3406506..7184b45 100644 --- a/Test/Case/Model/PhotoAlbumPhoto/GetWorkflowConditionsTest.php +++ b/Test/Case/Model/PhotoAlbumPhoto/GetWorkflowConditionsTest.php @@ -26,7 +26,12 @@ class PhotoAlbumPhotoGetWorkflowConditionsTest extends NetCommonsCakeTestCase { 'plugin.photo_albums.photo_album_photo', ); -/** + private $originPublishablePermission; + private $originEditablePermission; + private $originPermissions = []; + private $originCurrent =[]; + + /** * setUp method * * @return void @@ -53,9 +58,8 @@ public function tearDown() { * @return void */ public function testHasContentEditable() { - $currentValue['Permission']['content_editable']['value'] = true; - $currentValue['Language']['id'] = 99; - PhotoAlbumTestCurrentUtility::setValue($currentValue); + Current::write('Language.id', 99); + $this->__permissionEditable(); $expected = array ( array( @@ -74,7 +78,7 @@ public function testHasContentEditable() { $actual = $this->PhotoAlbumPhoto->getWorkflowConditions(); $this->assertEquals($expected, $actual); - PhotoAlbumTestCurrentUtility::setOriginValue(); + $this->__restorePermission(); } /** @@ -83,11 +87,17 @@ public function testHasContentEditable() { * @return void */ public function testHasPhotoCreatable() { - $currentValue['Permission']['content_editable']['value'] = false; - $currentValue['Permission']['photo_albums_photo_creatable']['value'] = true; - $currentValue['Language']['id'] = 99; - $currentValue['User']['id'] = 88; - PhotoAlbumTestCurrentUtility::setValue($currentValue); + //$currentValue['Permission']['content_editable']['value'] = false; + //$currentValue['Permission']['photo_albums_photo_creatable']['value'] = true; + $this->__setPermission('content_editable', false); + $this->__setPermission('photo_albums_photo_creatable', true); + + //$currentValue['Language']['id'] = 99; + //$currentValue['User']['id'] = 88; + //PhotoAlbumTestCurrentUtility::setValue($currentValue); + $this->__setCurrent('Language.id', 99); + $this->__setCurrent('User.id', 88); + $expected = array ( array( @@ -112,7 +122,10 @@ public function testHasPhotoCreatable() { $actual = $this->PhotoAlbumPhoto->getWorkflowConditions(); $this->assertEquals($expected, $actual); - PhotoAlbumTestCurrentUtility::setOriginValue(); + //PhotoAlbumTestCurrentUtility::setOriginValue(); + + $this->__restoreCurrent(); + $this->__restorePermission(); } /** @@ -121,11 +134,15 @@ public function testHasPhotoCreatable() { * @return void */ public function testNotHasPhotoCreatable() { - $currentValue['Permission']['content_editable']['value'] = false; - $currentValue['Permission']['photo_albums_photo_creatable']['value'] = false; - $currentValue['Language']['id'] = 99; - $currentValue['User']['id'] = 88; - PhotoAlbumTestCurrentUtility::setValue($currentValue); + //$currentValue['Permission']['content_editable']['value'] = false; + //$currentValue['Permission']['photo_albums_photo_creatable']['value'] = false; + //$currentValue['Language']['id'] = 99; + //$currentValue['User']['id'] = 88; + //PhotoAlbumTestCurrentUtility::setValue($currentValue); + $this->__setPermission('content_editable', false); + $this->__setPermission('photo_albums_photo_creatable', false); + $this->__setCurrent('Language.id', 99); + $this->__setCurrent('User.id', 88); $expected = array ( array( @@ -146,6 +163,55 @@ public function testNotHasPhotoCreatable() { $actual = $this->PhotoAlbumPhoto->getWorkflowConditions(); $this->assertEquals($expected, $actual); - PhotoAlbumTestCurrentUtility::setOriginValue(); + //PhotoAlbumTestCurrentUtility::setOriginValue(); + $this->__restoreCurrent(); + $this->__restorePermission(); } + +/** + * __permissionPublishable + * + * @return void + */ + private function __permissionEditable() { + $this->__setPermission('content_editable', true); + } + +/** + * __restorePermission + * + * @return void + */ + private function __restorePermission() { + Current::writePermission(null, 'content_publishable', $this->originPublishablePermission); + Current::writePermission(null, 'content_publishable', $this->originEditablePermission); + + foreach ($this->originPermissions as $permission => $permissionValue) { + Current::writePermission(null, $permission, $permissionValue); + } + } + +/** + * __setPermission + * + * @param string $permissionKey + * @param bool $allow + * @return void + */ + private function __setPermission($permissionKey, $allow) { + $this->originPermissions[$permissionKey] = Current::permission($permissionKey); + Current::writePermission(null, $permissionKey, $allow); + } + + private function __setCurrent($key, $value) { + $this->originCurrent[$key] = Current::read($key); + Current::write($key, $value); + } + + private function __restoreCurrent() { + foreach ($this->originCurrent as $key => $value) { + Current::write($key, $value); + } + } + } diff --git a/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php b/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php index 0f9bb5a..579c08b 100644 --- a/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php +++ b/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php @@ -15,6 +15,8 @@ /** * Summary for PhotoAlbumPhotoPublish Test Case + * + * @property PhotoAlbumPhoto $PhotoAlbumPhoto */ class PhotoAlbumPhotoPublishTest extends NetCommonsCakeTestCase { @@ -29,8 +31,9 @@ class PhotoAlbumPhotoPublishTest extends NetCommonsCakeTestCase { 'plugin.users.user', 'plugin.workflow.workflow_comment', ); + private $originPermission; -/** + /** * setUp method * * @return void @@ -59,15 +62,19 @@ public function tearDown() { * @return void */ public function testPublish() { - $currentValue['Permission']['content_publishable']['value'] = true; - PhotoAlbumTestCurrentUtility::setValue($currentValue); + //$currentValue['Permission']['content_publishable']['value'] = true; + //PhotoAlbumTestCurrentUtility::setValue($currentValue); + + $this->__permissionPublishable(); $data['PhotoAlbumPhoto']['id'] = 1; $data['PhotoAlbumPhoto']['language_id'] = 1; $actual = $this->PhotoAlbumPhoto->publish([$data]); $this->assertTrue($actual); - PhotoAlbumTestCurrentUtility::setOriginValue(); + //PhotoAlbumTestCurrentUtility::setOriginValue(); + + $this->__restorePermission(); } /** @@ -94,15 +101,36 @@ public function testPublishException() { ->method('save') ->will($this->returnValue(false)); - $currentValue['Permission']['content_publishable']['value'] = true; - PhotoAlbumTestCurrentUtility::setValue($currentValue); + //$currentValue['Permission']['content_publishable']['value'] = true; + //PhotoAlbumTestCurrentUtility::setValue($currentValue); + $this->__permissionPublishable(); $this->setExpectedException('InternalErrorException'); $data['PhotoAlbumPhoto']['id'] = 1; $data['PhotoAlbumPhoto']['language_id'] = 1; $MockPhotoAlbumPhoto->publish([$data]); - PhotoAlbumTestCurrentUtility::setOriginValue(); + //PhotoAlbumTestCurrentUtility::setOriginValue(); + $this->__restorePermission(); + } + +/** + * __permissionPublishable + * + * @return void + */ + private function __permissionPublishable() { + $this->originPermission = Current::permission('content_publishable'); + Current::writePermission(null, 'content_publishable', true); + } + +/** + * __restorePermission + * + * @return void + */ + private function __restorePermission() { + Current::writePermission(null, 'content_publishable', $this->originPermission); } } From fa3e810277bdc8c59c392f7f7b7e526c93ae986b Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Fri, 13 Sep 2019 21:01:12 +0900 Subject: [PATCH 07/59] =?UTF-8?q?fix:=20Mac=E3=81=8B=E3=82=89ZIP=E3=82=A2?= =?UTF-8?q?=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=99=E3=82=8B?= =?UTF-8?q?=E3=81=A8=5F=5FMACOSX=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=BE=E3=81=A7?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C=E3=81=A6=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=81=A7=E3=80=81=E3=81=9D=E3=82=8C=E3=82=89=E3=82=92=E9=99=A4?= =?UTF-8?q?=E5=A4=96=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index be8177a..09bd164 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -286,6 +286,10 @@ private function __regenerateDataForZip($data) { } foreach ($files as $file) { + // MacでZIPしたときにできるフォルダのファイルは無視させる + if (strpos($file, '/__MACOSX/') !== false) { + continue; + } $file = new File($file); $data['PhotoAlbumPhoto']['photo'] = array_merge( $data['PhotoAlbumPhoto']['photo'], From a9d732ebb279aa2d3a13139d7e784ca21fdb11f0 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 10:14:38 +0900 Subject: [PATCH 08/59] =?UTF-8?q?change:=20ZIP=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=89=E6=99=82=E3=81=AB=E9=9A=A0=E3=81=97?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=AF=E9=99=A4=E5=A4=96?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=80=82=E3=81=82=E3=82=8F=E3=81=9B=E3=81=A6ZIP=E3=81=A7?= =?UTF-8?q?=E8=A8=B1=E5=8F=AF=E3=81=99=E3=82=8B=E7=94=BB=E5=83=8F=E3=82=92?= =?UTF-8?q?=E5=8D=98=E7=8B=AC=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=A8=E5=90=8C=E3=81=98=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?png,=20gif,=20bmp=E3=81=AB=E6=8B=A1=E5=A4=A7=E3=80=82ZIP?= =?UTF-8?q?=E3=81=AB=E6=9C=89=E5=8A=B9=E3=81=AA=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=81=8C=E3=81=B2=E3=81=A8=E3=81=A4=E3=82=82=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=A8=E3=81=8D=E3=81=AB=E3=80=81?= =?UTF-8?q?=E7=84=A1=E5=8A=B9=E3=81=AA=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C?= =?UTF-8?q?=E7=99=BB=E9=8C=B2=E3=81=95=E3=82=8C=E3=82=8B=E3=81=AE=E3=82=82?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 46 +++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 09bd164..7be273f 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -1,4 +1,4 @@ - [PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME], 'Workflow.Workflow', 'Workflow.WorkflowComment', @@ -73,7 +74,7 @@ public function beforeValidate($options = array()) { $validate['photoExtension'] = array( 'rule' => array( 'extension', - array('gif', 'jpeg', 'png', 'jpg', 'zip') + array('gif', 'jpeg', 'png', 'jpg', 'zip', 'bmp') ), 'message' => array(__d('files', 'It is upload disabled file format')) ); @@ -272,24 +273,20 @@ public function getWorkflowConditions() { * @throws InternalErrorException */ private function __regenerateDataForZip($data) { - $files = array(); $zipType = ['application/zip', 'application/x-zip-compressed']; - if (in_array($data['PhotoAlbumPhoto']['photo']['type'], $zipType)) { - $zip = new UnZip($data['PhotoAlbumPhoto']['photo']['tmp_name']); - $unzipedFolder = $zip->extract(); - $dir = new Folder($unzipedFolder->path); - $files = $dir->findRecursive('.*\.(jpg|jpeg)'); - } - - if (!$files) { + if (in_array($data['PhotoAlbumPhoto']['photo']['type'], $zipType) === false) { return array($data); - } + } + // ZIP 処理 + $zip = new UnZip($data['PhotoAlbumPhoto']['photo']['tmp_name']); + $unzipedFolder = $zip->extract(); + $dir = new Folder($unzipedFolder->path); + $files = $dir->findRecursive('.*\.(jpg|jpeg|gif|png|bmp)'); + $files = $this->__excludeHiddenFile($files); + + $regenerateData = []; foreach ($files as $file) { - // MacでZIPしたときにできるフォルダのファイルは無視させる - if (strpos($file, '/__MACOSX/') !== false) { - continue; - } $file = new File($file); $data['PhotoAlbumPhoto']['photo'] = array_merge( $data['PhotoAlbumPhoto']['photo'], @@ -306,4 +303,21 @@ private function __regenerateDataForZip($data) { return $regenerateData; } +/** + * 隠しファイル除外 + * + * @param array $files + * @return array + */ + private function __excludeHiddenFile(array $files) { + $excludedFiles = []; + foreach ($files as $file) { + // "."はじまりのファイル(隠しファイル)は除外 + if (substr(basename($file), 0, 1) === '.') { + continue; + } + $excludedFiles[] = $file; + } + return $excludedFiles; + } } From 6004b85e06b0bd3bd4ac6bfd7e321929fee58af4 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 10:17:03 +0900 Subject: [PATCH 09/59] =?UTF-8?q?fix:=20=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=89=E3=82=A8=E3=83=A9=E3=83=BC=E6=99=82?= =?UTF-8?q?=E3=81=AB=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88=E5=B4=A9?= =?UTF-8?q?=E3=82=8C=E3=81=8C=E7=99=BA=E7=94=9F=E3=81=97=E3=81=A6=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/PhotoAlbumPhotosController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/PhotoAlbumPhotosController.php b/Controller/PhotoAlbumPhotosController.php index 6974871..3293364 100644 --- a/Controller/PhotoAlbumPhotosController.php +++ b/Controller/PhotoAlbumPhotosController.php @@ -154,7 +154,6 @@ public function view($id = null) { * @return void */ public function add() { - $this->layout = 'NetCommons.modal'; $this->view = 'edit'; $photo = $this->PhotoAlbumPhoto->create(); @@ -179,6 +178,7 @@ public function add() { } $this->NetCommons->handleValidationError($this->PhotoAlbumPhoto->validationErrors); } else { + $this->layout = 'NetCommons.modal'; $this->request->data = $photo; $this->request->data['PhotoAlbumPhoto']['album_key'] = $this->request->params['key']; } From b0e3e5490121347a55d4abe5873bf371760e41b9 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 10:36:27 +0900 Subject: [PATCH 10/59] =?UTF-8?q?fix:=20ZIP=20=E3=81=AB=E6=9C=89=E5=8A=B9?= =?UTF-8?q?=E3=81=AA=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=8C=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=81=A8=E3=81=8D=E3=81=AF=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 7be273f..581d220 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -285,6 +285,10 @@ private function __regenerateDataForZip($data) { $files = $dir->findRecursive('.*\.(jpg|jpeg|gif|png|bmp)'); $files = $this->__excludeHiddenFile($files); + if (!$files) { + $this->invalidate('photo', __d('photo_albums', 'Select photo.')); + } + $regenerateData = []; foreach ($files as $file) { $file = new File($file); From 4fd22c85e65f553224866350cb8aec5d8b6b9961 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 10:46:36 +0900 Subject: [PATCH 11/59] =?UTF-8?q?change:=20=E7=94=BB=E5=83=8F=E4=B8=80?= =?UTF-8?q?=E8=A6=A7=E3=81=A7is=5Factive=E3=81=8Ctrue=E3=81=A0=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=82=89=E3=82=A4=E3=83=B3=E3=83=A9=E3=82=A4=E3=83=B3?= =?UTF-8?q?=E7=94=BB=E5=83=8F=E3=80=81=E3=81=9D=E3=81=86=E3=81=A7=E3=81=AA?= =?UTF-8?q?=E3=81=91=E3=82=8C=E3=81=B0URL=E3=83=AA=E3=83=B3=E3=82=AF?= =?UTF-8?q?=E3=81=A7=E7=94=BB=E5=83=8F=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/Helper/PhotoAlbumsImageHelper.php | 41 ++++++++++++++++++++++++++ View/PhotoAlbumPhotos/index.ctp | 6 +++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/View/Helper/PhotoAlbumsImageHelper.php b/View/Helper/PhotoAlbumsImageHelper.php index d769908..cd0a370 100644 --- a/View/Helper/PhotoAlbumsImageHelper.php +++ b/View/Helper/PhotoAlbumsImageHelper.php @@ -86,6 +86,47 @@ public function photoUrl($data, $size = null) { ); } +/** + * is_active: trueだったらinlineイメージにして、is_active:falseならURLをかえす + * + * @param array $data PhotoAlbumAlbumPhoto data + * @param string $size thumb, small, medium, big + * @return string + */ + public function inlinePhotoIfActiveOtherwisePhotoUrl($data, $size = null) { + if ($data['PhotoAlbumPhoto']['is_active']) { + return $this->__inlinePhoto($data, $size); + } + return $this->photoUrl($data, $size); + } + +/** + * インライン画像 + * + * @param array $data PhotoAlbumAlbumPhoto data + * @param string $size thumb, small, medium, big + * @return string + */ + private function __inlinePhoto($data, $size = null) { + /** @var UploadFile $uploadFile */ + $uploadFile = ClassRegistry::init("Files.UploadFile"); + $file = $uploadFile->getFile( + 'photo_albums', + $data['PhotoAlbumPhoto']['id'], + PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME + ); + if (!$file) { + return ''; + } + $filepath = UPLOADS_ROOT . $file['UploadFile']['path'] . DS . $file['UploadFile']['id'] .DS . $size . '_' . $file['UploadFile']['real_file_name']; + if (file_exists($filepath) === false) { + return ''; + } + $mimeType = $file['UploadFile']['mimetype']; + $encodeData = base64_encode(file_get_contents($filepath)); + return sprintf('data:%s;base64,%s', $mimeType, $encodeData); + } + /** * Creates photo image url array * diff --git a/View/PhotoAlbumPhotos/index.ctp b/View/PhotoAlbumPhotos/index.ctp index 8a6a855..7e4e7c0 100644 --- a/View/PhotoAlbumPhotos/index.ctp +++ b/View/PhotoAlbumPhotos/index.ctp @@ -118,7 +118,11 @@ ?> ')"> -
+
From 16bbdb6df566c406351850082f64641b347bcf78 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 11:02:39 +0900 Subject: [PATCH 12/59] =?UTF-8?q?change:=20=E4=B8=80=E8=A6=A7=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E7=94=A8=E3=81=AEsmall=E3=82=B5=E3=82=A4=E3=82=BA?= =?UTF-8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=AB?= =?UTF-8?q?=E3=81=82=E3=82=8F=E3=81=9B=E3=81=A6=E6=9C=80=E5=A4=A7=E9=AB=98?= =?UTF-8?q?=E3=81=95152px=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 581d220..443c02d 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -33,8 +33,17 @@ class PhotoAlbumPhoto extends PhotoAlbumsAppModel { */ public $actsAs = array( 'NetCommons.OriginalKey', - // TODO サムネイルにあわせてsmallのサイズをきめる。 - 'Files.Attachment' => [PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME], + 'Files.Attachment' => [ + PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME => [ + 'thumbnailSizes' => array( + 'big' => '800ml', + 'medium' => '400ml', + 'small' => '152mh', + //'small' => '200ml', + 'thumb' => '80x80', + ), + ] + ], 'Workflow.Workflow', 'Workflow.WorkflowComment', //多言語 From 64d00c5201802e6b2005b221ab34232de09cad4e Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 12:55:30 +0900 Subject: [PATCH 13/59] =?UTF-8?q?add:=20=E3=82=A2=E3=83=83=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=83=BC=E3=83=89=E3=81=95=E3=82=8C=E3=81=9F=E5=85=83?= =?UTF-8?q?=E7=94=BB=E5=83=8F=E3=82=92=E3=81=9D=E3=81=AE=E3=81=BE=E3=81=BE?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E3=81=9B=E3=81=9A=E3=81=AB=E3=80=81=E3=83=AA?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E3=81=97=E3=81=A6=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginImageResizeBehavior.php | 107 +++++++++++++++++++ Model/PhotoAlbumPhoto.php | 8 +- 2 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 Model/Behavior/OriginImageResizeBehavior.php diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php new file mode 100644 index 0000000..a4ca2bb --- /dev/null +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -0,0 +1,107 @@ +__guradBeforeLoadingAttachmentBehavior($model); + + $this->settings[$model->alias] = $config; + parent::setup($model, $config); + } + +/** + * afterSave + * + * @param Model $model model + * @param bool $created created + * @param array $options options + * @return bool + */ + public function afterSave(Model $model, $created, $options = array()) { + $setting = $this->settings[$model->alias]; + + $this->__uploadFileModel = ClassRegistry::init('Files.UploadFile'); + + foreach ($setting as $fieldName => $fieldSetting) { + $pluginKey = Inflector::underscore($model->plugin); + $uploadFile = $this->__uploadFileModel->getFile($pluginKey, $model->id, $fieldName); + $this->overwriteOriginFile($uploadFile, $fieldSetting['resizeImagePrefix'] . '_'); + } + + return parent::afterSave($model, $created, $options); + } + +/** + * 元ファイルをリサイズしたファイルで上書き + * + * @param array $uploadFile UploadFileデータ + * @param string $overwriteFilePrefix リサイズされた画像のprefix このprefixのついたファイルを元画像あつかいにする。 + * @return array|false UploadFile::save()の結果 + * @throws InternalErrorException + */ + public function overwriteOriginFile(array $uploadFile, $overwriteFilePrefix) { + // 元ファイル削除 + $originFilePath = $this->__uploadFileModel->getRealFilePath($uploadFile); + + // origin_resizeからprefix削除 + $originResizePath = substr($originFilePath, 0, -1 * strlen($uploadFile['UploadFile']['real_file_name'])) . + $overwriteFilePrefix . $uploadFile['UploadFile']['real_file_name']; + + if (! file_exists($originResizePath)) { + //リネームするファイルがなければ、そのままuploadFileを返す。 + return $uploadFile; + } + + unlink($originFilePath); + rename($originResizePath, $originFilePath); + + // uploadFileのsize更新 + $stat = stat($originFilePath); + $uploadFile['UploadFile']['size'] = $stat['size']; + try { + $uploadFile = $this->__uploadFileModel->save( + $uploadFile, + ['callbacks' => false, 'validate' => false] + ); + } catch (Exception $e) { + throw new InternalErrorException('Failed Update UploadFile.size'); + } + return $uploadFile; + } + +/** + * 事前にAttachmentBehaviorが読みこまれているか + * + * @param Model $model model + * @return void + * @throws CakeException + */ + private function __guradBeforeLoadingAttachmentBehavior(Model $model) { + if (!$model->Behaviors->loaded('Files.Attachment')) { + $error = '"Files.AttachmentBehavior" not loaded in ' . $model->alias . '. '; + $error .= 'Load "Files.AttachmentBehavior" before loading "OriginImageResizeBehavior"'; + throw new CakeException($error); + } + } + +} \ No newline at end of file diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 443c02d..c351df3 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -1,4 +1,4 @@ - [ PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME => [ 'thumbnailSizes' => array( + 'origin' => '800ml', 'big' => '800ml', 'medium' => '400ml', 'small' => '152mh', @@ -44,6 +45,11 @@ class PhotoAlbumPhoto extends PhotoAlbumsAppModel { ), ] ], + 'PhotoAlbums.OriginImageResize' => [ + PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME => [ + 'resizeImagePrefix' => 'origin', + ] + ], 'Workflow.Workflow', 'Workflow.WorkflowComment', //多言語 From 176e75a7e91e9711e514142f0d3cc25a9c24e1e7 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 12:58:08 +0900 Subject: [PATCH 14/59] =?UTF-8?q?change:=20=E5=85=83=E7=94=BB=E5=83=8F?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E6=8C=87=E5=AE=9A=E3=81=AE=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=82=AD=E3=83=BC=E5=90=8D=E7=A7=B0=E3=82=92=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginImageResizeBehavior.php | 2 +- Model/PhotoAlbumPhoto.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php index a4ca2bb..48bb82b 100644 --- a/Model/Behavior/OriginImageResizeBehavior.php +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -45,7 +45,7 @@ public function afterSave(Model $model, $created, $options = array()) { foreach ($setting as $fieldName => $fieldSetting) { $pluginKey = Inflector::underscore($model->plugin); $uploadFile = $this->__uploadFileModel->getFile($pluginKey, $model->id, $fieldName); - $this->overwriteOriginFile($uploadFile, $fieldSetting['resizeImagePrefix'] . '_'); + $this->overwriteOriginFile($uploadFile, $fieldSetting['resizeImageSizeKey'] . '_'); } return parent::afterSave($model, $created, $options); diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index c351df3..10680f4 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -47,7 +47,7 @@ class PhotoAlbumPhoto extends PhotoAlbumsAppModel { ], 'PhotoAlbums.OriginImageResize' => [ PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME => [ - 'resizeImagePrefix' => 'origin', + 'resizeImageSizeKey' => 'origin', ] ], 'Workflow.Workflow', From c919ce6890131f8114a77756b64d874e6dba5448 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 13:11:50 +0900 Subject: [PATCH 15/59] =?UTF-8?q?change:=20uploadFile=E3=83=A2=E3=83=87?= =?UTF-8?q?=E3=83=AB=E3=81=AE=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=B3?= =?UTF-8?q?=E3=82=B9=E5=8F=96=E5=BE=97=E3=82=92setup=E3=81=B8=E7=A7=BB?= =?UTF-8?q?=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginImageResizeBehavior.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php index 48bb82b..6edb49e 100644 --- a/Model/Behavior/OriginImageResizeBehavior.php +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -26,6 +26,9 @@ public function setup(Model $model, $config = array()) { $this->__guradBeforeLoadingAttachmentBehavior($model); $this->settings[$model->alias] = $config; + + $this->__uploadFileModel = ClassRegistry::init('Files.UploadFile'); + parent::setup($model, $config); } @@ -40,8 +43,6 @@ public function setup(Model $model, $config = array()) { public function afterSave(Model $model, $created, $options = array()) { $setting = $this->settings[$model->alias]; - $this->__uploadFileModel = ClassRegistry::init('Files.UploadFile'); - foreach ($setting as $fieldName => $fieldSetting) { $pluginKey = Inflector::underscore($model->plugin); $uploadFile = $this->__uploadFileModel->getFile($pluginKey, $model->id, $fieldName); From 65f867e63a8ccc94d14a783940a035f918647640 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 13:16:35 +0900 Subject: [PATCH 16/59] comment: remove TODO comment --- Model/PhotoAlbumPhoto.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 581d220..35ebb46 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -33,7 +33,6 @@ class PhotoAlbumPhoto extends PhotoAlbumsAppModel { */ public $actsAs = array( 'NetCommons.OriginalKey', - // TODO サムネイルにあわせてsmallのサイズをきめる。 'Files.Attachment' => [PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME], 'Workflow.Workflow', 'Workflow.WorkflowComment', From 9fec14c962622c82494894726c9e55168a39f2ad Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 28 Sep 2019 13:38:08 +0900 Subject: [PATCH 17/59] =?UTF-8?q?fix:=20test:=20travis-ci=E3=81=AEphp7.2?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 ++ phpunit.xml.dist | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 2c06db5..5b46df1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,10 @@ php: - 5.6 - 7.0 - 7.1 + - 7.2 sudo: false +dist: trusty env: - NETCOMMONS_VERSION=master DB=mysql diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f619327..77e917f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,6 +14,5 @@ - From f75003c95b5f414af373261a45088e33a381b82d Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 29 Sep 2019 12:20:56 +0900 Subject: [PATCH 18/59] =?UTF-8?q?add:=20=E6=96=B0=E8=A6=8F=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E8=BF=BD=E5=8A=A0=E6=99=82=E3=81=AF=E8=A4=87=E6=95=B0?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/PhotoAlbumPhotosController.php | 3 +- Model/PhotoAlbumPhoto.php | 46 +++++++++++++++++++++-- View/PhotoAlbumPhotos/edit.ctp | 17 ++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Controller/PhotoAlbumPhotosController.php b/Controller/PhotoAlbumPhotosController.php index 3293364..4ac0fb2 100644 --- a/Controller/PhotoAlbumPhotosController.php +++ b/Controller/PhotoAlbumPhotosController.php @@ -155,11 +155,12 @@ public function view($id = null) { */ public function add() { $this->view = 'edit'; + $this->set('isAdd', true); $photo = $this->PhotoAlbumPhoto->create(); if ($this->request->is('post')) { $this->request->data['PhotoAlbumPhoto']['status'] = $this->Workflow->parseStatus(); - if ($this->PhotoAlbumPhoto->savePhoto($this->request->data)) { + if ($this->PhotoAlbumPhoto->savePhotos($this->request->data)) { $url = PhotoAlbumsSettingUtility::settingUrl( array( 'plugin' => 'photo_albums', diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 10680f4..44b9862 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -126,6 +126,46 @@ public function beforeFind($query) { return $query; } +/** + * savePhotos 複数ファイル保存 + * + * @param array $data CakeRequest::data + * @return bool + */ + public function savePhotos(array $data) { + $this->begin(); + + try { + if (!$this->__savePhotos($data)) { + $this->rollback(); + return false; + }; + } catch (Exception $ex) { + $this->rollback($ex); + } + + $this->commit(); + return true; + } + +/** + * 複数ファイル保存のメイン処理 + * + * @param array $data CakeRequest::data + * @return bool + */ + protected function __savePhotos(array $data) { + $base = $data; + + foreach ($data[$this->alias][self::ATTACHMENT_FIELD_NAME] as $photo) { + $base[$this->alias][self::ATTACHMENT_FIELD_NAME] = $photo; + if (!$this->savePhoto($base)) { + return false; + } + } + return true; + } + /** * Save photo * @@ -141,9 +181,7 @@ public function savePhoto($data) { $photo = array(); foreach ($regenerateData as $index => $data) { - if ($index > 0) { - $this->create(); - } + $this->create(); $this->set($data); if (!$this->validates()) { @@ -325,7 +363,7 @@ private function __regenerateDataForZip($data) { /** * 隠しファイル除外 * - * @param array $files + * @param array $files ファイルリスト * @return array */ private function __excludeHiddenFile(array $files) { diff --git a/View/PhotoAlbumPhotos/edit.ctp b/View/PhotoAlbumPhotos/edit.ctp index 7459c81..2a19382 100644 --- a/View/PhotoAlbumPhotos/edit.ctp +++ b/View/PhotoAlbumPhotos/edit.ctp @@ -40,13 +40,28 @@ NetCommonsForm->hidden('status'); ?> Form->unlockField('PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME); + // バリデーションエラーが表示されるようにフィールド名はモデルフィールド名のままで、name属性で複数可能なフィールド指定 + echo $this->NetCommonsForm->uploadFile( + 'PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME , + array( + 'label' => __d('photo_albums', 'Photo file'), + 'required' => true, + 'multiple', + 'name' => 'data[PhotoAlbumPhoto][photo][]', + ) + ); + } else { echo $this->NetCommonsForm->uploadFile( PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME, array( 'label' => __d('photo_albums', 'Photo file'), 'remove' => false ) - ) + ); + } + ?> Date: Fri, 4 Oct 2019 22:23:41 +0900 Subject: [PATCH 19/59] =?UTF-8?q?change:=20small=E3=81=AE=E3=82=B5?= =?UTF-8?q?=E3=82=A4=E3=82=BA=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 44b9862..3b28eb9 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -39,8 +39,9 @@ class PhotoAlbumPhoto extends PhotoAlbumsAppModel { 'origin' => '800ml', 'big' => '800ml', 'medium' => '400ml', - 'small' => '152mh', - //'small' => '200ml', + //'small' => '152mh', + 'small' => '120mh', + ////'small' => '200ml', 'thumb' => '80x80', ), ] From 6cfad073baba3dc744c0952b72549eb9d8dcb4ba Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 5 Oct 2019 11:31:39 +0900 Subject: [PATCH 20/59] =?UTF-8?q?fix:=20=E8=A1=A8=E7=A4=BA=E8=A8=AD?= =?UTF-8?q?=E5=AE=9A=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E7=99=BA?= =?UTF-8?q?=E7=94=9F=E3=81=97=E3=81=A6=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/PhotoAlbumFrameSettingsController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/Controller/PhotoAlbumFrameSettingsController.php b/Controller/PhotoAlbumFrameSettingsController.php index af8451e..e469eac 100644 --- a/Controller/PhotoAlbumFrameSettingsController.php +++ b/Controller/PhotoAlbumFrameSettingsController.php @@ -100,6 +100,7 @@ public function edit() { $this->NetCommons->handleValidationError($this->PhotoAlbumFrameSetting->validationErrors); } else { $this->request->data = $this->PhotoAlbumFrameSetting->getFrameSetting(); + $this->request->data['Frame'] = Current::read('Frame'); } $query = array( From 3a9d3656c420c1ff347c8ec3abc0e17df0dbec36 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 5 Oct 2019 11:53:10 +0900 Subject: [PATCH 21/59] =?UTF-8?q?change:=20=E5=85=83=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=81=AB=E9=96=A2=E9=80=A3=E3=81=A5=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=82=8B=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=81=8C=E3=81=AA=E3=81=91?= =?UTF-8?q?=E3=82=8C=E3=81=B0=E3=80=81=E5=85=83=E7=94=BB=E5=83=8F=E3=83=AA?= =?UTF-8?q?=E3=82=B5=E3=82=A4=E3=82=BA=E5=87=A6=E7=90=86=E3=81=AF=E5=AE=9F?= =?UTF-8?q?=E8=A1=8C=E3=81=97=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginImageResizeBehavior.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php index 6edb49e..bef7a80 100644 --- a/Model/Behavior/OriginImageResizeBehavior.php +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -46,7 +46,9 @@ public function afterSave(Model $model, $created, $options = array()) { foreach ($setting as $fieldName => $fieldSetting) { $pluginKey = Inflector::underscore($model->plugin); $uploadFile = $this->__uploadFileModel->getFile($pluginKey, $model->id, $fieldName); - $this->overwriteOriginFile($uploadFile, $fieldSetting['resizeImageSizeKey'] . '_'); + if ($uploadFile) { + $this->overwriteOriginFile($uploadFile, $fieldSetting['resizeImageSizeKey'] . '_'); + } } return parent::afterSave($model, $created, $options); From d45af3375834d2461b2418716d630baf7f0ef6a5 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 5 Oct 2019 22:07:08 +0900 Subject: [PATCH 22/59] =?UTF-8?q?style:=20phpcs=E3=82=A8=E3=83=A9=E3=83=BC?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1468?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 8 ++- .../GetWorkflowConditionsTest.php | 60 +++++++++++++++---- .../Model/PhotoAlbumPhoto/PublishTest.php | 14 +++-- 3 files changed, 62 insertions(+), 20 deletions(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 35ebb46..6a65c68 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -1,4 +1,4 @@ -__setCurrent('Language.id', 99); $this->__setCurrent('User.id', 88); - $expected = array ( array( 'OR' => array( @@ -183,10 +205,10 @@ private function __permissionEditable() { * @return void */ private function __restorePermission() { - Current::writePermission(null, 'content_publishable', $this->originPublishablePermission); - Current::writePermission(null, 'content_publishable', $this->originEditablePermission); + Current::writePermission(null, 'content_publishable', $this->__originPublishablePermission); + Current::writePermission(null, 'content_publishable', $this->__originEditablePermission); - foreach ($this->originPermissions as $permission => $permissionValue) { + foreach ($this->__originPermissions as $permission => $permissionValue) { Current::writePermission(null, $permission, $permissionValue); } } @@ -199,17 +221,29 @@ private function __restorePermission() { * @return void */ private function __setPermission($permissionKey, $allow) { - $this->originPermissions[$permissionKey] = Current::permission($permissionKey); + $this->__originPermissions[$permissionKey] = Current::permission($permissionKey); Current::writePermission(null, $permissionKey, $allow); } +/** + * Currentにセットする + * + * @param string $key + * @param mixed $value + * @return void + */ private function __setCurrent($key, $value) { - $this->originCurrent[$key] = Current::read($key); - Current::write($key, $value); + $this->__originCurrent[$key] = Current::read($key); + Current::write($key, $value); } +/** + * Currentの中身をリストアする + * + * @return void + */ private function __restoreCurrent() { - foreach ($this->originCurrent as $key => $value) { + foreach ($this->__originCurrent as $key => $value) { Current::write($key, $value); } } diff --git a/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php b/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php index 579c08b..ff686fd 100644 --- a/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php +++ b/Test/Case/Model/PhotoAlbumPhoto/PublishTest.php @@ -31,9 +31,15 @@ class PhotoAlbumPhotoPublishTest extends NetCommonsCakeTestCase { 'plugin.users.user', 'plugin.workflow.workflow_comment', ); - private $originPermission; - /** +/** + * 元のCurrentのデータ + * + * @var array + */ + private $__originPermission; + +/** * setUp method * * @return void @@ -120,7 +126,7 @@ public function testPublishException() { * @return void */ private function __permissionPublishable() { - $this->originPermission = Current::permission('content_publishable'); + $this->__originPermission = Current::permission('content_publishable'); Current::writePermission(null, 'content_publishable', true); } @@ -130,7 +136,7 @@ private function __permissionPublishable() { * @return void */ private function __restorePermission() { - Current::writePermission(null, 'content_publishable', $this->originPermission); + Current::writePermission(null, 'content_publishable', $this->__originPermission); } } From e6f5ad0a4e86f55c9fd3459857346cc294ee4303 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Mon, 14 Oct 2019 11:35:16 +0900 Subject: [PATCH 23/59] =?UTF-8?q?fix:=20=E3=82=A2=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=A0=E5=89=8A=E9=99=A4=E6=99=82=E3=81=AB=E5=AE=9F=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=84UploadFile=E3=83=86?= =?UTF-8?q?=E3=83=BC=E3=83=96=E3=83=AB=E3=83=87=E3=83=BC=E3=82=BF=E3=81=8C?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=81=95=E3=82=8C=E3=81=AA=E3=81=8B=E3=81=A3?= =?UTF-8?q?=E3=81=9F=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbum.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Model/PhotoAlbum.php b/Model/PhotoAlbum.php index ae8a29a..acb4b58 100644 --- a/Model/PhotoAlbum.php +++ b/Model/PhotoAlbum.php @@ -379,6 +379,11 @@ public function deleteAlbum($data) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } + if (!$this->__deleteJacketFile($data['PhotoAlbum']['key'])) { + throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); + } + + // アルバム内の写真削除 $Photo = ClassRegistry::init('PhotoAlbums.PhotoAlbumPhoto'); $conditions = array('PhotoAlbumPhoto.album_key' => $data['PhotoAlbum']['key']); $query = array( @@ -387,9 +392,13 @@ public function deleteAlbum($data) { 'recursive' => -1 ); $contentKeys = $Photo->find('list', $query); + if (!$Photo->deleteAll($conditions, false)) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } + if (!$Photo->deleteUploadFileByContentKeys($contentKeys)) { + throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); + } $DisplayAlbum = ClassRegistry::init('PhotoAlbums.PhotoAlbumDisplayAlbum'); $conditions = array('PhotoAlbumDisplayAlbum.album_key' => $data['PhotoAlbum']['key']); @@ -408,4 +417,14 @@ public function deleteAlbum($data) { return true; } + +/** + * __deleteJacketFile + * + * @param string $albumKey album.key + * @return mixed + */ + private function __deleteJacketFile($albumKey) { + return $this->deleteUploadFileByContentKeys([$albumKey]); + } } From b04d246e73f0716e1f4a570ad8a674aaa0e5184c Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 20 Oct 2019 13:43:42 +0900 Subject: [PATCH 24/59] style: fix phpcs problem --- Model/Behavior/OriginImageResizeBehavior.php | 7 ++++++- Model/PhotoAlbumPhoto.php | 2 +- View/Helper/PhotoAlbumsImageHelper.php | 6 +++++- View/PhotoAlbumPhotos/edit.ctp | 6 ++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php index bef7a80..22ec690 100644 --- a/Model/Behavior/OriginImageResizeBehavior.php +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -67,7 +67,12 @@ public function overwriteOriginFile(array $uploadFile, $overwriteFilePrefix) { $originFilePath = $this->__uploadFileModel->getRealFilePath($uploadFile); // origin_resizeからprefix削除 - $originResizePath = substr($originFilePath, 0, -1 * strlen($uploadFile['UploadFile']['real_file_name'])) . + $directoryPath = substr( + $originFilePath, + 0, + -1 * strlen($uploadFile['UploadFile']['real_file_name']) + ); + $originResizePath = $directoryPath . $overwriteFilePrefix . $uploadFile['UploadFile']['real_file_name']; if (! file_exists($originResizePath)) { diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 8635852..78afd3d 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -157,7 +157,7 @@ public function savePhotos(array $data) { * @param array $data CakeRequest::data * @return bool */ - protected function __savePhotos(array $data) { + private function __savePhotos(array $data) { $base = $data; foreach ($data[$this->alias][self::ATTACHMENT_FIELD_NAME] as $photo) { diff --git a/View/Helper/PhotoAlbumsImageHelper.php b/View/Helper/PhotoAlbumsImageHelper.php index cd0a370..ec91b84 100644 --- a/View/Helper/PhotoAlbumsImageHelper.php +++ b/View/Helper/PhotoAlbumsImageHelper.php @@ -118,7 +118,11 @@ private function __inlinePhoto($data, $size = null) { if (!$file) { return ''; } - $filepath = UPLOADS_ROOT . $file['UploadFile']['path'] . DS . $file['UploadFile']['id'] .DS . $size . '_' . $file['UploadFile']['real_file_name']; + $filepath = UPLOADS_ROOT . + $file['UploadFile']['path'] . DS . + $file['UploadFile']['id'] . DS . + $size . '_' . $file['UploadFile']['real_file_name']; + if (file_exists($filepath) === false) { return ''; } diff --git a/View/PhotoAlbumPhotos/edit.ctp b/View/PhotoAlbumPhotos/edit.ctp index 2a19382..959b5d2 100644 --- a/View/PhotoAlbumPhotos/edit.ctp +++ b/View/PhotoAlbumPhotos/edit.ctp @@ -41,10 +41,12 @@ Form->unlockField('PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME); + $this->Form->unlockField( + 'PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME + ); // バリデーションエラーが表示されるようにフィールド名はモデルフィールド名のままで、name属性で複数可能なフィールド指定 echo $this->NetCommonsForm->uploadFile( - 'PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME , + 'PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME, array( 'label' => __d('photo_albums', 'Photo file'), 'required' => true, From 2b9413db429f59e1220dab271243c17efaaab788 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 20 Oct 2019 14:21:28 +0900 Subject: [PATCH 25/59] =?UTF-8?q?change:=20savePhoto=E3=81=8Cbool=E5=80=A4?= =?UTF-8?q?=E3=82=92=E8=BF=94=E3=81=99=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbumPhoto.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 78afd3d..7083756 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -181,12 +181,10 @@ public function savePhoto($data) { $regenerateData = $this->__regenerateDataForZip($data); - $photo = array(); - - foreach ($regenerateData as $index => $data) { + foreach ($regenerateData as $datum) { $this->create(); - $this->set($data); + $this->set($datum); if (!$this->validates()) { $this->rollback(); return false; @@ -197,16 +195,16 @@ public function savePhoto($data) { if (! $result) { throw new InternalErrorException(__d('net_commons', 'Internal Server Error')); } - $photo[] = $result; } catch (Exception $ex) { $this->rollback($ex); + return false; } } $this->commit(); - return $photo; + return true; } /** From be724385a68cfe3e61dfa9a6b30565e86852a189 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 20 Oct 2019 16:01:36 +0900 Subject: [PATCH 26/59] =?UTF-8?q?comment:=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/Behavior/OriginImageResizeBehavior.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Behavior/OriginImageResizeBehavior.php b/Model/Behavior/OriginImageResizeBehavior.php index 22ec690..4cdb0ab 100644 --- a/Model/Behavior/OriginImageResizeBehavior.php +++ b/Model/Behavior/OriginImageResizeBehavior.php @@ -11,7 +11,7 @@ final class OriginImageResizeBehavior extends ModelBehavior { /** - * @var UploadFile + * @var UploadFile UploadFile model */ private $__uploadFileModel; From c0ee3a53032754b087d05f11ef152073a44b8d58 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 15:10:57 +0900 Subject: [PATCH 27/59] =?UTF-8?q?change:=20=E4=B8=80=E5=BA=A6=E3=81=AB?= =?UTF-8?q?=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89=E5=87=BA?= =?UTF-8?q?=E6=9D=A5=E3=82=8B=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E6=95=B0?= =?UTF-8?q?=E3=82=92=E5=88=B6=E9=99=90=E3=81=97=E3=81=A6=E3=80=81=E5=88=B6?= =?UTF-8?q?=E9=99=90=E4=BB=A5=E4=B8=8A=E3=81=AE=E3=83=95=E3=82=A1=E3=82=A4?= =?UTF-8?q?=E3=83=AB=E3=82=92=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=97=E3=82=88=E3=81=86=E3=81=A8=E3=81=97=E3=81=9F?= =?UTF-8?q?=E3=82=89=E3=83=A1=E3=83=83=E3=82=BB=E3=83=BC=E3=82=B8=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/config.php | 10 ++++++++ Controller/PhotoAlbumPhotosController.php | 30 +++++++++++++++++++++++ View/PhotoAlbumPhotos/edit.ctp | 19 +++++++++----- View/PhotoAlbumPhotos/index.ctp | 3 +++ webroot/js/photo_album_photo_edit.js | 10 ++++++++ 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 Config/config.php create mode 100644 webroot/js/photo_album_photo_edit.js diff --git a/Config/config.php b/Config/config.php new file mode 100644 index 0000000..bd53e7d --- /dev/null +++ b/Config/config.php @@ -0,0 +1,10 @@ + min(20, ini_get('max_file_uploads')) +]; \ No newline at end of file diff --git a/Controller/PhotoAlbumPhotosController.php b/Controller/PhotoAlbumPhotosController.php index 4ac0fb2..68c279e 100644 --- a/Controller/PhotoAlbumPhotosController.php +++ b/Controller/PhotoAlbumPhotosController.php @@ -70,6 +70,11 @@ class PhotoAlbumPhotosController extends PhotoAlbumsAppController { 'Users.DisplayUser', ); +/** + * @var int 同時にアップロードできる最大ファイル数 + */ + private $__maxFileUploads; + /** * beforeFilter * @@ -78,6 +83,10 @@ class PhotoAlbumPhotosController extends PhotoAlbumsAppController { public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('photo', 'slide'); + + Configure::load('PhotoAlbums.config'); + $this->__maxFileUploads = Configure::read('PhotoAlbums.maxFileUploads'); + $this->set('maxFileUploads', $this->__maxFileUploads); } /** @@ -160,6 +169,7 @@ public function add() { $photo = $this->PhotoAlbumPhoto->create(); if ($this->request->is('post')) { $this->request->data['PhotoAlbumPhoto']['status'] = $this->Workflow->parseStatus(); + $this->__removeOverMaxFileUploads(); if ($this->PhotoAlbumPhoto->savePhotos($this->request->data)) { $url = PhotoAlbumsSettingUtility::settingUrl( array( @@ -344,4 +354,24 @@ public function delete() { ); $this->redirect($url); } + +/** + * $this->request->data['PhotoAlbumPhoto']['photo']を__maxFileUploadsまでに制限する + * + * 超えたファイル情報は切り捨てる + * + * @return void + */ + private function __removeOverMaxFileUploads() { + if (!isset($this->request->data['PhotoAlbumPhoto']['photo'])) { + return; + } + $photo = $this->request->data['PhotoAlbumPhoto']['photo']; + + if (count($photo) <= $this->__maxFileUploads) { + return; + } + + $this->request->data['PhotoAlbumPhoto']['photo'] = array_slice($photo, 0, $this->__maxFileUploads); + } } diff --git a/View/PhotoAlbumPhotos/edit.ctp b/View/PhotoAlbumPhotos/edit.ctp index 959b5d2..fffecc6 100644 --- a/View/PhotoAlbumPhotos/edit.ctp +++ b/View/PhotoAlbumPhotos/edit.ctp @@ -7,6 +7,7 @@ * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License */ + ?> assign('title_for_modal', __d('photo_albums', 'Add photo')); ?> @@ -39,8 +40,8 @@ NetCommonsForm->hidden('block_id'); ?> NetCommonsForm->hidden('status'); ?> - + Form->unlockField( 'PhotoAlbumPhoto.' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME ); @@ -52,9 +53,16 @@ 'required' => true, 'multiple', 'name' => 'data[PhotoAlbumPhoto][photo][]', + + 'onChange' => 'photoAlbumValidateUploadFileCount(this)', + 'data-max-file-uploads' => $maxFileUploads, ) ); - } else { + ?> + + + + NetCommonsForm->uploadFile( PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME, array( @@ -62,9 +70,8 @@ 'remove' => false ) ); - } - - ?> + ?> + NetCommonsForm->input( diff --git a/View/PhotoAlbumPhotos/index.ctp b/View/PhotoAlbumPhotos/index.ctp index 7e4e7c0..686f085 100644 --- a/View/PhotoAlbumPhotos/index.ctp +++ b/View/PhotoAlbumPhotos/index.ctp @@ -11,6 +11,9 @@ NetCommonsHtml->css('/photo_albums/css/photo_albums.css'); ?> NetCommonsHtml->script('/photo_albums/js/photo_albums.js'); ?> +NetCommonsHtml->script('/photo_albums/js/photo_album_photo_edit.js'); +?>
PhotoAlbums->albumListLink(); ?> diff --git a/webroot/js/photo_album_photo_edit.js b/webroot/js/photo_album_photo_edit.js new file mode 100644 index 0000000..b9ed8ba --- /dev/null +++ b/webroot/js/photo_album_photo_edit.js @@ -0,0 +1,10 @@ +function photoAlbumValidateUploadFileCount(fileForm) { + var maxFileUploads = $(fileForm).data('maxFileUploads'); + if(fileForm.files.length > maxFileUploads) { + $('#PhotoAlbumPhotoMaxFileUploadsError').show(); + $('button[name^=save_]').prop('disabled', true); + } else { + $('#PhotoAlbumPhotoMaxFileUploadsError').hide(); + $('button[name^=save_]').prop('disabled', false); + } +} From 847417fe6e6e01f33fbeaf0f0a732087fbe3f534 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 17:26:00 +0900 Subject: [PATCH 28/59] =?UTF-8?q?change:=20=E3=82=A2=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=A0=E4=BD=9C=E6=88=90=E6=99=82=E3=82=82=E4=B8=80=E5=BA=A6?= =?UTF-8?q?=E3=81=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=81=A7=E3=81=8D=E3=82=8B=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E6=95=B0=E3=82=92=E5=88=B6=E9=99=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/config.php | 2 +- .../PhotoAlbumMaxFileUploadsComponent.php | 62 +++++++++++++++++++ Controller/PhotoAlbumPhotosController.php | 31 +--------- Controller/PhotoAlbumsController.php | 3 + Locale/jpn/LC_MESSAGES/photo_albums.po | 3 + View/Elements/jacket_select_add.ctp | 14 ++++- View/PhotoAlbumPhotos/edit.ctp | 4 +- View/PhotoAlbums/edit.ctp | 3 + webroot/js/photo_albums.js | 9 +++ 9 files changed, 99 insertions(+), 32 deletions(-) create mode 100644 Controller/Component/PhotoAlbumMaxFileUploadsComponent.php diff --git a/Config/config.php b/Config/config.php index bd53e7d..eb34342 100644 --- a/Config/config.php +++ b/Config/config.php @@ -5,6 +5,6 @@ $config['PhotoAlbums'] = [ - // TODO 20にする + /** 同時にアップロードできるファイル数 */ 'maxFileUploads' => min(20, ini_get('max_file_uploads')) ]; \ No newline at end of file diff --git a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php new file mode 100644 index 0000000..e0ef2de --- /dev/null +++ b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php @@ -0,0 +1,62 @@ +__controller = $controller; + + Configure::load('PhotoAlbums.config'); + $this->__maxFileUploads = Configure::read('PhotoAlbums.maxFileUploads'); + $this->__controller->set('maxFileUploads', $this->__maxFileUploads); + + } + +/** + * $request->data['PhotoAlbumPhoto']['photo']を__maxFileUploadsまでに制限する + * + * 超えたファイル情報は切り捨てる + * + * @param string $requestPath photoの配列パス + * @return void + */ + public function removeOverMaxFileUploads(string $requestPath) { + //// 写真の追加時はPhotoAlbumPhoto.photoが配列になる + //// アルバムの追加時はPhotoAlbumPhotoが配列 + $photo = Hash::get($this->__controller->request->data, $requestPath); + + if (!is_array($photo)) { + return; + } + + if (count($photo) <= $this->__maxFileUploads) { + return; + } + + $photo = array_slice($photo, 0, $this->__maxFileUploads); + $this->__controller->request->data = Hash::insert($this->__controller->request->data, $requestPath, $photo); + } + +} \ No newline at end of file diff --git a/Controller/PhotoAlbumPhotosController.php b/Controller/PhotoAlbumPhotosController.php index 68c279e..728f9c5 100644 --- a/Controller/PhotoAlbumPhotosController.php +++ b/Controller/PhotoAlbumPhotosController.php @@ -56,6 +56,7 @@ class PhotoAlbumPhotosController extends PhotoAlbumsAppController { 'Workflow.Workflow', 'PhotoAlbums.PhotoAlbumPhotos', 'PhotoAlbums.PhotoAlbums', + 'PhotoAlbums.PhotoAlbumMaxFileUploads', 'Files.Download' ); @@ -70,11 +71,6 @@ class PhotoAlbumPhotosController extends PhotoAlbumsAppController { 'Users.DisplayUser', ); -/** - * @var int 同時にアップロードできる最大ファイル数 - */ - private $__maxFileUploads; - /** * beforeFilter * @@ -83,10 +79,6 @@ class PhotoAlbumPhotosController extends PhotoAlbumsAppController { public function beforeFilter() { parent::beforeFilter(); $this->Auth->allow('photo', 'slide'); - - Configure::load('PhotoAlbums.config'); - $this->__maxFileUploads = Configure::read('PhotoAlbums.maxFileUploads'); - $this->set('maxFileUploads', $this->__maxFileUploads); } /** @@ -168,8 +160,8 @@ public function add() { $photo = $this->PhotoAlbumPhoto->create(); if ($this->request->is('post')) { + $this->PhotoAlbumMaxFileUploads->removeOverMaxFileUploads('PhotoAlbumPhoto.photo'); $this->request->data['PhotoAlbumPhoto']['status'] = $this->Workflow->parseStatus(); - $this->__removeOverMaxFileUploads(); if ($this->PhotoAlbumPhoto->savePhotos($this->request->data)) { $url = PhotoAlbumsSettingUtility::settingUrl( array( @@ -355,23 +347,4 @@ public function delete() { $this->redirect($url); } -/** - * $this->request->data['PhotoAlbumPhoto']['photo']を__maxFileUploadsまでに制限する - * - * 超えたファイル情報は切り捨てる - * - * @return void - */ - private function __removeOverMaxFileUploads() { - if (!isset($this->request->data['PhotoAlbumPhoto']['photo'])) { - return; - } - $photo = $this->request->data['PhotoAlbumPhoto']['photo']; - - if (count($photo) <= $this->__maxFileUploads) { - return; - } - - $this->request->data['PhotoAlbumPhoto']['photo'] = array_slice($photo, 0, $this->__maxFileUploads); - } } diff --git a/Controller/PhotoAlbumsController.php b/Controller/PhotoAlbumsController.php index 96ec822..673d934 100644 --- a/Controller/PhotoAlbumsController.php +++ b/Controller/PhotoAlbumsController.php @@ -56,6 +56,7 @@ class PhotoAlbumsController extends PhotoAlbumsAppController { 'Workflow.Workflow', 'Files.Download', 'PhotoAlbums.PhotoAlbums', + 'PhotoAlbums.PhotoAlbumMaxFileUploads', ); /** @@ -217,6 +218,8 @@ public function add() { $album = $this->PhotoAlbum->create(); if ($this->request->is('post')) { + $this->PhotoAlbumMaxFileUploads->removeOverMaxFileUploads('PhotoAlbumPhoto'); + $this->request->data['PhotoAlbum']['status'] = $this->Workflow->parseStatus(); $album = $this->PhotoAlbum->saveAlbumForAdd($this->request->data); if ($album) { diff --git a/Locale/jpn/LC_MESSAGES/photo_albums.po b/Locale/jpn/LC_MESSAGES/photo_albums.po index 07dc67f..2253798 100644 --- a/Locale/jpn/LC_MESSAGES/photo_albums.po +++ b/Locale/jpn/LC_MESSAGES/photo_albums.po @@ -201,3 +201,6 @@ msgstr "スライド写真の高さ(px)" msgid "'0' for default setting." msgstr "「0」を指定すると自動になります" + +msgid "You cannot upload more than %d photos." +msgstr "%dを超える写真をアップロードすることはできません。" \ No newline at end of file diff --git a/View/Elements/jacket_select_add.ctp b/View/Elements/jacket_select_add.ctp index 7a60c47..9e7d90b 100644 --- a/View/Elements/jacket_select_add.ctp +++ b/View/Elements/jacket_select_add.ctp @@ -7,9 +7,13 @@ * @link http://www.netcommons.org NetCommons Project * @license http://www.netcommons.org/license.txt NetCommons License */ + +/** + * @var int $maxFileUploads 一度にアップロードできるファイル数 + */ ?> -
+
Form->unlockField('PhotoAlbumPhoto..' . PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME); @@ -23,8 +27,16 @@ 'required' => true, 'multiple', 'nc-photo-albums-preview' => 'preview()', + 'onChange' => 'photoAlbumValidateUploadFileCount(this)', + 'data-max-file-uploads' => $maxFileUploads, ) ); + ?> + + + NetCommonsForm->hidden( 'PhotoAlbum.selectedJacketIndex', array('ng-value' => 'selectedJacket.index') diff --git a/View/PhotoAlbumPhotos/edit.ctp b/View/PhotoAlbumPhotos/edit.ctp index fffecc6..31c5e59 100644 --- a/View/PhotoAlbumPhotos/edit.ctp +++ b/View/PhotoAlbumPhotos/edit.ctp @@ -59,7 +59,9 @@ ) ); ?> - + NetCommonsHtml->css('/photo_albums/css/photo_albums.css'); ?> NetCommonsHtml->script('/photo_albums/js/photo_albums.js'); ?> +NetCommonsHtml->script('/photo_albums/js/photo_album_photo_edit.js'); +?>
NetCommonsForm->create('PhotoAlbum', array('type' => 'file')); ?> diff --git a/webroot/js/photo_albums.js b/webroot/js/photo_albums.js index 37ab820..ad9054c 100644 --- a/webroot/js/photo_albums.js +++ b/webroot/js/photo_albums.js @@ -86,11 +86,20 @@ NetCommonsApp.controller('PhotoAlbumsPreviewController', ['$scope', $scope.fileReaderResultsCount = 0; $scope.selectedJacket = {}; + $scope.init = function(maxFileUploads) { + $scope.maxFileUploads = maxFileUploads; + }; + $scope.preview = function() { $scope.fileReaderResults = {}; $scope.selectedJacket = {}; + var fileCount = 0; angular.forEach($scope.files, function(file, index) { + fileCount++; + if (fileCount > $scope.maxFileUploads) { + return;; + } if (!file.type.match('image/*')) { return; } From 38bb07a487e719fff2115662d030db5fabd5e42b Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 18:05:25 +0900 Subject: [PATCH 29/59] style: fix phpcs problem --- .../PhotoAlbumMaxFileUploadsComponent.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php index e0ef2de..e23c196 100644 --- a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php +++ b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php @@ -35,17 +35,15 @@ public function startup(Controller $controller) { } /** - * $request->data['PhotoAlbumPhoto']['photo']を__maxFileUploadsまでに制限する + * 写真追加、アルバム追加時にアップロードされるファイル数を__maxFileUploadsまでに制限する * * 超えたファイル情報は切り捨てる * - * @param string $requestPath photoの配列パス + * @param string $photoPathInData photoの配列パス * @return void */ - public function removeOverMaxFileUploads(string $requestPath) { - //// 写真の追加時はPhotoAlbumPhoto.photoが配列になる - //// アルバムの追加時はPhotoAlbumPhotoが配列 - $photo = Hash::get($this->__controller->request->data, $requestPath); + public function removeOverMaxFileUploads(string $photoPathInData) { + $photo = Hash::get($this->__controller->request->data, $photoPathInData); if (!is_array($photo)) { return; @@ -56,7 +54,11 @@ public function removeOverMaxFileUploads(string $requestPath) { } $photo = array_slice($photo, 0, $this->__maxFileUploads); - $this->__controller->request->data = Hash::insert($this->__controller->request->data, $requestPath, $photo); + $this->__controller->request->data = Hash::insert( + $this->__controller->request->data, + $photoPathInData, + $photo + ); } } \ No newline at end of file From 9f69377e25ea26adc8ab175b77fd0561842b5b26 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 20:17:02 +0900 Subject: [PATCH 30/59] style: fix phpcs problem --- Controller/Component/PhotoAlbumMaxFileUploadsComponent.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php index e23c196..34a6809 100644 --- a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php +++ b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php @@ -31,7 +31,6 @@ public function startup(Controller $controller) { Configure::load('PhotoAlbums.config'); $this->__maxFileUploads = Configure::read('PhotoAlbums.maxFileUploads'); $this->__controller->set('maxFileUploads', $this->__maxFileUploads); - } /** From 2add30b626926d4bb5a75510f097e1cbdae45879 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 20:32:58 +0900 Subject: [PATCH 31/59] =?UTF-8?q?change:=20=E3=82=B9=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=89=E3=82=B7=E3=83=A7=E3=83=BC=E3=81=AE=E3=83=AA=E3=83=9F?= =?UTF-8?q?=E3=83=83=E3=83=88=E3=82=921000=E3=81=AB=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=EF=BC=88=E3=81=93=E3=82=8C=E3=81=BE=E3=81=A7=E3=81=AFPaginator?= =?UTF-8?q?Component=E5=88=9D=E6=9C=9F=E5=80=A4=E3=81=AE100=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/config.php | 4 +++- Controller/PhotoAlbumPhotosController.php | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Config/config.php b/Config/config.php index eb34342..679eab9 100644 --- a/Config/config.php +++ b/Config/config.php @@ -6,5 +6,7 @@ $config['PhotoAlbums'] = [ /** 同時にアップロードできるファイル数 */ - 'maxFileUploads' => min(20, ini_get('max_file_uploads')) + 'maxFileUploads' => min(20, ini_get('max_file_uploads')), + /** スライドショーのリミット */ + 'slideShowMaxLimit' => 1000, ]; \ No newline at end of file diff --git a/Controller/PhotoAlbumPhotosController.php b/Controller/PhotoAlbumPhotosController.php index 728f9c5..34d96d1 100644 --- a/Controller/PhotoAlbumPhotosController.php +++ b/Controller/PhotoAlbumPhotosController.php @@ -120,12 +120,16 @@ public function slide() { $conditions = $this->PhotoAlbumPhoto->getWorkflowConditions(); $conditions['PhotoAlbumPhoto.album_key'] = $this->request->params['key']; + Configure::load('PhotoAlbums.config'); + $slideShowLimit = Configure::read('PhotoAlbums.slideShowMaxLimit'); + $this->Paginator->settings = array( 'PhotoAlbumPhoto' => array( 'sort' => $frameSetting['PhotoAlbumFrameSetting']['photos_sort'], 'direction' => $frameSetting['PhotoAlbumFrameSetting']['photos_direction'], - 'limit' => $this->Paginator->settings['maxLimit'], - 'conditions' => $conditions + 'conditions' => $conditions, + 'limit' => $slideShowLimit, + 'maxLimit' => $slideShowLimit, ) ); $this->set('photos', $this->Paginator->paginate('PhotoAlbumPhoto')); From 58a87edb203a04198c7adf20db8629dd06887b04 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 17 Nov 2019 21:07:14 +0900 Subject: [PATCH 32/59] =?UTF-8?q?change:=201=E3=82=A2=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=A0=E3=81=AB=E3=82=A2=E3=83=83=E3=83=97=E3=83=AD=E3=83=BC?= =?UTF-8?q?=E3=83=89=E3=81=A7=E3=81=8D=E3=82=8B=E6=9C=80=E5=A4=A7=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E6=95=B0=E3=82=92500=E3=81=AB?= =?UTF-8?q?=E5=88=B6=E9=99=90=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Config/config.php | 2 + Locale/jpn/LC_MESSAGES/photo_albums.po | 5 ++- Model/PhotoAlbumPhoto.php | 25 +++++++++++ .../MultiCallBeforeValidateTest.php | 42 +++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 Test/Case/Model/PhotoAlbumPhoto/MultiCallBeforeValidateTest.php diff --git a/Config/config.php b/Config/config.php index 679eab9..818d1e8 100644 --- a/Config/config.php +++ b/Config/config.php @@ -9,4 +9,6 @@ 'maxFileUploads' => min(20, ini_get('max_file_uploads')), /** スライドショーのリミット */ 'slideShowMaxLimit' => 1000, + /** 1アルバムにアップロードできる最大画像数 */ + 'maxFileInAlbum' => 500, ]; \ No newline at end of file diff --git a/Locale/jpn/LC_MESSAGES/photo_albums.po b/Locale/jpn/LC_MESSAGES/photo_albums.po index 2253798..98ad2e8 100644 --- a/Locale/jpn/LC_MESSAGES/photo_albums.po +++ b/Locale/jpn/LC_MESSAGES/photo_albums.po @@ -203,4 +203,7 @@ msgid "'0' for default setting." msgstr "「0」を指定すると自動になります" msgid "You cannot upload more than %d photos." -msgstr "%dを超える写真をアップロードすることはできません。" \ No newline at end of file +msgstr "%dを超える写真をアップロードすることはできません。" + +msgid "You have exceeded the maximum number of images that can be uploaded to this album." +msgstr "このアルバムにアップロードできる最大画像数を超えています。" \ No newline at end of file diff --git a/Model/PhotoAlbumPhoto.php b/Model/PhotoAlbumPhoto.php index 7083756..4e6c750 100644 --- a/Model/PhotoAlbumPhoto.php +++ b/Model/PhotoAlbumPhoto.php @@ -103,6 +103,13 @@ public function beforeValidate($options = array()) { 'message' => array(__d('files', 'It is upload disabled file format')) ); */ + $validate['maxFileInAlbum'] = [ + 'rule' => ['validationMaxFileInAlbum'], + 'message' => __d( + 'photo_albums', + 'You have exceeded the maximum number of images that can be uploaded to this album.' + ), + ]; } $this->validate = array_merge( @@ -115,6 +122,24 @@ public function beforeValidate($options = array()) { return parent::beforeValidate($options); } +/** + * validationMaxFileInAlbum アルバムの画像数が最大数未満かをチェック + * + * @param array $check check + * @return bool + */ + public function validationMaxFileInAlbum(array $check) { + Configure::load('PhotoAlbums.config'); + $maxFileInAlbum = Configure::read('PhotoAlbums.maxFileInAlbum'); + $count = $this->find('count', [ + 'conditions' => [ + 'PhotoAlbumPhoto.album_key' => $this->data['PhotoAlbumPhoto']['album_key'], + 'PhotoAlbumPhoto.is_latest' => true, + ] + ]); + return ($count < $maxFileInAlbum); + } + /** * Called before each find operation. Return false if you want to halt the find * call, otherwise return the (modified) query data. diff --git a/Test/Case/Model/PhotoAlbumPhoto/MultiCallBeforeValidateTest.php b/Test/Case/Model/PhotoAlbumPhoto/MultiCallBeforeValidateTest.php new file mode 100644 index 0000000..deb05dd --- /dev/null +++ b/Test/Case/Model/PhotoAlbumPhoto/MultiCallBeforeValidateTest.php @@ -0,0 +1,42 @@ +data['PhotoAlbumPhoto'][$field]['name']) + $photoModel->data['PhotoAlbumPhoto'][PhotoAlbumPhoto::ATTACHMENT_FIELD_NAME]['name'] = 'foo.jpg'; + $photoModel->beforeValidate(); + $call1stValidate = $photoModel->validate; + + $photoModel->beforeValidate(); + $call2ndValidate = $photoModel->validate; + + $this->assertSame($call1stValidate, $call2ndValidate); + } +} \ No newline at end of file From 531dd7a7a2d889dd216f98cf814542140c194a99 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 19 Nov 2019 08:53:52 +0900 Subject: [PATCH 33/59] style: fix gjslint problem --- webroot/js/photo_album_photo_edit.js | 2 +- webroot/js/photo_albums.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webroot/js/photo_album_photo_edit.js b/webroot/js/photo_album_photo_edit.js index b9ed8ba..2a194b4 100644 --- a/webroot/js/photo_album_photo_edit.js +++ b/webroot/js/photo_album_photo_edit.js @@ -1,6 +1,6 @@ function photoAlbumValidateUploadFileCount(fileForm) { var maxFileUploads = $(fileForm).data('maxFileUploads'); - if(fileForm.files.length > maxFileUploads) { + if (fileForm.files.length > maxFileUploads) { $('#PhotoAlbumPhotoMaxFileUploadsError').show(); $('button[name^=save_]').prop('disabled', true); } else { diff --git a/webroot/js/photo_albums.js b/webroot/js/photo_albums.js index ad9054c..d88963a 100644 --- a/webroot/js/photo_albums.js +++ b/webroot/js/photo_albums.js @@ -98,7 +98,7 @@ NetCommonsApp.controller('PhotoAlbumsPreviewController', ['$scope', angular.forEach($scope.files, function(file, index) { fileCount++; if (fileCount > $scope.maxFileUploads) { - return;; + return; } if (!file.type.match('image/*')) { return; From 3e4d83d9c115bb3e707e7339a71b279041664f88 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 19 Nov 2019 20:55:29 +0900 Subject: [PATCH 34/59] =?UTF-8?q?change:=20string=20typ=20hint=E3=82=92?= =?UTF-8?q?=E5=89=8A=E9=99=A4=E3=80=82=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=82=B5=E3=83=9E=E3=83=AA=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/Component/PhotoAlbumMaxFileUploadsComponent.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php index 34a6809..f691ac9 100644 --- a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php +++ b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php @@ -1,6 +1,6 @@ __controller->request->data, $photoPathInData); if (!is_array($photo)) { From 015780b12e8c4581dda21350217a5094953797eb Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 19 Nov 2019 20:55:58 +0900 Subject: [PATCH 35/59] =?UTF-8?q?comment:=20=E3=82=B3=E3=83=A1=E3=83=B3?= =?UTF-8?q?=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/Component/PhotoAlbumMaxFileUploadsComponent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php index f691ac9..e7cb79d 100644 --- a/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php +++ b/Controller/Component/PhotoAlbumMaxFileUploadsComponent.php @@ -14,7 +14,7 @@ class PhotoAlbumMaxFileUploadsComponent extends Component { private $__maxFileUploads; /** - * @var Controller + * @var Controller 呼び出し元コントローラ */ private $__controller; From bce3071816f5cd815a667295ec50c6dbc5bce90e Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sat, 23 Nov 2019 14:02:30 +0900 Subject: [PATCH 36/59] =?UTF-8?q?change:=20=E5=86=99=E7=9C=9F=E8=BF=BD?= =?UTF-8?q?=E5=8A=A0=E3=81=A7=E3=83=90=E3=83=AA=E3=83=87=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=A7=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=9F=E3=83=95=E3=82=A9=E3=83=BC?= =?UTF-8?q?=E3=83=A0=E3=81=A7=E3=82=82=E5=90=8C=E6=99=82=E3=81=AB=E9=81=B8?= =?UTF-8?q?=E6=8A=9E=E3=81=A7=E3=81=8D=E3=82=8B=E5=86=99=E7=9C=9F=E6=95=B0?= =?UTF-8?q?=E5=88=B6=E9=99=90=E3=81=8C=E3=81=8B=E3=81=8B=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/PhotoAlbumPhotos/edit.ctp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/View/PhotoAlbumPhotos/edit.ctp b/View/PhotoAlbumPhotos/edit.ctp index 31c5e59..bf0975b 100644 --- a/View/PhotoAlbumPhotos/edit.ctp +++ b/View/PhotoAlbumPhotos/edit.ctp @@ -9,6 +9,9 @@ */ ?> +NetCommonsHtml->script('/photo_albums/js/photo_album_photo_edit.js'); +?> assign('title_for_modal', __d('photo_albums', 'Add photo')); ?> From 9338f2b7871a83346351154e0bbd02714923ffa9 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 27 Dec 2019 12:19:16 +0900 Subject: [PATCH 37/59] =?UTF-8?q?fix:=20=E3=83=AA=E3=83=95=E3=82=A1?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E5=8F=96=E5=BE=97=E3=81=AE=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- View/PhotoAlbums/edit.ctp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/PhotoAlbums/edit.ctp b/View/PhotoAlbums/edit.ctp index 669f8d5..33e481d 100644 --- a/View/PhotoAlbums/edit.ctp +++ b/View/PhotoAlbums/edit.ctp @@ -52,7 +52,7 @@ echo $this->NetCommonsHtml->script('/photo_albums/js/photo_album_photo_edit.js') Workflow->inputComment('PhotoAlbum.status'); ?>
- Workflow->buttons('PhotoAlbum.status', $this->request->referer()); ?> + Workflow->buttons('PhotoAlbum.status', $this->request->referer(true)); ?> NetCommonsForm->end(); ?> request->params['action'] === 'edit' && $this->Workflow->canDelete('PhotoAlbum', $this->request->data)) : ?> From 3434b017051ad37ba68587e516d0275be5dcbc7f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 13 Mar 2020 23:43:01 +0900 Subject: [PATCH 38/59] =?UTF-8?q?change:=20test:=20travis.yml=E3=81=8B?= =?UTF-8?q?=E3=82=89php5.4,5.5=E3=82=92=E5=89=8A=E9=99=A4=E3=80=82php7.3,7?= =?UTF-8?q?.4=E3=82=92=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/?= =?UTF-8?q?NetCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b46df1..bf76046 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: php php: - - 5.4 - - 5.5 - 5.6 - 7.0 - 7.1 - 7.2 + - 7.3 + - 7.4 sudo: false dist: trusty From 78116a077f796131702226f82fe0118ec5bcd81f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 14 Mar 2020 09:02:17 +0900 Subject: [PATCH 39/59] =?UTF-8?q?change:=20test:=20TravisCI=E3=81=8Cphp74?= =?UTF-8?q?=E3=81=A7ZipArchive=E3=81=A8imagecreatefromgif=E3=82=92?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=82=81php73=E3=81=BE=E3=81=A7=E3=81=A8=E3=81=99?= =?UTF-8?q?=E3=82=8B=E3=80=82=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf76046..a50e7cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,6 @@ php: - 7.1 - 7.2 - 7.3 - - 7.4 sudo: false dist: trusty From ecf161f1c6b7eb50dc7c27c505031a81244a097d Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 14 Mar 2020 19:26:57 +0900 Subject: [PATCH 40/59] =?UTF-8?q?change:=20test:=20TravisCI=E3=81=8Cphp74?= =?UTF-8?q?=E3=81=A7ZipArchive=E3=81=A8imagecreatefromgif=E3=82=92?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=E3=81=97=E3=81=A6=E3=81=84=E3=81=AA=E3=81=84?= =?UTF-8?q?=E3=81=9F=E3=82=81=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=A8=E3=81=AA?= =?UTF-8?q?=E3=82=8B=E3=81=8Ctravis.yml=E3=81=AB=E8=BF=BD=E5=8A=A0?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=8A=E3=81=8F=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1560?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a50e7cb..bf76046 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,7 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4 sudo: false dist: trusty From 38eebfbbbc337a9129588b52ca14daa4fe9b3c07 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 7 Aug 2020 22:54:58 +0900 Subject: [PATCH 41/59] =?UTF-8?q?change:=20test:=20Travis=E3=81=8B?= =?UTF-8?q?=E3=82=89PHP5.6=E3=82=92=E5=89=8A=E9=99=A4,php72=E4=BB=A5?= =?UTF-8?q?=E9=99=8D=E3=81=A7UnitTest=E3=81=A7Warning=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 1 - phpunit.xml.dist | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index bf76046..95c16c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.6 - 7.0 - 7.1 - 7.2 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 77e917f..d8b7d92 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,11 @@ + + + + + + app/Plugin/PhotoAlbums From 3e614741b269bac204fc274fc7c491c46630f976 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 8 Aug 2020 13:18:37 +0900 Subject: [PATCH 42/59] =?UTF-8?q?change:=20test:=20Travis=E3=81=8B?= =?UTF-8?q?=E3=82=89PHP5.6=E3=82=92=E5=89=8A=E9=99=A4,php72=E4=BB=A5?= =?UTF-8?q?=E9=99=8D=E3=81=A7UnitTest=E3=81=A7Warning=E3=81=8C=E5=87=BA?= =?UTF-8?q?=E3=82=8B=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.?= =?UTF-8?q?com/NetCommons3/NetCommons3/issues/1588?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 95c16c1..020ebcd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,12 @@ php: sudo: false dist: trusty +matrix: + allow_failures: + # PHP 7.4 testing is allowed to fail because the GD extension and ZipArchive is not packaged on Travis CI yet. + # See https://travis-ci.community/t/some-extensions-are-missing-in-php-7-4-0-zip-gmp-sodium/6320/9 + - php: 7.4 + env: - NETCOMMONS_VERSION=master DB=mysql From 417b40a3802c2a226cae8366c1d448c757949607 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 26 Aug 2020 20:20:31 +0900 Subject: [PATCH 43/59] change: Version number to 3.3.2 --- VERSION.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 VERSION.txt diff --git a/VERSION.txt b/VERSION.txt new file mode 100644 index 0000000..4772543 --- /dev/null +++ b/VERSION.txt @@ -0,0 +1 @@ +3.3.2 From 0f14eec47159e8832c647c97995f16a8a846ff89 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 13 Dec 2020 18:33:41 +0900 Subject: [PATCH 44/59] =?UTF-8?q?fix:=20test:=20TravisCI=E3=81=AEphp7.3?= =?UTF-8?q?=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C=E5=87=BA=E3=82=8B?= =?UTF-8?q?=E3=81=9F=E3=82=81=E4=BF=AE=E6=AD=A3=20https://github.com/NetCo?= =?UTF-8?q?mmons3/NetCommons3/issues/1618?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 020ebcd..5444807 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ php: - 7.0 - 7.1 - 7.2 - - 7.3 + - 7.3.24 - 7.4 sudo: false From 19b251959bb4f4c3fac07166383384a97ce9284f Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 14:01:33 +0900 Subject: [PATCH 45/59] =?UTF-8?q?add:=20release=E3=82=BF=E3=82=B0=E4=BB=98?= =?UTF-8?q?=E3=81=91=E3=81=AEgithub=20action=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/NetCommons3/NetCommons3/issues/1619 --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a3225bc --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +on: + push: + # Sequence of patterns matched against refs/tags + tags: + - '3*' + +name: Create Release + +jobs: + build: + name: Create Release + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + body: | + NetCommons ${{ github.ref }} released. + draft: false + prerelease: false From 6c8ec3e1e21a5c2b0cc46cbe4e4e9204b8e57675 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 23 Jan 2021 14:01:38 +0900 Subject: [PATCH 46/59] change: Version number to 3.3.3 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 4772543..619b537 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.2 +3.3.3 From ad8c465877cdbafac684f0a6833a61619f3d7849 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sat, 31 Jul 2021 10:47:51 +0900 Subject: [PATCH 47/59] =?UTF-8?q?change:=20test:=20TravisCI=E3=81=8B?= =?UTF-8?q?=E3=82=89GithubAction=E3=81=AB=E5=A4=89=E6=9B=B4=20https://gith?= =?UTF-8?q?ub.com/NetCommons3/NetCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 137 ++++++++++++++++++++++++++++++++++++ .travis.yml | 34 --------- README.md | 9 +-- phpunit.xml.dist | 4 +- 4 files changed, 143 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/tests.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d6bd01e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,137 @@ +on: + push: + branches: + - main + - master + - availability + pull_request: + branches: + - main + - master + - availability + +name: tests + +jobs: + tests: + name: tests + runs-on: ubuntu-18.04 + strategy: + matrix: + php: [ '7.1', '7.2', '7.3', '7.4' ] + + env: + NC3_BUILD_DIR: "/opt/nc3" + NC3_DOCKER_DIR: "/opt/docker" + NC3_GIT_URL: "git://github.com/NetCommons3/NetCommons3.git" + NC3_GIT_BRANCH: "master" + PLUGIN_BUILD_DIR: ${{ github.workspace }} + PHP_VERSION: ${{ matrix.php }} + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: cakephp_test + + steps: + - uses: actions/checkout@v2 + + - name: environment + run: | + echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" + echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" + echo "PHP_VERSION=${PHP_VERSION}" + ls -al ${PLUGIN_BUILD_DIR} + + - name: docker-compose install + run: | + curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + chmod +x ~/docker-compose + sudo mv ~/docker-compose /usr/local/bin/docker-compose + docker-compose --version + + - name: git clone nc3 + run: git clone -b ${NC3_GIT_BRANCH} ${NC3_GIT_URL} ${NC3_BUILD_DIR} + + - name: git clone nc3_docker + run: git clone https://github.com/NetCommons3/nc3app-docker.git ${NC3_DOCKER_DIR} + + - name: docker-compose start + run: | + cd ${NC3_DOCKER_DIR} + docker-compose up -d + docker-compose start + + - run: docker ps + + - name: check libraries + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/start-on-docker.sh + + - name: nc3 build + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/app-build.sh + + - name: phpcs (PHP CodeSniffer) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh + + - name: phpmd (PHP Mess Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh + + - name: phpcpd (PHP Copy/Paste Detector) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh + + - name: gjslint (JavaScript Style Check) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh + + - name: phpdoc (PHP Documentor) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh + + - name: phpunit (PHP UnitTest) + run: | + cd ${NC3_DOCKER_DIR} + docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh + sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build + + - name: push coveralls + env: + COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COVERALLS_FLAG_NAME: ${{ matrix.php }} + run: | + cd ${NC3_BUILD_DIR} + ls -la ${NC3_BUILD_DIR} + vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v + + - name: docker-compose remove + run: | + cd ${NC3_DOCKER_DIR} + docker-compose rm -f + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: good + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} + SLACK_CHANNEL: notify-netcommons3 + SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_COLOR: danger diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 5444807..0000000 --- a/.travis.yml +++ /dev/null @@ -1,34 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3.24 - - 7.4 - -sudo: false -dist: trusty - -matrix: - allow_failures: - # PHP 7.4 testing is allowed to fail because the GD extension and ZipArchive is not packaged on Travis CI yet. - # See https://travis-ci.community/t/some-extensions-are-missing-in-php-7-4-0-zip-gmp-sodium/6320/9 - - php: 7.4 - -env: - - NETCOMMONS_VERSION=master DB=mysql - -before_script: - - export NETCOMMONS_BUILD_DIR=`dirname $TRAVIS_BUILD_DIR`/NetCommons3 - - git clone git://github.com/NetCommons3/NetCommons3 $NETCOMMONS_BUILD_DIR - - cd $NETCOMMONS_BUILD_DIR - - git checkout $NETCOMMONS_VERSION - - travis_wait . tools/build/plugins/cakephp/travis/pre.sh - - . tools/build/plugins/cakephp/travis/environment.sh - -script: - - . tools/build/plugins/cakephp/travis/main.sh - -after_script: - - . tools/build/plugins/cakephp/travis/post.sh diff --git a/README.md b/README.md index 6224646..52a1276 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# PhotoAlbums -PhotoAlbums for NetCommons3 +PhotoAlbums +============ -[![Build Status](https://travis-ci.org/NetCommons3/PhotoAlbums.svg?branch=master)](https://travis-ci.org/NetCommons3/PhotoAlbums) -[![Coverage Status](https://coveralls.io/repos/github/NetCommons3/PhotoAlbums/badge.svg?branch=master)](https://coveralls.io/github/NetCommons3/PhotoAlbums?branch=master) \ No newline at end of file +[![Tests Status](https://github.com/NetCommons3/PhotoAlbums/actions/workflows/tests.yml/badge.svg?branch=master)](https://github.com/NetCommons3/PhotoAlbums/actions/workflows/tests.yml) +[![Coverage Status](https://coveralls.io/repos/NetCommons3/PhotoAlbums/badge.svg?branch=master)](https://coveralls.io/r/NetCommons3/PhotoAlbums?branch=master) +[![Stable Version](https://img.shields.io/packagist/v/netcommons/photo-albums.svg?label=stable)](https://packagist.org/packages/netcommons/photo-albums) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d8b7d92..cfd95fa 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,9 +3,6 @@ - - - app/Plugin/PhotoAlbums @@ -20,5 +17,6 @@ + From 979743e8702cc75390fe5c9dcfda68bf094fdd93 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 3 Aug 2021 15:20:53 +0900 Subject: [PATCH 48/59] =?UTF-8?q?fix:=20test:=20UnitTest=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PhotoAlbumFrameSettingsController/EditTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php b/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php index 1e572a1..e55898e 100644 --- a/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php +++ b/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php @@ -110,7 +110,7 @@ public function testEdit($method, $data = null, $validationError = false, $excep TestAuthGeneral::login($this); $frameId = '6'; - if ($validationError) { + if (is_array($validationError)) { $data = Hash::insert($data, $validationError['field'], $validationError['value']); } From 51003b6e88f1964047cad5f59270b0b22dbf6e6b Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Tue, 3 Aug 2021 19:24:34 +0900 Subject: [PATCH 49/59] =?UTF-8?q?fix:=20test:=20UnitTest=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3=20https://github.com/NetCommons3/Ne?= =?UTF-8?q?tCommons3/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PhotoAlbumFrameSettingsController/EditTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php b/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php index e55898e..fb4154d 100644 --- a/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php +++ b/Test/Case/Controller/PhotoAlbumFrameSettingsController/EditTest.php @@ -148,7 +148,7 @@ public function testEdit($method, $data = null, $validationError = false, $excep ); //バリデーションエラー(エラー表示あり) - if ($validationError) { + if (is_array($validationError)) { if ($validationError['message']) { array_push($asserts, array( 'method' => 'assertNotEmpty', 'value' => $this->controller->validationErrors From 235be567066fc1b7a2c988b5d87dc183df95d344 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Wed, 11 Aug 2021 10:56:35 +0900 Subject: [PATCH 50/59] =?UTF-8?q?change:=20test:=20Slack=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3,=20mysql8.0=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20https://github.com/NetCommons3/NetCommons3?= =?UTF-8?q?/issues/1650?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 35 ++++++++++++++++++++++++-- .github/workflows/tests.yml | 47 +++++++++++++++++++++++++---------- 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a3225bc..592d72f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,16 +4,25 @@ on: tags: - '3*' -name: Create Release +name: create_release jobs: build: - name: Create Release + name: create_release runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v2 + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + SLACK_MESSAGE: "Start Job" + - name: Create Release id: create_release uses: actions/create-release@v1 @@ -26,3 +35,25 @@ jobs: NetCommons ${{ github.ref }} released. draft: false prerelease: false + + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Finish + uses: rtCamp/action-slack-notify@v2.2.0 + if: success() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-release + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good + SLACK_MESSAGE: "Job Success" + + # テスト失敗時はこちらのステップが実行される + - name: Slack Notification on Failure + uses: rtCamp/action-slack-notify@v2.2.0 + if: failure() + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_RELEASE }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: danger + SLACK_MESSAGE: "Job Failure" diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d6bd01e..1477ea2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,12 +13,26 @@ on: name: tests jobs: + setup: + name: setup + runs-on: ubuntu-18.04 + steps: + - name: Slack Notification on Start + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: "#f0ad4e" + tests: name: tests + needs: setup runs-on: ubuntu-18.04 strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] + mysql: [ '5.7', '8.0' ] env: NC3_BUILD_DIR: "/opt/nc3" @@ -27,6 +41,7 @@ jobs: NC3_GIT_BRANCH: "master" PLUGIN_BUILD_DIR: ${{ github.workspace }} PHP_VERSION: ${{ matrix.php }} + MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test @@ -38,6 +53,7 @@ jobs: echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" echo "PLUGIN_BUILD_DIR=${PLUGIN_BUILD_DIR}" echo "PHP_VERSION=${PHP_VERSION}" + echo "MYSQL_VERSION=${MYSQL_VERSION}" ls -al ${PLUGIN_BUILD_DIR} - name: docker-compose install @@ -116,22 +132,27 @@ jobs: cd ${NC3_DOCKER_DIR} docker-compose rm -f - # テスト成功時はこちらのステップが実行される - - name: Slack Notification on Success - if: success() - uses: rtCamp/action-slack-notify@v2.2.0 - env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" - SLACK_COLOR: good - # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 if: failure() env: - SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} - SLACK_CHANNEL: notify-netcommons3 - SLACK_TITLE: "${{ github.repository }}(${{ matrix.php }})" + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}(php${{ matrix.php }}, mysql${{ matrix.mysql }})" SLACK_COLOR: danger + + teardown: + name: teardown + runs-on: ubuntu-18.04 + needs: tests + steps: + # テスト成功時はこちらのステップが実行される + - name: Slack Notification on Success + if: success() + uses: rtCamp/action-slack-notify@v2.2.0 + env: + SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} + SLACK_CHANNEL: notify-nc3-tests + SLACK_TITLE: "${{ github.repository }}" + SLACK_COLOR: good From 5c0568246253ea9000c8da75adbe8ff43c47b863 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 13 Aug 2021 16:53:37 +0900 Subject: [PATCH 51/59] change: Version number to 3.3.4 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 619b537..a0891f5 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.3 +3.3.4 From 2e525f78f0b30b5b081ff55b132a66bfb15ccd77 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 11 Feb 2022 20:44:08 +0900 Subject: [PATCH 52/59] change: Version number to 3.3.5 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index a0891f5..fa7adc7 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.4 +3.3.5 From d5aea2aa0dcb44a30f5ff7edf719d84ba32497f4 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Fri, 24 Feb 2023 15:57:03 +0900 Subject: [PATCH 53/59] =?UTF-8?q?test:=20Github=20Action=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1477ea2..7cfa881 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,10 +44,14 @@ jobs: MYSQL_VERSION: ${{ matrix.mysql }} MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: cakephp_test + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 + - name: Fix up git URLs + run: echo -e '[url "https://github.com/"]\n insteadOf = "git://github.com/"' >> ~/.gitconfig + - name: environment run: | echo "GITHUB_WORKSPACE=${GITHUB_WORKSPACE}" @@ -58,7 +62,7 @@ jobs: - name: docker-compose install run: | - curl -L https://github.com/docker/compose/releases/download/1.11.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose + curl -L https://github.com/docker/compose/releases/download/1.29.2/docker-compose-`uname -s`-`uname -m` > ~/docker-compose chmod +x ~/docker-compose sudo mv ~/docker-compose /usr/local/bin/docker-compose docker-compose --version From 939737062978dff9e2358897c7b250c917e22928 Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Sun, 26 Feb 2023 03:50:44 +0900 Subject: [PATCH 54/59] change: Version number to 3.3.6 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index fa7adc7..9c25013 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.5 +3.3.6 From 3b7d1a06b27b6bd9e306d912c45df140020a4c5e Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Thu, 1 Jun 2023 13:30:51 +0900 Subject: [PATCH 55/59] =?UTF-8?q?fix:=E3=82=A2=E3=83=AB=E3=83=90=E3=83=A0?= =?UTF-8?q?=E3=81=AB=E5=85=AC=E9=96=8B=E4=BB=A5=E5=A4=96=E3=81=AE=E5=86=99?= =?UTF-8?q?=E7=9C=9F=E3=81=8C=E3=81=82=E3=82=8B=E3=81=A8=E3=80=81=E3=82=A2?= =?UTF-8?q?=E3=83=AB=E3=83=90=E3=83=A0=E3=83=AA=E3=82=B9=E3=83=88=E3=81=AB?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=82=8B=E5=86=99=E7=9C=9F?= =?UTF-8?q?=E6=9E=9A=E6=95=B0=E3=81=8C=E6=AD=A3=E3=81=97=E3=81=8F=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=8F=E3=81=AA=E3=82=8B?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Model/PhotoAlbum.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Model/PhotoAlbum.php b/Model/PhotoAlbum.php index acb4b58..d544fda 100644 --- a/Model/PhotoAlbum.php +++ b/Model/PhotoAlbum.php @@ -128,9 +128,8 @@ public function afterFind($results, $primary = false) { $photoCount = []; foreach ($countArr as $result) { $result = $result['PhotoAlbumPhoto']; - $photoCount[$result['album_key']] = [ - $result['status'] => $result['photo_count'] - ]; + $photoCount[$result['album_key']][$result['status']] = $result['photo_count']; + } foreach ($results as $index => $result) { From 9f21259407d88d52452913af6cc05e8fdd0c114a Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Fri, 2 Jun 2023 21:12:38 +0900 Subject: [PATCH 56/59] =?UTF-8?q?fix:=20github=20Action=E3=81=A7=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7cfa881..1ae272d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ name: tests jobs: setup: name: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Slack Notification on Start uses: rtCamp/action-slack-notify@v2.2.0 @@ -28,7 +28,7 @@ jobs: tests: name: tests needs: setup - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest strategy: matrix: php: [ '7.1', '7.2', '7.3', '7.4' ] @@ -92,46 +92,53 @@ jobs: docker-compose exec -T nc3app bash /opt/scripts/app-build.sh - name: phpcs (PHP CodeSniffer) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcs.sh - name: phpmd (PHP Mess Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpmd.sh - name: phpcpd (PHP Copy/Paste Detector) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpcpd.sh - name: gjslint (JavaScript Style Check) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/gjslint.sh - name: phpdoc (PHP Documentor) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpdoc.sh - name: phpunit (PHP UnitTest) + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose exec -T nc3app bash /opt/scripts/phpunit.sh sudo -s chmod a+w -R ${NC3_BUILD_DIR}/build - - name: push coveralls - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_FLAG_NAME: ${{ matrix.php }} - run: | - cd ${NC3_BUILD_DIR} - ls -la ${NC3_BUILD_DIR} - vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v +# - name: push coveralls +# env: +# COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# COVERALLS_FLAG_NAME: ${{ matrix.php }} +# run: | +# cd ${NC3_BUILD_DIR} +# ls -la ${NC3_BUILD_DIR} +# vendors/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v - name: docker-compose remove + if: always() run: | cd ${NC3_DOCKER_DIR} docker-compose rm -f From 3eac4b507fb461a4353b221a70f1ae6aa50d1aab Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Sun, 4 Jun 2023 14:42:46 +0900 Subject: [PATCH 57/59] fix: tests.yml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1ae272d..a4ab928 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -155,7 +155,7 @@ jobs: teardown: name: teardown - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest needs: tests steps: # テスト成功時はこちらのステップが実行される From b3c1287b666a1719d56a8a193f8ba9451af9ac4a Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Thu, 5 Oct 2023 19:40:45 +0900 Subject: [PATCH 58/59] =?UTF-8?q?test:=20github=20action=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/tests.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a4ab928..6da4321 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -3,12 +3,10 @@ on: branches: - main - master - - availability pull_request: branches: - main - master - - availability name: tests @@ -19,6 +17,7 @@ jobs: steps: - name: Slack Notification on Start uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -146,7 +145,7 @@ jobs: # テスト失敗時はこちらのステップが実行される - name: Slack Notification on Failure uses: rtCamp/action-slack-notify@v2.2.0 - if: failure() + if: env.SLACK_WEBHOOK != '' && failure() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests @@ -160,8 +159,8 @@ jobs: steps: # テスト成功時はこちらのステップが実行される - name: Slack Notification on Success - if: success() uses: rtCamp/action-slack-notify@v2.2.0 + if: env.SLACK_WEBHOOK != '' && success() env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_TESTS }} SLACK_CHANNEL: notify-nc3-tests From 211d16e3b5fbb0be475d433a134ea40b1cefc51e Mon Sep 17 00:00:00 2001 From: s-nakajima Date: Mon, 9 Oct 2023 21:08:06 +0900 Subject: [PATCH 59/59] change: Version number to 3.3.7 --- VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.txt b/VERSION.txt index 9c25013..86fb650 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -3.3.6 +3.3.7