Skip to content
Permalink
Browse files

option to show new caches or logs for or without the selected country…

…; updates #183
  • Loading branch information...
following5 committed Aug 27, 2015
1 parent bfcb9e0 commit 72b1892ac9cf42c612818abe9ef80a07c062a967

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -229,24 +229,26 @@ function display($dummy1=null, $dummy2=null, $dummy3=null)
$optn['template']['title'] = $menu->GetMenuTitle();
// build address for switching locales
$locale_pageadr = $_SERVER['REQUEST_URI'];
$base_pageadr = $_SERVER['REQUEST_URI'];
// workaround for http://redmine.opencaching.de/issues/703
$strange_things_pos = strpos($locale_pageadr,".php/");
$strange_things_pos = strpos($base_pageadr,".php/");
if ($strange_things_pos)
$locale_pageadr = substr($locale_pageadr,0,$strange_things_pos + 4);
$lpos = strpos($locale_pageadr,"locale=");
$base_pageadr = substr($base_pageadr,0,$strange_things_pos + 4);
$lpos = strpos($base_pageadr,"locale=");
if (!$lpos) $lpos = strpos($base_pageadr,"usercountry=");
if (!$lpos) $lpos = strpos($base_pageadr,"country=");
if ($lpos)
$locale_pageadr = substr($locale_pageadr,0,$lpos);
$base_pageadr = substr($base_pageadr,0,$lpos);
else
{
$urx = explode('#', $locale_pageadr);
$locale_pageadr = $urx[0];
if (strpos($locale_pageadr,'?') == 0)
$locale_pageadr .= '?';
$urx = explode('#', $base_pageadr);
$base_pageadr = $urx[0];
if (strpos($base_pageadr,'?') == 0)
$base_pageadr .= '?';
else
$locale_pageadr .= '&';
$base_pageadr .= '&';
}
$this->assign('locale_pageadr', $locale_pageadr);
$this->assign('base_pageadr', $base_pageadr);
if ($opt['logic']['license']['disclaimer'])
{
@@ -10,7 +10,8 @@
$tpl->menuitem = MNU_START_NEWCACHES;
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat']+0 : 0;
$country = isset($_REQUEST['country']) ? $_REQUEST['country'] : '';
$country = isset($_REQUEST['country']) ? $_REQUEST['country'] :
(isset($_REQUEST['usercountry']) ? $_REQUEST['usercountry'] : '');
$cachetype = isset($_REQUEST['cachetype']) ? $_REQUEST['cachetype']+0 : 0;
$bEvents = ($cachetype == 6);
@@ -75,17 +76,17 @@
$tpl->assign('defaultcountry', $opt['template']['default']['country']);
$tpl->assign('countryCode', $country);
if ($country != '')
{
$tpl->assign(
'countryName',
sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'", '', $country, $opt['template']['locale'])
$tpl->assign(
'countryName',
sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'",
'',
$country ? $country : $login->getUserCountry(),
$opt['template']['locale'])
);
}
$tpl->assign('events', $bEvents);
}
@@ -7,19 +7,21 @@
require('./lib2/web.inc.php');
$tpl->name = 'newcachesrest';
$tpl->menuitem = MNU_START_NEWCACHESREST;
$tpl->menuitem = MNU_START_NEWCACHES;
$tpl->caching = true;
$tpl->cache_lifetime = 3600;
$country = isset($_REQUEST['country']) ? $_REQUEST['country'] : $login->getUserCountry();
if (!$tpl->is_cached())
{
require($opt['rootpath'] . 'lib2/logic/cacheIcon.inc.php');
$newCaches = array();
sql_temp_table_slave('cachelist');
sql_slave("CREATE TEMPORARY TABLE &cachelist (`cache_id` INT(11) PRIMARY KEY) SELECT `cache_id` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `cache_status`.`allow_user_view`=1 AND `country`!='DE' ORDER BY `date_created` DESC LIMIT 200");
sql_slave("CREATE TEMPORARY TABLE &cachelist (`cache_id` INT(11) PRIMARY KEY) SELECT `cache_id` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `cache_status`.`allow_user_view`=1 AND `country`!='". sql_escape($country) . "' ORDER BY `date_created` DESC LIMIT 200");
$rsNewCaches = sql_slave("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`) `country_name`, `caches`.`cache_id` `cacheid`, `caches`.`wp_oc` `wpoc`, `user`.`user_id` `userid`, `caches`.`country` `country`, `caches`.`name` `cachename`, `caches`.`type`, `caches`.`country` `country`, `user`.`username` `username`, `caches`.`date_created` `date_created`, `cache_type`.`icon_large` `icon_large`, `ca`.`attrib_id` IS NOT NULL AS `oconly`
FROM `caches`
@@ -43,6 +45,19 @@
sql_drop_temp_table_slave('cachelist');
$tpl->assign('newCaches', $newCaches);
$tpl->assign('countryCode', $country);
$tpl->assign(
'countryName',
sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'",
'',
$country,
$opt['template']['locale'])
);
}
$tpl->display();
@@ -15,7 +15,9 @@
if (isset($ownerid))
{
// all logs for caches of one owner
$country = false;
$exclude_country = '*';
$include_country = '%';
$add_where = "AND `caches`.`user_id`='" . sql_escape($ownerid) . "' ";
if (!$show_own_logs)
$add_where .= "AND `cache_logs`.`user_id`<>'" . sql_escape($login->userid) . "' ";
@@ -30,7 +32,9 @@
elseif (isset($userid))
{
// all logs by one user
$country = false;
$exclude_country = '*';
$include_country = '%';
$add_where = "AND `cache_logs`.`user_id`='" . sql_escape($userid) . "' ";
$tpl->caching = false;
$logcount = 100;
@@ -42,9 +46,9 @@
{
// latest logs for all countries but Germany
$tpl->name = 'newlogsrest';
$tpl->menuitem = MNU_START_NEWLOGSREST;
$exclude_country = 'DE';
$tpl->menuitem = MNU_START_NEWLOGS;
$country = $exclude_country = $login->getUserCountry();
$include_country = '%';
// As nearly all logs are from Germany, retrieving non-German logs is
// expensive -> longer cache lifetime.
$tpl->caching = true;
@@ -55,10 +59,19 @@
}
else
{
// latest logs for all countries
// latest logs for all countries or for one country
$tpl->name = 'newlogs';
$tpl->menuitem = MNU_START_NEWLOGS;
$exclude_country = '*';
if (isset($_REQUEST['country']))
$country = $include_country = $_REQUEST['country'];
else if (isset($_REQUEST['usercountry']))
$country = $include_country = $_REQUEST['usercountry'];
else
{
$country = '';
$include_country = '%';
}
$tpl->caching = true;
$tpl->cache_lifetime = 300;
$logcount = 250;
@@ -79,11 +92,13 @@
INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id`
INNER JOIN `user` ON `cache_logs`.`user_id`=`user`.`user_id`
WHERE `cache_status`.`allow_user_view`=1
AND `caches`.`country`<>'&1'
AND `username`<>'&2'".
AND `caches`.`country` LIKE '&1'
AND `caches`.`country`<>'&2'
AND `username`<>'&3'".
$add_where."
ORDER BY " . $orderByDate . "`cache_logs`.`date_created` DESC
LIMIT &3, &4",
LIMIT &4, &5",
$include_country,
$exclude_country,
isset($_GET['showsyslogs']) ? '' : $opt['logic']['systemuser']['user'],
$startat,
@@ -192,6 +207,19 @@
$tpl->assign('addpiclines', max($pics-1,0));
$tpl->assign('newLogsPerCountry', $newLogsPerCountry);
$tpl->assign('countryCode', $country);
$tpl->assign(
'countryName',
sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)
FROM `countries`
LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`
LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'
WHERE `countries`.`short`='&1'",
'',
$country ? $country : $login->getUserCountry(),
$opt['template']['locale'])
);
$tpl->assign('paging', $paging);
if ($paging)
{
@@ -339,6 +339,7 @@ td.content-title-flag {
.content-subtitle { color: #426d7e; }
.subtitle { font-weight:bold; }
.subtitle-header { font-weight:bold; line-height: 1.6em }
p.subtitle-select { line-height:2.5em; }

/* Headings */
h1 {margin: 1.0em 0px 0.5em 0px; font-weight: bold; font-size: 160%;}
@@ -9,9 +9,19 @@
{if $events}{t}Planned events{/t}{elseif $countryCode == ''}{t}Latest caches{/t}{else}{t 1=$countryName|escape}Newest caches in %1{/t}{/if}
</div>

{if !$events}
<p class="subtitle-select">
[{if $countryCode == ''}<b>{else}<a href="newcaches.php" class="systemlink">{/if}{t}All caches{/t}{if $countryCode == ''}</b>{else}</a>{/if}]
&nbsp;&ndash;&nbsp;
[{if $countryCode != ''}<b>{else}<a href="newcaches.php?country={$opt.template.country}" class="systemlink">{/if}{t 1=$countryName}Caches in %1{/t}{if $countryCode != ''}</b>{else}</a>{/if}]
&nbsp;&ndash;&nbsp;
[<a href="newcachesrest.php{if $countryCode != ''}?country={$countryCode}{/if}" class="systemlink">{t 1=$countryName}Caches without %1{/t}</a>]
</p>
{/if}

<table width="100%" class="table">
<tr>
<td colspan="3" class="header-small">
<td colspan="3" class="header-small" >
{include file="res_pager.tpl"}
</td>
</tr>
@@ -20,7 +30,7 @@
{foreach name=newCaches from=$newCaches item=newCache}
<tr>
<td style="width:1%; vertical-align:center">{$newCache.date_created|date_format:$opt.format.date}</td>
<td class="listicon"><img src="resource2/{$opt.template.style}/images/cacheicon/16x16-{$newCache.type}.gif" width="16" height="16" border="0" /></td><td style="vertical-align:center"> <a href="viewcache.php?wp={$newCache.wpoc}">{$newCache.cachename|escape}</a> {include file="res_oconly.tpl" oconly=$newCache.oconly} {t}by{/t} <a href="viewprofile.php?userid={$newCache.userid}">{$newCache.username|escape}</a> {if $countryCode == '' && $newCache.country != $defaultcountry}&nbsp;&nbsp;<img src="images/flags/{$newCache.country|lower}.gif" alt="({$newCache.country_name})" title="{$newCache.country_name}" />{/if} </td>
<td class="listicon">{if $events}<img src="resource2/{$opt.template.style}/images/cacheicon/event-rand{rand min=1 max=4}.gif" alt="{t}Event Geocache{/t}" border="0" width="22" height="22" align="left" style="margin-right: 5px;" />{else}<img src="resource2/{$opt.template.style}/images/cacheicon/16x16-{$newCache.type}.gif" width="16" height="16" border="0" />{/if}</td><td style="vertical-align:center"> <a href="viewcache.php?wp={$newCache.wpoc}">{$newCache.cachename|escape}</a> {include file="res_oconly.tpl" oconly=$newCache.oconly} {t}by{/t} <a href="viewprofile.php?userid={$newCache.userid}">{$newCache.username|escape}</a> {if $countryCode == '' && $newCache.country != $defaultcountry}&nbsp;&nbsp;<img src="images/flags/{$newCache.country|lower}.gif" alt="({$newCache.country_name})" title="{$newCache.country_name}" />{/if} </td>
</tr>
{/foreach}

@@ -5,10 +5,18 @@
***************************************************************************}
{* OCSTYLE *}
<div class="content2-pagetitle">
<img src="resource2/{$opt.template.style}/images/cacheicon/traditional.gif" style="margin-right: 10px;" width="32" height="32" alt="{t}Latest caches without germany{/t}" />
{t}Latest caches without germany{/t}
<img src="resource2/{$opt.template.style}/images/cacheicon/traditional.gif" style="margin-right: 10px;" width="32" height="32" alt="" />
{t}{t 1=$countryName}Latest caches without %1{/t}
</div>

<p class="subtitle-select">
[<a href="newcaches.php" class="systemlink">{t}All caches{/t}</a>]
&nbsp;&ndash;&nbsp;
[<a href="newcaches.php?country={$opt.template.country}" class="systemlink">{t 1=$countryName}Caches in %1{/t}</a>]
&nbsp;&ndash;&nbsp;
[<b>{t 1=$countryName}Caches without %1{/t}</b>]
</p>

<table width="100%" class="table">
{assign var='lastCountry' value=''}

@@ -16,10 +16,31 @@
{elseif $ownlogs}
{t}Your log entries{/t}
{else}
{t}Latest logs entries{/t} {if $rest}{t}Without Germany{/t}{/if}
{if $rest}{t 1=$countryName}Latest log entries without %1{/t}{elseif $countryCode}{t 1=$countryName}Latest log entries in %1{/t}{else}{t}Latest logs entries{/t}{/if}
{/if}
</div>

{if $rest}
<p class="subtitle-select">
[<a href="newlogs.php" class="systemlink">{t}All logs{/t}</a>]
&nbsp;&ndash;&nbsp;
[<a href="newlogs.php?country={$opt.template.country}" class="systemlink">{t 1=$countryName}Logs in %1{/t}</a>]
&nbsp;&ndash;&nbsp;
[<b>{t 1=$countryName}Logs without %1{/t}</b>]
</p>
{elseif $countryCode !== false}
<p class="subtitle-select">
[{if $countryCode == ''}<b>{else}<a href="newlogs.php" class="systemlink">{/if}{t}All logs{/t}{if $countryCode == ''}</b>{else}</a>{/if}]
&nbsp;&ndash;&nbsp;
[{if $countryCode != ''}<b>{else}<a href="newlogs.php?country={$opt.template.country}" class="systemlink">{/if}{t 1=$countryName}Logs in %1{/t}{if $countryCode != ''}</b>{else}</a>{/if}]
&nbsp;&ndash;&nbsp;
[<a href="newlogsrest.php" class="systemlink">{t 1=$countryName}Logs without %1{/t}</a>]
</p>
{/if}

{if !$rest && $countryCode}
<div style="height:4px"></div>
{/if}
<p style="line-height:2em">
{if $paging}
{include file="res_pager.tpl"}
@@ -38,7 +59,7 @@
{assign var='lastCountry' value=''}

{foreach name=newLogs from=$newLogs item=newLog}
{if $newLogsPerCountry}
{if $newLogsPerCountry && ($rest || !$countryCode)}
{if $newLog.country_name!=$lastCountry}
<tr><td class="spacer"></td></tr>
<tr><td colspan="3">
@@ -5,4 +5,4 @@
***************************************************************************}
{* OCSTYLE *}

{include file="newlogs.tpl" ownerlogs=true}
{include file="newlogs.tpl" ownerlogs=true countryCode=false}
@@ -5,4 +5,4 @@
***************************************************************************}
{* OCSTYLE *}

{include file="newlogs.tpl" ownlogs=true}
{include file="newlogs.tpl" ownlogs=true countryCode=false}
@@ -146,8 +146,8 @@
<div class="content2-container bg-blue02">
<p class="content-title-noshade-size3">
<img src="resource2/{$opt.template.style}/images/cacheicon/traditional.gif" style="margin-right: 10px;" width="24" height="24" alt="" />
<a href="newcaches.php" style="color:rgb(88,144,168); text-decoration: none;">{t 1=$usercountry|escape}Newest caches in %1{/t}</a>
&nbsp; <span class="content-title-link">[<a href="newcaches.php?country={$usercountryCode}">{t}more{/t}...</a>]</span>
<a href="newcaches.php?country={$usercountryCode}" style="color:rgb(88,144,168); text-decoration: none;">{t 1=$usercountry|escape}Newest caches in %1{/t}</a>
&nbsp; <span class="content-title-link">[<a href="newcaches.php">{t}more{/t}...</a>]</span>
</p>
</div>
<p style="line-height: 1.6em;">({t 1=$count_hiddens 2=$count_founds 3=$count_users}Total of %1 active Caches and %2 founds by %3 users{/t})</p>
@@ -54,7 +54,7 @@
if (sCurrentOption!=oUserCountryCombo.value)
{
window.location = 'index.php?usercountry=' + oUserCountryCombo.value;
window.location = '{/literal}{$base_pageadr}{literal}usercountry=' + oUserCountryCombo.value;
}
}

@@ -146,7 +146,7 @@
<td>
{foreach from=$opt.template.locales key=localeKey item=localeItem}
{if $localeItem.show}
<a style="text-decoration: none;" href="{$locale_pageadr}locale={$localeKey}"><img src="{$localeItem.flag}" alt="{$localeItem.name|escape}" width="24px" height="18px" /></a>
<a style="text-decoration: none;" href="{$base_pageadr}locale={$localeKey}"><img src="{$localeItem.flag}" alt="{$localeItem.name|escape}" width="24px" height="18px" /></a>
{/if}
{/foreach}
</td>

0 comments on commit 72b1892

Please sign in to comment.
You can’t perform that action at this time.