Add your event form
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Aug 2014 18:53:17 +0000 (14:53 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 15 Aug 2014 18:54:24 +0000 (14:54 -0400)
Adding the form.
Make form template so it is like the other forms and uses foundation
styles.
Update to use cdn for jquery-ui and the theme

Toolkit/Events/AddCommonEventForm.php
Toolkit/Events/application.ini [new file with mode: 0644]
Toolkit/Events/libjs/addEvent.js
Toolkit/Events/templates/form.html [new file with mode: 0644]
Toolkit/FormBuilder.php
static/40.phtml [new file with mode: 0644]

index 18e4a6e..d4cc8b2 100644 (file)
@@ -100,6 +100,7 @@ class Toolkit_Events_AddCommonEventForm
      * @access protected
      */
     protected $subject = 'New Event Submission';
+    public $formTemplate = 'form.html';
 
     /**
      * Message to display if the form is successfully submitted
@@ -303,8 +304,8 @@ class Toolkit_Events_AddCommonEventForm
         //     All Elements are created here.  This includes group element definitions.
         $e[] = array(
             'type'    => 'header',
-            'name'    => 'eventInfoHdr',
-            'display' => 'Event Information'
+            'name'    => 'eventNameHdr',
+            'display' => 'Event Name'
         );
         $e[] = array(
             'type'    => 'text',
@@ -312,6 +313,11 @@ class Toolkit_Events_AddCommonEventForm
             'name'    => 'header',
             'display' => 'Event Name'
         );
+        $e[] = array(
+            'type'    => 'header',
+            'name'    => 'eventDateHdr',
+            'display' => 'Event Date / Time'
+        );
         $e[] = array(
             'type'    => 'text',
             'req'     => true,
@@ -365,6 +371,11 @@ class Toolkit_Events_AddCommonEventForm
                 ),
             ),
         );
+        $e[] = array(
+            'type'    => 'header',
+            'name'    => 'eventInfoHdr',
+            'display' => 'Event Information'
+        );
         $e[] = array(
             'type'    => 'select',
             'req'     => true,
@@ -529,7 +540,8 @@ class Toolkit_Events_AddCommonEventForm
             'type'    => 'submit',
             'req'     => false,
             'name'    => 'submit_rmv',
-            'display' => 'Submit'
+            'display' => 'Submit',
+            'opts'    => array('class' => 'button')
         );
 
         $this->setupElements($e);
@@ -957,18 +969,20 @@ class Toolkit_Events_AddCommonEventForm
      */
     protected function setupRenderers()
     {
-        parent::setupRenderers();
-        $renderer = $this->defaultRenderer();
-        $required = '<!-- BEGIN required --><span class="req">*</span><!-- END required -->';
-        $error    = '<!-- BEGIN error --><div class="req">{error}</div><!-- END error -->';
+        $formConfig = new Zend_Config_Ini(
+            BASE . 'Toolkit/Events/application.ini',
+            strtolower($_ENV['GLM_HOST_ID'])
+        );
 
-        $renderer->setElementTemplate('<tr><td colspan="2">' . $required . '{label}' . $error . '{element}</td></tr>', 'descr');
-        $renderer->setElementTemplate('<tr align="center"><td colspan="2">' . $required . '{label}' . $error . '{element}</td></tr>', 'submit_rmv');
+        $renderer = new HTML_QuickForm_Renderer_Object(true);
+        $this->accept($renderer);
+        $this->template = new HTML_Template_Flexy(
+            $formConfig->flexyOptions->toArray()
+        );
 
-        if ($this->useCaptcha) {
-            $renderer->setElementTemplate('<tr><td class="labelcell"><label>{label}</label></td><td class="fieldcell captcha">{element}</td></tr>', 'captcha_question');
-            $renderer->setElementTemplate('<tr><td class="labelcell">' . $required . '<label>{label}</label></td><td class="fieldcell">' . $error . '{element}<span class="tooltip" title="Verification Code|To help us distinguish between information submitted by individuals and those automatically entered by software robots, please type the letters shown.">What is this?</span></td></tr>', 'captcha_rmv');
-        }
+        $this->view = $this;
+        $this->view->form = $renderer->toObject();
+        $this->template->compile($this->formTemplate);
     }
 
     // }}}
@@ -985,7 +999,6 @@ class Toolkit_Events_AddCommonEventForm
      */
     public function toHtml()
     {
-        $this->setupRenderers();
         if ($this->validate()) {
             $this->captchaQuestion->destroy();
             $this->cleanForm();
@@ -1003,11 +1016,9 @@ class Toolkit_Events_AddCommonEventForm
             }
             $output                     = $this->errorMsg;
             $GLOBALS['topScripts'][]
-                = MEDIA_APP_BASE_URL
-                . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js';
+                = '//code.jquery.com/ui/1.11.1/jquery-ui.min.js';
             $GLOBALS['styleSheets'][]
-                = MEDIA_APP_BASE_URL
-                . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css';
+                = '//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css';
             $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js';
             $GLOBALS['topScripts'][]
                 = 'http://maps.googleapis.com/maps/api/js?sensor=true';
@@ -1015,18 +1026,17 @@ class Toolkit_Events_AddCommonEventForm
                 = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js';
             $GLOBALS['bottomScripts'][]
                 = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js';
-            $output .= parent::toHtml();
+            $output  = $this->errorMsg;
+            $output .= $this->template->bufferedOutputObject($this->view);
         } else {
             if ($this->useCaptcha) {
                 $this->captchaQuestion->destroy();
                 $this->captchaAnswer->setValue('');
             }
             $GLOBALS['topScripts'][]
-                = MEDIA_APP_BASE_URL
-                . 'libjs/jqueryui/1.8.13/js/jquery-ui-1.8.13.custom.min.js';
+                = '//code.jquery.com/ui/1.11.1/jquery-ui.min.js';
             $GLOBALS['styleSheets'][]
-                = MEDIA_APP_BASE_URL
-                . 'libjs/jqueryui/1.8.13/development-bundle/themes/base/jquery.ui.all.css';
+                = '//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css';
             $GLOBALS['bottomScripts'][] = MEDIA_APP_BASE_URL . 'libjs/textlimit.js';
             $GLOBALS['topScripts'][]
                 = 'http://maps.googleapis.com/maps/api/js?sensor=true';
@@ -1034,7 +1044,8 @@ class Toolkit_Events_AddCommonEventForm
                 = MEDIA_BASE_URL . 'Toolkit/Maps/geoCoder.js';
             $GLOBALS['bottomScripts'][]
                 = MEDIA_BASE_URL . 'Toolkit/Events/libjs/addEvent.js';
-            $output                     = parent::toHtml();
+            $this->setupRenderers();
+            $output .= $this->template->bufferedOutputObject($this->view);
         }
         return $output;
     }
diff --git a/Toolkit/Events/application.ini b/Toolkit/Events/application.ini
new file mode 100644 (file)
index 0000000..121f873
--- /dev/null
@@ -0,0 +1,23 @@
+; Production server configuration data
+[production]
+; flexyOptions
+flexyOptions.templateDir  = BASE "Toolkit/Events/templates"
+flexyOptions.compileDir   = BASE "Toolkit/Events/templates/compiled"
+flexyOptions.forceCompile = Off
+flexyOptions.allowPHP     = On
+
+; development server configuration data inherits from production and
+; overrides values as necessary
+[development : production]
+
+; chuck's server configuration data inherits from development
+; and overrides values as necessary
+[chuck : development]
+
+; steve's server configuration data inherits from development
+; and overrides values as necessary
+[steve : development]
+
+; Vagrant server configuration inherits from development and
+; overrides values as needed
+[vagrant : development]
index b912912..ebdffb7 100644 (file)
@@ -21,6 +21,7 @@ var AddEvent =
             e.preventDefault();
             $("#map-dialog").dialog('open');
             GLM_GeoMap.initialize();
+            return false;
         });
        }
 }
diff --git a/Toolkit/Events/templates/form.html b/Toolkit/Events/templates/form.html
new file mode 100644 (file)
index 0000000..34f1676
--- /dev/null
@@ -0,0 +1,104 @@
+
+    {form.javascript:h}
+    {form.outputHeader():h}
+    {form.hidden:h}
+    {hidden}
+
+    {foreach:form.sections,sec}
+    {if:sec.header}
+    <fieldset>
+            <legend>{sec.header:h}</legend>
+    {end:}
+                    <div class="row">
+        {foreach:sec.elements,elem}
+            {if:elem.style}
+              {elem.outputStyle():h}
+            {else:}
+                {if:elem.isButton()}
+                    {if:elem.notFrozen()}
+                        <div class="medium-6 small-12 columns">{elem.html:h}</div>
+                    
+                    {end:}
+                {else:}
+                    {if:elem.error}
+                        <div class="medium-6  small-12 columns error">
+                    {else:}
+                        <div class="medium-6  small-12 columns">
+                        {end:}
+                    {if:elem.isType(#textarea#)}
+                        {if:elem.required}<label class="req">{else:}<label>{end:}
+
+                            {if:elem.required}<span class="req">*</span>{end:}
+                            {elem.label:h}
+                    {else:}
+                        {if:elem.isType(#CAPTCHA_Image#)}
+                                {if:elem.required}<label>{else:}<label class="req">{end:}
+                                {if:elem.required}<span class="req">*</span>{end:}
+                            {elem.label:h}
+
+                        {else:}
+                            {if:elem.isType(#group#)}
+                                {if:element.isName(#interest#)}
+                                {else:}
+                                    {if:elem.required}<label class="req">{else:}<label>{end:}
+                                    {if:elem.required}<span class="req">*</span>{end:}
+                                    {elem.label:h}<br>
+                                {end:}
+                            {else:}
+
+                                    {if:elem.required}<label class="req">{else:}<label>{end:}
+                                    {if:elem.required}<span class="req">*</span>{end:}
+                                    {elem.label:h}
+
+                                {if:elem.isName(#interest#)}
+
+                                {else:}
+
+                                {end:}
+                            {end:}
+                        {end:}
+                    {end:}
+
+                    {if:elem.isType(#group#)}
+
+                        <div class="row collapse">
+
+                            {foreach:elem.elements,gitem}
+                            <div class="small-12 columns">
+                                {gitem.html:h}{if:gitem.required}<div class="req">*</div>{end:}
+                                {if:elem.separator}{elem.separator:h}{end:}
+                            </div>
+                            {end:}
+
+                        </div>
+
+                    {else:}
+                        {elem.html:h}
+                        {if:elem.isName(#captcha_rmv#)}
+                            <span
+                                class="tooltip"
+                                title="Verification Code|To help us distinguish between
+                                information submitted by individuals and those automatically
+                                entered by software robots, please type the letters shown.">What is this?
+                            </span>
+                        {end:}
+                    {end:}
+                                    </label>
+                            {if:elem.error}<small class="error">{elem.error}</small>{end:}
+                                </div> <!-- end for columns -->
+                {end:}
+            {end:}
+        {end:}  <!-- end for foreach:sec.element,elem -->
+                    </div> <!-- end for row -->
+
+    {if:sec.header}
+    </fieldset>
+    {end:}
+    {end:} <!-- end for foreach:form.section,sec -->
+
+
+       </form>
+       {if:form.requirednote}
+    <div>{form.requirednote:h}</div>
+    {end:}
+
index 4eb5592..a95d669 100644 (file)
@@ -1205,7 +1205,7 @@ abstract class Toolkit_FormBuilder extends HTML_QuickForm
      */
     public function useCaptcha($useCaptcha)
     {
-        $this->useClueTip();
+//        $this->useClueTip();
         $this->useCaptcha = $useCaptcha;
     }
 
diff --git a/static/40.phtml b/static/40.phtml
new file mode 100644 (file)
index 0000000..536bac4
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+if (defined('COMMON_EVENTS') && COMMON_EVENTS) {
+    if (!defined('COMMON_APP_BASE')) {
+        define('COMMON_APP_BASE', '/var/www/server/CommonApps/');
+    }
+    require_once COMMON_APP_BASE . 'EventCalendar/V1/models/EventMapper.php';
+    $eventMapper = new EventMapper(Toolkit_Database::getInstance());
+    $form = new Toolkit_Events_AddCommonEventForm(
+        Toolkit_Database::getInstance(),
+        'new_event',
+        'post',
+        '',
+        '',
+        null,
+        false,
+        $eventMapper
+    );
+    $form->useCaptcha(true);
+    $form->setAutoValidateDateElements(false);
+    $form->configureForm();
+    echo $form->toHtml();
+} else {
+    $scriptTag = <<<EOD
+<script type="text/javascript">
+$(document).ready(function(){
+  $("textarea[name='descr']").textlimit('span.counter',1000);
+});
+</script>
+EOD;
+    $form = new Toolkit_Events_AddEventForm(
+        Toolkit_Database::getInstance(),
+        'new_event'
+    );
+    $form->useCaptcha(true);
+    $form->setAutoValidateDateElements(false);
+    $form->configureForm();
+    echo $form->toHtml();
+}