From 78e1cdea6942d9c7b05852356d78f72fdaf29459 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Tue, 29 Mar 2016 08:15:54 -0400 Subject: [PATCH] removed form from agenda view and added separate page with shortcode --- css/front.css | 2 +- models/front/events/frontAdd.php | 167 ++++++++++++++++++ setup/shortcodes.php | 9 + setup/validActions.php | 3 +- views/front/events/agenda.html | 1 - .../front/events/{add.html => frontAdd.html} | 0 6 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 models/front/events/frontAdd.php rename views/front/events/{add.html => frontAdd.html} (100%) diff --git a/css/front.css b/css/front.css index f3d73c9..2211ea9 100644 --- a/css/front.css +++ b/css/front.css @@ -113,5 +113,5 @@ background-position: 0px 0px !important; } #addEventFields{ - display:none; + } \ No newline at end of file diff --git a/models/front/events/frontAdd.php b/models/front/events/frontAdd.php new file mode 100644 index 0000000..7f26ffa --- /dev/null +++ b/models/front/events/frontAdd.php @@ -0,0 +1,167 @@ + + * @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) + { + $allEvents = $this->getList(); + //echo '
' . print_r( $allEvents, true ) . '
'; + $status = $categoryId = null; + $action = ''; + $settings = $events = $event = $categoryEvents = array(); + if (isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) { + $search = true; + $action = 'event-detail'; + } + if (isset($_REQUEST['category']) && $categoryId = filter_var($_REQUEST['category'], FILTER_VALIDATE_INT)) { + $search = true; + $action = 'event-list'; + } + if (isset($_REQUEST['search']) && $search = filter_var($_REQUEST['search'], FILTER_VALIDATE_INT)) { + $search = true; + $action = 'event-list'; + } + if ( isset($_REQUEST['glm_event_from']) ) { + $fromDate = filter_var($_REQUEST['glm_event_from'], FILTER_SANITIZE_STRING); + } else { + $fromDate = date('m/d/Y'); + } + if ( isset($_REQUEST['glm_event_to']) ) { + $toDate = filter_var($_REQUEST['glm_event_to'], FILTER_SANITIZE_STRING); + } else { + if ( isset($_REQUEST['t']) && $t = filter_var( $_REQUEST['t'], FILTER_SANITIZE_STRING ) ) { + switch ( $t ) { + case 'today': + $toDate = date('m/d/Y'); + break; + case 'tomorrow': + $fromDate = $toDate = date('m/d/Y', strtotime( '+ 1 day' )); + break; + case 'nextseven': + $toDate = date('m/d/Y', strtotime( '+ 7 days' )); + break; + default: + $toDate = date('m/d/Y', strtotime( '+ 2 weeks' )); + break; + } + } else { + $toDate = date('m/d/Y', strtotime( '+ 2 weeks' )); + } + } + if ( $fromDate && $toDate ) { + $from = date('Y-m-d', strtotime($fromDate)); + $to = date('Y-m-d', strtotime($toDate)); + $this->dateRange = "start_time BETWEEN CAST('{$from}' AS DATE) AND CAST('{$to}' as DATE)"; + } + //echo '
$this->dateRange: ' . print_r($this->dateRange, true) . '
'; + + if (isset($_REQUEST['event_name']) && $eventNameSearch = filter_var($_REQUEST['event_name'], FILTER_SANITIZE_STRING)) { + $search = true; + $action = 'event-list'; + } else { + $eventNameSearch = false; + } + + $categories = $this->getCategories(); + 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-list': + $events = $this->getModelEventsData($categoryId); + $view = 'agenda.html'; + break; + default: + $view = 'agenda.html'; + $events = $this->getModelEventsData($categoryId); + break; + } + + // group the events by the starting date + $eventsByDate = array(); + if ($events) { + foreach ( $events as $event ) { + foreach ( $event['times'] as $eventTime ) { + $eventDateTime = mktime( + 0, 0, 0, + date('n', $eventTime['start_time']['timestamp']), + date('j', $eventTime['start_time']['timestamp']), + date('Y', $eventTime['start_time']['timestamp']) + ); + $event['starting_date'] = $eventTime['start_time']['timestamp']; + $event['ending_date'] = $eventTime['end_time']['timestamp']; + $event['hasSameTimes'] = ($event['starting_date'] == $event['ending_date']) ? 1 : 0; + $eventsByDate[$eventDateTime][$eventTime['start_time']['timestamp']] = $event; + } + } + ksort($eventsByDate); + } + //echo '
$eventsByDate: ' . print_r($eventsByDate, true) . '
'; + //if ($eventNameSearch) { + //$events = array_filter($events, function($event) use($eventNameSearch){ + //return preg_match('/' . preg_quote( $eventNameSearch ) . '/i', $event['title']); + //}); + //} + + // Compile template data + $templateData = array( + 'siteBaseUrl' => GLM_MEMBERS_EVENTS_SITE_BASE_URL, + 'currentUrl' => GLM_MEMBERS_EVENTS_PLUGIN_CURRENT_URL, + 'categoryId' => $categoryId, + 'categories' => $categories, + //'events' => $events, + 'eventsByDate' => $eventsByDate, + //'event' => $event, + 'catEvents' => $categoryEvents, + 'fromDate' => $fromDate, + 'toDate' => $toDate, + 'eventName' => $eventNameSearch, + 'imgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/' + ); + + 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 89767f0..8a4dba4 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -114,6 +114,15 @@ $glmMembersEventsShortcodes = array( 'id' => false ) ), + 'glm-members-event-frontAdd' => array( + 'plugin' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, + 'menu' => 'events', + 'action' => 'frontAdd', + 'table' => false, + 'attributes' => array( + 'id' => false + ) + ), ); diff --git a/setup/validActions.php b/setup/validActions.php index 245998a..5cdf7de 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/agenda.html b/views/front/events/agenda.html index 736c33d..48f7223 100644 --- a/views/front/events/agenda.html +++ b/views/front/events/agenda.html @@ -3,7 +3,6 @@ {include file='front/events/searchForm.html'} {include file='front/events/shortCuts.html'} - {include file='front/events/add.html'}
diff --git a/views/front/events/add.html b/views/front/events/frontAdd.html similarity index 100% rename from views/front/events/add.html rename to views/front/events/frontAdd.html -- 2.17.1