From 2fa9d49632129129615d8c9afea30ec5885809bb Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 12 Dec 2022 21:56:23 -0500 Subject: [PATCH 01/18] Normalize padding in image grid - Remove outside padding, vertical and horizontal - Remove artificial padding with
in content/image.tpl --- view/global.css | 19 ++++++++----------- view/templates/content/image.tpl | 1 - 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/view/global.css b/view/global.css index 81a1ba2095..d327da0c2c 100644 --- a/view/global.css +++ b/view/global.css @@ -687,25 +687,22 @@ audio { .imagegrid-row { display: -ms-flexbox; /* IE10 */ display: flex; - -ms-flex-wrap: wrap; /* IE10 */ - flex-wrap: wrap; - padding: 0 4px; - box-sizing: border-box; + margin-top: 1em; + column-gap: 5px; } -/* Create four equal columns that sits next to each other */ .imagegrid-column { -ms-flex: 50%; /* IE10 */ flex: 50%; - max-width: 50%; - padding: 0 4px; - box-sizing: border-box; + display: -ms-flexbox; /* IE10 */ + display: flex; + flex-direction: column; + row-gap: 5px; } .imagegrid-column img { - margin-top: 8px; - vertical-align: middle; - width: 100%; + -ms-flex: 50%; /* IE10 */ + flex: 50%; } /** * Image grid settings END diff --git a/view/templates/content/image.tpl b/view/templates/content/image.tpl index 2885d869fb..92a37915ff 100644 --- a/view/templates/content/image.tpl +++ b/view/templates/content/image.tpl @@ -3,4 +3,3 @@ {{else}} {{$image.attachment.description}} {{/if}} -
From d9361f2b818bc3383dfdf36df76f44ad09074c2f Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Tue, 13 Dec 2022 09:33:01 -0500 Subject: [PATCH 02/18] Improve code standards in Model\Item --- src/Model/Item.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/Model/Item.php b/src/Model/Item.php index 69b1595c20..8dce7a7880 100644 --- a/src/Model/Item.php +++ b/src/Model/Item.php @@ -3096,7 +3096,7 @@ class Item ]; Hook::callAll('prepare_body', $hook_data); $s = $hook_data['html']; - + unset($hook_data); if (!$attach) { @@ -3146,18 +3146,18 @@ class Item */ public static function makeImageGrid(array $images): string { - $landscapeimages = array(); - $portraitimages = array(); + $landscapeimages = []; + $portraitimages = []; foreach ($images as $image) { ($image['attachment']['width'] > $image['attachment']['height']) ? ($landscapeimages[] = $image) : ($portraitimages[] = $image); } // Image for first column (fc) and second column (sc) - $images_fc = array(); - $images_sc = array(); - $lcount = count($landscapeimages); - $pcount = count($portraitimages); + $images_fc = []; + $images_sc = []; + $lcount = count($landscapeimages); + $pcount = count($portraitimages); if ($lcount == 0 || $pcount == 0) { if ($lcount == 0) { // only portrait @@ -3424,9 +3424,8 @@ class Item $media = ''; if (count($images) > 1) { $media = self::makeImageGrid($images); - } - elseif (count($images) == 1) { - $media = $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [ + } elseif (count($images) == 1) { + $media = Renderer::replaceMacros(Renderer::getMarkupTemplate('content/image.tpl'), [ '$image' => $images[0], ]); } From 8f56aa316b9e156c1d8f6073fbe0330a98acb701 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 12:48:50 -0500 Subject: [PATCH 03/18] Allow album to be empty string thus defaulting to i10n "Wall Photos" like in UI --- src/Module/Api/Friendica/Photo/Create.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index bb3dc63b22..868296342a 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -64,8 +64,8 @@ class Create extends BaseApi // do several checks on input parameters // we do not allow calls without album string - if ($album == null) { - throw new HTTPException\BadRequestException('no albumname specified'); + if ($album === null) { + throw new HTTPException\BadRequestException('no album name specified'); } // error if no media posted in create-mode From 800f94495b99feb91b053ef581f54128927092da Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:27:23 -0500 Subject: [PATCH 04/18] Add Photo album cache flushes to Friendica Photo endpoints --- src/Module/Api/Friendica/Photo/Create.php | 1 + src/Module/Api/Friendica/Photo/Delete.php | 2 +- src/Module/Api/Friendica/Photo/Update.php | 1 + src/Module/Api/Friendica/Photoalbum/Delete.php | 1 + src/Module/Api/Friendica/Photoalbum/Update.php | 1 + 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photo/Create.php b/src/Module/Api/Friendica/Photo/Create.php index 868296342a..1f60998b7b 100644 --- a/src/Module/Api/Friendica/Photo/Create.php +++ b/src/Module/Api/Friendica/Photo/Create.php @@ -88,6 +88,7 @@ class Create extends BaseApi // return success of updating or error message if (!empty($photo)) { + Photo::clearAlbumCache($uid); $data = ['photo' => $this->friendicaPhoto->createFromId($photo['resource_id'], null, $uid, $type)]; $this->response->exit('photo_create', $data, $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photo/Delete.php b/src/Module/Api/Friendica/Photo/Delete.php index e8dabe3a1f..64cc2e03ae 100644 --- a/src/Module/Api/Friendica/Photo/Delete.php +++ b/src/Module/Api/Friendica/Photo/Delete.php @@ -60,7 +60,7 @@ class Delete extends BaseApi // to the user and the contacts of the users (drop_items() do all the necessary magic to avoid orphans in database and federate deletion) $condition = ['uid' => $uid, 'resource-id' => $request['photo_id'], 'post-type' => Item::PT_IMAGE, 'origin' => true]; Item::deleteForUser($condition, $uid); - + Photo::clearAlbumCache($uid); $result = ['result' => 'deleted', 'message' => 'photo with id `' . $request['photo_id'] . '` has been deleted from server.']; $this->response->exit('photo_delete', ['$result' => $result], $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photo/Update.php b/src/Module/Api/Friendica/Photo/Update.php index 44fd554b09..83ceb7a5c5 100644 --- a/src/Module/Api/Friendica/Photo/Update.php +++ b/src/Module/Api/Friendica/Photo/Update.php @@ -135,6 +135,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'updated', 'message' => 'Image id `' . $photo_id . '` has been updated.']; $this->response->exit('photo_update', ['$result' => $answer], $this->parameters['extension'] ?? null); return; diff --git a/src/Module/Api/Friendica/Photoalbum/Delete.php b/src/Module/Api/Friendica/Photoalbum/Delete.php index 4215ddda7f..76062b2fde 100644 --- a/src/Module/Api/Friendica/Photoalbum/Delete.php +++ b/src/Module/Api/Friendica/Photoalbum/Delete.php @@ -66,6 +66,7 @@ class Delete extends BaseApi // return success of deletion or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'deleted', 'message' => 'album `' . $request['album'] . '` with all containing photos has been deleted.']; $this->response->exit('photoalbum_delete', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { diff --git a/src/Module/Api/Friendica/Photoalbum/Update.php b/src/Module/Api/Friendica/Photoalbum/Update.php index 0eca5b22ee..3fa01fe1b4 100644 --- a/src/Module/Api/Friendica/Photoalbum/Update.php +++ b/src/Module/Api/Friendica/Photoalbum/Update.php @@ -58,6 +58,7 @@ class Update extends BaseApi // return success of updating or error message if ($result) { + Photo::clearAlbumCache($uid); $answer = ['result' => 'updated', 'message' => 'album `' . $request['album'] . '` with all containing photos has been renamed to `' . $request['album_new'] . '`.']; $this->response->exit('photoalbum_update', ['$result' => $answer], $this->parameters['extension'] ?? null); } else { From e1823c7138e74815aea4b181ce0fab583bc64108 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:28:34 -0500 Subject: [PATCH 05/18] Add Photo Album index endpoint to Friendica API --- src/Module/Api/Friendica/Photoalbum/Index.php | 53 +++++++++++++++++++ static/routes.config.php | 1 + 2 files changed, 54 insertions(+) create mode 100644 src/Module/Api/Friendica/Photoalbum/Index.php diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php new file mode 100644 index 0000000000..84c5f2d604 --- /dev/null +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -0,0 +1,53 @@ +. +* +*/ + +namespace Friendica\Module\Api\Friendica\Photoalbum; + +use Friendica\Database\DBA; +use Friendica\Model\Photo; +use Friendica\Module\BaseApi; + +/** + * api/friendica/photoalbum + * + * @package Friendica\Module\Api\Friendica\Photoalbum + */ +class Index extends BaseApi +{ + protected function rawContent(array $request = []) + { + self::checkAllowedScope(self::SCOPE_READ); + $uid = self::getCurrentUserID(); + + $albums = Photo::getAlbums($uid); + + $items = []; + foreach ($albums as $album) { + $items[] = [ + 'name' => $album['album'], + 'created' => $album['created'], + 'count' => $album['total'], + ]; + } + + $this->response->exit('albums', ['albums' => $items], $this->parameters['extension'] ?? null); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index e3c87f1502..dc1f97b687 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -93,6 +93,7 @@ $apiRoutes = [ '/group_delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Delete::class, [ R::POST]], '/group_update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Update::class, [ R::POST]], '/profile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Profile\Show::class, [R::GET ]], + '/photoalbums[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Index::class, [R::GET ]], '/photoalbum/delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Delete::class, [ R::POST]], '/photoalbum/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Update::class, [ R::POST]], '/photos/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photo\Lists::class, [R::GET ]], From 951b221e214a0b3472a3d5f53d9597b01057c036 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 13:31:10 -0500 Subject: [PATCH 06/18] Fix Friendica API Photo Album list documentation to reflect endpoint --- src/Module/Api/Friendica/Photoalbum/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 84c5f2d604..b7038c6dc0 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -26,7 +26,7 @@ use Friendica\Model\Photo; use Friendica\Module\BaseApi; /** - * api/friendica/photoalbum + * api/friendica/photoalbums * * @package Friendica\Module\Api\Friendica\Photoalbum */ From 5b52533749dfca10fe8fc1a35b52e0fbf53036fb Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 14:14:58 -0500 Subject: [PATCH 07/18] Fix Friendica API Photo Album list documentation to reflect endpoint --- src/Module/Api/Friendica/Photoalbum/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index b7038c6dc0..84c5f2d604 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -26,7 +26,7 @@ use Friendica\Model\Photo; use Friendica\Module\BaseApi; /** - * api/friendica/photoalbums + * api/friendica/photoalbum * * @package Friendica\Module\Api\Friendica\Photoalbum */ From 4fc01c93ce0f3dfd61c00422e399a4cab50f3fcf Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 14:16:08 -0500 Subject: [PATCH 08/18] Add photo album show endpoint that lists photos in an album --- src/Module/Api/Friendica/Photoalbum/Show.php | 111 +++++++++++++++++++ static/routes.config.php | 1 + 2 files changed, 112 insertions(+) create mode 100644 src/Module/Api/Friendica/Photoalbum/Show.php diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php new file mode 100644 index 0000000000..20c5c4a6fb --- /dev/null +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -0,0 +1,111 @@ +. + * + */ + +namespace Friendica\Module\Api\Friendica\Photoalbum; + +use Friendica\App; +use Friendica\Core\L10n; +use Friendica\Database\DBA; +use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto; +use Friendica\Model\Contact; +use Friendica\Model\Photo; +use Friendica\Module\Api\ApiResponse; +use Friendica\Module\BaseApi; +use Friendica\Network\HTTPException; +use Friendica\Util\Profiler; +use Psr\Log\LoggerInterface; + +/** + * api/friendica/photoalbum/:name + * + * @package Friendica\Module\Api\Friendica\Photoalbum + */ +class Show extends BaseApi +{ + /** @var FriendicaPhoto */ + private $friendicaPhoto; + + + public function __construct(FriendicaPhoto $friendicaPhoto, App $app, L10n $l10n, App\BaseURL $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, ApiResponse $response, array $server, array $parameters = []) + { + parent::__construct($app, $l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters); + + $this->friendicaPhoto = $friendicaPhoto; + } + + protected function rawContent(array $request = []) + { + BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); + $uid = BaseApi::getCurrentUserID(); + $type = $this->getRequestValue($this->parameters, 'extension', 'json'); + $request = $this->getRequest([ + 'album' => '', // Get pictures in this album + 'offset' => 0, // Return results offset by this value + 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + ], $request); + if (empty($request['album'])) { + throw new HTTPException\BadRequestException('No album name specified.'); + } + + + $album = $request['album']; + $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; + $params = ['order' => ['id'], 'group_by' => ['resource-id']]; + + //'limit' => [$request['offset'], $request['limit']] + $limit = $request['limit']; + if ($limit > 500) { + $limit = 500; + } + + if ($limit <= 0) { + $limit = 1; + } + + if(!empty($request['offset'])) { + $params['limit'] = [$request['offset'], $limit]; + } else { + $params['limit'] = $limit; + } + + $photos = Photo::selectToArray(['resource-id'], $condition, $params); + + $data = ['photo' => []]; + if (DBA::isResult($photos)) { + foreach ($photos as $photo) { + $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); + + $element['thumb'] = end($element['link']); + unset($element['link']); + + if ($type == 'xml') { + $thumb = $element['thumb']; + unset($element['thumb']); + $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; + } else { + $data['photo'][] = $element; + } + } + } + + $this->response->exit('statuses', $data, $this->parameters['extension'] ?? null, Contact::getPublicIdByUserId($uid)); + } +} diff --git a/static/routes.config.php b/static/routes.config.php index dc1f97b687..e84dde9b9b 100644 --- a/static/routes.config.php +++ b/static/routes.config.php @@ -94,6 +94,7 @@ $apiRoutes = [ '/group_update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Group\Update::class, [ R::POST]], '/profile/show[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Profile\Show::class, [R::GET ]], '/photoalbums[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Index::class, [R::GET ]], + '/photoalbum[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Show::class, [R::GET ]], '/photoalbum/delete[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Delete::class, [ R::POST]], '/photoalbum/update[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photoalbum\Update::class, [ R::POST]], '/photos/list[.{extension:json|xml|rss|atom}]' => [Module\Api\Friendica\Photo\Lists::class, [R::GET ]], From 991c5fa6de529df26fb91365158472a748f04d85 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 15:41:24 -0500 Subject: [PATCH 09/18] Add latest_first parameter to photo gallery listing Friendica API endpoint --- src/Module/Api/Friendica/Photoalbum/Show.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 20c5c4a6fb..da16cbedc2 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -60,15 +60,17 @@ class Show extends BaseApi 'album' => '', // Get pictures in this album 'offset' => 0, // Return results offset by this value 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); if (empty($request['album'])) { throw new HTTPException\BadRequestException('No album name specified.'); } + $orderDescending = $request['latest_first']; $album = $request['album']; $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; - $params = ['order' => ['id'], 'group_by' => ['resource-id']]; + $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; //'limit' => [$request['offset'], $request['limit']] $limit = $request['limit']; From 8576610c54b8db9d96ed6279141e8f4177424769 Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 15:58:03 -0500 Subject: [PATCH 10/18] Fix copyright header issues... --- src/Module/Api/Friendica/Photoalbum/Index.php | 36 +++++++++---------- src/Module/Api/Friendica/Photoalbum/Show.php | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 84c5f2d604..0666fd2b1b 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -1,23 +1,23 @@ . -* -*/ + * @copyright Copyright (C) 2010-2022, the Friendica project + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ namespace Friendica\Module\Api\Friendica\Photoalbum; diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index da16cbedc2..34bffcb246 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -1,6 +1,6 @@ Date: Tue, 13 Dec 2022 15:59:45 -0500 Subject: [PATCH 11/18] Fix space missing after if style error in src/Module/Api/Friendica/Photoalbum/Show.php --- src/Module/Api/Friendica/Photoalbum/Show.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 34bffcb246..c1a7959506 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -82,7 +82,7 @@ class Show extends BaseApi $limit = 1; } - if(!empty($request['offset'])) { + if (!empty($request['offset'])) { $params['limit'] = [$request['offset'], $limit]; } else { $params['limit'] = $limit; From 5288ed46d4c2809349060608a87642518fad280d Mon Sep 17 00:00:00 2001 From: Hank Grabowski Date: Tue, 13 Dec 2022 16:04:03 -0500 Subject: [PATCH 12/18] Remove extraneous comment and fix whitespace between lines for style --- src/Module/Api/Friendica/Photoalbum/Show.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index c1a7959506..ac9573da38 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -62,17 +62,16 @@ class Show extends BaseApi 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); + if (empty($request['album'])) { throw new HTTPException\BadRequestException('No album name specified.'); } - $orderDescending = $request['latest_first']; $album = $request['album']; $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; - //'limit' => [$request['offset'], $request['limit']] $limit = $request['limit']; if ($limit > 500) { $limit = 500; From d74345782aa315c2a668109e47dd529d35d1e24b Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:34 -0500 Subject: [PATCH 13/18] Update src/Module/Api/Friendica/Photoalbum/Index.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 0666fd2b1b..46778bc456 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -42,9 +42,9 @@ class Index extends BaseApi $items = []; foreach ($albums as $album) { $items[] = [ - 'name' => $album['album'], - 'created' => $album['created'], - 'count' => $album['total'], + 'name' => $album['album'], + 'created' => $album['created'], + 'count' => $album['total'], ]; } From 7bb60776c6e91722e396eabd6a42bad2c84dc6cf Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:49 -0500 Subject: [PATCH 14/18] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index ac9573da38..e47ef51daa 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -54,13 +54,13 @@ class Show extends BaseApi protected function rawContent(array $request = []) { BaseApi::checkAllowedScope(BaseApi::SCOPE_READ); - $uid = BaseApi::getCurrentUserID(); - $type = $this->getRequestValue($this->parameters, 'extension', 'json'); + $uid = BaseApi::getCurrentUserID(); + $type = $this->getRequestValue($this->parameters, 'extension', 'json'); $request = $this->getRequest([ - 'album' => '', // Get pictures in this album - 'offset' => 0, // Return results offset by this value - 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 - 'latest_first' => false, // Whether to reverse the order so newest are first + 'album' => '', // Get pictures in this album + 'offset' => 0, // Return results offset by this value + 'limit' => 50, // Maximum number of results to return. Defaults to 50. Max 500 + 'latest_first' => false, // Whether to reverse the order so newest are first ], $request); if (empty($request['album'])) { From ae8f1a1c5b21ae80501f7a903d197f3f78174659 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:45:56 -0500 Subject: [PATCH 15/18] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index e47ef51daa..485b3e91e7 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -68,9 +68,9 @@ class Show extends BaseApi } $orderDescending = $request['latest_first']; - $album = $request['album']; - $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; - $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; + $album = $request['album']; + $condition = ["`uid` = ? AND `album` = ?", $uid, $album]; + $params = ['order' => ['id' => $orderDescending], 'group_by' => ['resource-id']]; $limit = $request['limit']; if ($limit > 500) { From 6af4bfae21f00b11a5ae8a91b6a5c6990f84f7b4 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:46:16 -0500 Subject: [PATCH 16/18] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 22 +++++++++----------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 485b3e91e7..14f561a990 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -90,20 +90,18 @@ class Show extends BaseApi $photos = Photo::selectToArray(['resource-id'], $condition, $params); $data = ['photo' => []]; - if (DBA::isResult($photos)) { - foreach ($photos as $photo) { - $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); + foreach ($photos as $photo) { + $element = $this->friendicaPhoto->createFromId($photo['resource-id'], null, $uid, 'json', false); - $element['thumb'] = end($element['link']); - unset($element['link']); + $element['thumb'] = end($element['link']); + unset($element['link']); - if ($type == 'xml') { - $thumb = $element['thumb']; - unset($element['thumb']); - $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; - } else { - $data['photo'][] = $element; - } + if ($type == 'xml') { + $thumb = $element['thumb']; + unset($element['thumb']); + $data['photo'][] = ['@attributes' => $element, '1' => $thumb]; + } else { + $data['photo'][] = $element; } } From 2338a268d33397ed9423276292878e7438a03766 Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:52:21 -0500 Subject: [PATCH 17/18] Update src/Module/Api/Friendica/Photoalbum/Show.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Show.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Show.php b/src/Module/Api/Friendica/Photoalbum/Show.php index 14f561a990..1a50416ecb 100644 --- a/src/Module/Api/Friendica/Photoalbum/Show.php +++ b/src/Module/Api/Friendica/Photoalbum/Show.php @@ -23,7 +23,6 @@ namespace Friendica\Module\Api\Friendica\Photoalbum; use Friendica\App; use Friendica\Core\L10n; -use Friendica\Database\DBA; use Friendica\Factory\Api\Friendica\Photo as FriendicaPhoto; use Friendica\Model\Contact; use Friendica\Model\Photo; From 7072a7178896c567caf5003e94a8f8045221bd8f Mon Sep 17 00:00:00 2001 From: Hank G Date: Tue, 13 Dec 2022 16:52:28 -0500 Subject: [PATCH 18/18] Update src/Module/Api/Friendica/Photoalbum/Index.php Co-authored-by: Hypolite Petovan --- src/Module/Api/Friendica/Photoalbum/Index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Module/Api/Friendica/Photoalbum/Index.php b/src/Module/Api/Friendica/Photoalbum/Index.php index 46778bc456..83fbb5d3d3 100644 --- a/src/Module/Api/Friendica/Photoalbum/Index.php +++ b/src/Module/Api/Friendica/Photoalbum/Index.php @@ -21,7 +21,6 @@ namespace Friendica\Module\Api\Friendica\Photoalbum; -use Friendica\Database\DBA; use Friendica\Model\Photo; use Friendica\Module\BaseApi;