当前位置: 首页>>代码示例>>PHP>>正文


PHP Calendar::get方法代码示例

本文整理汇总了PHP中Calendar::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Calendar::get方法的具体用法?PHP Calendar::get怎么用?PHP Calendar::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Calendar的用法示例。


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

示例1: getDashletFields

 public function getDashletFields()
 {
     $fields = parent::getDashletFields();
     $fields->push(MultiSelect2Field::create('Calendars', 'Calendars')->setSource(Calendar::get()->map()->toArray())->setMultiple(true));
     $fields->push(CheckboxField::create('OnlyUpcoming'));
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-intranet-sis,代码行数:7,代码来源:EventDashlet.php

示例2: events

 function events($group_id = FALSE)
 {
     $calendar = new Calendar();
     if ($group_id) {
         $calendar->where('group_id', $group_id);
     }
     $events = $calendar->get()->all_to_array();
     echo json_encode($events);
 }
开发者ID:unisexx,项目名称:thaigcd2015,代码行数:9,代码来源:calendars.php

示例3: process

 public function process()
 {
     increase_time_limit_to(300);
     DB::query("DELETE FROM CachedCalendarEntry");
     $future_years = $this->config()->cache_future_years;
     foreach (Calendar::get() as $calendar) {
         echo "<h2>Caching calendar '{$calendar->Title}'</h2>\n";
         foreach ($calendar->getAllCalendars() as $c) {
             foreach ($c->AllChildren() as $event) {
                 // All the dates of regular events
                 if ($event->Recursion) {
                     echo "<h3>Creating recurring events for '{$event->Title}'</h3>\n";
                     $i = 0;
                     $dt = $event->DateTimes()->first();
                     if (!$dt) {
                         continue;
                     }
                     if ($dt->EndDate) {
                         $end_date = sfDate::getInstance($dt->EndDate);
                     } else {
                         $end_date = sfDate::getInstance()->addYear($future_years);
                     }
                     $start_date = sfDate::getInstance($dt->StartDate);
                     $recursion = $event->getRecursionReader();
                     while ($start_date->get() <= $end_date->get()) {
                         if ($recursion->recursionHappensOn($start_date->get())) {
                             $dt->StartDate = $start_date->format('Y-m-d');
                             $cached = CachedCalendarEntry::create_from_datetime($dt, $calendar);
                             $cached->EndDate = $cached->StartDate;
                             $cached->write();
                         }
                         $start_date->addDay();
                         $i++;
                     }
                     echo "<p>{$i} events created.</p>\n";
                 } else {
                     foreach ($event->DateTimes() as $dt) {
                         echo "<p>Adding dates for event '{$event->Title}'</p>\n";
                         $cached = CachedCalendarEntry::create_from_datetime($dt, $calendar);
                         $cached->write();
                     }
                 }
                 // Announcements
             }
             foreach ($c->Announcements() as $a) {
                 echo "<p>Adding announcement {$a->Title}</p>\n";
                 $cached = CachedCalendarEntry::create_from_announcement($a, $calendar);
                 $cached->write();
             }
         }
     }
     echo "Done!";
 }
开发者ID:vinstah,项目名称:body,代码行数:53,代码来源:CachedCalendarTask.php

示例4: getCMSFields

 public function getCMSFields()
 {
     Requirements::javascript('event_calendar/javascript/calendar_cms.js');
     $f = parent::getCMSFields();
     $configuration = _t('Calendar.CONFIGURATION', 'Configuration');
     $f->addFieldsToTab("Root.{$configuration}", array(new DropdownField('DefaultView', _t('Calendar.DEFAULTVIEW', 'Default view'), array('upcoming' => _t('Calendar.UPCOMINGVIEW', "Show a list of upcoming events."), 'month' => _t('Calendar.MONTHVIEW', "Show this month's events."), 'week' => _t('Calendar.WEEKVIEW', "Show this week's events. If none, fall back on this month's"), 'today' => _t('Calendar.TODAYVIEW', "Show today's events. If none, fall back on this week's events"), 'weekend' => _t('Calendar.WEEKENDVIEW', "Show this weekend's events."))), new NumericField('DefaultFutureMonths', _t('Calendar.DEFAULTFUTUREMONTHS', 'Number maximum number of future months to show in default view')), new NumericField('EventsPerPage', _t('Calendar.EVENTSPERPAGE', 'Events per page')), new TextField('DefaultDateHeader', _t('Calendar.DEFAULTDATEHEADER', 'Default date header (displays when no date range has been selected)')), new NumericField('OtherDatesCount', _t('Calendar.NUMBERFUTUREDATES', 'Number of future dates to show for repeating events'))));
     // Announcements
     $announcements = _t('Calendar.Announcements', 'Announcements');
     $f->addFieldToTab("Root.{$announcements}", $announcementsField = GridField::create("Announcements", $announcements, $this->Announcements(), GridFieldConfig_RecordEditor::create()));
     $announcementsField->setDescription(_t('Calendar.ANNOUNCEMENTDESCRIPTION', 'Announcements are simple entries you can add to your calendar that do not have detail pages, e.g. "Office closed"'));
     // Feeds
     $feeds = _t('Calendar.FEEDS', 'Feeds');
     $f->addFieldToTab("Root.{$feeds}", $feedsField = GridField::create("Feeds", $feeds, $this->Feeds(), GridFieldConfig_RecordEditor::create()));
     $feedsField->setDescription(_t('Calendar.ICSFEEDDESCRIPTION', 'Add ICS feeds to your calendar to include events from external sources, e.g. a Google Calendar'));
     $otherCals = Calendar::get()->exclude(array("ID" => $this->ID));
     if ($otherCals->exists()) {
         $f->addFieldToTab("Root.{$feeds}", new CheckboxSetField('NestedCalendars', _t('Calendar.NESTEDCALENDARS', 'Include events from these calendars'), $otherCals->map('ID', 'Link')));
     }
     $f->addFieldToTab("Root.Main", new TextField('RSSTitle', _t('Calendar.RSSTITLE', 'Title of RSS Feed')), 'Content');
     $this->extend('updateCMSFields', $f);
     return $f;
 }
开发者ID:tim-lar,项目名称:silverstripe-event-calendar,代码行数:22,代码来源:Calendar.php

示例5: set

            } else {
                if ($days === 42) {
                    break;
                }
            }
            $res[] = $calendar;
            $days++;
        }
        return $res;
    }
    public function set($arr = [])
    {
        foreach ($arr as $key => $val) {
            if ($key === 'year') {
                $this->year = $val;
            } else {
                if ($key === 'month') {
                    $this->month = $val;
                }
            }
        }
    }
    private function build($unixtime)
    {
        $date = getdate($unixtime);
        return ['unixtime' => $unixtime, 'wday' => $date['wday'], 'year' => $date['year'], 'month' => $date['mon'], 'day' => $date['mday'], 'isToday' => $this->today === $unixtime ? true : false];
    }
}
$calendar = new Calendar();
var_dump($calendar->get());
开发者ID:masa69,项目名称:php-sample,代码行数:30,代码来源:Calendar.php

示例6: cal

 /**
  * Single calendar
  * Can be public or private
  * For public calendars either the calendar id or the calendar url can be supplied
  * For private calendars user email and hash need to be supplied - like this.
  * The private calendar hash is created in {@see PrivateCalendarMemberExtension}
  */
 function cal()
 {
     //echo 'test';
     $call = null;
     $request = $this->getRequest();
     $ics = null;
     $idOrURL = $request->param('ID');
     //echo $idOrURL;
     //Public calendar via id
     if (is_numeric($idOrURL)) {
         //calendar id is requested
         //echo 'request is numeric';
         $cal = Calendar::get()->ByID((int) $request->param('ID'));
         //echo $cal->getLink();
         //Public calendar via url
     } else {
         //calendar url is requested
         //echo 'request is a string';
         $url = Convert::raw2url($idOrURL);
         $cal = Calendar::get()->filter('URLSegment', $url)->First();
     }
     //If not public calendar is found we check for a private calendar
     if (!$cal) {
         echo $idOrURL;
         $member = Member::get()->filter('Email', $idOrURL)->filter('PrivateCalendarKey', $request->param('OtherID'))->First();
         if ($member && $member->exists()) {
             return $this->memberCalendar($member);
         }
     }
     if ($cal && $cal->exists()) {
         //everybody can access public calendars
         if ($cal->ClassName == 'PublicCalendar') {
             $ics = ICSExport::ics_from_sscal($cal);
             $calName = $cal->Title;
         }
         return $this->output($ics, $calName);
     } else {
         echo "calendar can't be found";
     }
 }
开发者ID:helpfulrobot,项目名称:titledk-silverstripe-calendar,代码行数:47,代码来源:ICSExport.php

示例7: importEvents_MyEventOn_Step2

 /**
  * Import events created with: http://www.myeventon.com/
  * into a 'CalendarEvent' Page type from Unclecheese's "Event Calendar" module
  *
  * Step 2) Update the page to 'CalendarEvent' page type and add event data appropriately
  */
 public function importEvents_MyEventOn_Step2($calendarHolder = null)
 {
     $this->logFunctionStart(__FUNCTION__);
     if (!class_exists('CalendarDateTime')) {
         throw new WordpressImportException(__FUNCTION__ . ' requires Unclecheese\'s "Event Calendar" module');
     }
     if (!CalendarDateTime::has_extension('WordpressImportDataExtension')) {
         throw new WordpressImportException('CalendarDateTime requires WordpressImportDataExtension.');
     }
     // Debug
     //Debug::dump($this->_db->getPosts('ajde_events', true)); exit;
     // Get the calendar holder the events should belong to.
     if ($calendarHolder === null) {
         $calendarHolder = Calendar::get()->filter(array('WordpressData' => '1'))->first();
         if (!$calendarHolder) {
             $calendarHolder = Calendar::create();
             $calendarHolder->Title = 'Wordpress Imported Events';
             $calendarHolder->URLSegment = 'events';
             $calendarHolder->WordpressData = 1;
             try {
                 $this->writeAndPublishRecord($calendarHolder);
             } catch (Exception $e) {
                 $this->log($calendarHolder, 'error', $e);
             }
         }
     }
     // Convert to CalendarEvent and attach relevant event data
     $existingWpRecords = singleton('Page')->WordpressRecordsByWordpressID();
     foreach ($this->_db->getPosts('ajde_events') as $wpData) {
         $wpID = $wpData['ID'];
         if (!isset($existingWpRecords[$wpID])) {
             $this->log('Unable to find Wordpress ID #' . $wpID, 'error');
             continue;
         }
         $record = $existingWpRecords[$wpID];
         $wpMeta = $this->_db->attachAndGetPostMeta($wpData);
         if ($record->ClassName !== 'CalendarEvent') {
             $record = $record->newClassInstance('CalendarEvent');
         }
         $record->ParentID = $calendarHolder->ID;
         $startDate = isset($wpMeta['evcal_srow']) && $wpMeta['evcal_srow'] ? (int) $wpMeta['evcal_srow'] : null;
         $endDate = isset($wpMeta['evcal_erow']) && $wpMeta['evcal_erow'] ? (int) $wpMeta['evcal_erow'] : null;
         if ($startDate && $endDate) {
             $subRecord = null;
             if ($record->exists()) {
                 $subRecord = $record->DateTimes()->find('WordpressID', $wpID);
             }
             if (!$subRecord) {
                 $subRecord = CalendarDateTime::create();
             }
             $subRecord->AllDay = isset($wpMeta['evcal_allday']) && $wpMeta['evcal_allday'] === 'yes';
             $subRecord->StartDate = date('Y-m-d', $startDate);
             $subRecord->StartTime = date('H:i:s', $startDate);
             $subRecord->EndDate = date('Y-m-d', $endDate);
             $subRecord->EndTime = date('H:i:s', $endDate);
             $subRecord->WordpressData = $record->WordpressData;
             if (!$subRecord->exists()) {
                 // NOTE(Jake): Will write $subRecord when $record is written if not exists, otherwise
                 //			   it will write it when it's ->add()'d
                 $record->DateTimes()->add($subRecord);
             } else {
                 try {
                     $record->write();
                     $this->log($record, 'changed');
                 } catch (Exception $e) {
                     $this->log($record, 'error', $e);
                 }
             }
         }
         // Support Addressable extension from Addressable module
         if (isset($wpMeta['evcal_location'])) {
             if ($record->Address !== $wpMeta['evcal_location']) {
                 $record->Address = $wpMeta['evcal_location'];
             }
         }
         // Support Geocodable extension from Addressable module
         if (isset($wpMeta['evcal_lat'])) {
             $record->Lat = $wpMeta['evcal_lat'];
         }
         if (isset($wpMeta['evcal_lng'])) {
             $record->Lng = $wpMeta['evcal_lng'];
         }
         $changedFields = $record->getChangedFields(true, DataObject::CHANGE_VALUE);
         unset($changedFields['Lat']);
         unset($changedFields['Lng']);
         if ($changedFields) {
             try {
                 $isPublished = isset($wpData['post_status']) && $wpData['post_status'] === 'publish' || $record->isPublished();
                 $this->writeAndPublishRecord($record, $isPublished);
             } catch (Exception $e) {
                 $this->log($record, 'error', $e);
             }
         } else {
             $this->log($record, 'nochange');
//.........这里部分代码省略.........
开发者ID:silbinarywolf,项目名称:silverstripe-wordpressmigrationtools,代码行数:101,代码来源:WordpressImportService.php

示例8: events

 function events()
 {
     $calendar = new Calendar();
     $events = $calendar->get()->all_to_array();
     echo json_encode($events);
 }
开发者ID:unisexx,项目名称:imac,代码行数:6,代码来源:calendars.php


注:本文中的Calendar::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。