From aa0d730f0391bd902b440ec8df4915f073216ce3 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 29 Mar 2016 10:11:27 -0400 Subject: [PATCH] adding front end form adding shortcode, action, model and view --- models/front/events/frontAdd.php | 126 +++++++++++++++++++ setup/shortcodes.php | 10 ++ setup/validActions.php | 3 +- views/front/events/frontAdd.html | 198 ++++++++++++++++++++++++++++++ views/front/events/shortCuts.html | 1 + 5 files changed, 337 insertions(+), 1 deletion(-) create mode 100644 models/front/events/frontAdd.php create mode 100644 views/front/events/frontAdd.html diff --git a/models/front/events/frontAdd.php b/models/front/events/frontAdd.php new file mode 100644 index 0000000..0d3f454 --- /dev/null +++ b/models/front/events/frontAdd.php @@ -0,0 +1,126 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GLmMembersFront_events_frontAdd extends GlmMembersFront_events_baseAction +{ + /** + * modelAction + * + * @param bool $actionData Action Data passed to the modelAction + * + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + $status = null; + $action = ''; + $settings = $event = array(); + + if ( isset($_REQUEST['glm_event_from']) ) { + $fromDate = filter_var($_REQUEST['glm_event_from'], FILTER_SANITIZE_STRING); + } else { + $fromDate = date('m/d/Y'); + } + $this->dateRange = "start_time >= '{$fromDate}'"; + + if ( isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) { + $search = true; + $action = 'event-detail'; + } else { + $search = true; + $action = 'event-detail'; + $eventslug = get_query_var( 'eventslug' ); + //echo '
$eventslug: ' . print_r($eventslug, true) . '
'; + $sql = " + SELECT id + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX. "events + WHERE name_slug = '$eventslug'"; + $eventId = $this->wpdb->get_var($sql); + } + + $categories = $this->getCategories(); + wp_register_script( + 'googlemaps-js', + 'http://maps.googleapis.com/maps/api/js?key=', + null, + GLM_MEMBERS_EVENTS_PLUGIN_VERSION, + true + ); + wp_enqueue_script('googlemaps-js'); + wp_register_script( + 'event-geocoder-js', + GLM_MEMBERS_EVENTS_PLUGIN_BASE_URL . '/js/geoCoder.js', + null, + GLM_MEMBERS_EVENTS_PLUGIN_VERSION, + true + ); + wp_enqueue_script('event-geocoder-js'); + wp_register_script( + 'event-dashboard-js', + GLM_MEMBERS_EVENTS_PLUGIN_BASE_URL . '/js/dashboard.js', + 'jquery-datepicker', + GLM_MEMBERS_EVENTS_PLUGIN_VERSION, + true + ); + wp_enqueue_script('event-dashboard-js'); + + + switch ($action) { + case 'event-detail': + $event = $this->getModelEventData($eventId); + //echo '
$event: ' . print_r($event, true) . '
'; + $view = 'detail.html'; + break; + default: + // for the dashboard need to get list of event categories and + // filter out the events + $events = $this->getModelEventsData(); + $view = 'agenda.html'; + $categoryEvents = array(); + break; + } + $permalink = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; + $title = get_the_title(); + + // Compile template data + $templateData = array( + 'siteBaseUrl' => GLM_MEMBERS_EVENTS_SITE_BASE_URL, + 'currentUrl' => $_SERVER['HTTP_REFERER'], + 'categories' => $categories, + 'fromDate' => $fromDate, + 'event' => $event, + 'permalink' => $permalink, + 'title' => $title, + 'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/' + ); + + error_reporting(E_ALL ^ E_NOTICE); + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/events/frontAdd.html', + 'data' => $templateData, + 'settings' => $settings + ); + } +} diff --git a/setup/shortcodes.php b/setup/shortcodes.php index c2ca3de..f0b9fdc 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -115,6 +115,16 @@ $glmMembersEventsShortcodes = array( ) ), + 'glm-members-event-frontAdd' => array( + 'plugin' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, + 'menu' => 'events', + 'action' => 'frontAdd', + 'table' => false, + 'attributes' => array( + 'id' => false + ) + + ), ); $glmMembersEventsShortcodesDescription = ' diff --git a/setup/validActions.php b/setup/validActions.php index f0c382e..0454059 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -49,7 +49,8 @@ $glmMembersEventsAddOnValidActions = array( 'frontActions' => array( 'events' => array( 'list' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, - 'detail' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG + 'detail' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, + 'frontAdd' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG ) ) ); diff --git a/views/front/events/frontAdd.html b/views/front/events/frontAdd.html new file mode 100644 index 0000000..abe0ea2 --- /dev/null +++ b/views/front/events/frontAdd.html @@ -0,0 +1,198 @@ + + +

Add Your Event

+ + + + + + + + + +{if $haveEvent} + + + + + + + + + + + + + + + + +{/if} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Event Name: + + {if $event.fieldFail.name}

{$event.fieldFail.name}

{/if}
+
Member: + {if $haveMember} + {$memberData.member_name} + {else} + + {/if} +
Name for URLs:{$event.fieldData.name_slug}
Created:{$event.fieldData.created.datetime}
Last Updated:{$event.fieldData.updated.datetime}
Last Approved:{$event.fieldData.approved.datetime}
Status: + + {if $event.fieldFail.status}

{$event.fieldFail.status}

{/if} +
Categories + + + +
Add a new Category
+
+ + + + + + + + + +
Category Name: + +
+
Parent Category: + +
OR
+ +
+

* Required

+ Cancel + +
+ + + +    Select a category to add to box below.
+
+ + {if isset($event.fieldData.categories) && $event.fieldData.categories} + {foreach $event.fieldData.categories as $c} +
+ {if $c.parent_name != ''}{$c.parent_name}: {/if}{$c.name} + X + +
+ {/foreach} + {/if} +
+
Intro Text: + + {if $event.fieldFail.intro}

{$event.fieldFail.intro}

{/if} +
Description: + {php} + wp_editor('{$event.fieldData.descr|escape:quotes}', 'glm_descr', array( + // 'media_buttons' => true, + // 'quicktags' => false, + // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text. + 'textarea_name' => 'descr', + 'editor_height' => 200, // Height in px, overrides editor_rows + // 'textarea_rows' => 8 + )); + {/php} + {if $event.fieldFail.descr}

{$event.fieldFail.descr}

{/if} +
Image: + + {if $event.fieldData.image} + + + + + {/if} + +
+
+ +
+
+ Delete Image
+ {$event.fieldData.image}
+
New image:
+
+ {if $event.fieldFail.image}

{$event.fieldFail.image}

{/if} +
Web Address (URL): + + {if $event.fieldFail.url}

{$event.fieldFail.url}

{/if}
+
Ticketing Address (URL): + + {if $event.fieldFail.ticket_url}

{$event.fieldFail.ticket_url}

{/if}
+
Description of Cost: + + {if $event.fieldFail.cost}

{$event.fieldFail.cost}

{/if}
+
Notes: + + {if $event.fieldFail.notes}

{$event.fieldFail.notes}

{/if} +
+ diff --git a/views/front/events/shortCuts.html b/views/front/events/shortCuts.html index a37abb9..4b26f7b 100644 --- a/views/front/events/shortCuts.html +++ b/views/front/events/shortCuts.html @@ -3,6 +3,7 @@
  • Today's Events
  • Tomorrow's Events
  • Next 7 Days
  • +
  • Add an Event
  • -- 2.17.1