本文整理汇总了PHP中PerchUtil::http_get_request方法的典型用法代码示例。如果您正苦于以下问题:PHP PerchUtil::http_get_request方法的具体用法?PHP PerchUtil::http_get_request怎么用?PHP PerchUtil::http_get_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PerchUtil
的用法示例。
在下文中一共展示了PerchUtil::http_get_request方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _process_map
private function _process_map($id, $tag, $value)
{
$out = array();
if (isset($value['adr'])) {
$out['adr'] = $value['adr'];
$out['_title'] = $value['adr'];
$out['_default'] = $value['adr'];
if (!isset($value['lat'])) {
$lat = false;
$lng = false;
$path = '/maps/api/geocode/json?address=' . urlencode($value['adr']) . '&sensor=false';
$result = PerchUtil::http_get_request('http://', 'maps.googleapis.com', $path);
if ($result) {
$result = PerchUtil::json_safe_decode($result, true);
//PerchUtil::debug($result);
if ($result['status'] == 'OK') {
if (isset($result['results'][0]['geometry']['location']['lat'])) {
$lat = $result['results'][0]['geometry']['location']['lat'];
$lng = $result['results'][0]['geometry']['location']['lng'];
}
}
}
} else {
$lat = $value['lat'];
$lng = $value['lng'];
}
$out['lat'] = $lat;
$out['lng'] = $lng;
if (!isset($value['clat'])) {
$clat = $lat;
$clng = $lng;
} else {
$clat = $value['clat'];
$clng = $value['clng'];
}
$out['clat'] = $clat;
$out['clng'] = $clng;
if (!isset($value['zoom'])) {
if ($tag->zoom()) {
$zoom = $tag->zoom();
} else {
$zoom = 15;
}
} else {
$zoom = $value['zoom'];
}
if (!isset($value['type'])) {
if ($tag->type()) {
$type = $tag->type();
} else {
$type = 'roadmap';
}
} else {
$type = $value['type'];
}
$adr = $value['adr'];
if (PERCH_RWD) {
$width = $tag->width() ? $tag->width() : '';
$height = $tag->height() ? $tag->height() : '';
} else {
$width = $tag->width() ? $tag->width() : '460';
$height = $tag->height() ? $tag->height() : '320';
}
$static_width = $width == '' ? '460' : $width;
$static_height = $height == '' ? '320' : $height;
$out['zoom'] = $zoom;
$out['type'] = $type;
$r = '<img id="cmsmap' . PerchUtil::html($id) . '" src="//maps.google.com/maps/api/staticmap';
$r .= '?center=' . $clat . ',' . $clng . '&size=' . $static_width . 'x' . $static_height . '&zoom=' . $zoom . '&maptype=' . $type;
if ($lat && $lng) {
$r .= '&markers=color:red|color:red|' . $lat . ',' . $lng;
}
$r .= '" ';
if ($tag->class()) {
$r .= ' class="' . PerchUtil::html($tag->class()) . '"';
}
$r .= ' width="' . $static_width . '" height="' . $static_height . '" alt="' . PerchUtil::html($adr) . '" />';
$out['admin_html'] = $r;
$map_js_path = PerchUtil::html(PERCH_LOGINPATH) . '/core/assets/js/public_maps.min.js';
if (defined('PERCH_MAP_JS') && PERCH_MAP_JS) {
$map_js_path = PerchUtil::html(PERCH_MAP_JS);
}
// JavaScript
$r .= '<script type="text/javascript">/* <![CDATA[ */ ';
$r .= "if(typeof CMSMap =='undefined'){var CMSMap={};CMSMap.maps=[];document.write('<scr'+'ipt type=\"text\\/javascript\" src=\"" . $map_js_path . "\"><'+'\\/sc'+'ript>');}";
$r .= "CMSMap.maps.push({'mapid':'cmsmap" . PerchUtil::html($id) . "','width':'" . $width . "','height':'" . $height . "','type':'" . $type . "','zoom':'" . $zoom . "','adr':'" . addslashes(PerchUtil::html($adr)) . "','lat':'" . $lat . "','lng':'" . $lng . "','clat':'" . $clat . "','clng':'" . $clng . "'});";
$r .= '/* ]]> */';
$r .= '</script>';
if (defined('PERCH_XHTML_MARKUP') && PERCH_XHTML_MARKUP == false) {
$r = str_replace('/>', '>', $r);
}
$out['html'] = $r;
}
return $out;
}