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


PHP Horde_Date::toJson方法代码示例

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


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

示例1: toJson

 /**
  * Returns a simple object suitable for json transport representing this
  * object.
  *
  * Possible properties are:
  * - t: type
  * - i: interval
  * - e: end date
  * - c: count
  * - d: data
  * - co: completions
  * - ex: exceptions
  *
  * @return object  A simple object.
  */
 public function toJson()
 {
     $json = new stdClass();
     $json->t = $this->recurType;
     $json->i = $this->recurInterval;
     if ($this->hasRecurEnd()) {
         $json->e = $this->recurEnd->toJson();
     }
     if ($this->recurCount) {
         $json->c = $this->recurCount;
     }
     if ($this->recurData) {
         $json->d = $this->recurData;
     }
     if ($this->completions) {
         $json->co = $this->completions;
     }
     if ($this->exceptions) {
         $json->ex = $this->exceptions;
     }
     return $json;
 }
开发者ID:claudineyqr,项目名称:Kolab-Roundcube-Calendar,代码行数:37,代码来源:Horde_Date_Recurrence.php

示例2: toJson

 /**
  * Returns a simple object suitable for json transport representing this
  * event.
  *
  * Possible properties are:
  * - t: title
  * - d: description
  * - c: calendar id
  * - s: start date
  * - e: end date
  * - fi: first day of a multi-day event
  * - la: last day of a multi-day event
  * - x: status (Kronolith::STATUS_* constant)
  * - al: all-day?
  * - bg: background color
  * - fg: foreground color
  * - pe: edit permissions?
  * - pd: delete permissions?
  * - vl: variable, i.e. editable length?
  * - a: alarm text or minutes
  * - r: recurrence type (Horde_Date_Recurrence::RECUR_* constant)
  * - bid: The baseid for an event representing an exception
  * - eod: The original date that an exception is replacing
  * - ic: icon
  * - ln: link
  * - aj: ajax link
  * - id: event id
  * - ty: calendar type (driver)
  * - l: location
  * - u: url
  * - sd: formatted start date
  * - st: formatted start time
  * - ed: formatted end date
  * - et: formatted end time
  * - at: attendees
  * - rs:  resources
  * - tg: tag list,
  * - mt: meeting (Boolean true if event has attendees, false otherwise).
  *
  * @param boolean $allDay      If not null, overrides whether the event is
  *                             an all-day event.
  * @param boolean $full        Whether to return all event details.
  * @param string $time_format  The date() format to use for time formatting.
  *
  * @return stdClass  A simple object.
  */
 public function toJson($allDay = null, $full = false, $time_format = 'H:i')
 {
     $json = new stdClass();
     $json->uid = $this->uid;
     $json->t = $this->getTitle();
     $json->c = $this->calendar;
     $json->s = $this->start->toJson();
     $json->e = $this->end->toJson();
     $json->fi = $this->first;
     $json->la = $this->last;
     $json->x = (int) $this->status;
     $json->al = is_null($allDay) ? $this->isAllDay() : $allDay;
     $json->pe = $this->hasPermission(Horde_Perms::EDIT);
     $json->pd = $this->hasPermission(Horde_Perms::DELETE);
     $json->l = $this->getLocation();
     $json->mt = !empty($this->attendees);
     $json->sort = sprintf('%010s%06s', $this->originalStart->timestamp(), 240000 - $this->end->format('His'));
     if ($this->icon) {
         $json->ic = $this->icon;
     }
     if ($this->alarm) {
         if ($this->alarm % 10080 == 0) {
             $alarm_value = $this->alarm / 10080;
             $json->a = sprintf(ngettext("%d week", "%d weeks", $alarm_value), $alarm_value);
         } elseif ($this->alarm % 1440 == 0) {
             $alarm_value = $this->alarm / 1440;
             $json->a = sprintf(ngettext("%d day", "%d days", $alarm_value), $alarm_value);
         } elseif ($this->alarm % 60 == 0) {
             $alarm_value = $this->alarm / 60;
             $json->a = sprintf(ngettext("%d hour", "%d hours", $alarm_value), $alarm_value);
         } else {
             $alarm_value = $this->alarm;
             $json->a = sprintf(ngettext("%d minute", "%d minutes", $alarm_value), $alarm_value);
         }
     }
     if ($this->recurs()) {
         $json->r = $this->recurrence->getRecurType();
     } elseif ($this->baseid) {
         $json->bid = $this->baseid;
         if ($this->exceptionoriginaldate) {
             $json->eod = sprintf(_("%s at %s"), $this->exceptionoriginaldate->strftime($GLOBALS['prefs']->getValue('date_format')), $this->exceptionoriginaldate->strftime($GLOBALS['prefs']->getValue('twentyFour') ? '%H:%M' : '%I:%M %p'));
         }
     }
     if ($this->_resources) {
         $json->rs = $this->_resources;
     }
     if ($full) {
         $json->id = $this->id;
         $json->ty = $this->calendarType;
         $json->sd = $this->start->strftime('%x');
         $json->st = $this->start->format($time_format);
         $json->ed = $this->end->strftime('%x');
         $json->et = $this->end->format($time_format);
         $json->tz = $this->timezone;
//.........这里部分代码省略.........
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:101,代码来源:Event.php

示例3: toJson

 /**
  * Converts free/busy data to a simple object suitable to be transferred
  * as json.
  *
  * @param Horde_Icalendar_Vfreebusy $fb  A Free/busy component.
  *
  * @return object  A simple object representation.
  */
 public static function toJson(Horde_Icalendar_Vfreebusy $fb)
 {
     $json = new stdClass();
     $start = $fb->getStart();
     if ($start) {
         $start = new Horde_Date($start);
         $json->s = $start->dateString();
     }
     $end = $fb->getEnd();
     if ($end) {
         $end = new Horde_Date($end);
         $json->e = $end->dateString();
     }
     $b = $fb->getBusyPeriods();
     if (empty($b)) {
         $b = new StdClass();
     }
     $new = new StdClass();
     foreach ($b as $from => $to) {
         $from = new Horde_Date($from);
         $to = new Horde_Date($to);
         $new->{$from->toJson()} = $to->toJson();
     }
     $json->b = $new;
     return $json;
 }
开发者ID:horde,项目名称:horde,代码行数:34,代码来源:FreeBusy.php

示例4: toJson

 /**
  * Returns a simple object suitable for json transport representing this
  * task.
  *
  * @param boolean $full        Whether to return all task details.
  * @param string $time_format  The date() format to use for time formatting.
  *
  * @return object  A simple object.
  */
 public function toJson($full = false, $time_format = 'H:i')
 {
     $json = new stdClass();
     $json->l = $this->tasklist;
     $json->i = $this->indent;
     $json->n = $this->name;
     if ($this->desc) {
         //TODO: Get the proper amount of characters, and cut by last
         //whitespace
         $json->sd = Horde_String::substr($this->desc, 0, 80);
     }
     $json->cp = (bool) $this->completed;
     if ($this->due && ($due = $this->getNextDue())) {
         $json->du = $due->toJson();
     }
     if ($this->start) {
         $date = new Horde_Date($this->start);
         $json->s = $date->toJson();
     }
     $json->pr = (int) $this->priority;
     if ($this->recurs()) {
         $json->r = $this->recurrence->getRecurType();
     }
     $json->t = array_values($this->tags);
     if ($full) {
         // @todo: do we really need all this?
         $json->id = $this->id;
         $json->p = $this->parent_id;
         $json->de = $this->desc;
         if ($this->due) {
             $date = new Horde_Date($this->due);
             $json->dd = $date->strftime('%x');
             $json->dt = $date->format($time_format);
         }
         $json->as = $this->assignee;
         if ($this->estimate) {
             $json->e = $this->estimate;
         }
         /*
         $json->p = $this->parent_id;
         $json->o = $this->owner;
         
         if ($this->completed_date) {
             $date = new Horde_Date($this->completed_date);
             $json->cd = $date->toJson();
         }
         */
         $json->a = (int) $this->alarm;
         $json->m = $this->methods;
         //$json->pv = (boolean)$this->private;
         if ($this->recurs()) {
             $json->r = $this->recurrence->toJson();
         }
         try {
             $share = $GLOBALS['nag_shares']->getShare($this->tasklist);
         } catch (Horde_Share_exception $e) {
             Horde::log($e->getMessage(), 'ERR');
             throw new Nag_Exception($e);
         }
         $json->pe = $share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
         $json->pd = $share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
     }
     return $json;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:73,代码来源:Task.php

示例5: toJson

 /**
  * Returns a simple object suitable for json transport representing this
  * event.
  *
  * Possible properties are:
  * - t: title
  * - d: description
  * - c: calendar id
  * - s: start date
  * - e: end date
  * - fi: first day of a multi-day event
  * - la: last day of a multi-day event
  * - x: status (Kronolith::STATUS_* constant)
  * - al: all-day?
  * - bg: background color
  * - fg: foreground color
  * - pe: edit permissions?
  * - pd: delete permissions?
  * - vl: variable, i.e. editable length?
  * - a: alarm text or minutes
  * - r: recurrence type (Horde_Date_Recurrence::RECUR_* constant)
  * - bid: The baseid for an event representing an exception
  * - eod: The original date that an exception is replacing
  * - ic: icon
  * - ln: link
  * - aj: ajax link
  * - id: event id
  * - ty: calendar type (driver)
  * - l: location
  * - u: url
  * - sd: formatted start date
  * - st: formatted start time
  * - ed: formatted end date
  * - et: formatted end time
  * - at: attendees
  * - rs: resources
  * - tg: tag list
  * - mt: meeting (Boolean true if event has attendees, false otherwise).
  * - cb: created by (string describing when and who created the event).
  * - mb: modified by (string describing when and who last modified event).
  * - o: organizer (if known)
  * - oy: organizer you
  * - cr: creator's attendance response
  * - fs: Array of attached files.
  *
  * @param array $options  An array of options:
  *
  *  - all_day: (boolean)    If not null, overrides whether the event is an
  *                          all-day event.
  *                          DEFAULT: null (Do not override).
  *  - full: (boolean)       Whether to return all event details.
  *                          DEFAULT: false (Do not return all details).
  *  - time_format: (string) The date() format to use for time formatting.
  *                          DEFAULT: 'H:i'
  *  - history: (boolean)    If true, ensures that this event's history is
  *                          loaded from the History backend.
  *                          DEFAULT: false (Do not ensure history is loaded).
  *
  * @return stdClass  A simple object.
  */
 public function toJson(array $options = array())
 {
     $options = array_merge(array('all_day' => null, 'full' => false, 'time_format' => 'H:i', 'history' => false), $options);
     $json = new stdClass();
     $json->uid = $this->uid;
     $json->t = $this->getTitle();
     $json->c = $this->calendar;
     $json->s = $this->start->toJson();
     $json->e = $this->end->toJson();
     $json->fi = $this->first;
     $json->la = $this->last;
     $json->x = (int) $this->status;
     $json->al = is_null($options['all_day']) ? $this->isAllDay() : $options['all_day'];
     $json->pe = $this->hasPermission(Horde_Perms::EDIT);
     $json->pd = $this->hasPermission(Horde_Perms::DELETE);
     $json->l = $this->getLocation();
     $json->mt = (bool) count($this->attendees);
     $json->sort = sprintf('%010s%06s', $this->originalStart->timestamp(), 240000 - $this->end->format('His'));
     if ($this->icon) {
         $json->ic = $this->icon;
     }
     if ($this->alarm) {
         if ($this->alarm % 10080 == 0) {
             $alarm_value = $this->alarm / 10080;
             $json->a = sprintf(ngettext("%d week", "%d weeks", $alarm_value), $alarm_value);
         } elseif ($this->alarm % 1440 == 0) {
             $alarm_value = $this->alarm / 1440;
             $json->a = sprintf(ngettext("%d day", "%d days", $alarm_value), $alarm_value);
         } elseif ($this->alarm % 60 == 0) {
             $alarm_value = $this->alarm / 60;
             $json->a = sprintf(ngettext("%d hour", "%d hours", $alarm_value), $alarm_value);
         } else {
             $alarm_value = $this->alarm;
             $json->a = sprintf(ngettext("%d minute", "%d minutes", $alarm_value), $alarm_value);
         }
     }
     if ($this->recurs()) {
         $json->r = $this->recurrence->getRecurType();
     } elseif ($this->baseid) {
         $json->bid = $this->baseid;
//.........这里部分代码省略.........
开发者ID:horde,项目名称:horde,代码行数:101,代码来源:Event.php


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