本文整理汇总了PHP中map类的典型用法代码示例。如果您正苦于以下问题:PHP map类的具体用法?PHP map怎么用?PHP map使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __create
public static function __create()
{
$trigger = new static();
$trigger->sprite_url = 'not-found.png';
$trigger->map_id = 1;
$trigger->name = 'Trigger';
$trigger->x = 50;
$trigger->y = 50;
$weaponDealer = clone $trigger;
$weaponDealer->script = 'merchants/weapon_dealer';
$weaponDealer->script_arguments = '{"min_level":0,"max_level":80}';
$weaponDealer->name = 'Weapon Dealer';
$weaponDealer->map_id = map::load_one('Trainee Village', 'name')->id;
$weaponDealer->save();
$weaponDealer->id = null;
$weaponDealer->name = 'Weapon Dealer';
$weaponDealer->map_id = map::load_one('Kinata', 'name')->id;
$weaponDealer->save();
$dungeonEntrance = clone $trigger;
$dungeonEntrance->script = 'dungeon_entrance';
$dungeonEntrance->script_arguments = '{"dungeon_script":"","modes":[0,1,2,3,4,5]}';
$dungeonEntrance->name = 'Dungeon Entrance';
$traineeCave = clone $dungeonEntrance;
$traineeCave->script_arguments = '{"dungeon_script":"trainee_cave","modes":[0,1,2,3,4,5]}';
$traineeCave->name = 'Trainee Cave';
$traineeCave->map_id = map::load_one('Trainee Fields', 'name')->id;
$traineeCave->save();
$kinataUnderground = clone $dungeonEntrance;
$kinataUnderground->script_arguments = '{"dungeon_script":"kinata_underground","modes":[0,1,2,3,4,5]}';
$kinataUnderground->name = 'Kinata Underground';
$kinataUnderground->x = 100;
$kinataUnderground->y = 100;
$kinataUnderground->map_id = map::load_one('Kinata', 'name')->id;
$kinataUnderground->save();
}
示例2: __construct
public function __construct()
{
$this->BASE_FILE = ROOT_URL . "Carte.php";
$this->map = map::getinstance();
$this->lng = language::getinstance()->GetLngBlock('carte');
parent::__construct();
}
示例3: layers_array
/**
* Generate the Map Array.
* These are the maps that show up in the Layer Switcher
* if $all is set to TRUE all maps are rendered
* **caveat is that each mapping api js must be loaded **
*
* @param bool $all
* @return string $js
*/
public static function layers_array($all = FALSE)
{
// Javascript
$js = "[";
// Get All Layers
$layers = map::base();
// Next get the default base layer
$default_map = Kohana::config('settings.default_map');
if (!isset($layers[$default_map])) {
// Map Layer Doesn't Exist - default to google
$default_map = "google_normal";
}
// Get openlayers type
$openlayers_type = $layers[$default_map]->openlayers;
$js .= $default_map;
foreach ($layers as $layer) {
if ($layer->name != $default_map and $layer->active) {
if ($all == TRUE) {
$js .= "," . $layer->name;
} else {
if ($layer->openlayers == $openlayers_type) {
$js .= "," . $layer->name;
}
}
}
}
$js .= "]";
return $js;
}
示例4: instance
/**
* 单例模式
* @return map
*/
public static function instance()
{
if (!self::$_instance instanceof self) {
self::$_instance = new self();
}
return self::$_instance;
}
示例5: calcdist
function calcdist($sys1, $sys2)
{
//Pour avoir l'abscisse des coordonnées du système 1 [syst1 = 2456 ax = 2456%100]
//Pour avoir l'ordonée des coordonnées du système 1 [syst1 = 2456 ay = (2456-2456%100)/100]
list($syst1y, $syst1x) = map::ss2xy($sys1);
list($syst2y, $syst2x) = map::ss2xy($sys2);
return round(round(round(sqrt(carre($syst1x - $syst2x) + carre($syst1y - $syst2y)), 2), 1), 0);
}
示例6: geocode_location
/**
* Google Location GeoCoding
*
* Reuses map::geocode() rather than reimplementing.
* Only really keeping this for backwards compat
*
* @param string location / address
* @return array (longitude, latitude)
*/
function geocode_location($address = NULL)
{
$result = map::geocode($address);
if ($result) {
return array($result['longitude'], $result['latitude'], $result['country_id']);
} else {
return false;
}
}
示例7: path
public function path($CoordA, $CoordB)
{
list($sX, $sY) = map::ss2xy($CoordA);
list($sX2, $sY2) = map::ss2xy($CoordB);
$x1 = floor($this->tc * $sX - $this->tc / 2);
$y1 = floor($this->tc * ($sY + 1) - $this->tc / 2);
$x2 = floor($this->tc * $sX2 - $this->tc / 2);
$y2 = floor($this->tc * ($sY2 + 1) - $this->tc / 2);
imageline($this->im, $x1, $y1, $x2, $y2, $this->color);
}
示例8: index_action
public function index_action()
{
$char = character::current();
$mapId = $char->map_id;
$map = map::load_one($mapId);
if (!$map) {
page::redirect('/world/map-not-found');
}
$this->set('map', $map);
}
示例9: prepare
public function prepare()
{
global $SITE, $db;
$this->template = "maps";
$this->tab = 'map';
$this->title = 'Popular maps';
$f = $db->query_first("SELECT id, name, rank, score, plays, players FROM tf2_vars v INNER JOIN tf2_maps m on v.value = m.id");
$fa = array('image' => map_functions::image('x600.y360', $f), 'label' => map_functions::label('', $f), 'link' => map_functions::link('', $f), 'type' => map_functions::type('', $f));
$mlen = 18;
$f['display_name'] = strlen($f['name']) > $mlen ? substr($f['name'], 0, $mlen - 3) . '...' : $f['name'];
$this->params['feat'] = array_merge($f, $fa);
///////////////////////////////////////// New maps ////////////////////////////////////
$this->params['new_maps'] = map::get_map_list(array('funcs' => array('count' => array('func' => 'count', 'param' => '%02d'), 'link' => array('func' => 'link'), 'label' => array('func' => 'label', 'param' => 25)), 'query' => 'SELECT * FROM tf2_maps ORDER BY first_seen DESC LIMIT 10;'));
//////////////////////////////////////// popular maps ///////////////////////////////////
$this->params['popular_maps'] = map::get_map_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label'), 'image' => array('func' => 'image', 'param' => 'xy165')), 'query' => sprintf('SELECT id,name, official FROM tf2_maps ORDER BY score DESC LIMIT 10', $time)));
}
示例10: prepare
public function prepare()
{
global $SITE, $db;
$this->template = "map_list";
$this->tab = 'map';
$this->title = 'Map list';
$page_size = 50;
$page = mysql_real_escape_string((int) $this->request[1]);
$method = $this->request[0];
$query = '';
switch ($method) {
case 'rank':
case 'score':
default:
$method = 'score';
$query = sprintf('SELECT id, name, official, score, rank, players, servers, plays FROM tf2_maps ORDER BY score DESC LIMIT ' . $page * $page_size . ', ' . $page_size);
}
$this->params['maps'] = map::get_map_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label'), 'type' => array('func' => 'type'), 'icon' => array('func' => 'icon'), 'image' => array('func' => 'image', 'param' => 'x128.y96')), 'query' => $query));
$this->params['method'] = $method;
$this->params['page'] = $page;
}
示例11: prepare
public function prepare()
{
global $db;
$this->template = "map_search";
require_once 'classes/map.php';
$q = $this->request['search'];
//$db->debug=true;
$db->query("SELECT name FROM tf2_maps WHERE name LIKE %s", array(sprintf("%%%%%s%%%%", $q)));
//echo mysql_error();
if ($db->num_rows() == 1) {
$row = $db->fetch_array();
//die();
header('Location: /map/' . $row['name']);
exit;
}
if (!$db->num_rows()) {
page::error("We searched and searched", "But we just couldn't find the map you were looking for.\r\n\t\t\t\tRest assured Heavy is on the job. He won't rest until he knows who's been tampering with his gun.\r\n\t\t\t\t<br/><br/>That's what you were searching for, right?", array('image' => "heavy_yell"));
}
//$db->debug=true;
$this->params['list'] = map::get_map_list(array('funcs' => array('link' => array('func' => 'link'), 'label' => array('func' => 'label')), 'query' => sprintf('SELECT m.id, m.name, m.official, m.score, plays, servers, first_seen FROM tf2_maps m WHERE name LIKE \'%%%s%%\' ORDER BY score DESC LIMIT 50', $q)));
$this->title = sprintf("Search: %s", htmlspecialchars($this->request[0]));
}
示例12: prepare
public function prepare()
{
$this->template = "map";
$this->tab = 'map';
global $SITE;
$SITE['head'] .= '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
require_once 'classes/map.php';
$map = new map($this->request[0]);
$i = $map->get_info();
$s = $map->get_stats();
$stats[] = array('key' => 'Players', 'now' => $i['players'], 'average' => $s['avg_players']);
$stats[] = array('key' => 'Servers', 'now' => $i['servers'], 'average' => $s['avg_servers']);
$stats[] = array('key' => 'Saturation', 'now' => $i['players'] > 0 ? $i['servers'] / $i['players'] : 0, 'average' => $s['saturation']);
$this->title = htmlspecialchars($this->request[0]);
$this->params['info'] = $i;
$this->params['servers'] = $map->get_servers(25);
$this->params['images'] = $map->get_images();
$this->params['extra'] = $map->get_extra();
$this->params['stats'] = $stats;
}
示例13: date_default_timezone_set
Kohana::config_set('settings.email_host', $settings->email_host);
Kohana::config_set('settings.email_servertype', $settings->email_servertype);
Kohana::config_set('settings.email_ssl', $settings->email_ssl);
Kohana::config_set('settings.alerts_email', $settings->alerts_email);
Kohana::config_set('settings.db_version', $settings->db_version);
Kohana::config_set('settings.ushahidi_version', $settings->ushahidi_version);
Kohana::config_set('settings.private_deployment', $settings->private_deployment);
// Set Site Timezone
if (function_exists('date_default_timezone_set')) {
$timezone = $settings->site_timezone;
// Set default timezone, due to increased validation of date settings
// which cause massive amounts of E_NOTICEs to be generated in PHP 5.2+
date_default_timezone_set(empty($timezone) ? date_default_timezone_get() : $timezone);
Kohana::config_set('settings.site_timezone', $timezone);
}
// Cache Settings
$cache_pages = $settings->cache_pages ? TRUE : FALSE;
Kohana::config_set('cache.cache_pages', $cache_pages);
Kohana::config_set('cache.default.lifetime', $settings->cache_pages_lifetime);
$default_map = $settings->default_map;
$map_layer = map::base($default_map);
if ($map_layer) {
Kohana::config_set('settings.api_url', "<script type=\"text/javascript\" src=\"" . $map_layer->api_url . "\"></script>");
}
// And in case you want to display all maps on one page...
$api_google = $settings->api_google;
$api_yahoo = $settings->api_yahoo;
Kohana::config_set('settings.api_url_all', '<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6"></script><script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=' . $api_yahoo . '"></script><script src="http://maps.google.com/maps/api/js?v=3.2&sensor=false" type="text/javascript"></script>' . html::script('http://www.openstreetmap.org/openlayers/OpenStreetMap.js'));
// Additional Mime Types (KMZ/KML)
Kohana::config_set('mimes.kml', array('text/xml'));
Kohana::config_set('mimes.kmz', array('text/xml'));
示例14: article_list
function article_list($vars)
{
if ($vars['loop'] === "rel" && empty($vars['id'])) {
return false;
}
$resource = array();
$map_where = array();
$status = '1';
isset($vars['status']) && ($status = (int) $vars['status']);
$where_sql = "WHERE `status`='{$status}'";
$vars['call'] == 'user' && ($where_sql .= " AND `postype`='0'");
$vars['call'] == 'admin' && ($where_sql .= " AND `postype`='1'");
$hidden = iCache::get('iCMS/category/hidden');
$hidden && ($where_sql .= iPHP::where($hidden, 'cid', 'not'));
$maxperpage = isset($vars['row']) ? (int) $vars['row'] : 10;
$cache_time = isset($vars['time']) ? (int) $vars['time'] : -1;
isset($vars['userid']) && ($where_sql .= " AND `userid`='{$vars['userid']}'");
isset($vars['weight']) && ($where_sql .= " AND `weight`='" . _int($vars['weight']) . "'");
if (isset($vars['ucid']) && $vars['ucid'] != '') {
$where_sql .= " AND `ucid`='{$vars['ucid']}'";
}
if (isset($vars['cid!'])) {
$ncids = explode(',', $vars['cid!']);
$vars['sub'] && ($ncids += iCMS::get_category_ids($ncids, true));
$where_sql .= iPHP::where($ncids, 'cid', 'not');
}
if ($vars['cid'] && !isset($vars['cids'])) {
$cid = explode(',', $vars['cid']);
$vars['sub'] && ($cid += iCMS::get_category_ids($cid, true));
$where_sql .= iPHP::where($cid, 'cid');
}
if (isset($vars['cids']) && !$vars['cid']) {
$cids = explode(',', $vars['cids']);
$vars['sub'] && ($cids += iCMS::get_category_ids($vars['cids'], true));
if ($cids) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('category', iCMS_APP_ARTICLE);
$map_where += map::where($cids);
}
}
if (isset($vars['pid']) && !isset($vars['pids'])) {
$where_sql .= iPHP::where($vars['pid'], 'pid');
}
if (isset($vars['pids']) && !isset($vars['pid'])) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', iCMS_APP_ARTICLE);
$map_where += map::where($vars['pids']);
}
if (isset($vars['tids'])) {
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('tags', iCMS_APP_ARTICLE);
$map_where += map::where($vars['tids']);
}
if (isset($vars['keywords'])) {
//最好使用 iCMS:article:search
if (empty($vars['keywords'])) {
return;
}
if (strpos($vars['keywords'], ',') === false) {
$vars['keywords'] = str_replace(array('%', '_'), array('\\%', '\\_'), $vars['keywords']);
$where_sql .= " AND CONCAT(title,keywords,description) like '%" . addslashes($vars['keywords']) . "%'";
} else {
$kws = explode(',', $vars['keywords']);
foreach ($kws as $kwv) {
$keywords .= addslashes($kwv) . "|";
}
$keywords = substr($keywords, 0, -1);
$where_sql .= " AND CONCAT(title,keywords,description) REGEXP '{$keywords}' ";
}
}
$vars['id'] && ($where_sql .= iPHP::where($vars['id'], 'id'));
$vars['id!'] && ($where_sql .= iPHP::where($vars['id!'], 'id', 'not'));
$by = $vars['by'] == "ASC" ? "ASC" : "DESC";
isset($vars['pic']) && ($where_sql .= " AND `haspic`='1'");
isset($vars['nopic']) && ($where_sql .= " AND `haspic`='0'");
switch ($vars['orderby']) {
case "id":
$order_sql = " ORDER BY `id` {$by}";
break;
case "hot":
$order_sql = " ORDER BY `hits` {$by}";
break;
case "week":
$order_sql = " ORDER BY `hits_week` {$by}";
break;
case "month":
$order_sql = " ORDER BY `hits_month` {$by}";
break;
case "comment":
$order_sql = " ORDER BY `comments` {$by}";
break;
case "pubdate":
$order_sql = " ORDER BY `pubdate` {$by}";
break;
case "disorder":
$order_sql = " ORDER BY `ordernum` {$by}";
break;
case "rand":
$order_sql = " ORDER BY rand() {$by}";
break;
//.........这里部分代码省略.........
示例15: do_save
function do_save()
{
$appid = $this->appid;
$cid = (int) $_POST['cid'];
$rootid = (int) $_POST['rootid'];
$status = (int) $_POST['status'];
$isucshow = (int) $_POST['isucshow'];
$issend = (int) $_POST['issend'];
$isexamine = (int) $_POST['isexamine'];
$ordernum = (int) $_POST['ordernum'];
$mode = (int) $_POST['mode'];
$pid = implode(',', (array) $_POST['pid']);
$_pid = iS::escapeStr($_POST['_pid']);
$_rootid_hash = iS::escapeStr($_POST['_rootid_hash']);
$name = iS::escapeStr($_POST['name']);
$subname = iS::escapeStr($_POST['subname']);
$domain = iS::escapeStr($_POST['domain']);
$htmlext = iS::escapeStr($_POST['htmlext']);
$url = iS::escapeStr($_POST['url']);
$password = iS::escapeStr($_POST['password']);
$pic = iS::escapeStr($_POST['pic']);
$mpic = iS::escapeStr($_POST['mpic']);
$spic = iS::escapeStr($_POST['spic']);
$dir = iS::escapeStr($_POST['dir']);
$title = iS::escapeStr($_POST['title']);
$keywords = iS::escapeStr($_POST['keywords']);
$description = iS::escapeStr($_POST['description']);
$categoryURI = iS::escapeStr($_POST['categoryURI']);
$categoryRule = iS::escapeStr($_POST['categoryRule']);
$contentRule = iS::escapeStr($_POST['contentRule']);
$urlRule = iS::escapeStr($_POST['urlRule']);
$indexTPL = iS::escapeStr($_POST['indexTPL']);
$listTPL = iS::escapeStr($_POST['listTPL']);
$contentTPL = iS::escapeStr($_POST['contentTPL']);
$metadata = iS::escapeStr($_POST['metadata']);
$contentprop = iS::escapeStr($_POST['contentprop']);
$body = $_POST['body'];
$hasbody = (int) $_POST['hasbody'];
$hasbody or $hasbody = $body ? 1 : 0;
if ($_rootid_hash) {
$_rootid = authcode($_rootid_hash);
if ($rootid != $_rootid) {
iPHP::alert('非法数据提交!');
} else {
iACP::CP($_rootid, 'a', 'alert');
exit;
}
}
$cid && $cid == $rootid && iPHP::alert('不能以自身做为上级' . $this->category_name);
empty($name) && iPHP::alert($this->category_name . '名称不能为空!');
if ($metadata) {
$md = array();
foreach ($metadata['key'] as $_mk => $_mval) {
!preg_match("/[a-zA-Z0-9_\\-]/", $_mval) && iPHP::alert($this->category_name . '附加属性名称只能由英文字母、数字或_-组成(不支持中文)');
$md[$_mval] = $metadata['value'][$_mk];
}
$metadata = addslashes(serialize($md));
}
if ($contentprop) {
$ca = array();
foreach ($contentprop['key'] as $_cak => $_caval) {
$_caval or $_caval = strtolower(pinyin($contentprop['name'][$_cak]));
!preg_match("/[a-zA-Z0-9_\\-]/", $_caval) && iPHP::alert('内容附加属性字段只能由英文字母、数字或_-组成(不支持中文)');
$ca[$_caval] = $contentprop['name'][$_cak];
}
$contentprop = addslashes(serialize($ca));
}
if ($mode == "2") {
if (strpos($categoryRule, '{CDIR}') === FALSE && strpos($categoryRule, '{CID}') === FALSE && strpos($categoryRule, '{0xCID}') === FALSE) {
iPHP::alert('伪静态模式下版块URL规则<hr />必需要有<br />{CDIR}版块目录<br />或者<br />{CID},{0xCID}版块ID');
}
if (strpos($contentRule, '{ID}') === FALSE && strpos($contentRule, '{0xID}') === FALSE && strpos($contentRule, '{LINK}') === FALSE) {
iPHP::alert('伪静态模式下内容URL规则<hr />必需要有<br />{ID}' . $this->_app_name . 'ID <br />或者<br />{0xID}' . $this->_app_name . 'ID补零<br />或者<br />{LINK}' . $this->_app_name . '自定义链接');
}
}
iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
map::init('prop', iCMS_APP_CATEGORY);
$fields = array('rootid', 'appid', 'ordernum', 'name', 'subname', 'password', 'title', 'keywords', 'description', 'dir', 'mode', 'domain', 'url', 'pic', 'mpic', 'spic', 'htmlext', 'categoryURI', 'categoryRule', 'contentRule', 'urlRule', 'indexTPL', 'listTPL', 'contentTPL', 'metadata', 'contentprop', 'hasbody', 'pid', 'isexamine', 'issend', 'isucshow', 'status');
$data = compact($fields);
if (empty($cid)) {
iACP::CP($rootid, 'a', 'alert');
$nameArray = explode("\n", $name);
$_count = count($nameArray);
foreach ($nameArray as $nkey => $_name) {
$_name = trim($_name);
if (empty($_name)) {
continue;
}
if ($_count == "1") {
if (empty($dir) && empty($url)) {
$dir = strtolower(pinyin($_name));
}
} else {
empty($url) && ($dir = strtolower(pinyin($_name)));
}
$this->check_dir($dir, $appid, $url);
$data['name'] = $_name;
$data['dir'] = $dir;
$data['userid'] = iMember::$userid;
$data['creator'] = iMember::$nickname;
//.........这里部分代码省略.........