Horde_Date_Recurrence::toJson PHP Méthode

toJson() public méthode

Possible properties are: - t: type - i: interval - e: end date - c: count - d: data - co: completions - ex: exceptions
public toJson ( ) : object
Résultat 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;
    }

Usage Example

Exemple #1
0
 /**
  * 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->p = $this->parent_id;
     $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 && ($start = $this->getNextStart())) {
         $json->s = $start->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->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->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();
         }
         if ($this->tasklist == '**EXTERNAL**') {
             $json->vl = (string) $this->view_link;
             $json->cl = (string) $this->complete_link;
             $json->pe = $json->pd = false;
         } else {
             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;
 }
All Usage Examples Of Horde_Date_Recurrence::toJson