Hide the calculation for "previous" and "next" behind a setting

This commit is contained in:
Michael 2017-01-15 14:50:26 +00:00
parent 021a4fad71
commit 7e846ba7ac

View File

@ -10,6 +10,8 @@ require_once('include/tags.php');
require_once('include/threads.php'); require_once('include/threads.php');
require_once('include/Probe.php'); require_once('include/Probe.php');
use \Friendica\Core\Config;
function photos_init(App $a) { function photos_init(App $a) {
if ($a->argc > 1) if ($a->argc > 1)
@ -1339,12 +1341,15 @@ function photos_content(App $a) {
$prevlink = ''; $prevlink = '';
$nextlink = ''; $nextlink = '';
/// @todo This query is totally bad, the whole functionality has to be changed
// The query leads to a really intense used index.
// By now we hide it if someone wants to.
if (!Config::get('system', 'no_count', false)) {
if ($_GET['order'] === 'posted') if ($_GET['order'] === 'posted')
$order = 'ASC'; $order = 'ASC';
else else
$order = 'DESC'; $order = 'DESC';
/// @todo This query is totally bad, the whole functionality has to be changed
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0 $prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
$sql_extra ORDER BY `created` $order ", $sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']), dbesc($ph[0]['album']),
@ -1367,7 +1372,7 @@ function photos_content(App $a) {
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : ''); $nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
} }
}
if (count($ph) == 1) if (count($ph) == 1)
$hires = $lores = $ph[0]; $hires = $lores = $ph[0];