Hide the calculation for "previous" and "next" behind a setting
This commit is contained in:
parent
021a4fad71
commit
7e846ba7ac
|
@ -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,35 +1341,38 @@ function photos_content(App $a) {
|
||||||
$prevlink = '';
|
$prevlink = '';
|
||||||
$nextlink = '';
|
$nextlink = '';
|
||||||
|
|
||||||
if ($_GET['order'] === 'posted')
|
|
||||||
$order = 'ASC';
|
|
||||||
else
|
|
||||||
$order = 'DESC';
|
|
||||||
|
|
||||||
/// @todo This query is totally bad, the whole functionality has to be changed
|
/// @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
|
// The query leads to a really intense used index.
|
||||||
$sql_extra ORDER BY `created` $order ",
|
// By now we hide it if someone wants to.
|
||||||
dbesc($ph[0]['album']),
|
if (!Config::get('system', 'no_count', false)) {
|
||||||
intval($owner_uid)
|
if ($_GET['order'] === 'posted')
|
||||||
);
|
$order = 'ASC';
|
||||||
|
else
|
||||||
|
$order = 'DESC';
|
||||||
|
|
||||||
if (count($prvnxt)) {
|
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
|
||||||
for($z = 0; $z < count($prvnxt); $z++) {
|
$sql_extra ORDER BY `created` $order ",
|
||||||
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
|
dbesc($ph[0]['album']),
|
||||||
$prv = $z - 1;
|
intval($owner_uid)
|
||||||
$nxt = $z + 1;
|
);
|
||||||
if ($prv < 0)
|
|
||||||
$prv = count($prvnxt) - 1;
|
if (count($prvnxt)) {
|
||||||
if ($nxt >= count($prvnxt))
|
for($z = 0; $z < count($prvnxt); $z++) {
|
||||||
$nxt = 0;
|
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
|
||||||
break;
|
$prv = $z - 1;
|
||||||
|
$nxt = $z + 1;
|
||||||
|
if ($prv < 0)
|
||||||
|
$prv = count($prvnxt) - 1;
|
||||||
|
if ($nxt >= count($prvnxt))
|
||||||
|
$nxt = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
|
||||||
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
|
$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];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user