本文整理汇总了PHP中valid::initGetVal方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::initGetVal方法的具体用法?PHP valid::initGetVal怎么用?PHP valid::initGetVal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::initGetVal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index($cluster_id = 0)
{
// Cacheable Controller
$this->is_cachable = TRUE;
$this->template->header->this_page = 'reports';
$this->template->content = new View('reports');
$this->themes->js = new View('reports_js');
// Get locale
$l = Kohana::config('locale.language.0');
$this->template->content->area_name = "";
$this->template->content->disp_distance = "";
//FORMのhiddenタグ用パラメータ初期化と代入
if(isset($_SESSION["locale"])){
$_GET["l"] = $_SESSION["locale"];
}
// 引き回すGETパラメータのテンプレートへの引き渡し
$this->template->content->keyword = valid::initGetVal('keyword',"text");
$this->template->content->address = valid::initGetVal('address',"text");
$this->template->content->distance = valid::initGetVal('distance',"number");
$this->template->content->c = valid::initGetVal('c',"number");
$this->template->content->sw = valid::initGetVal('sw',"text");
$this->template->content->ne = valid::initGetVal('ne',"text");
$this->template->content->l = valid::initGetVal('l',"natural_numbewr");
$this->template->content->mode = valid::initGetVal('mode',"text");
$this->template->content->order = valid::initGetVal('order',"text");
$db = new Database;
// Get incident_ids if we are to filter by category
$allowed_ids = array();
if (isset($_GET['c']) AND !empty($_GET['c']) AND $_GET['c']!=0)
{
$category_id = $db->escape($_GET['c']);
$query = 'SELECT ic.incident_id AS incident_id FROM '.$this->table_prefix.'incident_category AS ic INNER JOIN '.$this->table_prefix.'category AS c ON (ic.category_id = c.id) WHERE c.id='.$category_id.' OR c.parent_id='.$category_id.';';
$query = $db->query($query);
foreach ( $query as $items )
{
$allowed_ids[] = $items->incident_id;
}
}
// Get location_ids if we are to filter by location
$location_ids = array();
// Break apart location variables, if necessary
$southwest = array();
if (isset($_GET['sw']))
{
$southwest = explode(",",$_GET['sw']);
}
$northeast = array();
if (isset($_GET['ne']))
{
$northeast = explode(",",$_GET['ne']);
}
//指定地区の指定半径内インシデント取得でGoogleMAPAPIで緯度経度を取得できなかった場合DBを取りに行かないようにするためのフラグ
$dbget_flg = true;
$this->template->content->choices_flg = false;
//指定地区の指定半径内インシデント取得処理
if(isset($_GET["address"]) && trim($_GET["address"]) !== "" && isset($_GET["distance"]) && is_numeric($_GET["distance"]) && $_GET["distance"] > 0){
$address = urlencode($_GET["address"]);
// http://www.geocoding.jp/を利用して指定地区名の緯度経度を取得
$geocoding_url = 'http://www.geocoding.jp/api/?q='.$address;
$geo_geocoding = @file_get_contents($geocoding_url,false,stream_context_create(array('http' => array('timeout'=>$this->api_timeout))));
// APIのエラーハンドリング
if($geo_geocoding === FALSE){
if(count($http_response_header) > 0){
$stat_tokens = explode(' ', $http_response_header[0]);
switch($stat_tokens[1]){
case 404:
// 404 Not found の場合
break;
case 500:
// 500 Internal Server Error の場合
break;
default:
// その他
break;
}
}else{
// タイムアウトの場合
}
}else{
$geo_geocoding = simplexml_load_string($geo_geocoding);
}
//結果の取得とインシデントの取得
if(isset($geo_geocoding->coordinate)){
if(isset($geo_geocoding->coordinate->lat) && isset($geo_geocoding->coordinate->lng)){
$lat_center = $geo_geocoding->coordinate->lat;
$lon_center = $geo_geocoding->coordinate->lng;
$area_name = $geo_geocoding->address;
$_GET["address"] = $this->template->content->area_name = trim($area_name);
if($_GET["distance"] >= 1){
$this->template->content->disp_distance = $_GET["distance"]."km";
}else{
$this->template->content->disp_distance = ($_GET["distance"]*1000)."m";
}
$query = 'SELECT id FROM '.$this->table_prefix.'location WHERE (round(sqrt(pow(('.$this->table_prefix.'location.latitude - '.$lat_center.')/0.0111, 2) + pow(('.$this->table_prefix.'location.longitude - '.$lon_center.')/0.0091, 2)), 1)) <= '.$_GET["distance"];
//.........这里部分代码省略.........