• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP eo_get_blog_timezone函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中eo_get_blog_timezone函数的典型用法代码示例。如果您正苦于以下问题:PHP eo_get_blog_timezone函数的具体用法?PHP eo_get_blog_timezone怎么用?PHP eo_get_blog_timezone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了eo_get_blog_timezone函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: handle_calendar_shortcode

 static function handle_calendar_shortcode($atts = array())
 {
     /* Shortcodes don't accept hyphens, so convert taxonomy names */
     $taxs = array('category', 'tag', 'venue');
     foreach ($taxs as $tax) {
         if (isset($atts['event_' . $tax])) {
             $atts['event-' . $tax] = $atts['event_' . $tax];
             unset($atts['event_' . $tax]);
         }
     }
     if (isset($atts['show_long'])) {
         $atts['show-long'] = $atts['show_long'];
         unset($atts['show_long']);
     }
     if (isset($atts['link_to_single'])) {
         $atts['link-to-single'] = $atts['link_to_single'];
         unset($atts['link_to_single']);
     }
     /* Parse defaults */
     $atts = wp_parse_args($atts, array('showpastevents' => 1, 'show-long' => 0, 'link-to-single' => 0));
     self::$add_script = true;
     $id = count(self::$widget_calendars);
     $cal_id = 'eo_shortcode_calendar_' . $id;
     self::$widget_calendars[$cal_id] = $atts;
     $tz = eo_get_blog_timezone();
     $date = isset($_GET['eo_month']) ? $_GET['eo_month'] . '-01' : 'now';
     $month = new DateTime($date, $tz);
     $month = date_create($month->format('Y-m-1'), $tz);
     $html = '<div class="widget_calendar eo-calendar eo-calendar-shortcode eo_widget_calendar" id="' . $cal_id . '">';
     $html .= '<div id="' . $cal_id . '_content" class="eo-widget-cal-wrap" data-eo-widget-cal-id="' . $cal_id . '">';
     $html .= EO_Calendar_Widget::generate_output($month, $atts);
     $html .= '</div>';
     $html .= '</div>';
     return $html;
 }
开发者ID:hmorv,项目名称:Event-Organiser,代码行数:35,代码来源:class-eventorganiser-shortcodes.php


示例2: testEventMetaList

 public function testEventMetaList()
 {
     $event_id = $this->factory->event->create(array('start' => new DateTime('2014-07-09 13:02:00', eo_get_blog_timezone()), 'end' => new DateTime('2014-07-09 14:02:00', eo_get_blog_timezone()), 'all_day' => 0, 'schedule' => 'once'));
     $tag = wp_insert_term('foobar', 'event-tag');
     wp_set_object_terms($event_id, (int) $tag['term_id'], 'event-tag');
     $cat = wp_insert_term('hellworld', 'event-category');
     wp_set_object_terms($event_id, (int) $cat['term_id'], 'event-category');
     $html = eo_get_event_meta_list($event_id);
     $expected = file_get_contents(EO_DIR_TESTDATA . '/event-functions/event-meta-list.html');
     $this->assertXmlStringEqualsXmlString($expected, $html);
 }
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:11,代码来源:eventFunctionsTest.php


示例3: testSeriesQuery

 /**
  * When grouping events by series, the plug-in should use the first date
  * (chronologicaly) of the series, matching the query 
  */
 public function testSeriesQuery()
 {
     $events = eo_get_events(array('event_start_after' => '2015-03-01 00:00:00', 'showpastevents' => true, 'group_events_by' => 'series'));
     $actual = array();
     foreach ($events as $event) {
         $actual[] = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
     }
     $expected = array(new DateTime('2015-03-02 14:00:00', eo_get_blog_timezone()), new DateTime('2015-03-20 19:30:00', eo_get_blog_timezone()), new DateTime('2015-03-23 09:45:00', eo_get_blog_timezone()));
     $this->assertEquals($expected, $actual);
     foreach ($this->event_ids as $event_id) {
         //var_dump( eo_get_the_occurrences( $event_id ) );
     }
     $events = eo_get_events(array('event_start_after' => '2015-03-22 00:00:00', 'showpastevents' => true, 'group_events_by' => 'series'));
     $actual = array();
     foreach ($events as $event) {
         $actual[] = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
     }
     $expected = array(new DateTime('2015-03-22 19:30:00', eo_get_blog_timezone()), new DateTime('2015-03-23 09:45:00', eo_get_blog_timezone()), new DateTime('2015-03-23 14:00:00', eo_get_blog_timezone()));
     $this->assertEquals($expected, $actual);
 }
开发者ID:hmorv,项目名称:Event-Organiser,代码行数:24,代码来源:eventQueryTest.php


示例4: eventorganiser_delete_expired_events

/**
 * Callback for the delete expired events cron job. Deletes events that finished at least 24 hours ago.
 * For recurring events it is only deleted once the last occurrence has expired.
 *
 * @since 1.4.0
 * @ignore
 * @access private
 */
function eventorganiser_delete_expired_events()
{
    //Get expired events
    $events = eo_get_events(array('showrepeats' => 0, 'showpastevents' => 1, 'eo_interval' => 'expired'));
    $time_until_expired = (int) apply_filters('eventorganiser_events_expire_time', 24 * 60 * 60);
    $time_until_expired = max($time_until_expired, 0);
    if ($events) {
        $now = new DateTime('now', eo_get_blog_timezone());
        foreach ($events as $event) {
            $start = eo_get_the_start(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $end = eo_get_the_end(DATETIMEOBJ, $event->ID, null, $event->occurrence_id);
            $expired = round(abs($end->format('U') - $start->format('U'))) + $time_until_expired;
            //Duration + expire time
            $finished = eo_get_schedule_last(DATETIMEOBJ, $event->ID);
            $finished->modify("+{$expired} seconds");
            //[Expired time] after the last occurrence finishes
            //Delete if [expired time] has passed
            if ($finished <= $now) {
                wp_trash_post((int) $event->ID);
            }
        }
    }
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:31,代码来源:event-organiser-register.php


示例5: php52_modify

 /**
  * Deals with ordinal month manipulation (e.g. second day of +2 month) for PHP <5.3
  * @since 1.2
  * @param datetime - 'current' date-time 
  * @string the modify string: second day of +2 month
  * @return datetime - the date-time calculated.
  */
 function php52_modify($date = '', $modify = '')
 {
     $pattern = '/([a-zA-Z]+)\\s([a-zA-Z]+) of \\+(\\d+) month/';
     preg_match($pattern, $modify, $matches);
     $ordinal_arr = array('last' => 0, 'first' => 1, 'second' => 2, 'third' => 3, 'fourth' => 4);
     $week = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
     $ordinal = $ordinal_arr[$matches[1]];
     $day = array_search(strtolower($matches[2]), $week);
     $freq = intval($matches[3]);
     //set to first day of month
     $date = date_create($date->format('Y-m-1'));
     //add months
     $date->modify('+' . $freq . ' month');
     //Calculate offset to day of week
     //Date of desired day
     if ($ordinal > 0) {
         $offset = ($day - intval($date->format('w')) + 7) % 7;
         $d = $offset + 7 * ($ordinal - 1) + 1;
     } else {
         $date = date_create($date->format('Y-m-t'));
         $offset = intval(($date->format('w') - $day + 7) % 7);
         $d = intval($date->format('t')) - $offset;
     }
     $blog_tz = eo_get_blog_timezone();
     $date = date_create($date->format('Y-m-' . $d), $blog_tz);
     return $date;
 }
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:34,代码来源:class-eo-event.php


示例6: testTimezoneChangeRRULE

 public function testTimezoneChangeRRULE()
 {
     //When day changes when start date is converted to UTC timezone (for iCal feed)
     //Remember to correct [day] the 'reccurs weekly by [day]', so thats true for UTC timezone.
     wp_cache_set('eventorganiser_timezone', 'America/New_York');
     //Event recurrs every Monday evening in New York (event recurs very Tuesday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 21:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 23:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 21:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=TU;UNTIL=20131231T020000Z", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
     //Now try it the other direction....
     wp_cache_set('eventorganiser_timezone', 'Europe/Moscow');
     //Event recurrs every Monday morning in Moscow (event recurs very Sunday in UTC)
     $event_id = $this->factory->event->create(array('start' => new DateTime('2013-12-02 01:00', eo_get_blog_timezone()), 'end' => new DateTime('2013-12-02 02:00', eo_get_blog_timezone()), 'schedule_last' => new DateTime('2013-12-30 01:00', eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'weekly', 'schedule_meta' => array('MO'), 'post_title' => 'The Event Title', 'post_content' => 'My event content'));
     $this->assertEquals("FREQ=WEEKLY;INTERVAL=1;BYDAY=SU;UNTIL=20131229T210000Z", eventorganiser_generate_ics_rrule($event_id));
     wp_cache_delete('eventorganiser_timezone');
 }
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:16,代码来源:iCalFeedTest.php


示例7: eventorganiser_pre_get_posts

/**
 * Parses event queries and alters the WP_Query object appropriately
 *
 * Parse's the query, and sets date range and other event specific query variables.
 * If query is for 'event' post type - the posts_* filters are added.
 *
 * Hooked onto pre_get_posts
 * @since 1.0.0
 * @access private
 * @ignore
 *
 * @param WP_Query $query The query
 */
function eventorganiser_pre_get_posts($query)
{
    //Deprecated, use event-venue instead.
    if (!empty($query->query_vars['venue'])) {
        $venue = $query->get('venue');
        $query->set('event-venue', $venue);
        $query->set('post_type', 'event');
    }
    //If the query is for eo-events feed, set post type
    if ($query->is_feed('eo-events')) {
        $query->set('post_type', 'event');
    }
    //If querying for all events starting on given date, set the date parameters
    if (!empty($query->query_vars['ondate'])) {
        $ondate_start = str_replace('/', '-', $query->query_vars['ondate']);
        $ondate_end = str_replace('/', '-', $query->query_vars['ondate']);
        $parts = count(explode('-', $ondate_start));
        if ($parts == 1 && is_numeric($ondate_start)) {
            //Numeric - interpret as year
            $ondate_start .= '-01-01';
            $ondate_end .= '-12-31';
        } elseif ($parts == 2) {
            // 2012-01 format: interpret as month
            $ondate_start .= '-01';
            try {
                $end = new DateTime($ondate_start);
                $ondate_end = $end->format('Y-m-t');
            } catch (Exception $e) {
                $query->set('ondate', false);
                break;
            }
        }
        $query->set('post_type', 'event');
        $query->set('event_start_before', $ondate_end);
        $query->set('event_end_after', $ondate_start);
    }
    //If not on event, stop here.
    if (!eventorganiser_is_event_query($query, true)) {
        return $query;
    }
    $blog_now = new DateTime(null, eo_get_blog_timezone());
    //Determine whether or not to show past events and each occurrence. //If not set, use options
    if (!is_admin() && !is_single() && !$query->is_feed('eo-events') && !isset($query->query_vars['showpastevents'])) {
        //If showpastevents is not set - use options (except for admin / single pages.
        $query->set('showpastevents', eventorganiser_get_option('showpast'));
    }
    //Deprecated: showrepeats - use group_events_by instead
    if (isset($query->query_vars['showrepeats']) && !isset($query->query_vars['group_events_by'])) {
        if (!$query->query_vars['showrepeats']) {
            $query->set('group_events_by', 'series');
        }
    }
    //Determine how to group events: by series or show each occurrence
    if (!isset($query->query_vars['group_events_by'])) {
        //Group by isn't set - default depends on context:
        if ($query->is_main_query() && (is_admin() || is_single() || $query->is_feed('eo-events'))) {
            //If in admin or single page - we probably don't want to see duplicates of (recurrent) events - unless specified otherwise.
            $query->set('group_events_by', 'series');
        } elseif (eventorganiser_get_option('group_events') == 'series') {
            //In other instances (archives, shortcode listing) if showrepeats option is false display only the next event.
            $query->set('group_events_by', 'series');
        } else {
            $query->set('group_events_by', 'occurrence');
        }
    }
    //Parse user input as date-time objects
    $date_objs = array('event_start_after' => '', 'event_start_before' => '', 'event_end_after' => '', 'event_end_before' => '');
    foreach ($date_objs as $prop => $value) {
        $date = $query->get($prop);
        try {
            $date = empty($date) ? false : new DateTime($date, eo_get_blog_timezone());
        } catch (Exception $e) {
            $date = false;
        }
        $date_objs[$prop] = $date;
        $query->set($prop, $date);
    }
    //If eo_interval is set, determine date ranges
    if (!empty($query->query_vars['eo_interval'])) {
        switch ($query->get('eo_interval')) {
            case 'expired':
                $meta_query = (array) $query->get('meta_query');
                $meta_query[] = array('key' => '_eventorganiser_schedule_last_finish', 'value' => $blog_now->format('Y-m-d H:i:s'), 'compare' => '<=');
                $query->set('meta_query', $meta_query);
                break;
            case 'future':
                $meta_query = $query->get('meta_query');
//.........这里部分代码省略.........
开发者ID:windyjonas,项目名称:fredrika,代码行数:101,代码来源:event-organiser-archives.php


示例8: eventorganiser_150_update

/**
 * Upgrade routine for 1.5
 *
 *@since 1.5
 *@access private
 *@ignore
*/
function eventorganiser_150_update()
{
    global $wpdb;
    $et = $wpdb->eo_events;
    $events = $wpdb->get_results("SELECT*, min({$et}.StartDate) as StartDate, min({$et}.EndDate) as EndDate FROM {$wpdb->eo_events} GROUP BY {$et}.post_id ORDER BY {$et}.StartDate");
    if ($events) {
        foreach ($events as $event) {
            $post_id = (int) $event->post_id;
            $event_data = array('schedule' => $event->event_schedule, 'all_day' => $event->event_allday, 'schedule_meta' => 'weekly' == $event->event_schedule ? maybe_unserialize($event->event_schedule_meta) : $event->event_schedule_meta, 'frequency' => $event->event_frequency, 'exclude' => array(), 'include' => array());
            $start = new DateTime($event->StartDate . ' ' . $event->StartTime, eo_get_blog_timezone());
            $end = new DateTime($event->EndDate . ' ' . $event->FinishTime, eo_get_blog_timezone());
            $schedule_last = new DateTime($event->reoccurrence_end . ' ' . $event->StartTime, eo_get_blog_timezone());
            $seconds = round(abs($start->format('U') - $end->format('U')));
            $days = floor($seconds / 86400);
            // 86400 = 60*60*24 seconds in a normal day
            $sec_diff = $seconds - $days * 86400;
            $duration_str = '+' . $days . 'days ' . $sec_diff . ' seconds';
            $event_data['duration_str'] = $duration_str;
            $schedule_last_end = clone $schedule_last;
            $schedule_last_end->modify($duration_str);
            update_post_meta($post_id, '_eventorganiser_event_schedule', $event_data);
            update_post_meta($post_id, '_eventorganiser_schedule_start_start', $start->format('Y-m-d H:i:s'));
            //Schedule start
            update_post_meta($post_id, '_eventorganiser_schedule_start_finish', $end->format('Y-m-d H:i:s'));
            //Schedule start
            update_post_meta($post_id, '_eventorganiser_schedule_last_start', $schedule_last->format('Y-m-d H:i:s'));
            //Schedule last
            update_post_meta($post_id, '_eventorganiser_schedule_last_finish', $schedule_last_end->format('Y-m-d H:i:s'));
            //Schedule last
        }
    }
}
开发者ID:windyjonas,项目名称:fredrika,代码行数:39,代码来源:event-organiser-install.php


示例9: testMoveOccurrenceNotAllowed

 /**
  * Currently the following case is not allowed:
  * - Changing the start date to a date where an occurrence already exists
  */
 public function testMoveOccurrenceNotAllowed()
 {
     $event = array('start' => new DateTime('2014-08-11 18:48:00', eo_get_blog_timezone()), 'end' => new DateTime('2014-08-11 19:48:00', eo_get_blog_timezone()), 'schedule' => 'weekly', 'until' => new DateTime('2014-09-01 18:48:00', eo_get_blog_timezone()));
     $event_id = $this->factory->event->create($event);
     $occurrences = eo_get_the_occurrences_of($event_id);
     $occurrence_ids = array_keys($occurrences);
     $occurrence_id = $occurrence_ids[2];
     //Check the start/end datetimes are as expected
     $this->assertEquals(array('start' => new DateTime('2014-08-25 18:48:00', eo_get_blog_timezone()), 'end' => new DateTime('2014-08-25 19:48:00', eo_get_blog_timezone())), $occurrences[$occurrence_id]);
     //Try to move to an 'occupied date' (even with different time)
     $new_start = new DateTime('2014-08-18 15:48:00', eo_get_blog_timezone());
     $new_end = new DateTime('2014-08-18 16:48:00', eo_get_blog_timezone());
     $response = eventorganiser_move_occurrence($event_id, $occurrence_id, $new_start, $new_end);
     $this->assertInstanceOf('WP_Error', $response);
     $this->assertEquals('events-cannot-share-date', $response->get_error_code());
 }
开发者ID:hmorv,项目名称:Event-Organiser,代码行数:20,代码来源:recurrenceTest.php


示例10: eo_has_event_finished

/**
 * @ignore
*/
function eo_has_event_finished($id = '', $occurrence = 0)
{
    $tz = eo_get_blog_timezone();
    $end = new DateTime(eo_get_the_end('d-m-Y H:i', $id, $occurrence), $tz);
    $now = new DateTime('now', $tz);
    return $end <= $now;
}
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:10,代码来源:event-organiser-event-functions.php


示例11: _eventorganiser_generate_occurrences

/**
* This is a private function - handles the generation of occurrence dates from the schedule data
* @access private
* @ignore
*
* @param array $event_data - Array containing the event's schedule data
* @return array $event_data - Array containing the event's schedule data including 'occurrences', an array of DateTimes
*/
function _eventorganiser_generate_occurrences($event_data = array())
{
    $event_defaults = array('start' => '', 'end' => '', 'all_day' => 0, 'schedule' => 'once', 'schedule_meta' => '', 'frequency' => 1, 'schedule_last' => '', 'number_occurrences' => 0, 'exclude' => array(), 'include' => array());
    extract(wp_parse_args($event_data, $event_defaults));
    $occurrences = array();
    //occurrences array
    $exclude = array_filter((array) $exclude);
    $include = array_filter((array) $include);
    $exclude = array_udiff($exclude, $include, '_eventorganiser_compare_datetime');
    $include = array_udiff($include, $exclude, '_eventorganiser_compare_datetime');
    //White list schedule
    if (!in_array($schedule, array('once', 'daily', 'weekly', 'monthly', 'yearly', 'custom'))) {
        return new WP_Error('eo_error', __('Schedule not recognised.', 'eventorganiser'));
    }
    //Ensure event frequency is a positive integer. Else set to 1.
    $frequency = max(absint($frequency), 1);
    $all_day = (int) $all_day;
    $number_occurrences = absint($number_occurrences);
    //Check dates are supplied and are valid
    if (!$start instanceof DateTime) {
        return new WP_Error('eo_error', __('Start date not provided.', 'eventorganiser'));
    }
    if (!$end instanceof DateTime) {
        $end = clone $start;
    }
    //If use 'number_occurrences' to limit recurring event, set dummy 'schedule_last' date.
    if (!$schedule_last instanceof DateTime && $number_occurrences && in_array($schedule, array('daily', 'weekly', 'monthly', 'yearly'))) {
        //Set dummy "last occurrance" date.
        $schedule_last = clone $start;
    } else {
        $number_occurrences = 0;
    }
    if ('once' == $schedule || !$schedule_last instanceof DateTime) {
        $schedule_last = clone $start;
    }
    //Check dates are in chronological order
    if ($end < $start) {
        return new WP_Error('eo_error', __('Start date occurs after end date.', 'eventorganiser'));
    }
    if ($schedule_last < $start) {
        return new WP_Error('eo_error', __('Schedule end date is before is before the start date.', 'eventorganiser'));
    }
    //Now set timezones
    $timezone = eo_get_blog_timezone();
    $start->setTimezone($timezone);
    $end->setTimezone($timezone);
    $schedule_last->setTimezone($timezone);
    $H = intval($start->format('H'));
    $i = intval($start->format('i'));
    $start_days = array();
    $workaround = '';
    $icaldays = array('SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA');
    $weekdays = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
    $ical2day = array('SU' => 'Sunday', 'MO' => 'Monday', 'TU' => 'Tuesday', 'WE' => 'Wednesday', 'TH' => 'Thursday', 'FR' => 'Friday', 'SA' => 'Saturday');
    //Set up schedule
    switch ($schedule) {
        case 'once':
        case 'custom':
            $frequency = 1;
            $schedule_meta = '';
            $schedule_start = clone $start;
            $schedule_last = clone $start;
            $start_days[] = clone $start;
            $workaround = 'once';
            //Not strictly a workaround.
            break;
        case 'daily':
            $interval = "+" . $frequency . "day";
            $start_days[] = clone $start;
            break;
        case 'weekly':
            $schedule_meta = $schedule_meta ? array_filter($schedule_meta) : array();
            if (!empty($schedule_meta) && is_array($schedule_meta)) {
                foreach ($schedule_meta as $day) {
                    $start_day = clone $start;
                    $start_day->modify($ical2day[$day]);
                    $start_days[] = $start_day;
                }
            } else {
                $schedule_meta = array($icaldays[$start->format('w')]);
                $start_days[] = clone $start;
            }
            $interval = "+" . $frequency . "week";
            break;
        case 'monthly':
            $start_days[] = clone $start;
            $rule_value = explode('=', $schedule_meta, 2);
            $rule = $rule_value[0];
            $values = !empty($rule_value[1]) ? explode(',', $rule_value[1]) : array();
            //Should only be one value, but may support more in future
            $values = array_filter($values);
            if ($rule == 'BYMONTHDAY') {
//.........这里部分代码省略.........
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:101,代码来源:event.php


示例12: update_event

 /**
  * Update and EO event, given a CiviEvent. If no EO event exists
  * then create one. This will NOT create sequences and is intended for the
  * initial migration of CiviEvents to WordPress
  *
  * @since 0.1
  *
  * @param array $civi_event An array of data for the CiviEvent
  * @return int $event_id The numeric ID of the event
  */
 public function update_event($civi_event)
 {
     /*
     error_log( print_r( array(
     	'method' => __METHOD__,
     	'civi_event' => $civi_event,
     ), true ) );
     */
     // define schedule
     $event_data = array('start' => new DateTime($civi_event['start_date'], eo_get_blog_timezone()), 'end' => new DateTime($civi_event['end_date'], eo_get_blog_timezone()), 'schedule_last' => new DateTime($civi_event['end_date'], eo_get_blog_timezone()), 'frequency' => 1, 'all_day' => 0, 'schedule' => 'once');
     // define post
     $post_data = array('post_title' => $civi_event['title'], 'post_content' => isset($civi_event['description']) ? $civi_event['description'] : '', 'post_excerpt' => isset($civi_event['summary']) ? $civi_event['summary'] : '', 'to_ping' => '', 'pinged' => '', 'post_content_filtered' => '');
     // test for created date, which may be absent
     if (isset($civi_event['created_date']) and !empty($civi_event['created_date'])) {
         // create DateTime object
         $datetime = new DateTime($civi_event['created_date'], eo_get_blog_timezone());
         // add it, but format it first since Civi seems to send data in the form 20150916135435
         $post_data['post_date'] = $datetime->format('Y-m-d H:i:s');
     }
     // assume the CiviEvent is live
     $post_data['post_status'] = 'publish';
     // is the event active?
     if ($civi_event['is_active'] == 0) {
         // make the CiviEvent unpublished
         $post_data['post_status'] = 'draft';
     }
     // init venue as undefined
     $venue_id = 0;
     // get location ID
     if (isset($civi_event['loc_block_id'])) {
         // we have a location...
         // get location data
         $location = $this->plugin->civi->get_location_by_id($civi_event['loc_block_id']);
         // get corresponding EO venue ID
         $venue_id = $this->plugin->eo_venue->get_venue_id($location);
         // did we get one?
         if ($venue_id === false) {
             // no, let's create one
             $venue_id = $this->plugin->eo_venue->create_venue($location);
         } else {
             // yes, update it
             $venue_id = $this->plugin->eo_venue->update_venue($location);
         }
     }
     // init category as undefined
     $terms = array();
     // get location ID
     if (isset($civi_event['event_type_id'])) {
         // we have a category...
         //print_r( $this->plugin->civi->get_event_types() ); die();
         // get event type data for this pseudo-ID (actually "value")
         $type = $this->plugin->civi->get_event_type_by_value($civi_event['event_type_id']);
         // does this type have an existing term?
         $term_id = $this->get_term_id($type);
         // if not...
         if ($term_id === false) {
             // create one
             $term = $this->create_term($type);
             // assign term ID
             $term_id = $term['term_id'];
         }
         // define as array
         $terms = array(absint($term_id));
     }
     // add to post data
     $post_data['tax_input'] = array('event-venue' => array(absint($venue_id)), 'event-category' => $terms);
     /*
     error_log( print_r( array(
     	'method' => __METHOD__,
     	'post_data' => $post_data,
     	'type' => isset( $type ) ? $type : 'NOT SET',
     ) ); die();
     */
     // do we have a post ID for this event?
     $eo_post_id = $this->plugin->db->get_eo_event_id_by_civi_event_id($civi_event['id']);
     // remove hooks
     remove_action('wp_insert_post', array($this, 'insert_post'), 10);
     remove_action('eventorganiser_save_event', array($this, 'intercept_save_event'), 10);
     // did we get a post ID?
     if ($eo_post_id === false) {
         // use EO's API to create event
         $event_id = eo_insert_event($post_data, $event_data);
     } else {
         // use EO's API to update event
         $event_id = eo_update_event($eo_post_id, $post_data, $event_data);
     }
     // re-add hooks
     add_action('wp_insert_post', array($this, 'insert_post'), 10, 2);
     add_action('eventorganiser_save_event', array($this, 'intercept_save_event'), 10, 1);
     // --<
//.........这里部分代码省略.........
开发者ID:academe,项目名称:civicrm-event-organiser,代码行数:101,代码来源:civicrm-event-organiser-eo.php


示例13: eventorganiser_delete_expired_events

function eventorganiser_delete_expired_events()
{
    //Get expired events
    $events = eo_get_events(array('showrepeats' => 0, 'showpastevents' => 1, 'eo_interval' => 'expired'));
    if ($events) {
        foreach ($events as $event) {
            $now = new DateTime('now', eo_get_blog_timezone());
            $start = new DateTime($event->StartDate . ' ' . $event->StartTime, eo_get_blog_timezone());
            $end = new DateTime($event->EndDate . ' ' . $event->FinishTime, eo_get_blog_timezone());
            $duration = date_diff($start, $end);
            $finished = new DateTime($event->reoccurrence_end . ' ' . $event->StartTime, eo_get_blog_timezone());
            $finished->add($duration);
            $finished->modify('+1 day');
            //Delete if 24 hours has passed
            if ($finished <= $now) {
                wp_trash_post((int) $event->ID);
            }
        }
    }
}
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:20,代码来源:event-organiser-register.php


示例14: testPrePropertyParseAction

 public function testPrePropertyParseAction()
 {
     add_filter('eventorganiser_pre_ical_property_dtstart', array($this, '_modifyDtstart'), 10, 5);
     $ical = new EO_ICAL_Parser();
     $ical->parse(EO_DIR_TESTDATA . '/ical/eventWithInvalidDateTime.ics');
     remove_filter('eventorganiser_pre_ical_property_dtstart', array($this, '_modifyDtstart'));
     $exp_start = new DateTime('2015-02-01', eo_get_blog_timezone());
     $event = $ical->events[0];
     $this->assertEquals($exp_start, $event['start']);
 }
开发者ID:Borgoroth,项目名称:Event-Organiser,代码行数:10,代码来源:iCalTest.php


示例15: handle_eventlist_shortcode

 function handle_eventlist_shortcode($atts = array(), $content = null)
 {
     global $post;
     $tmp_post = $post;
     $taxs = array('category', 'tag', 'venue');
     foreach ($taxs as $tax) {
         if (isset($atts['event_' . $tax])) {
             $atts['event-' . $tax] = $atts['event_' . $tax];
             unset($atts['event_' . $tax]);
         }
     }
     if (isset($atts['venue']) && $atts['venue'] == '%this%' || isset($atts['event-venue']) && $atts['event-venue'] == '%this%') {
         if (!empty($post->Venue)) {
             $atts['event-venue'] = eo_get_venue_slug();
         } else {
             unset($atts['venue']);
             unset($atts['event-venue']);
         }
     }
     $events = eo_get_events($atts);
     $tz = eo_get_blog_timezone();
     if ($events) {
         $return = '<ul class="eo-events eo-events-shortcode">';
         foreach ($events as $post) {
             setup_postdata($post);
             //Check if all day, set format accordingly
             if (eo_is_all_day()) {
                 $format = get_option('date_format');
             } else {
                 $format = get_option('date_format') . '  ' . get_option('time_format');
             }
             $dateTime = new DateTime($post->StartDate . ' ' . $post->StartTime, $tz);
             if (empty($content)) {
                 $return .= '<li><a title="' . the_title_attribute(array('echo' => false)) . '" href="' . get_permalink() . '">' . get_the_title() . '</a> ' . __('on', 'eventorganiser') . ' ' . eo_format_date($post->StartDate . ' ' . $post->StartTime, $format) . '</li>';
             } else {
                 $return .= '<li>' . self::read_template($content) . '</li>';
             }
         }
         $return .= '</ul>';
         $post = $tmp_post;
         wp_reset_postdata();
         return $return;
     }
 }
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:44,代码来源:class-eventorganiser-shortcodes.php


示例16: eventorganiser_widget_agenda

function eventorganiser_widget_agenda()
{
    global $wpdb, $wp_locale;
    $meridiem = $wp_locale->meridiem;
    $direction = intval($_GET['direction']);
    $today = new DateTIme('now', eo_get_blog_timezone());
    $before_or_after = $direction < 1 ? 'before' : 'after';
    $date = $direction < 1 ? $_GET['start'] : $_GET['end'];
    $order = $direction < 1 ? 'DESC' : 'ASC';
    $selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
    if ($order == 'ASC') {
        $whereDates = " WHERE {$wpdb->eo_events}.StartDate >= %s ";
    } else {
        $whereDates = " WHERE {$wpdb->eo_events}.StartDate <= %s ";
    }
    $whereDates .= " AND {$wpdb->eo_events}.StartDate >= %s ";
    $orderlimit = "ORDER BY  {$wpdb->eo_events}.StartDate {$order} LIMIT 4";
    $dates = $wpdb->get_col($wpdb->prepare($selectDates . $whereDates . $orderlimit, $date, $today->format('Y-m-d')));
    if (!$dates) {
        return false;
    }
    $date1 = min($dates[0], $dates[count($dates) - 1]);
    $date2 = max($dates[0], $dates[count($dates) - 1]);
    $events = eo_get_events(array('event_start_after' => $date1, 'event_start_before' => $date2));
    $return_array = array();
    global $post;
    foreach ($events as $post) {
        $startDT = new DateTime($post->StartDate . ' ' . $post->StartTime);
        if (!eo_is_all_day()) {
            $ampm = trim($meridiem[$startDT->format('a')]);
            $ampm = empty($ampm) ? $startDT->format('a') : $ampm;
            //Tranlsate am/pm
            $time = $startDT->format('g:i') . $ampm;
        } else {
            $time = __('All Day', 'eventorganiser');
        }
        $color = '';
        $terms = get_the_terms($post->ID, 'event-category');
        if ($terms) {
            $term = array_shift(array_values($terms));
            $color = isset($term->color) ? $term->color : '';
        }
        //'StartDate'=>eo_format_date($post->StartDate,'l jS F'),
        $return_array[] = array('StartDate' => $post->StartDate, 'time' => $time, 'post_title' => substr($post->post_title, 0, 25), 'event_allday' => $post->event_allday, 'color' => $color, 'link' => get_permalink(), 'Glink' => eo_get_the_GoogleLink());
    }
    echo json_encode($return_array);
    exit;
}
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:48,代码来源:event-organiser-ajax.php


示例17: import_events

 /**
 * Parses through an array of lines (of an ICAL file), creates events and inserts them as they are found.
 
 * @since 1.1.0
 *
 * @param array - $lines, array of lines of an ICAL file
 */
 function import_events($lines)
 {
     global $EO_Errors;
     $state = "NONE";
     $error = false;
     $error_count = 0;
     $event_count = 0;
     $event_array = array();
     $event_array['event'] = array();
     $event_array['event_post'] = array();
     $event_array['event_meta'] = array();
     //Get Blog timezone, set Calendar timezone to this by default
     $blog_tz = eo_get_blog_timezone();
     $cal_tz = $blog_tz;
     $output = "";
     //Record number of venues / categories created
     global $eventorganiser_venues_created, $eventorganiser_cats_created;
     $eventorganiser_venues_created = 0;
     $eventorganiser_cats_created = 0;
     //Read through each line
     for ($n = 0; $n < count($lines) && !$error; $n++) {
         $buff = trim($lines[$n]);
         if (!empty($buff)) {
             $line = explode(':', $buff, 2);
             //On the right side of the line we may have DTSTART;TZID= or DTSTART;VALUE=
             $modifiers = explode(';', $line[0]);
             $property = array_shift($modifiers);
             $value = isset($line[1]) ? trim($line[1]) : '';
             //If we are in EVENT state
             if ($state == "VEVENT") {
                 //If END:VEVENT, insert event into database
                 if ($property == 'END' && $value == 'VEVENT') {
                     $state = "VCALENDAR";
                     $event_array['event']['YmdFormated'] = true;
                     $event_array['event']['dateObjects'] = true;
                     //Insert new post from objects
                     $post_id = EO_Event::insertNewEvent($event_array['event_post'], $event_array['event']);
                     if (!$post_id) {
                         $error_count++;
                     }
                 } else {
                     //Otherwise, parse event property
                     try {
                         $event_array = $this->parse_Event_Property($event_array, $property, $value, $modifiers, $blog_tz, $cal_tz);
                     } catch (Exception $e) {
                         $error_count++;
                         $preamble = sprintf(__('Line: %1$d', 'eventorganiser'), $n + 1);
                         $EO_Errors->add('eo_error', $preamble . '   ' . $e->getMessage());
                         //Abort parsing event
                         $state = "VCALENDAR";
                     }
                 }
                 // If we are in CALENDAR state
             } elseif ($state == "VCALENDAR") {
                 //Begin event
                 if ($property == 'BEGIN' && $value == 'VEVENT') {
                     $state = "VEVENT";
                     $event_count++;
                     $event_array['event'] = array();
                     $event_array['event_post'] = array();
                     $event_array['event_meta'] = array();
                 } elseif ($property == 'END' && $value == 'VCALENDAR') {
                     $state = "NONE";
                 } elseif ($property == 'X-WR-TIMEZONE') {
                     try {
                         $cal_tz = self::parse_TZID($value);
                     } catch (Exception $e) {
                         $preamble = sprintf(__('Line: %1$d', 'eventorganiser'), $n + 1);
                         $EO_Errors->add('eo_error', $preamble . '   ' . $e->getMessage());
                         break;
                     }
                 }
             } elseif ($state == "NONE" && $property == 'BEGIN' && $value == 'VCALENDAR') {
                 $state = "VCALENDAR";
             }
         }
         //If line is not empty
     }
     //For each line
     //Display message
     if ($event_count == 0) {
         $EO_Errors->add('eo_error', __("No events were imported.", 'eventorganiser'));
     } elseif ($error_count > 0) {
         $EO_Errors->add('eo_error', sprintf(__('There was an error with %1$d of %2$d events in the ical file'), $error_count, $event_count));
     } else {
         if ($event_count == 1) {
             $message = __("1 event was successfully imported", 'eventorganiser') . ".";
         } else {
             $message = sprintf(__("%d events were successfully imported", 'eventorganiser'), $event_count) . ".";
         }
         if ($eventorganiser_venues_created == 1) {
             $message .= " " . __("1 venue was created", 'eventorganiser') . ".";
         } elseif ($eventorganiser_venues_created > 1) {
//.........这里部分代码省略.........
开发者ID:rashadrussell,项目名称:UIUC_WebMonkeys_Website,代码行数:101,代码来源:class-event-organiser-im-export.php


示例18: eventorganiser_widget_agenda

/**
 * Ajax response for the agenda widget
*
 * This gets the month being viewed and generates the
 *
 *@since 1.0
 *@access private
 *@ignore
*/
function eventorganiser_widget_agenda()
{
    global $wpdb;
    $number = (int) $_GET['instance_number'];
    $wid = new EO_Events_Agenda_Widget();
    $settings = $wid->get_settings();
    $instance = $settings[$number];
    $today = new DateTime('now', eo_get_blog_timezone());
    $query = array();
    $return_array = array();
    $query['mode'] = !empty($instance['mode']) ? $instance['mode'] : 'day';
    $query['direction'] = intval($_GET['direction']);
    $query['date'] = $query['direction'] < 1 ? $_GET['start'] : $_GET['end'];
    $query['order'] = $query['direction'] < 1 ? 'DESC' : 'ASC';
    $key = 'eo_ag_' . md5(serialize($query)) . get_locale();
    $agenda = get_transient('eo_widget_agenda');
    if ($agenda && is_array($agenda) && isset($agenda[$key])) {
        echo json_encode($agenda[$key]);
        exit;
    }
    if ('day' == $query['mode']) {
        //Day mode
        $selectDates = "SELECT DISTINCT StartDate FROM {$wpdb->eo_events}";
        $whereDates = " WHERE {$wpdb->eo_events}.StartDate" . ($query['order'] == 'ASC' ? " >= " : " <= ") . "%s ";
        $whereDates .= " AN 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP eo_get_the_start函数代码示例发布时间:2022-05-15
下一篇:
PHP envoi_mail函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap