本文整理汇总了PHP中okapi\Okapi::fix_oc_html方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::fix_oc_html方法的具体用法?PHP Okapi::fix_oc_html怎么用?PHP Okapi::fix_oc_html使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类okapi\Okapi
的用法示例。
在下文中一共展示了Okapi::fix_oc_html方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
//.........这里部分代码省略.........
}
# is_ignored
if (in_array('is_ignored', $fields)) {
if ($request->token == null) {
throw new BadRequest("Level 3 Authentication is required to access 'is_ignored' field.");
}
$tmp = Db::select_column("\n select c.wp_oc\n from\n caches c,\n cache_ignore ci\n where\n c.cache_id = ci.cache_id\n and ci.user_id = '" . mysql_real_escape_string($request->token->user_id) . "'\n ");
$tmp2 = array();
foreach ($tmp as $cache_code) {
$tmp2[$cache_code] = true;
}
foreach ($results as $cache_code => &$result_ref) {
$result_ref['is_ignored'] = isset($tmp2[$cache_code]);
}
}
# Descriptions and hints.
if (in_array('description', $fields) || in_array('descriptions', $fields) || in_array('short_description', $fields) || in_array('short_descriptions', $fields) || in_array('hint', $fields) || in_array('hints', $fields) || in_array('hint2', $fields) || in_array('hints2', $fields)) {
# At first, we will fill all those fields, even if user requested just one
# of them. We will chop off the unwanted ones at the end.
foreach ($results as &$result_ref) {
$result_ref['short_descriptions'] = new ArrayObject();
$result_ref['descriptions'] = new ArrayObject();
$result_ref['hints'] = new ArrayObject();
$result_ref['hints2'] = new ArrayObject();
}
# Get cache descriptions and hints.
$rs = Db::query("\n select cache_id, language, `desc`, short_desc, hint\n from cache_desc\n where cache_id in ('" . implode("','", array_map('mysql_real_escape_string', array_keys($cacheid2wptcode))) . "')\n ");
while ($row = mysql_fetch_assoc($rs)) {
$cache_code = $cacheid2wptcode[$row['cache_id']];
// strtolower - ISO 639-1 codes are lowercase
if ($row['desc']) {
/* Note, that the "owner" and "internal_id" fields are automatically included,
* whenever the cache description is included. */
$tmp = Okapi::fix_oc_html($row['desc']);
if ($attribution_append != 'none') {
$tmp .= "\n<p><em>" . self::get_cache_attribution_note($row['cache_id'], strtolower($row['language']), $langpref, $results[$cache_code]['owner'], $attribution_append) . "</em></p>";
}
$results[$cache_code]['descriptions'][strtolower($row['language'])] = $tmp;
}
if ($row['short_desc']) {
$results[$cache_code]['short_descriptions'][strtolower($row['language'])] = $row['short_desc'];
}
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['short_description'] = Okapi::pick_best_language($result_ref['short_descriptions'], $langpref);
$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('short_description', 'short_descriptions', 'description', 'descriptions', 'hint', 'hints', 'hint2', 'hints2') as $field) {
if (!in_array($field, $fields)) {
foreach ($results as &$result_ref) {
unset($result_ref[$field]);
}
}
}
}
# Images.
if (in_array('images', $fields) || in_array('preview_image', $fields)) {
if (in_array('images', $fields)) {
foreach ($results as &$result_ref) {
示例2: call
public static function call(OkapiRequest $request)
{
$log_uuids = $request->get_parameter('log_uuids');
if ($log_uuids === null) {
throw new ParamMissing('log_uuids');
}
if ($log_uuids === "") {
$log_uuids = array();
} else {
$log_uuids = explode("|", $log_uuids);
}
if (count($log_uuids) > 500 && !$request->skip_limits) {
throw new InvalidParam('log_uuids', "Maximum allowed number of referenced " . "log entries is 500. You provided " . count($log_uuids) . " UUIDs.");
}
if (count($log_uuids) != count(array_unique($log_uuids))) {
throw new InvalidParam('log_uuids', "Duplicate UUIDs detected (make sure each UUID is referenced only once).");
}
$fields = $request->get_parameter('fields');
if (!$fields) {
$fields = "date|user|type|comment";
}
$fields = explode("|", $fields);
foreach ($fields as $field) {
if (!in_array($field, self::$valid_field_names)) {
throw new InvalidParam('fields', "'{$field}' is not a valid field code.");
}
}
if (Settings::get('OC_BRANCH') == 'oc.de') {
$teamentry_field = 'cl.oc_team_comment';
$ratingdate_condition = 'and cr.rating_date=cl.date';
$needs_maintenance_SQL = 'cl.needs_maintenance';
$listing_is_outdated_SQL = 'cl.listing_outdated';
} else {
$teamentry_field = '(cl.type=12)';
$ratingdate_condition = '';
$needs_maintenance_SQL = 'IF(cl.type=5, 2, IF(cl.type=6, 1, 0))';
$listing_is_outdated_SQL = '0';
}
$rs = Db::query("\n select\n cl.id, c.wp_oc as cache_code, cl.uuid, cl.type,\n " . $teamentry_field . " as oc_team_entry,\n " . $needs_maintenance_SQL . " as needs_maintenance2,\n " . $listing_is_outdated_SQL . " as listing_is_outdated,\n unix_timestamp(cl.date) as date, cl.text,\n u.uuid as user_uuid, u.username, u.user_id,\n if(cr.user_id is null, 0, 1) as was_recommended\n from\n (cache_logs cl,\n user u,\n caches c)\n left join cache_rating cr\n on cr.user_id = u.user_id\n and cr.cache_id = c.cache_id\n " . $ratingdate_condition . "\n and cl.type in (\n " . Okapi::logtypename2id("Found it") . ",\n " . Okapi::logtypename2id("Attended") . "\n )\n where\n cl.uuid in ('" . implode("','", array_map('\\okapi\\Db::escape_string', $log_uuids)) . "')\n and " . (Settings::get('OC_BRANCH') == 'oc.pl' ? "cl.deleted = 0" : "true") . "\n and cl.user_id = u.user_id\n and c.cache_id = cl.cache_id\n and c.status in (1,2,3)\n ");
$results = array();
$log_id2uuid = array();
/* Maps logs' internal_ids to uuids */
$flag_options = array('null', 'false', 'true');
while ($row = Db::fetch_assoc($rs)) {
$results[$row['uuid']] = array('uuid' => $row['uuid'], 'cache_code' => $row['cache_code'], 'date' => date('c', $row['date']), 'user' => array('uuid' => $row['user_uuid'], 'username' => $row['username'], 'profile_url' => Settings::get('SITE_URL') . "viewprofile.php?userid=" . $row['user_id']), 'type' => Okapi::logtypeid2name($row['type']), 'was_recommended' => $row['was_recommended'] ? true : false, 'needs_maintenance2' => $flag_options[$row['needs_maintenance2']], 'listing_is_outdated' => $flag_options[$row['listing_is_outdated']], 'oc_team_entry' => $row['oc_team_entry'] ? true : false, 'comment' => Okapi::fix_oc_html($row['text'], Okapi::OBJECT_TYPE_CACHE_LOG), 'images' => array(), 'internal_id' => $row['id']);
$log_id2uuid[$row['id']] = $row['uuid'];
}
Db::free_result($rs);
# fetch images
if (in_array('images', $fields)) {
# For OCPL log entry images, pictures.seq currently is always = 1,
# while OCDE uses it for ordering the images.
$rs = Db::query("\n select object_id, uuid, url, title, spoiler\n from pictures\n where\n object_type = 1\n and object_id in ('" . implode("','", array_map('\\okapi\\Db::escape_string', array_keys($log_id2uuid))) . "')\n and display = 1 /* currently is always 1 for logpix */\n and unknown_format = 0\n order by seq, date_created\n ");
if (Settings::get('OC_BRANCH') == 'oc.de') {
$object_type_param = 'type=1&';
} else {
$object_type_param = '';
}
while ($row = Db::fetch_assoc($rs)) {
$results[$log_id2uuid[$row['object_id']]]['images'][] = array('uuid' => $row['uuid'], 'url' => $row['url'], 'thumb_url' => Settings::get('SITE_URL') . 'thumbs.php?' . $object_type_param . 'uuid=' . $row['uuid'], 'caption' => $row['title'], 'is_spoiler' => $row['spoiler'] ? true : false);
}
Db::free_result($rs);
}
# Check which UUIDs were not found and mark them with null.
foreach ($log_uuids as $log_uuid) {
if (!isset($results[$log_uuid])) {
$results[$log_uuid] = null;
}
}
# Remove unwanted fields.
foreach (self::$valid_field_names as $field) {
if (!in_array($field, $fields)) {
foreach ($results as &$result_ref) {
unset($result_ref[$field]);
}
}
}
# Order the results in the same order as the input codes were given.
$ordered_results = array();
foreach ($log_uuids as $log_uuid) {
$ordered_results[$log_uuid] = $results[$log_uuid];
}
return Okapi::formatted_response($request, $ordered_results);
}