当前位置: 首页>>代码示例>>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;未经允许,请勿转载。