some search.php refactoring; fixed 'ignore' checkbox

This commit is contained in:
following 2013-07-18 12:06:41 +02:00
parent e0cce5c679
commit a7879a0bce
5 changed files with 34 additions and 24 deletions

View File

@ -58,6 +58,10 @@
define('MAX_LOGENTRIES_ON_CACHEPAGE', 5);
define('MAX_PICTURES_PER_GALLERY_PAGE', 48); // must be multiple of 6
// threshold for caches to be marked as "new"
// changed from 7 to 14 -- following 2013/6/17
$NEWCACHES_DAYS = 14;
// constants for user options (must match values in DB!)
define('USR_OPT_GMZOOM', 1);
define('USR_OPT_SHOWSTATS', 5);

View File

@ -31,9 +31,9 @@
function search_output()
{
global $opt, $tpl, $login;
global $newcache_days, $showonmap;
global $calledbysearch, $options, $lat_rad, $lon_rad, $distance_unit;
global $opt, $tpl, $login, $NEWCACHES_DAYS;
global $search_in_gm, $search_in_gm_zip;
global $called_by_search, $called_by_profile_query, $options, $lat_rad, $lon_rad, $distance_unit;
global $startat, $caches_per_page, $sql;
$tpl->name = 'search.result.caches';
@ -76,7 +76,7 @@ function search_output()
// decide if the cache is new
$dDiff = abs(dateDiff('d', $rCache['date_created'], date('Y-m-d')));
$rCache['isnew'] = ($dDiff <= $newcache_days);
$rCache['isnew'] = ($dDiff <= $NEWCACHES_DAYS);
// get last logs
if ($options['sort'] != 'bymylastlog' || !$login->logged_in())
@ -113,8 +113,6 @@ function search_output()
$pager = new pager('search.php?queryid=' . $options['queryid'] . '&startat={offset}', 2, 9);
$pager->make_from_offset($startat, $resultcount, $caches_per_page);
$tpl->assign('showonmap', $showonmap);
// downloads
$tpl->assign('queryid', $options['queryid']);
@ -133,7 +131,18 @@ function search_output()
$tpl->assign('distanceunit', $distance_unit);
$tpl->assign('displayownlogs', $options['sort'] == 'bymylastlog');
$tpl->assign('search_headline_caches', $calledbysearch);
$tpl->assign('search_headline_caches', $called_by_search);
if ($called_by_profile_query)
{
$tpl->assign('search_in_gm', '');
$tpl->assign('search_in_gm_zip', '');
}
else
{
$tpl->assign('search_in_gm', $search_in_gm);
$tpl->assign('search_in_gm_zip', $search_in_gm_zip);
}
$tpl->display();
}

View File

@ -1471,6 +1471,6 @@ div#havefound {
#forum div.rsstext img {max-width:200px; max-height:120px;}
p.editlog { font-weight: 400; display:inline; }
.newsymbol { background:#ff9d11; color:#fff; }
.newsymbol { background:#ff9d11; color:#fff; font-size:0.9em;}
label.disabled { color:grey; }

View File

@ -18,6 +18,9 @@
calls the output formatting module as specified by the 'output' parameter.
If 'showresult' != 1, the query search form is presented to the user.
Note that 'showresult' is also stored in saved queries, so it can be
automatically included when the 'queryid' parameter is given.
search type options:
searchbyname
searchbydistance
@ -44,10 +47,9 @@
To do:
- port attributes code to lib2 code as used by map2 (see outputSearchForm)
- port attributes code to res_attribgroup.tpl (see outputSearchForm)
- port output data list generation from prepareLocSelectionForm and
outputLocidSelectionForm to search_selectlocid.tpl.
- merge search.tpl.inc.php into search.tpl
- wtf is "expert mode"?
****************************************************************************/
@ -72,20 +74,17 @@
// Determine if search.php was called by a search function ('Caches' menu,
// stored query etc.) or for other purpose (e.g. user profile cache lists):
$calledbysearch = isset($_REQUEST['calledbysearch']) && $_REQUEST['calledbysearch'];
// default template variables
$tpl->assign('search_in_gm', $search_in_gm);
$tpl->assign('search_in_gm_zip', $search_in_gm_zip);
$called_by_search = isset($_REQUEST['calledbysearch']) && $_REQUEST['calledbysearch'];
$called_by_profile_query = false;
if (isset($_REQUEST['queryid']) || isset($_REQUEST['showresult']))
{ // Ocprop: showresult, queryid
$bCookieQueryid = false;
$queryid = isset($_REQUEST['queryid']) ? $_REQUEST['queryid'] : 0;
if ($queryid)
if ($queryid &&
sql_value("SELECT `user_id` FROM `queries` WHERE `id`='&1'", 0, $queryid))
{
$tpl->assign('search_in_gm', '');
$tpl->assign('search_in_gm_zip', '');
$called_by_profile_query = true;
}
}
else
@ -210,7 +209,7 @@
// build search options from GET/POST parameters or default values
// hack
if(isset($_REQUEST['searchto']) && ($_REQUEST['searchto'] != ''))
if (isset($_REQUEST['searchto']) && ($_REQUEST['searchto'] != ''))
{
unset($_REQUEST['searchbyname']);
unset($_REQUEST['searchbydistance']);
@ -1300,7 +1299,8 @@
//
// The following variables from search.php are used by output modules:
//
// $calledbysearch
// $called_by_search
// $called_by_profile_query
// $distance_unit
// $lat_rad, $lon_rad
// $startat
@ -1411,7 +1411,7 @@ function outputSearchForm($options)
$tpl->assign('hidopt_disabled', ($options['f_disabled'] == 1) ? '1' : '0');
$tpl->assign('f_ignored_disabled', !$login->logged_in());
$tpl->assign('f_ignored_disabled', $login->logged_in() && ($options['f_ignored'] == 1));
$tpl->assign('f_ignored_checked', $login->logged_in() && ($options['f_ignored'] == 1));
$tpl->assign('hidopt_ignored', ($options['f_ignored'] == 1) ? '1' : '0');
$tpl->assign('f_otherPlatforms_checked', $options['f_otherPlatforms'] == 1);

View File

@ -5,8 +5,6 @@
Unicode Reminder メモ
variable search template contents
Todo: Integrate into search.tpl
****************************************************************************/
// search.php -> $tpl->error
@ -32,7 +30,6 @@
$no_location_coords = _('no coordinates available');
// search.html.inc.php -> search.result.caches.tpl
$newcache_days = 14; // changed from 7 to 14 -- following 2013/6/17
$caches_newstring = '<b class="newsymbol">&nbsp;' . _('NEW') . '&nbsp;</b>&nbsp;';
$caches_oconlystring = '<img src="resource2/ocstyle/images/misc/is_oconly.png" alt="OConly" title="OConly" style="margin:0px; padding:0px" width="64" height="35" />';