okapi r817: fixed hint format

This commit is contained in:
following
2013-06-12 16:41:15 +02:00
parent e9222e8963
commit 9874a8cd23
5 changed files with 28 additions and 12 deletions

View File

@ -806,7 +806,7 @@ class Okapi
{
public static $data_store;
public static $server;
public static $revision = 810; # This gets replaced in automatically deployed packages
public static $revision = 817; # This gets replaced in automatically deployed packages
private static $okapi_vars = null;
/** Get a variable stored in okapi_vars. If variable not found, return $default. */

View File

@ -118,7 +118,7 @@ class WebService
# We don't need to do any additional queries here.
$fields = 'code|name|location|date_created|url|type|status|size|size2|oxsize'.
'|difficulty|terrain|description|hint|rating|owner|url|internal_id';
'|difficulty|terrain|description|hint2|rating|owner|url|internal_id';
if ($vars['images'] != 'none')
$fields .= "|images";
if ($vars['attrs'] != 'none')

View File

@ -113,7 +113,7 @@ http://www.gsak.net/xmlv1/5 http://www.gsak.net/xmlv1/5/gsak.xsd
</ul>
<? } ?>
</groundspeak:long_description>
<groundspeak:encoded_hints><?= Okapi::xmlescape($c['hint']) ?></groundspeak:encoded_hints>
<groundspeak:encoded_hints><?= Okapi::xmlescape($c['hint2']) ?></groundspeak:encoded_hints>
<? if ($vars['latest_logs']) { /* Does user want us to include latest log entries? */ ?>
<groundspeak:logs>
<? foreach ($c['latest_logs'] as $log) { ?>

View File

@ -177,12 +177,17 @@
<li><b>req_passwd</b> - boolean; states if this cache requires a password
in order to submit a "Found it" log entry,</li>
<li><b>description</b> - HTML string, description of the cache,</li>
<li><b>descriptions</b> - a dictionary (language code => HTML string) of cache
<li><b>descriptions</b> - a dictionary (language code =&gt; HTML string) of cache
descriptions,</li>
<li><b>hint</b> - plain-text string, cache hints/spoilers; in general, hints should not be displayed to the user
unless user specifically asks for them,</li>
<li><b>hints</b> - a dictionary (language code => plain-text string) of cache
hints/spoilers,</li>
<li class="deprecated"><b>hint</b> - HTML-encoded string, cache hints/spoilers;
deprecated (<a href="http://code.google.com/p/opencaching-api/issues/detail?id=261">Why?</a>),
use <b>hint2</b> instead,</li>
<li class="deprecated"><b>hints</b> - a dictionary (language code =&gt;
HTML-encoded string) of cache hints/spoilers; deprecated, use hints2 instead,</li>
<li><b>hint2</b> - plain-text string, cache hints/spoilers; in general, hints
should not be displayed to the user unless user specifically asks for them,</li>
<li><b>hints2</b> - a dictionary (language code =&gt;
plain-text string) of cache hints/spoilers,</li>
<li>
<p><b>images</b> - list of dictionaries, each dictionary represents one
image saved along the cache description; each dictionary has the

View File

@ -33,7 +33,7 @@ class WebService
'my_notes', 'trackables_count', 'trackables', 'alt_wpts', 'last_found',
'last_modified', 'date_created', 'date_hidden', 'internal_id', 'is_watched',
'is_ignored', 'willattends', 'country', 'state', 'preview_image',
'trip_time', 'trip_distance', 'attribution_note','gc_code');
'trip_time', 'trip_distance', 'attribution_note','gc_code', 'hint2', 'hints2');
public static function call(OkapiRequest $request)
{
@ -73,6 +73,7 @@ class WebService
if (
in_array('description', $fields) || in_array('descriptions', $fields)
|| in_array('hint', $fields) || in_array('hints', $fields)
|| in_array('hint2', $fields) || in_array('hints2', $fields)
|| in_array('attribution_note', $fields)
)
{
@ -317,6 +318,8 @@ class WebService
case 'descriptions': /* handled separately */ break;
case 'hint': /* handled separately */ break;
case 'hints': /* handled separately */ break;
case 'hint2': /* handled separately */ break;
case 'hints2': /* handled separately */ break;
case 'images': /* handled separately */ break;
case 'preview_image': /* handled separately */ break;
case 'attrnames': /* handled separately */ break;
@ -461,15 +464,18 @@ class WebService
# Descriptions and hints.
if (in_array('description', $fields) || in_array('descriptions', $fields)
|| in_array('hint', $fields) || in_array('hints', $fields))
|| in_array('hint', $fields) || in_array('hints', $fields)
|| in_array('hint2', $fields) || in_array('hints2', $fields))
{
# At first, we will fill all those 4 fields, even if user requested just one
# of them. We will chop off the remaining three at the end.
foreach ($results as &$result_ref)
{
$result_ref['descriptions'] = array();
foreach ($results as &$result_ref)
$result_ref['hints'] = array();
$result_ref['hints2'] = array();
}
# Get cache descriptions and hints.
@ -500,17 +506,22 @@ class WebService
$results[$cache_code]['descriptions'][strtolower($row['language'])] = $tmp;
}
if ($row['hint'])
{
$results[$cache_code]['hints'][strtolower($row['language'])] = $row['hint'];
$results[$cache_code]['hints2'][strtolower($row['language'])]
= htmlspecialchars_decode(mb_ereg_replace("<br />", "" , $row['hint']), ENT_COMPAT);
}
}
foreach ($results as &$result_ref)
{
$result_ref['description'] = Okapi::pick_best_language($result_ref['descriptions'], $langpref);
$result_ref['hint'] = Okapi::pick_best_language($result_ref['hints'], $langpref);
$result_ref['hint2'] = Okapi::pick_best_language($result_ref['hints2'], $langpref);
}
# Remove unwanted fields.
foreach (array('description', 'descriptions', 'hint', 'hints') as $field)
foreach (array('description', 'descriptions', 'hint', 'hints', 'hint2', 'hints2') as $field)
if (!in_array($field, $fields))
foreach ($results as &$result_ref)
unset($result_ref[$field]);