當前位置: 首頁>>代碼示例>>PHP>>正文


PHP map::borough方法代碼示例

本文整理匯總了PHP中map::borough方法的典型用法代碼示例。如果您正苦於以下問題:PHP map::borough方法的具體用法?PHP map::borough怎麽用?PHP map::borough使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在map的用法示例。


在下文中一共展示了map::borough方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: submit


//.........這裏部分代碼省略.........
         }
         // Validate photo uploads
         $post->add_rules('incident_photo', 'upload::valid', 'upload::type[gif,jpg,png]', 'upload::size[2M]');
         // Validate Personal Information
         if (!empty($_POST['person_first'])) {
             $post->add_rules('person_first', 'length[3,100]');
         }
         if (!empty($_POST['person_last'])) {
             $post->add_rules('person_last', 'length[3,100]');
         }
         if (!empty($_POST['person_email'])) {
             $post->add_rules('person_email', 'email', 'length[3,100]');
         }
         $custom_fields = (!isset($_POST['custom_field']) or !is_array($_POST['custom_field'])) ? array() : $_POST['custom_field'];
         // XXX can make more generic by iterating through field definitions
         // and verifying the required ones are present in the post
         $custom_fieldid = 14;
         $custom_fieldname = "custom_field[{$custom_fieldid}]";
         $custom_error = false;
         if (!isset($custom_fields[$custom_fieldid]) or empty($custom_fields[$custom_fieldid])) {
             $custom_message_key = "report.{$custom_fieldname}.required";
             $errors[$custom_fieldname] = Kohana::lang($custom_message_key);
             $custom_error = true;
         }
         // Test to see if things passed the rule checks
         if ($post->validate() and !$custom_error) {
             // STEP 1: SAVE LOCATION
             $location = new Location_Model();
             $location->location_name = $post->location_name;
             $location->latitude = $post->latitude;
             $location->longitude = $post->longitude;
             $location->location_date = date("Y-m-d H:i:s", time());
             // reverse geocode to get borough
             $borough = map::borough($post->latitude, $post->longitude);
             if ($borough) {
                 $location->borough = $borough;
             }
             $location->save();
             // STEP 2: SAVE INCIDENT
             $incident = new Incident_Model();
             $incident->location_id = $location->id;
             $incident->form_id = $post->form_id;
             $incident->user_id = 0;
             $incident->incident_title = $post->incident_title;
             $incident->incident_description = $post->incident_description;
             $incident_date = explode("/", $post->incident_date);
             // The $_POST['date'] is a value posted by form in mm/dd/yyyy format
             $incident_date = $incident_date[2] . "-" . $incident_date[0] . "-" . $incident_date[1];
             $incident_time = $post->incident_hour . ":" . $post->incident_minute . ":00 " . $post->incident_ampm;
             $incident->incident_date = date("Y-m-d H:i:s", strtotime($incident_date . " " . $incident_time));
             $incident->incident_dateadd = date("Y-m-d H:i:s", time());
             $incident->save();
             // STEP 3: SAVE CATEGORIES
             foreach ($post->incident_category as $item) {
                 $incident_category = new Incident_Category_Model();
                 $incident_category->incident_id = $incident->id;
                 $incident_category->category_id = $item;
                 $incident_category->save();
             }
             // STEP 4: SAVE MEDIA
             // a. News
             foreach ($post->incident_news as $item) {
                 if (!empty($item)) {
                     $news = new Media_Model();
                     $news->location_id = $location->id;
                     $news->incident_id = $incident->id;
開發者ID:rmarianski,項目名稱:pps-ushahidi,代碼行數:67,代碼來源:reports.php


注:本文中的map::borough方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。