本文整理汇总了PHP中okapi\Okapi::cache_status_name2id方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::cache_status_name2id方法的具体用法?PHP Okapi::cache_status_name2id怎么用?PHP Okapi::cache_status_name2id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类okapi\Okapi
的用法示例。
在下文中一共展示了Okapi::cache_status_name2id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_short_row
/**
* Convert OKAPI's cache object to a short database row to be inserted
* into okapi_tile_caches table. Returns the list of the following attributes:
* cache_id, z21x, z21y, status, type, rating, flags, name_crc
* (rating may be null!).
*/
public static function generate_short_row($cache)
{
list($lat, $lon) = explode("|", $cache['location']);
try {
list($z21x, $z21y) = self::latlon_to_z21xy($lat, $lon);
} catch (Exception $e) {
/* E.g. division by zero, if the cache is placed at the north pole. */
return false;
}
$flags = 0;
if ($cache['founds'] > 6 && $cache['recommendations'] / $cache['founds'] > 0.3) {
$flags |= self::$FLAG_STAR;
}
if ($cache['trackables_count'] > 0) {
$flags |= self::$FLAG_HAS_TRACKABLES;
}
if ($cache['founds'] == 0) {
$flags |= self::$FLAG_NOT_YET_FOUND;
}
return array($cache['internal_id'], $z21x, $z21y, Okapi::cache_status_name2id($cache['status']), Okapi::cache_type_name2id($cache['type']), $cache['rating'], $flags, self::compute_name_crc($cache['name']));
}
示例2: prepare_common_search_params
//.........这里部分代码省略.........
}
}
}
#
# size2
#
if ($tmp = $this->request->get_parameter('size2')) {
$operator = "in";
if ($tmp[0] == '-') {
$tmp = substr($tmp, 1);
$operator = "not in";
}
$types = array();
foreach (explode("|", $tmp) as $name) {
try {
$id = Okapi::cache_size2_to_sizeid($name);
$types[] = $id;
} catch (Exception $e) {
throw new InvalidParam('size2', "'{$name}' is not a valid cache size.");
}
}
$where_conds[] = "caches.size {$operator} ('" . implode("','", array_map('mysql_real_escape_string', $types)) . "')";
}
#
# status - filter by status codes
#
$tmp = $this->request->get_parameter('status');
if ($tmp == null) {
$tmp = "Available";
}
$codes = array();
foreach (explode("|", $tmp) as $name) {
try {
$codes[] = Okapi::cache_status_name2id($name);
} catch (Exception $e) {
throw new InvalidParam('status', "'{$name}' is not a valid cache status.");
}
}
$where_conds[] = "caches.status in ('" . implode("','", array_map('mysql_real_escape_string', $codes)) . "')";
#
# owner_uuid
#
if ($tmp = $this->request->get_parameter('owner_uuid')) {
$operator = "in";
if ($tmp[0] == '-') {
$tmp = substr($tmp, 1);
$operator = "not in";
}
try {
$users = OkapiServiceRunner::call("services/users/users", new OkapiInternalRequest($this->request->consumer, null, array('user_uuids' => $tmp, 'fields' => 'internal_id')));
} catch (InvalidParam $e) {
throw new InvalidParam('owner_uuid', $e->whats_wrong_about_it);
}
$user_ids = array();
foreach ($users as $user) {
$user_ids[] = $user['internal_id'];
}
$where_conds[] = "caches.user_id {$operator} ('" . implode("','", array_map('mysql_real_escape_string', $user_ids)) . "')";
}
#
# terrain, difficulty, size, rating - these are similar, we'll do them in a loop
#
foreach (array('terrain', 'difficulty', 'size', 'rating') as $param_name) {
if ($tmp = $this->request->get_parameter($param_name)) {
if (!preg_match("/^[1-5]-[1-5](\\|X)?\$/", $tmp)) {
throw new InvalidParam($param_name, "'{$tmp}'");