Add new template for front page current events.
$feed['next_runtime'] = wp_next_scheduled( GLM_MEMBERS_EVENTS_PLUGIN_CRON_EVENT, array( (int)$feed['id'] ) );
}
}
-
+
// Populate the state list for event default state selection
$event_settings['event_default_state'] = $this->config['states'];
-
+
// Compile template data
$template_data = array(
'import_feeds' => $import_feeds,
*/
public function addCategories()
{
+ $category_label = ( $this->settings['tablename'] == 'event' ) ? 'descr' : 'name';
$return = '';
$sql = "
SELECT *
$sql = "
SELECT id
FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "categories
- WHERE name = '" . esc_sql( trim($category['name']) ) . "'";
+ WHERE name = '" . esc_sql( trim($category[$category_label]) ) . "'";
$return .= '<pre>$sql: ' . print_r($sql, true) . '</pre>';
$found = $this->wpdb->get_row($sql, ARRAY_A);
$return .= '<pre>$found: ' . print_r($found, true) . '</pre>';
$this->wpdb->insert(
GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . 'categories',
array(
- 'name' => trim($category['name']),
+ 'name' => trim($category[$category_label]),
'parent' => 0
),
array(
)
);
$catid = $this->wpdb->insert_id;
- $this->categories[$catid] = trim($category['name']);
+ $this->categories[$catid] = trim($category[$category_label]);
$this->oldCatMap[$category['id']] = $catid;
} else {
- $this->categories[$found['id']] = trim($category['name']);
+ $this->categories[$found['id']] = trim($category[$category_label]);
$this->oldCatMap[$category['id']] = $found['id'];
}
}
$get_file_data = $this->dbh->prepare($prepare_sql);
}
//$sql .=" AND file != '' ";
- //$sql .= " AND id = 5";
+ //$sql .= " AND id = 2396";
$this->wpdb->show_errors();
- echo '<pre>$sql: ' . print_r($sql, true) . '</pre>';
+ //echo '<pre>$sql: ' . print_r($sql, true) . '</pre>';
try {
$events = $this->dbh->query($sql)->fetchAll(PDO::FETCH_ASSOC);
$return .= '<pre>$events: ' . print_r($events, true) . '</pre>';
}
}
if ( $old_event_format ) {
- $intro = substr(strip_tags($event['descr']), 0, 150);
+ $intro = substr(
+ str_replace(
+ "\n",
+ ' ',
+ strip_tags( $event['descr'] )
+ ),
+ 0,
+ 150
+ );
+ $descr = preg_replace(
+ '%<br />|<br>%',
+ '',
+ $event['descr']
+ );
+ $descr = str_replace(
+ "\n",
+ '',
+ $descr
+ );
$event_data = array(
'status' => (($event['visable'] == '1')
? $this->config['status_numb']['Active']
'approved' => $event['approved_date'],
'name' => $event['header'],
'intro' => $intro,
- 'descr' => $event['descr'],
+ 'descr' => $descr,
'image' => $event['img'],
'file1' => $event['file'],
'file1_descr' => $event['filename'],
return $events;
}
+ /**
+ * getFeaturedEventsData
+ *
+ * Fetch all events from current date on that are marked featured.
+ *
+ * @access public
+ * @return mixed
+ */
+ public function getCurrentEvents( $limit = 3 )
+ {
+ // Get the last $limit Events.
+ $events = $this->wpdb->get_results(
+ $this->wpdb->prepare(
+ "SELECT E.*,T1.start_time as start,T2.end_time as end
+ FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events E,
+ " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T1,
+ " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times T2
+ WHERE E.status = 10
+ AND T1.event = E.id AND T1.start_time IN (SELECT MIN(start_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = E.id AND end_time <= %s)
+ AND T2.event = E.id AND T2.end_time IN (SELECT MAX(end_time) FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "times WHERE event = E.id AND end_time >= %s)
+ ORDER BY start, end
+ LIMIT %d
+ OFFSET 0",
+ date( 'Y-m-d' ),
+ date( 'Y-m-d' ),
+ $limit
+ ),
+ ARRAY_A
+ );
+ if ( $events ) {
+ foreach ( $events as &$event ) {
+ $event['dates'] = $this->getEventDate( strtotime( $event['start'] ), strtotime( $event['end'] ), 'timestamp', false );
+ }
+ }
+ return $events;
+ }
+
/**
* getModelEventData
*
function getEventDate( $sdate, $edate, $dateType, $microFormat = false )
{
switch($dateType) {
- case "Postgres":
+ case "Postgres":
$postgresPattern = "/([0-9]{1,2})[/-]([0-9]{1,2})[/-]([0-9]{4})/";
if (preg_match($postgresPattern, $sdate, $spt)) {
- $mon = $spt[1];
- $day = $spt[2];
- $yr = $spt[3];
- }
+ $mon = $spt[1];
+ $day = $spt[2];
+ $yr = $spt[3];
+ }
if (preg_match($postgresPattern, $edate, $ept)) {
- $mon2 = $ept[1];
- $day2 = $ept[2];
- $yr2 = $ept[3];
- }
- break;
+ $mon2 = $ept[1];
+ $day2 = $ept[2];
+ $yr2 = $ept[3];
+ }
+ break;
case "eventstamp":
- case "timestamp":
- $mon = date("m",$sdate);
- $day = date("d",$sdate);
- $yr = date("Y",$sdate);
- $mon2 = date("m",$edate);
- $day2 = date("d",$edate);
- $yr2 = date("Y",$edate);
- break;
+ case "timestamp":
+ $mon = date("m",$sdate);
+ $day = date("d",$sdate);
+ $yr = date("Y",$sdate);
+ $mon2 = date("m",$edate);
+ $day2 = date("d",$edate);
+ $yr2 = date("Y",$edate);
+ break;
}
$start = mktime(0,0,0,$mon,$day,$yr);
$memberId = null;
$view = null;
$featured = null;
+ $current = null;
$eventsByDate = null;
// If a memberID has been specified, limit to that member
if ( isset( $actionData['request']['limit'] ) ) {
$limit = filter_var( $actionData['request']['limit'], FILTER_VALIDATE_INT );
}
+ if ( isset ( $actionData['request']['template'] ) ) {
+ $view = $actionData['request']['template'];
+ }
if ( $limit ) {
$action = 'front-page';
}
$featured = filter_var( $actionData['request']['featured'], FILTER_VALIDATE_BOOLEAN );
$action = 'featured';
}
+ if ( isset( $actionData['request']['current'] ) ) {
+ $current = filter_var( $actionData['request']['current'], FILTER_VALIDATE_BOOLEAN );
+ $action = 'current';
+ }
if (isset($_REQUEST['eventId']) && $eventId = filter_var($_REQUEST['eventId'], FILTER_VALIDATE_INT)) {
$search = true;
$action = 'event-detail';
exit;
}
break;
+ case 'current':
+ $events = $this->getCurrentEvents( $limit );
+ if ( isset ( $actionData['request']['template'] ) && $actionData['request']['template'] ) {
+ $view = $actionData['request']['template'];
+ } else {
+ $view = 'eventsHomeCurrent.html';
+ }
+ break;
case 'featured':
$events = $this->getFeaturedEventsData( $featured );
- if ( isset ( $actionData['request']['template'] ) ) {
+ if ( isset ( $actionData['request']['template'] ) && $actionData['request']['template'] ) {
$view = $actionData['request']['template'];
} else {
$view = 'agenda.html';
include_once GLM_MEMBERS_EVENTS_PLUGIN_PATH . '/SetaPDF/Autoload.php';
$this->postAddLocations = true;
$this->postAddRecurrences = true;
- $events = $this->getModelEventsData($categoryId);
+ $events = $this->getModelEventsData($categoryId);
$this->postAddLocations = false;
$this->postAddRecurrences = false;
$pdfY -= self::LINE_HEIGHT;
}
$intro->draw($page->getCanvas(), self::PDF_LFT_COL_X, $pdfY);
- //echo '<pre>lineCount: ' . print_r($lineCount, true) . '</pre>';
$pdfY -= self::LINE_HEIGHT;// * $lineCount;
$page->getCanvas()->draw()->line(self::PDF_LFT_COL_X, $pdfY, self::PDF_WIDTH, $pdfY);
// group the events by the starting date
$eventsByDate = $mainEvents = array();
- if ( $events && $action != 'featured' ) {
+ if ( $events && $action != 'featured' && $action != 'current' ) {
foreach ( $events as $event ) {
if ( isset( $event['times'] ) && is_array( $event['times'] ) ) {
foreach ( $event['times'] as $eventTime ) {
$calendar_view = $calendar_view[0]['calendar_view'];
}
-// print_r($calDates);
-// echo "<pre>", print_r($eventsByDate), "</pre>";
// Compile template data
$templateData = array(
'assetsUrl' => GLM_MEMBERS_EVENTS_PLUGIN_URL . 'assets/',
'template' => false,
'limit' => null,
'featured' => null,
+ 'current' => null,
)
),
'glm-members-event-detail' => array(
--- /dev/null
+{if $events}
+ {foreach $events as $event}
+ <div class="event">
+ <h5>{$event.name}</h5>
+ {if $event.image}
+ <div class="small-12 text-center medium-4 medium-text-left large-3 columns event-post">
+ <img src="{$mainImgUrl}{$event.image}">
+ </div>
+ <div class="small-12 medium-8 large-9 columns event-post">
+ {else}
+ <div class="mall-12 columns event-post">
+ {/if}
+ <p class="post-date">{$event.dates}</p>
+ <p>{$event.intro}</p>
+ <a href="{$siteBaseUrl}event-detail/{$event.name_slug}/">find out more...</a>
+ </div>
+ </div>
+ {/foreach}
+{/if}