本文整理汇总了PHP中okapi\Okapi::cache_type_name2id方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::cache_type_name2id方法的具体用法?PHP Okapi::cache_type_name2id怎么用?PHP Okapi::cache_type_name2id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类okapi\Okapi
的用法示例。
在下文中一共展示了Okapi::cache_type_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
/**
* Load, parse and check common geocache search parameters (the ones
* described in services/caches/search/all method) from $this->request.
* Most cache search methods share a common set
* of filtering parameters recognized by this method. It initalizes
* search params, which can be further altered by calls to other methods
* of this class, or outside of this class by a call to get_search_params();
*
* This method doesn't return anything. See get_search_params method.
*/
public function prepare_common_search_params()
{
$where_conds = array('true');
$extra_tables = array();
$extra_joins = array();
# At the beginning we have to set up some "magic e$Xpressions".
# We will use them to make our query run on both OCPL and OCDE databases.
if (Settings::get('OC_BRANCH') == 'oc.pl') {
# OCPL's 'caches' table contains some fields which OCDE's does not
# (topratings, founds, notfounds, last_found, votes, score). If
# we're being run on OCPL installation, we will simply use them.
$X_TOPRATINGS = 'caches.topratings';
$X_FOUNDS = 'caches.founds';
$X_NOTFOUNDS = 'caches.notfounds';
$X_LAST_FOUND = 'caches.last_found';
$X_VOTES = 'caches.votes';
$X_SCORE = 'caches.score';
} else {
# OCDE holds this data in a separate table. Additionally, OCDE
# does not provide a rating system (votes and score fields).
# If we're being run on OCDE database, we will include this
# additional table in our query and we will map the field
# expressions to approriate places.
# stat_caches entries are optional, therefore we must do a left join:
$extra_joins[] = 'left join stat_caches on stat_caches.cache_id = caches.cache_id';
$X_TOPRATINGS = 'ifnull(stat_caches.toprating,0)';
$X_FOUNDS = 'ifnull(stat_caches.found,0)';
$X_NOTFOUNDS = 'ifnull(stat_caches.notfound,0)';
$X_LAST_FOUND = 'ifnull(stat_caches.last_found,0)';
$X_VOTES = '0';
// no support for ratings
$X_SCORE = '0';
// no support for ratings
}
#
# type
#
if ($tmp = $this->request->get_parameter('type')) {
$operator = "in";
if ($tmp[0] == '-') {
$tmp = substr($tmp, 1);
$operator = "not in";
}
$types = array();
foreach (explode("|", $tmp) as $name) {
try {
$id = Okapi::cache_type_name2id($name);
$types[] = $id;
} catch (Exception $e) {
throw new InvalidParam('type', "'{$name}' is not a valid cache type.");
}
}
if (count($types) > 0) {
$where_conds[] = "caches.type {$operator} ('" . implode("','", array_map('mysql_real_escape_string', $types)) . "')";
} else {
if ($operator == "in") {
$where_conds[] = "false";
}
}
}
#
# 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 {
//.........这里部分代码省略.........