Update process data so it doesn't override lat lon if given.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 20 May 2016 12:42:35 +0000 (08:42 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 20 May 2016 12:42:35 +0000 (08:42 -0400)
Toolkit/Events/AddCommonEventForm.php
config/eventCalendar.ini

index 2005e37..d60f378 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-//     vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
+//  vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker syntax=php:
 
 /**
  * New Event Form
@@ -29,7 +29,7 @@ class Toolkit_Events_AddCommonEventForm
     extends Toolkit_FormBuilder
     implements Toolkit_Form
 {
-    // {{{     properties
+    //  {{{ properties
 
     /**
      * Table in Database which holds the contact data
@@ -113,11 +113,11 @@ class Toolkit_Events_AddCommonEventForm
         #category {display:none};
         .listings {display:none};
     </style>
-               <div id="form-sucess-top">
+        <div id="form-sucess-top">
             Your event has been successfully added to the events calendar,
             however will not be visible until it has been approved by
             the Web site administrator. Thank You.
-               </div>';
+        </div>';
 
     /**
      * Extra rules for processesing
@@ -159,8 +159,8 @@ class Toolkit_Events_AddCommonEventForm
 
     protected $eventMapper;
 
-    // }}}
-    // {{{     __construct()
+    //  }}}
+    //  {{{ __construct()
 
     /**
      * Class constructor
@@ -172,7 +172,7 @@ class Toolkit_Events_AddCommonEventForm
      * @param string $target      (optional)Form's target defaults to '_self'
      * @param mixed  $attributes  (optional)Extra attributes for <form> tag
      * @param bool   $trackSubmit (optional)Whether to track if the form was
-     *                                                           submitted by adding a special hidden field
+     *                            submitted by adding a special hidden field
      *
      * @access public
      */
@@ -194,7 +194,7 @@ class Toolkit_Events_AddCommonEventForm
         $this->eventMapper = $eventMapper;
 
         if ($this->email !== false && empty($this->email)) {
-            // Set to false to turn off email function.
+            //  Set to false to turn off email function.
             $this->email = ADD_EVENT_EMAIL;
         }
         if (empty($this->siteName)) {
@@ -228,7 +228,7 @@ class Toolkit_Events_AddCommonEventForm
         );
     }
 
-    // }}}
+    //  }}}
     //  {{{ checkDate()
 
     /**
@@ -289,7 +289,7 @@ class Toolkit_Events_AddCommonEventForm
     }
 
     //  }}}
-    // {{{     configureElements()
+    //  {{{ configureElements()
 
     /**
      * Form element definitions
@@ -301,7 +301,7 @@ class Toolkit_Events_AddCommonEventForm
     {
         $e = array();
 
-        //     All Elements are created here.  This includes group element definitions.
+        //  All Elements are created here.  This includes group element definitions.
         $e[] = array(
             'type'    => 'header',
             'name'    => 'eventNameHdr',
@@ -558,8 +558,8 @@ class Toolkit_Events_AddCommonEventForm
         $this->setupElements($e);
     }
 
-    // }}}
-    // {{{     configureFilters()
+    //  }}}
+    //  {{{ configureFilters()
 
     /**
      * Form filter definitions
@@ -585,7 +585,7 @@ class Toolkit_Events_AddCommonEventForm
         $this->setupFilters($f);
     }
 
-    // }}}
+    //  }}}
     //  {{{ configureForm()
 
     /**
@@ -602,7 +602,7 @@ class Toolkit_Events_AddCommonEventForm
     }
 
     //  }}}
-    // {{{     configureRules()
+    //  {{{ configureRules()
 
     /**
      * Form rule definitions
@@ -614,7 +614,7 @@ class Toolkit_Events_AddCommonEventForm
      */
     public function configureRules()
     {
-        //     Form Rules
+        //  Form Rules
         $r[] = array(
             'element'    => 'topicid',
             'message'    => 'ERROR: Invalid Category!',
@@ -696,8 +696,8 @@ class Toolkit_Events_AddCommonEventForm
         $this->setupRules($r);
     }
 
-    // }}}
-    // {{{     getTopicFields()
+    //  }}}
+    //  {{{ getTopicFields()
 
     /**
      * get event topics
@@ -715,7 +715,7 @@ class Toolkit_Events_AddCommonEventForm
         return $categories;
     }
 
-    // }}}
+    //  }}}
     //  {{{ hasEndDate()
 
     /**
@@ -736,7 +736,7 @@ class Toolkit_Events_AddCommonEventForm
     }
 
     //  }}}
-    // {{{     emailOwner()
+    //  {{{ emailOwner()
 
     /**
      * Emails the owner the submitted data from the submitted form
@@ -802,7 +802,7 @@ class Toolkit_Events_AddCommonEventForm
         $template->compile('emailOwner.tpl');
         $htmlMsg = $template->bufferedOutputObject($page);
 
-        //     Text version can't have HTML in it
+        //  Text version can't have HTML in it
         $msg = "{$page->subject}\n\n";
         $msg .= "From {$page->fname} {$page->lname}\n\n";
         $msg .= "Information\n\n";
@@ -829,7 +829,7 @@ class Toolkit_Events_AddCommonEventForm
         }
     }
 
-    // }}}
+    //  }}}
     //  {{{ formatValue()
 
     /**
@@ -856,7 +856,7 @@ class Toolkit_Events_AddCommonEventForm
     }
 
     //  }}}
-    // {{{     insertData()
+    //  {{{ insertData()
 
     /**
      * Inserts contact data into the contact db
@@ -902,21 +902,24 @@ class Toolkit_Events_AddCommonEventForm
         }
     }
 
-    // }}}
+    //  }}}
     private function _geocode(array $values)
     {
         $geocoder = new GeocodeYahoo();
         if (!$values['address'] && !$values['city'] && !$values['state']) {
             return $values;
         }
+        if ($values['lat'] && $values['lon']) {
+            return $values;
+        }
         $address = array(
-                       'city'  => $values['city'],
-                       'state' => $values['state'],
-                       'zip'   => $values['zip'],
-               );
-               if (!empty($values['address'])) {
-                       $address['street'] = $values['address'];
-               }
+            'city'  => $values['city'],
+            'state' => $values['state'],
+            'zip'   => $values['zip'],
+        );
+        if (!empty($values['address'])) {
+            $address['street'] = $values['address'];
+        }
         try {
             $response = $geocoder->geocodeAddress($address);
             $responseArray = unserialize($response);
@@ -936,7 +939,7 @@ class Toolkit_Events_AddCommonEventForm
         }
 
     }
-    // {{{     processData()
+    //  {{{ processData()
 
     /**
      * Handles how to process the form when submitted
@@ -948,14 +951,14 @@ class Toolkit_Events_AddCommonEventForm
      */
     public function processData($values)
     {
-        //     Form data used for the insert/update sql queries and
-        //     the form email.
+        //  Form data used for the insert/update sql queries and
+        //  the form email.
         $e = array();
         $this->setFormData($e);
 
-        //     Get rid of any defined un-needed elements.
-        //     un-needed elements after the form is submitted are defined
-        //     by the ending _rmv name.
+        //  Get rid of any defined un-needed elements.
+        //  un-needed elements after the form is submitted are defined
+        //  by the ending _rmv name.
         foreach ($values as $k => &$v) {
             if (!is_array($v)) {
                 $values[$k] = preg_replace("/\r/", "\n", $v);
@@ -969,8 +972,8 @@ class Toolkit_Events_AddCommonEventForm
         return $this->insertData($values);
     }
 
-    // }}}
-    // {{{     setupRenderers()
+    //  }}}
+    //  {{{ setupRenderers()
 
     /**
      * Custom rendering templates for special fields on the form
@@ -996,8 +999,8 @@ class Toolkit_Events_AddCommonEventForm
         $this->template->compile($this->formTemplate);
     }
 
-    // }}}
-    // {{{     toHtml()
+    //  }}}
+    //  {{{ toHtml()
 
     /**
      * Handles how to display the current step the user is at in the form
@@ -1062,7 +1065,7 @@ class Toolkit_Events_AddCommonEventForm
         return $output;
     }
 
-    // }}}
+    //  }}}
 }
 
 ?>
index b8d5906..2104ac9 100644 (file)
@@ -27,6 +27,8 @@ css.ignore.regex[] = "response/V0/css/1140.css"
 css.replace[] = MEDIA_BASE_URL "Toolkit/Events/css/event.css"
 
 front.list.sortByCategory  = Off
+
+editForm.show_lat_lon = On
 ; development server configuration inherits from production and
 ; overrides values as needed
 [development : production]