Пример #1
0
    /**
     * Creates the filter and pagination bar in the overview
     * @param $filter
     * @param $part
     * @param $page
     * @param $epp
     * @param $count
     * @param $bl
     * @return unknown_type
     */
    function printNavigationBar($filter = array(), $part = 1, $page = 1, $epp = 20, $count = 0, $bl = '')
    {
        global $wpdb;
        global $fsCalendar;
        ?>
		<div class="tablenav">
			<div class="alignleft actions">
				<select name="action<?php 
        echo $part == 2 ? '2' : '';
        ?>
">
					<option selected="selected" value=""><?php 
        _e('Choose action', fsCalendar::$plugin_textdom);
        ?>
</option>
					<option value="delete"><?php 
        _e('Delete', fsCalendar::$plugin_textdom);
        ?>
</option>
					<?php 
        if ($fsCalendar->userCanPublishEvents()) {
            echo '<option value="publish">' . __('Publish', fsCalendar::$plugin_textdom) . '</option>';
        }
        ?>
					<?php 
        if ($fsCalendar->userCanEditEvents()) {
            echo '<option value="draft">' . __('Set to Draft', fsCalendar::$plugin_textdom) . '</option>';
        }
        ?>
				</select>
				<input id="doaction<?php 
        echo $part;
        ?>
" class="button-secondary action" type="submit" name="doaction" value="<?php 
        _e('Apply', fsCalendar::$plugin_textdom);
        ?>
" />
				<?php 
        if ($part == 1) {
            ?>
					<select name="event_start">
					<option value="-1"<?php 
            echo !isset($filter['datefrom']) ? ' selected="selected"' : '';
            ?>
><?php 
            _e('Show all dates', fsCalendar::$plugin_textdom);
            ?>
</option>
					<option value="0"<?php 
            echo isset($filter['datefrom']) && !isset($filter['dateto']) ? ' selected="selected"' : '';
            ?>
><?php 
            _e('Show future dates only', fsCalendar::$plugin_textdom);
            ?>
</option>
					<?php 
            $min = $wpdb->get_var('SELECT MIN(tsfrom) AS min FROM ' . $wpdb->prefix . 'fsevents');
            $max = $wpdb->get_var('SELECT MAX(tsto)   AS max FROM ' . $wpdb->prefix . 'fsevents');
            if ($min != NULL && $max != NULL) {
                $ms = fsCalendar::date('m', $min);
                $ys = fsCalendar::date('Y', $min);
                $me = fsCalendar::date('m', $max);
                $ye = fsCalendar::date('Y', $max);
                while ($ys <= $ye) {
                    while ($ms <= 12 && ($ys < $ye || $ms <= $me)) {
                        $time = mktime(0, 0, 0, $ms, 1, $ys);
                        echo '<option value="' . $time . '"' . ($time == $filter['datefrom'] ? ' selected="selected"' : '') . '>' . fsCalendar::date_i18n('F Y', $time) . '</option>';
                        $ms++;
                    }
                    $ms = 1;
                    $ys++;
                }
            }
            ?>
					</select>
					
					<?php 
            $dropdown_options = array('show_option_all' => __('View all categories'), 'hide_empty' => 0, 'hierarchical' => 1, 'show_count' => 0, 'name' => 'event_category', 'orderby' => 'name');
            if (isset($filter['categories'][0])) {
                $dropdown_options['selected'] = $filter['categories'][0];
            }
            wp_dropdown_categories($dropdown_options);
            ?>
					<input id="event-query-submit" class="button-secondary" type="submit" value="<?php 
            _e('Filter', fsCalendar::$plugin_textdom);
            ?>
" />
				<?php 
        }
        ?>
			</div>
		<?php 
        if ($count > $epp) {
            $evon = ($page - 1) * $epp + 1;
            $ebis = $page * $epp;
            $pages = ceil($count / $epp);
            ?>
			<div class="tablenav-pages">		
			<span class="displaying-num"><?php 
            printf('Showing %d-%d of %d', $evon, $ebis, $count);
            ?>
</span>
				<?php 
            if ($page > 1) {
                echo '<a class="prev page-numbers" href="' . $bl . 'paged=1">&laquo;</a>';
            }
            for ($i = 1; $i <= $pages; $i++) {
                if ($i == $page) {
                    echo '<span class="page-numbers current">' . $i . '</span>';
                } else {
                    echo '<a class="page-numbers" href="' . $bl . 'paged=' . $i . '">' . $i . '</a>';
                }
            }
            if ($page < $pages) {
                echo '<a class="next page-numbers" href="' . $bl . 'paged=' . $pages . '">&raquo;</a>';
            }
            ?>
			</div>
		<?php 
        }
        ?>
		</div>
		<?php 
    }
Пример #2
0
                 break;
             case 'nosync':
                 $evt->disableSynchronization();
                 $success[] = __('Synchronization with post data has been disabled', fsCalendar::$plugin_textdom);
                 break;
         }
     }
 } else {
     if ($evt->eventid == 0 && !$copy) {
         // Calculate date and time
         $current = time();
         $day = fsCalendar::date('d', $current);
         $mon = fsCalendar::date('m', $current);
         $yea = fsCalendar::date('Y', $current);
         $std = fsCalendar::date('H', $current);
         $min = fsCalendar::date('i', $current);
         // No changes
         if ($min > 0) {
             $min = ceil($min / $steps) * $steps;
             if ($min == 0) {
                 $std++;
             }
             $current = mktime($std, $min, 0, $mon, $day, $yea);
         }
         $evt->date_admin_from = fsCalendar::date_i18n($evt->date_admin_format, $current);
         $evt->time_admin_from = fsCalendar::date_i18n($evt->time_admin_format, $current);
         // End date/time
         $min += $add_min;
         if ($min >= 60) {
             $std++;
             $min -= 60;
Пример #3
0
 /**
  * Returns all events in a certain state
  * For date selection, you can specify a start and/or an end timestamp.
  * If both dates are specified, all events are returned, which are valid
  * between this two dates in mode `ALL` (can start before and end after the
  * corresponding dates. In mode `START` only events are returned, which start
  * between this two dates. In mode `END` only events are returned, which end
  * between this two dates. 
  * If only a start date is spefied, all Events are returned, which are valid
  * after this date in mode `ALL` and all events are returned, which start
  * after this date in mode `START`. Mode `END` corresponds to `ALL`.
  * If only a end date is specified, all events are returned, which are valid
  * before this date in mode `ALL` and all events are returnd, which end
  * before this date in mode `END`. Mode `START` corresponds to `ALL`.
  * @param $filter using the following keys: id_inc, id_exc, author, state, categories, datefrom, dateto, datemode
  * @param $sort_string Sort string
  * @return Array of event IDs
  */
 function getEvents($filter, $sort_string = '', $limit = 0, $start = 0, $count = false)
 {
     global $wpdb;
     if (empty($sort_string)) {
         $sort_string = 'e.tsfrom ASC';
     }
     // If its an allday event, modify any selection time, because allday events allways starts at 00:00
     if (isset($filter['allday']) && $filter['allday'] == true) {
         if (isset($filter['datefrom'])) {
             $df = $filter['datefrom'];
             $filter['datefrom'] = mktime(0, 0, 0, fsCalendar::date('m', $df), fsCalendar::date('d', $df), fsCalendar::date('Y', $df));
         }
         if (isset($filter['dateto'])) {
             $df = $filter['dateto'];
             $filter['dateto'] = mktime(0, 0, 0, fsCalendar::date('m', $df), fsCalendar::date('d', $df) + 1, fsCalendar::date('Y', $df)) - 1;
         }
     }
     $where = ' WHERE ';
     if (isset($filter['id_inc']) && is_array($filter['id_inc'])) {
         $where .= " e.eventid IN (" . implode(',', $filter['id_inc']) . ") AND";
     }
     if (isset($filter['id_exc']) && is_array($filter['id_exc'])) {
         $where .= " e.eventid NOT IN (" . implode(',', $filter['id_exc']) . ") AND";
     }
     if (isset($filter['state']) && isset(self::$valid_states[$filter['state']])) {
         $where .= " e.state='{$filter['state']}' AND";
     }
     if (isset($filter['author'])) {
         $where .= " e.author='{$filter['author']}' AND";
     }
     if (isset($filter['allday'])) {
         $where .= " e.allday=" . ($filter['allday'] === true ? '1' : '0') . " AND";
     }
     if (isset($filter['datefrom']) || isset($filter['dateto'])) {
         if (!isset($filter['datemode'])) {
             $filter['datemode'] = FSE_DATE_MODE_ALL;
         }
         // Make date selection complete
         if (!isset($filter['datefrom'])) {
             $filter['datefrom'] = 0;
         }
         if (!isset($filter['dateto'])) {
             $filter['dateto'] = mktime(23, 59, 59, 12, 31, 2037);
         }
         // Allday events to-stamp is at the beginning of the day!
         $date_to_allday = mktime(0, 0, 0, fsCalendar::date('m', $filter['datefrom']), fsCalendar::date('d', $filter['datefrom']), fsCalendar::date('y', $filter['datefrom']));
         // Events must always start before the end and
         // must end after start
         $where .= ' (e.tsfrom <= ' . $filter['dateto'] . ') AND ' . ' ((e.tsto >= ' . $filter['datefrom'] . ') OR (e.tsto >= ' . $date_to_allday . ' AND allday = 1))';
         //
         if ($filter['datemode'] == FSE_DATE_MODE_START) {
             $where .= ' AND (e.tsfrom >= ' . $filter['datefrom'] . ')';
         } elseif ($filter['datemode'] == FSE_DATE_MODE_END) {
             $where .= ' AND (e.tsfrom <= ' . $filter['dateto'] . ')';
         }
         $where .= ' AND';
     }
     // Join for categories
     $join = '';
     if (isset($filter['categories'])) {
         $f = $filter['categories'];
         if (!is_array($f)) {
             $f = array($f);
         }
         $in = '';
         foreach ($f as $c) {
             $c = intval($c);
             if (!empty($c)) {
                 $in .= $c . ',';
             }
         }
         if (!empty($in)) {
             $in = substr($in, 0, strlen($in) - 1);
             $where .= ' c.catid IN (' . $in . ') AND';
             $join = ' LEFT JOIN ' . $wpdb->prefix . 'fsevents_cats AS c ON e.eventid = c.eventid ';
         }
     }
     if ($where != ' WHERE ') {
         $where = substr($where, 0, strlen($where) - 3);
     } else {
         $where = '';
     }
     // Special Case 'Count'!
     if ($count == true) {
         $sql = 'SELECT DISTINCT count(e.eventid) FROM ' . $wpdb->prefix . 'fsevents AS e ' . $join . $where . ' ORDER BY ' . $sort_string;
         return $wpdb->get_var($sql);
     } else {
         $sql = 'SELECT DISTINCT e.eventid FROM ' . $wpdb->prefix . 'fsevents AS e ' . $join . $where . ' ORDER BY ' . $sort_string;
         if (!empty($limit)) {
             $sql .= ' LIMIT ' . intval($start) . ', ' . intval($limit);
         }
     }
     $res = $wpdb->get_col($sql);
     if ($res === NULL) {
         return false;
     }
     return $res;
 }
Пример #4
0
</td>
					<td class="num">
					<?php 
            $count = $wpdb->get_var('SELECT COUNT(*) FROM ' . $wpdb->commentmeta . ' WHERE meta_key="event_id" AND meta_value="' . $e->eventid . '"');
            echo '<span class="post-com-count" style="cursor: default"><span class="comment-count" style="cursor: default">' . $count . '</span></span>';
            ?>
					</td>
					<td><?php 
            echo esc_attr(fsCalendar::$valid_states[$e->state]);
            ?>
 <?php 
            _e('on', fsCalendar::$plugin_textdom);
            ?>
<br />
					<?php 
            echo fsCalendar::date('d.m.Y H:i:s', $e->state == 'publish' ? $e->publishdate : $e->createdate);
            ?>
<br /></td>
				</tr>
				<?php 
        }
    }
    ?>
		</tbody>
	</table>
	<?php 
    $this->printNavigationBar($filter, 2, $page, $epp, $event_count, $bl_filter);
    ?>
	<?php 
    if ($fsCalendar->userCanAddEvents()) {
        ?>