From 30d90bbc4a852e214893c8e79eaba2139bc4ce46 Mon Sep 17 00:00:00 2001 From: Jaisen Mathai Date: Mon, 30 Sep 2013 16:25:25 -0700 Subject: [PATCH] Changing date sort logic to not group by date. See #1341 for discussion. Closes #1341 (meta) Closes #735 Closes #1339 Closes #1286 Closes #1340 --- src/html/assets/themes/fabrizio1.0/config/settings.ini | 2 +- .../assets/themes/fabrizio1.0/templates/photos.php | 10 +++++----- src/libraries/adapters/DatabaseMySql.php | 9 +++++---- src/libraries/controllers/ApiPhotoController.php | 6 ++++++ 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/html/assets/themes/fabrizio1.0/config/settings.ini b/src/html/assets/themes/fabrizio1.0/config/settings.ini index a96e0026f..e09e574c8 100644 --- a/src/html/assets/themes/fabrizio1.0/config/settings.ini +++ b/src/html/assets/themes/fabrizio1.0/config/settings.ini @@ -1,5 +1,5 @@ [site] -mediaVersion="df" +mediaVersion="dg" [behavior] useDefaultMobile="0" diff --git a/src/html/assets/themes/fabrizio1.0/templates/photos.php b/src/html/assets/themes/fabrizio1.0/templates/photos.php index f2f629a0d..d06ed541d 100644 --- a/src/html/assets/themes/fabrizio1.0/templates/photos.php +++ b/src/html/assets/themes/fabrizio1.0/templates/photos.php @@ -1,9 +1,6 @@ -theme->display('partials/user-badge.php'); ?> -
-
- +

utility->safe($album['name']); ?> @@ -13,11 +10,14 @@ user->isAdmin()) { ?> | + · )

-

utility->safe(implode(', ', $tags)); ?> (utility->safe($photos[0]['totalRows']); ?> photos)

+

utility->safe(implode(', ', $tags)); ?> (utility->safe($photos[0]['totalRows']); ?> photos · )

+ +

Gallery ( utility->safe($photos[0]['totalRows']); ?> photos · )

diff --git a/src/libraries/adapters/DatabaseMySql.php b/src/libraries/adapters/DatabaseMySql.php index e1490a5ab..9a973c9bc 100644 --- a/src/libraries/adapters/DatabaseMySql.php +++ b/src/libraries/adapters/DatabaseMySql.php @@ -1879,14 +1879,15 @@ private function buildQuery($filters, $limit, $offset, $table) $where = $this->buildWhere($where, sprintf("`dateUploaded`<'%s'", $this->_(strtotime($value)))); break; case 'sortBy': + // default is dateTaken,desc if($value === 'dateTaken,desc') - $sortBy = 'ORDER BY dateSortByDay DESC'; + $sortBy = 'ORDER BY dateTaken DESC'; elseif($value === 'dateTaken,asc') - $sortBy = 'ORDER BY dateSortByDay ASC'; + $sortBy = 'ORDER BY `dateTaken` ASC'; elseif($value === 'dateUploaded,desc') - $sortBy = 'ORDER BY dateSortByDay DESC, dateUploaded ASC'; + $sortBy = 'ORDER BY `dateUploaded` DESC'; elseif($value === 'dateUploaded,asc') - $sortBy = 'ORDER BY dateSortByDay ASC, dateUploaded ASC'; + $sortBy = 'ORDER BY `dateUploaded` ASC'; else $sortBy = 'ORDER BY ' . $this->_(str_replace(',', ' ', $value)); $field = $this->_(substr($value, 0, strpos($value, ','))); diff --git a/src/libraries/controllers/ApiPhotoController.php b/src/libraries/controllers/ApiPhotoController.php index 62b7e672f..681f54def 100644 --- a/src/libraries/controllers/ApiPhotoController.php +++ b/src/libraries/controllers/ApiPhotoController.php @@ -238,6 +238,12 @@ public function list_($filterOpts = null) // this extracts local variables $permission, $filter, $pageSize, etc extract($this->parseFilters($filterOpts)); $db = getDb(); + + // on gallery sort by date uploaded, album date taken #1340 + $filters['sortBy'] = 'dateUploaded,desc'; + if(isset($filters['album'])) + $filters['sortBy'] = 'dateTaken,asc'; + $photos = $db->getPhotos($filters, $pageSize); if(empty($photos))