* @access public
* @return array events
*/
- public function getModelEventsData($categoryId = null, $limit = null, $memberId = null)
+ public function getModelEventsData( $categoryId = null, $limit = null, $memberId = null )
{
$this->postAddTimes = true;
// If a catgegory ID is supplied
if ($catId = filter_var( $categoryId, FILTER_VALIDATE_INT )) {
$events = $this->getEventsByCategory( $catId, $limit );
- // Else if a event name is supplied
+ // Else if a event name is supplied
} else if ($term = filter_var( $categoryId, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES )) {
$searchTerm = $this->wpdb->esc_like( stripslashes( $term ) );
$where .= "T.name like '%" . $term . "%'
";
$order = "T.id";
$order .= " LIMIT 2 OFFSET 0";
- $events = $this->getList($where, $order);
- } else if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
- // Need to get the event id's for the next $limit number of events.
- $where .= "T.id
- AND T.status = " . $this->config['status_numb']['Active'] . "
- AND T.id IN (
- SELECT distinct event
- FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
- WHERE active
- AND start_time >= NOW()
- )
- ";
- $order = "T.id";
$events = $this->getList( $where, $order );
- // Otherwise get all categories
+ } else if ( $limit = filter_var( $limit, FILTER_VALIDATE_INT ) ) {
+ // Need to get the event id's for the next $limit number of events.
+ $where .= "T.id
+ AND T.status = " . $this->config['status_numb']['Active'] . "
+ AND T.id IN (
+ SELECT distinct event
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times AS ET
+ WHERE active
+ AND start_time >= NOW()
+ )
+ ";
+ $order = "T.id";
+ $events = $this->getList( $where, $order );
+ // Otherwise get all categories
} else {
$where .= "T.status = " . $this->config['status_numb']['Active'] . "
AND T.id IN (
AND " . $this->dateRange . "
)
";
- $events = $this->getList($where);
+ $events = $this->getList( $where );
}
- //echo '<pre>$events: ' . print_r($events, true) . '</pre>';
- if ( !empty($events) ) {
+ if ( !empty( $events ) ) {
foreach ( $events as &$event ) {
// grab the first from times and see if it's ongoing or not
- if ($event['times']) {
- reset($event['times']);
- $firstKey = key($event['times']);
- reset($event['times']);
+ if ( $event['times'] ) {
+ reset( $event['times'] );
+ $firstKey = key( $event['times'] );
+ reset( $event['times'] );
}
$event['dates'] = $this->getEventDate(
- strtotime($event['starting_date']),
- strtotime($event['ending_date']),
+ strtotime( $event['starting_date'] ),
+ strtotime( $event['ending_date'] ),
'timestamp'
);
}
return $events;
}
+ /**
+ * getFeaturedEventsData
+ *
+ * Fetch all events from current date on that are marked featured.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getFeaturedEventsData()
+ {
+ $this->postAddTimes = true;
+ $where .= "T.featured = 1";
+ $events = $this->getList( $where );
+ $this->postAddTimes = false;
+ return $events;
+ }
+
/**
* getModelEventData
*
* @access public
* @return array The event
*/
- public function getModelEventData($eventId)
+ public function getModelEventData( $eventId )
{
$this->postAddTimes = true;
$this->postAddLocations = true;
- $event = $this->getEntry($eventId);
+ $event = $this->getEntry( $eventId );
if ( $event['url'] ) {
if ( !preg_match( '/^http:|https:/', $event['url'] ) ) {
$event['url'] = 'http://' . $event['url'];
}
}
$event['dates'] = $this->getEventDate(
- strtotime($event['starting_date']),
- strtotime($event['ending_date']),
+ strtotime( $event['starting_date'] ),
+ strtotime( $event['ending_date'] ),
'timestamp'
);
$this->postAddTimes = false;
* @access public
* @return void
*/
- public function modelAction($actionData = false)
+ public function modelAction( $actionData = false )
{
- $status = $categoryId = null;
- $action = '';
- $settings = $events = $event = $categoryEvents = array();
- $calDates = false;
+ $status = null;
+ $categoryId = null;
+ $action = '';
+ $settings = array();
+ $events = array();
+ $event = array();
+ $calDates = false;
+ $memberId = null;
+ $view = null;
+ $featured = null;
+ $eventsByDate = null;
// If a memberID has been specified, limit to that member
- $memberId = $actionData['request']['member'] - 0;
+ if ( isset( $actiondata['request']['member'] ) ) {
+ $memberId = $actionData['request']['member'] - 0;
+ }
if ($memberId == 0) {
$memberId = null;
}
- $limit = filter_var( $actionData['request']['limit'], FILTER_VALIDATE_INT );
+ if ( isset( $actionData['request']['limit'] ) ) {
+ $limit = filter_var( $actionData['request']['limit'], FILTER_VALIDATE_INT );
+ }
if ( $limit ) {
$action = 'front-page';
}
-
+ if ( isset( $actionData['request']['featured'] ) ) {
+ $featured = filter_var( $actionData['request']['featured'], FILTER_VALIDATE_BOOLEAN );
+ $action = 'featured';
+ }
if (isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) {
$search = true;
$action = 'event-detail';
$action = 'nameSearch';
}
if ( isset($_REQUEST['glm_event_from']) ) {
- //$fromDate = filter_var($_REQUEST['glm_event_from'], FILTER_SANITIZE_STRING);
$fromDate = filter_var(
$_REQUEST['glm_event_from'],
FILTER_VALIDATE_REGEXP,
$fromDate = date('m/d/Y');
}
if ( isset($_REQUEST['glm_event_to']) ) {
- //$toDate = filter_var($_REQUEST['glm_event_to'], FILTER_SANITIZE_STRING);
$toDate = filter_var(
$_REQUEST['glm_event_to'],
FILTER_VALIDATE_REGEXP,
)
)
);
- } else if ( in_array($action, array( 'event-list-name', 'nameSearch' )) ) {
+ } else if ( in_array($action, array( 'event-list-name', 'nameSearch', 'featured' )) ) {
$toDate = null;
} else {
if ( isset($_REQUEST['t']) && $t = filter_var( $_REQUEST['t'], FILTER_SANITIZE_STRING ) ) {
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times
WHERE DATE(start_time) >= '{$from}')";
}
- //echo '<pre>$this->dateRange: ' . print_r($this->dateRange, true) . '</pre>';
if (isset($_REQUEST['event_name'])
&& $eventNameSearch = filter_var($_REQUEST['event_name'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)) {
wp_enqueue_style('jquery-style', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
- switch ($action) {
+ switch ( $action ) {
case 'front-page':
$events = $this->getModelEventsData($categoryId, $limit);
break;
case 'event-list-name':
- $events = $this->getModelEventsData($eventNameSearch);
+ $events = $this->getModelEventsData( $eventNameSearch );
$view = 'agenda.html';
break;
case 'event-list':
exit;
}
break;
+ case 'featured':
+ $events = $this->getFeaturedEventsData();
+ //echo '<pre>$events: ' . print_r( $events, true ) . '</pre>';
+ if ( isset ( $actionData['request']['template'] ) ) {
+ $view = $actionData['request']['template'];
+ } else {
+ $view = 'agenda.html';
+ }
+ //$view = 'agenda.html';
+ break;
case 'pdf':
include_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/SetaPDF/Autoload.php';
$this->postAddLocations = true;
// group the events by the starting date
$eventsByDate = $mainEvents = array();
- if ($events) {
+ if ( $events && $action != 'featured' ) {
foreach ( $events as $event ) {
if ( isset( $event['times'] ) && is_array( $event['times'] ) ) {
foreach ( $event['times'] as $eventTime ) {
}
// Check for alternate template requests
- switch($actionData['request']['template']) {
+ switch( $actionData['request']['template'] ) {
case 'member-list':
wp_enqueue_style('glm-member-db-events-style', GLM_MEMBERS_EVENTS_PLUGIN_URL . 'css/front.css');
$view = 'listForMemberListing.html';
// No changes otherwise
break;
}
+ $option_name = GLM_MEMBERS_PLUGIN_OPTION_PREFIX . 'event_list_id';
+ $event_page_id = get_option( $option_name );
+ if ( $event_page_id ) {
+ $mainEventPageUrl = get_permalink( $event_page_id );
+ }
// Compile template data
$templateData = array(
'eventId' => false,
'categoryId' => $categoryId,
'categories' => $categories,
+ 'events' => $events,
'eventsByDate' => $eventsByDate,
- 'catEvents' => $categoryEvents,
'fromDate' => $fromDate,
'toDate' => $toDate,
'eventName' => stripslashes( $eventNameSearch ),
+ 'mainEventUrl' => $mainEventPageUrl,
+ 'mainImgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/',
'imgUrl' => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/small/',
'calDates' => $calDates
);
* @link http://dev.gaslightmedia.com/
*/
-/*
+/**
* Array of short-code
*
* This array lists all of the short-codes available from the main
'type' => 'all',
'order' => 'title',
'member' => false,
- 'template' => false,
- 'limit' => null
+ 'template' => false,
+ 'limit' => null,
+ 'featured' => null,
)
),
'glm-members-event-detail' => array(
<td width="50%">
Displays a list of events.
</td>
+ </tr>
+ <tr>
+ <td> </td>
+ <th>
+ order="{ fieldName }"
+ </th>
+ <td>
+ The "order" attribute is used to set the field to use for ordering results. Defaults to \'title\'.
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <th>
+ template="{ template }"
+ </th>
+ <td>
+ The "template" attribute is used to set the template that will be
+ used for smarty. Defaults to false.
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <th>
+ featured="{ True/False }"
+ </th>
+ <td>
+ The "featured" attribute filters the result with the featured field. Defaults to null.
+ </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <th>
+ limit="{ (number) }"
+ </th>
+ <td>
+ The "limit" attribute limits the results to (number). Defaults to null.
+ </td>
</tr>
<tr>
<th>[glm-members-event-detail]</th>
--- /dev/null
+<div class="small-12 medium-9 large-10 columns">
+ <h1>Upcoming Events</h1>
+</div>
+<div class="small-12 show-for-medium-up medium-3 large-2 columns">
+ <a href="{$mainEventUrl}"><button>View All Events</button></a>
+</div>
+<div class="small-12 columns">
+ <div id="feed" class="row collapse">
+ {foreach $events as $event}
+ <div class="small-12 text-left medium-6 large-4 columns">
+ <a href="{$siteBaseUrl}event-detail/{$event.name_slug}/"><img src="{$mainImgUrl}{$event.image}"></a>
+ <a href="{$siteBaseUrl}event-detail/{$event.name_slug}/"><h6>{$event.name}</h6></a>
+ <hr>
+ <span>{$event.starting_timestamp|date_format:"%b %e"}</span>
+ <a href="{$siteBaseUrl}event-detail/{$event.name_slug}/" class="read">More</a>
+ </div>
+ {/foreach}
+ </div>
+</div>