Skip to content

Commit

Permalink
Changing date sort logic to not group by date. See #1341 for discussion.
Browse files Browse the repository at this point in the history
Closes #1341 (meta)
Closes #735
Closes #1339
Closes #1286
Closes #1340
  • Loading branch information
jmathai committed Sep 30, 2013
1 parent e8a1359 commit 30d90bb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/html/assets/themes/fabrizio1.0/config/settings.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[site]
mediaVersion="df"
mediaVersion="dg"

[behavior]
useDefaultMobile="0"
Expand Down
10 changes: 5 additions & 5 deletions src/html/assets/themes/fabrizio1.0/templates/photos.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php $this->theme->display('partials/user-badge.php'); ?>

<div class="row">
<div class="span12 photo-grid <?php if(isset($album)) { ?>is-album<?php } ?>">
<div class="photo-grid-hr"></div>
<?php if(isset($album)) { ?>
<?php if(isset($album) && !empty($album)) { ?>
<h4>
<i class="icon-th-large"></i>
<?php $this->utility->safe($album['name']); ?>
Expand All @@ -13,11 +10,14 @@
<?php if($this->user->isAdmin()) { ?>
<span class="hide"> | <a href="#" class="shareAlbum share trigger" data-id="<?php $this->utility->safe($album['id']); ?>" title="Share this album"><i class="icon-share"></i> Share</a></span>
<?php } ?>
&middot; <i class="icon-sort-by-order" title="Photos sorted oldest taken to newest"></i>
)
</small>
</h4>
<?php } else if(isset($tags)) { ?>
<h4><i class="icon-tags"></i> <?php $this->utility->safe(implode(', ', $tags)); ?> <small>(<?php $this->utility->safe($photos[0]['totalRows']); ?> photos)</small></h4>
<h4><i class="icon-tags"></i> <?php $this->utility->safe(implode(', ', $tags)); ?> <small>(<?php $this->utility->safe($photos[0]['totalRows']); ?> photos &middot; <i class="icon-sort-by-order-alt" title="Photos sorted newest uploaded to oldest"></i>)</small></h4>
<?php } else { ?>
<h4><i class="icon-picture"></i> Gallery <small>( <?php $this->utility->safe($photos[0]['totalRows']); ?> photos &middot; <i class="icon-sort-by-order-alt" title="Photos sorted newest uploaded to oldest"></i> )</small></h4>
<?php } ?>
<?php if(!empty($photos)) { ?>
<script> var initData = <?php echo json_encode($photos); ?>; var filterOpts = <?php echo json_encode($options); ?>;</script>
Expand Down
9 changes: 5 additions & 4 deletions src/libraries/adapters/DatabaseMySql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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, ',')));
Expand Down
6 changes: 6 additions & 0 deletions src/libraries/controllers/ApiPhotoController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 30d90bb

Please sign in to comment.