Example #1
0
function events_build_output($type, $category, $link, $title, $title_link, $pre_message, $post_message, $thetime, $theend, $allday, $author, $location)
{
    global $wpdb, $events_config, $events_language, $events_template;
    if ($type == 'default') {
        $template = $events_template['page_template'];
    }
    if ($type == 'archive') {
        $template = $events_template['archive_template'];
    }
    if ($type == 'today') {
        $template = $events_template['daily_template'];
    }
    if ($type == 'week') {
        $template = $events_template['page_template'];
    }
    if ($type == 'month') {
        $template = $events_template['page_template'];
    }
    if ($title_link == 'Y') {
        $title = '<a href="' . $link . '" target="' . $events_config['linktarget'] . '">' . $title . '</a>';
    }
    $template = str_replace('%title%', $title, $template);
    $template = str_replace('%event%', $pre_message, $template);
    if (current_time('timestamp') <= $theend) {
        $template = str_replace('%after%', '', $template);
    } else {
        $template = str_replace('%after%', $post_message, $template);
    }
    if (strlen($link) > 0) {
        $template = str_replace('%link%', '<a href="' . $link . '" target="' . $events_config['linktarget'] . '">' . $events_language['language_pagelink'] . '</a>', $template);
    }
    if (strlen($link) == 0) {
        $template = str_replace('%link%', '', $template);
    }
    $template = str_replace('%countdown%', events_countdown($thetime, $theend, $post_message, $allday), $template);
    $template = str_replace('%countup%', events_countup($thetime, $theend, $post_message), $template);
    $template = str_replace('%duration%', events_duration($thetime, $theend, $allday), $template);
    $template = str_replace('%startdate%', gmstrftime($events_config['dateformat'], $thetime), $template);
    if ($thetime == $theend and $events_config['hideend'] == 'hide') {
        $template = str_replace('%endtime%', '', $template);
        $template = str_replace('%enddate%', '', $template);
    } else {
        if ($allday == "Y") {
            $template = str_replace('%endtime%', '', $template);
        } else {
            if ($events_config['hideendsidebar'] == 'hide') {
                $template = str_replace('%enddate%', '', $template);
            }
            $template = str_replace('%endtime%', str_replace('00:00', '', gmstrftime($events_config['timeformat'], $theend)), $template);
        }
        $template = str_replace('%enddate%', gmstrftime($events_config['dateformat'], $theend), $template);
    }
    if ($allday == "Y") {
        $template = str_replace('%starttime%', '', $template);
    } else {
        $template = str_replace('%starttime%', str_replace('00:00', '', gmstrftime($events_config['timeformat'], $thetime)), $template);
    }
    $template = str_replace('%author%', $author, $template);
    $template = str_replace('%category%', $category, $template);
    if (strlen($location) == 0) {
        $template = str_replace('%location%', '', $template);
    } else {
        $template = str_replace('%location%', $events_template['location_seperator'] . $location, $template);
    }
    return $template;
}
Example #2
0
function events_manage()
{
    global $wpdb, $events_config;
    $action = $order = '';
    if (isset($_GET['action'])) {
        $action = esc_attr($_GET['action']);
    }
    if (isset($_POST['order'])) {
        $order = esc_attr($_POST['order']);
    } else {
        $order = 'thetime DESC';
    }
    ?>
	<div class="wrap">
		<h2><?php 
    _e('Manage Events', 'wpevents');
    ?>
</h2>

		<?php 
    if ($action == 'delete-event') {
        ?>
			<div id="message" class="updated fade"><p><?php 
        _e('Event <strong>deleted</strong>', 'wpevents');
        ?>
</p></div>
		<?php 
    } else {
        if ($action == 'updated') {
            ?>
			<div id="message" class="updated fade"><p><?php 
            _e('Event <strong>updated</strong>', 'wpevents');
            ?>
</p></div>
		<?php 
        } else {
            if ($action == 'no_access') {
                ?>
			<div id="message" class="updated fade"><p><?php 
                _e('Action prohibited', 'wpevents');
                ?>
</p></div>
		<?php 
            }
        }
    }
    ?>

		<form name="events" id="post" method="post" action="admin.php?page=wp-events">
		<div class="tablenav">

			<div class="alignleft actions">
				<input onclick="return confirm('<?php 
    _e('You are about to delete one or more events!', 'wpevents');
    ?>
\n<?php 
    _e('[OK] to continue, [Cancel] to stop.', 'wpevents');
    ?>
')" type="submit" value="<?php 
    _e('Delete events', 'wpevents');
    ?>
" name="delete_events" class="button-secondary delete" />
				<select name='order'>
			        <option value="thetime DESC" <?php 
    if ($order == "thetime DESC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by date', 'wpevents');
    ?>
 (<?php 
    _e('descending', 'wpevents');
    ?>
, <?php 
    _e('default', 'wpevents');
    ?>
)</option>
			        <option value="thetime ASC" <?php 
    if ($order == "thetime ASC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by date', 'wpevents');
    ?>
 (<?php 
    _e('ascending', 'wpevents');
    ?>
)</option>
			        <option value="ID ASC" <?php 
    if ($order == "ID ASC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('in the order you made them', 'wpevents');
    ?>
 (<?php 
    _e('ascending', 'wpevents');
    ?>
)</option>
			        <option value="ID DESC" <?php 
    if ($order == "ID DESC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('in the order you made them', 'wpevents');
    ?>
 (<?php 
    _e('descending', 'wpevents');
    ?>
)</option>
			        <option value="title ASC" <?php 
    if ($order == "title ASC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by title', 'wpevents');
    ?>
 (A-Z)</option>
			        <option value="title DESC" <?php 
    if ($order == "title DESC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by title', 'wpevents');
    ?>
 (Z-A)</option>
			        <option value="category ASC" <?php 
    if ($order == "category ASC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by category', 'wpevents');
    ?>
 (A-Z)</option>
			        <option value="category DESC" <?php 
    if ($order == "category DESC") {
        echo 'selected';
    }
    ?>
><?php 
    _e('by category', 'wpevents');
    ?>
 (Z-A)</option>
				</select>
				<input type="submit" id="post-query-submit" value="<?php 
    _e('Sort', 'wpevents');
    ?>
" class="button-secondary" />
			</div>
		</div>
		<table class="widefat">
  			<thead>
  				<tr>
					<th scope="col" class="check-column">&nbsp;</th>
					<th scope="col" width="15%"><?php 
    _e('Date', 'wpevents');
    ?>
</th>
					<th scope="col"><?php 
    _e('Title', 'wpevents');
    ?>
</th>
					<th scope="col" width="10%"><?php 
    _e('Category', 'wpevents');
    ?>
</th>
					<th scope="col" width="20%"><?php 
    _e('Starts when', 'wpevents');
    ?>
</th>
				</tr>
  			</thead>
  			<tbody>
		<?php 
    if (events_mysql_table_exists($wpdb->prefix . 'events')) {
        $events = $wpdb->get_results("SELECT * FROM `{$wpdb->prefix}events` ORDER BY {$order}");
        if ($events) {
            $class = '';
            foreach ($events as $event) {
                $cat = $wpdb->get_row("SELECT `name` FROM `{$wpdb->prefix}events_categories` WHERE `id` = '{$event->category}'");
                $class = 'alternate' != $class ? 'alternate' : '';
                ?>
				    <tr id='event-<?php 
                echo $event->id;
                ?>
' class=' <?php 
                echo $class;
                ?>
'>
						<th scope="row" class="check-column"><input type="checkbox" name="eventcheck[]" value="<?php 
                echo $event->id;
                ?>
" /></th>
						<td><?php 
                echo gmdate('d-m-Y H:i', $event->thetime);
                ?>
</td>
						<td><strong><a class="row-title" href="<?php 
                echo get_option('siteurl') . '/wp-admin/admin.php?page=wp-events-edit&amp;edit_event=' . $event->id;
                ?>
" title="<?php 
                _e('Edit', 'wpevents');
                ?>
"><?php 
                echo stripslashes(html_entity_decode($event->title));
                ?>
</a></strong></td>
						<td><?php 
                echo $cat->name;
                ?>
</td>
						<td><?php 
                echo events_countdown($event->thetime, $event->theend, $event->post_message, $event->allday);
                ?>
</td>
					</tr>
	 			<?php 
            }
            ?>
	 		<?php 
        } else {
            ?>
				<tr id='no-id'><td scope="row" colspan="5"><em><?php 
            _e('No Events yet!', 'wpevents');
            ?>
</em></td></tr>
			<?php 
        }
    } else {
        ?>
			<tr id='no-id'><td scope="row" colspan="5"><span style="font-weight: bold; color: #f00;"><?php 
        _e('There was an error locating the main database table for Events.', 'wpevents');
        _e('Please deactivate and re-activate Events from the plugin page!!', 'wpevents');
        ?>
<br /><?php 
        echo sprintf(__('If this does not solve the issue please seek support at <a href="%s">%s</a>.', 'wpevents'), 'http://meandmymac.net/contact-and-support/?pk_campaign=wpevents-eventslist&pk_kwd=databaseerror', 'http://meandmymac.net/support/');
        ?>
</span></td></tr>

		<?php 
    }
    ?>
			</tbody>
		</table>
		</form>

		<br class="clear" />
		<?php 
    events_credits();
    ?>

	</div>
	<?php 
}