fixed newlogs piclinks; added myhome and viewcache pic paging

This commit is contained in:
following
2013-03-17 21:18:54 +01:00
parent 1a9592159c
commit cc2fc6c25e
15 changed files with 103 additions and 91 deletions

View File

@ -53,10 +53,6 @@
define('MAX_LOGENTRIES_ON_CACHEPAGE', 5);
define('MAX_PICTURES_PER_GALLERY_PAGE', 48); // must be multiple of 6
define('MAX_PICTURES_IN_CACHE_GALLERY', 120); // must be multiple of 6
// As of march 2013, there are a good deal of OC.de caches with 50-100 pics,
// but only one with more (~500 pics). If lots of caches have >100 pics,
// it may pay out to limit the gallery e.g. to 60 pics and implement browsing.
// constants for user options (must match values in DB!)
define('USR_OPT_GMZOOM', 1);

View File

@ -15,13 +15,13 @@
define('LOGPICS_FOR_STARTPAGE_GALLERY', 1);
define('LOGPICS_FOR_NEWPICS_GALLERY', 2);
define('LOGPICS_FOR_USER_STAT', 3);
define('LOGPICS_FOR_USER_GALLERY', 4); // params: userid, startat
define('LOGPICS_FOR_USER_GALLERY', 4); // params: userid
define('LOGPICS_FOR_MYHOME_GALLERY', 5);
define('LOGPICS_FOR_CACHE_STAT', 6); // params: cacheid
define('LOGPICS_FOR_CACHE_GALLERY', 7); // params: userid, cacheid
function get_logpics($purpose, $userid=0, $cacheid=0, $startat=0)
function get_logpics($purpose, $userid=0, $cacheid=0)
{
global $login;
@ -117,8 +117,7 @@ function get_logpics($purpose, $userid=0, $cacheid=0, $startat=0)
$join_caches
$join_cachestatus
WHERE `object_type`=1 AND `logs`.`user_id`='&1' AND NOT `spoiler`
ORDER BY `logs`.`date` DESC
LIMIT &2, &3", $userid, $startat, MAX_PICTURES_PER_GALLERY_PAGE+1);
ORDER BY `logs`.`date` DESC", $userid);
break;
case LOGPICS_FOR_MYHOME_GALLERY:
@ -155,8 +154,7 @@ function get_logpics($purpose, $userid=0, $cacheid=0, $startat=0)
($userid == $login->userid ? "" : "$join_caches $join_cachestatus") . "
$join_user
WHERE `object_type`=1 AND `logs`.`cache_id`='&1'
ORDER BY `logs`.`date` DESC
LIMIT &2", $cacheid, MAX_PICTURES_IN_CACHE_GALLERY+1);
ORDER BY `logs`.`date` DESC", $cacheid);
break;
default:
@ -171,5 +169,52 @@ function get_logpics($purpose, $userid=0, $cacheid=0, $startat=0)
return $result;
}
// set all template variables needed to display log pictures page browser;
// all displaying is done in res_logpictures.tpl
function set_paged_pics($purpose, $userid, $cacheid, $tpl, $url)
{
global $_REQUEST;
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat']+0 : 0;
$pictures = get_logpics($purpose, $userid, $cacheid);
$tpl->assign('pictures', array_slice($pictures, $startat, MAX_PICTURES_PER_GALLERY_PAGE));
$paging = (count($pictures) > MAX_PICTURES_PER_GALLERY_PAGE);
$tpl->assign('paging', $paging);
if ($paging)
{
$pages = floor((count($pictures) + MAX_PICTURES_PER_GALLERY_PAGE - 1)/MAX_PICTURES_PER_GALLERY_PAGE);
$page = floor($startat/MAX_PICTURES_PER_GALLERY_PAGE) + 1;
$pl = "";
/* paging overhead - does not look nice ...
if ($startat > 0)
$pl .= "<a href='" . $url . "&startat=" . ($startat - MAX_PICTURES_PER_GALLERY_PAGE) . "'>&lt;</a> ";
else
$pl .= "&lt; ";
*/
for ($p=1; $p<=$pages; $p++)
{
if ($pl != "") $pl .= " ";
if ($p != $page) $pl .= "<a href='" . $url . "&startat=" . (($p-1)*MAX_PICTURES_PER_GALLERY_PAGE) . "'>";
else $pl .= "<strong>";
$pl .= $p;
if ($p != $page) $pl .= "</a>";
else $pl .= "</strong>";
}
/*
if ($startat + MAX_PICTURES_PER_GALLERY_PAGE < count($pictures))
$pl .= " <a href='" . $url . "&startat=" . ($startat + MAX_PICTURES_PER_GALLERY_PAGE) . "'>&gt;</a> ";
else
$pl .= " &gt;";
*/
$tpl->assign('pagelinks', $pl);
}
}
?>

View File

@ -52,8 +52,12 @@
// $tpl->assign('emails', sql_value("SELECT COUNT(*) FROM `email_user` WHERE `from_user_id`='&1'", 0, $login->userid));
// get log pictures
$tpl->assign('pictures', get_logpics(LOGPICS_FOR_MYHOME_GALLERY));
$tpl->assign('allpics', isset($_REQUEST['allpics']) && $_REQUEST['allpics'] ? 1 : 0);
$allpics = isset($_REQUEST['allpics']) && $_REQUEST['allpics'];
if ($allpics)
set_paged_pics(LOGPICS_FOR_MYHOME_GALLERY, 0, 0, $tpl, "myhome.php?allpics=1");
else
$tpl->assign('pictures',get_logpics(LOGPICS_FOR_MYHOME_GALLERY));
$tpl->assign('allpics', $allpics ? 1 : 0);
// display
$tpl->display();

View File

@ -54,16 +54,24 @@
if ($pics <= 0 ||
($pics == $lines_per_pic && count($newLogs)==1 && !$newLogs[0]['picshow']))
{
$rsPic = sql_slave("SELECT `uuid` FROM `pictures`
$rsPic = sql_slave("SELECT `uuid`,`url`,`title` FROM `pictures`
WHERE `object_type`=1 AND `object_id`='&1'
AND `local`=1 AND `display`=1 AND `spoiler`=0 AND `unknown_format`=0
LIMIT 1", $rLog['id']);
if ($rPic = sql_fetch_assoc($rsPic))
{
if (count($newLogs))
{
$newLogs[count($newLogs)-1]['pic_uuid'] = $rPic['uuid'];
$newLogs[count($newLogs)-1]['pic_url'] = $rPic['url'];
$newLogs[count($newLogs)-1]['title'] = $rPic['title'];
}
else
{
$rLog['pic_uuid'] = $rPic['uuid'];
$rLog['pic_url'] = $rPic['url'];
$rLog['title'] = $rPic['title'];
}
$rLog['picshown'] = true;
$pics = $lines_per_pic;
}

View File

@ -1388,6 +1388,12 @@ div#havefound {
color: #819ac1;
}
.picpaging {
text-align: right;
font-size: 1.2em;
margin: 0 0 6px 0;
}
/* RSS feeds */
#blog div.newsblock { margin-left:00px }
#forum div.newsblock { margin-left:20px }

View File

@ -5,14 +5,6 @@ General Public License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version. See LICENSE.TXT
for details. */
// disable non-javascript fallback links do that enlargeit receives the mouse clicks
function remove_piclinks()
{
var piclinks = document.getElementsByName("piclink");
for (var pic=0; pic<piclinks.length; pic++)
piclinks[pic].removeAttribute('href');
}
// modify these
var enl_gifpath='./resource2/ocstyle/js/enlargeit/'; // path to graphics
var enl_brdsize=6; // border thickness (5-30)

View File

@ -51,7 +51,7 @@
[<a href="myhome.php?allpics=1">{t}Show all{/t}</a>] - <b>{t}Your latest log pictures{/t}:</b></p>
{assign var=maxlines value=1}
{else}
<b>{t}Your log pictures{/t}:</b>
{assign var=subtitle value="{t}Your log pictures{/t}:"}
{assign var=maxlines value=0}
{/if}
</p>

View File

@ -67,4 +67,4 @@
</tr>
{assign var='lastCountry' value=$newLog.country_name}
{/foreach}
</table>
</table>

View File

@ -45,9 +45,3 @@
{* $log != "N" *}
{/if}
<script type="text/javascript">
<!--
remove_piclinks();
-->
</script>

View File

@ -2,8 +2,8 @@
<table width="100%" height="100%"><tr>
<td style="text-align:center; padding:0" align="center" valign="middle">
<div style="max-width:{$itemwidth}px; overflow:hidden">
<a name="piclink" href="{$picture.pic_url}">
<img src="thumbs.php?uuid={$picture.pic_uuid}" class="img-shadow-loggallery" onclick="enlarge(this);" longdesc="{$picture.pic_url}" onload="this.alt='{$picture.title}'" />
<a id="pl{$picture.pic_uuid}" href="{$picture.pic_url}">
<img src="thumbs.php?uuid={$picture.pic_uuid}" class="img-shadow-loggallery" onclick="enlarge(this);" longdesc="{$picture.pic_url}" onload="document.getElementById('pl{$picture.pic_uuid}').removeAttribute('href'); this.alt='{$picture.title}'"/>
</a>
{if $logdate || $loguser}
<div style="line-height:1.2em; max-height:2.4em; margin-top:5px">

View File

@ -1,5 +1,18 @@
{* see lib2/logic/logpics.inc.php for data retreival *}
{if $paging}
<div class="content2-container">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td><font size="2">{$subtitle}</font></td>
<td class="picpaging">{t}Page{/t} {$pagelinks}</td>
</tr>
</table>
</div>
{elseif "$subtitle" != ""}
<p>{$subtitle}</p>
{/if}
{assign var=itemwidth value=120}
<div style="padding-right:14px; clear:both">
@ -21,18 +34,12 @@
{/if}
{/foreach}
{* fill up remaining cells so that 2..5 pictures will not spread over container width *}
{if $piccount<6}<td width="{$itemwidth+6}px"></td>{/if}
{if $piccount<5}<td width="{$itemwidth+6}px"></td>{/if}
{if $piccount<4}<td width="{$itemwidth+6}px"></td>{/if}
{if $piccount<3}<td width="{$itemwidth+6}px"></td>{/if}
{if $piccount<2}<td width="{$itemwidth+6}px"></td>{/if}
{if $piccount<6}<td width="{$itemwidth+4}px"></td>{/if}
{if $piccount<5}<td width="{$itemwidth+4}px"></td>{/if}
{if $piccount<4}<td width="{$itemwidth+4}px"></td>{/if}
{if $piccount<3}<td width="{$itemwidth+4}px"></td>{/if}
{if $piccount<2}<td width="{$itemwidth+4}px"></td>{/if}
</tr>
</table>
<div style="height:8px"></div>
</div>
<script type="text/javascript">
<!--
remove_piclinks();
-->
</script>

View File

@ -140,20 +140,11 @@
</div>
<!-- End Cachemeta -->
<!-- Warning, if temporary not available, archived or locked -->
{include file="res_state_warning.tpl" cache=$cache}
<!-- End Warning -->
{if $show_logpics}
<!-- picture gallery -->
<div class="content2-container">
<p>&lt;&lt; <a href="viewcache.php?cacheid={$cache.cacheid|urlencode}">{t}Back to the cache description{/t}</a></p>
{include file="res_logpictures.tpl" logdate=true loguser=true profilelink=true shortyear=true}
{if $morepics}
<p>{t 1=$maxpics}Only the last %1 pictures are displayed.{/t}</p>
{/if}
{if $cache.type != 5 && $cache.type != 6}
<br />
<img src="resource2/{$opt.template.style}/images/misc/hint.gif" border="0" width="15" height="11" alt="" align="middle" />
@ -162,6 +153,10 @@
</div>
{else}
<!-- Warning, if temporary not available, archived or locked -->
{include file="res_state_warning.tpl" cache=$cache}
<!-- End Warning -->
<!-- Cachedetails -->
<div class="content2-container">
<div class="content2-container-2col-left" id="viewcache-baseinfo">

View File

@ -9,13 +9,6 @@
{t 1=$username}Log pictures of %1{/t}
</div>
{if $paging}
<div class="content2-container" style="text-align:right" >
<p>{t}Page{/t} {$pagelinks}</p>
</div>
{/if}
{include file="res_logpictures.tpl" logdate=true loguser=false fullyear=true}
<p><br />{t}All pictures are copyrighted. If you want to use them, ask the picture author for permission. From April 7, 2013, the logs including pictures may be used in unchanged form under the terms of the new <a href="articles.php?page=impressum#datalicense">data license</a>.{/t}</p>

View File

@ -281,11 +281,10 @@ function getChildWaypoints($cacheid)
$tpl->assign('show_logpics', $logpics ? 1 : 0);
if ($logpics)
{
$pictures = get_logpics(LOGPICS_FOR_CACHE_GALLERY, 0, $cacheid);
$tpl->assign('morepics', count($pictures) > MAX_PICTURES_IN_CACHE_GALLERY);
$tpl->assign('maxpics', MAX_PICTURES_IN_CACHE_GALLERY);
array_splice($pictures, MAX_PICTURES_IN_CACHE_GALLERY);
$tpl->assign('pictures', $pictures);
set_paged_pics(LOGPICS_FOR_CACHE_GALLERY, 0, $cacheid, $tpl, "viewcache.php?cacheid=" . $cacheid . "&logpics=1");
$tpl->assign('subtitle',"&lt;&lt; <a href='viewcache.php?cacheid=" . $cacheid . "'>" .
$translate->t("Back to the cache description", "", "", 0) . "</a>");
}
else
$tpl->assign('logpics', get_logpics(LOGPICS_FOR_CACHE_STAT, 0, $cacheid));

View File

@ -16,7 +16,6 @@
$userid = isset($_REQUEST['userid']) ? $_REQUEST['userid']+0 : 0;
$allpics = isset($_REQUEST['allpics']) ? $_REQUEST['allpics']+0 : 0;
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat']+0 : 0;
$rs = sql("SELECT `user`.`username`,
`user`.`last_login`,
@ -108,33 +107,7 @@
$tpl->assign('logpics', get_logpics(LOGPICS_FOR_USER_STAT, $userid));
else
{
$pictures = get_logpics(LOGPICS_FOR_USER_GALLERY, $userid, 0, $startat);
$more = (count($pictures) > MAX_PICTURES_PER_GALLERY_PAGE);
if ($more)
array_splice($pictures, MAX_PICTURES_PER_GALLERY_PAGE);
$tpl->assign('pictures', $pictures);
$paging = $more || ($startat>0 && count($pictures)>0);
$tpl->assign('paging', $paging);
if ($paging)
{
$pages = floor((get_logpics(LOGPICS_FOR_USER_STAT, $userid) + MAX_PICTURES_PER_GALLERY_PAGE - 1)/MAX_PICTURES_PER_GALLERY_PAGE);
$page = floor($startat/MAX_PICTURES_PER_GALLERY_PAGE) + 1;
$pl = "";
for ($p=1; $p<=$pages; $p++)
{
if ($pl != "") $pl .= " ";
if ($p != $page) $pl .= "<a href='viewprofile.php?userid=" . $userid . "&allpics=1&startat=" . (($p-1)*MAX_PICTURES_PER_GALLERY_PAGE) . "'>";
else $pl .= "<strong>";
$pl .= $p;
if ($p != $page) $pl .= "</a>";
else $pl .= "</strong>";
}
$tpl->assign('pagelinks', $pl);
}
set_paged_pics(LOGPICS_FOR_USER_GALLERY, $userid, 0, $tpl, "viewprofile.php?userid=" . $userid . "&allpics=1");
$tpl->name = 'viewprofile_pics';
// actually we dont need all the other stuff here ..
}