);
}
+ if (!empty($this->poco)) {
+ $object['contact'] = $this->poco->asArray();
+ }
+
return array_filter($object);
}
}
$act = $notice->asActivity($cur);
$act->extra[] = $notice->noticeInfo($cur);
-
array_push($this->doc['items'], $act->asArray());
}
$url->outputTo($xo);
}
}
+
+ /**
+ * Output a Portable Contact as an array suitable for serializing
+ * as JSON
+ *
+ * @return $array the PoCo array
+ */
+
+ function asArray()
+ {
+ $poco = array();
+
+ $poco['preferredUsername'] = $this->preferredUsername;
+ $poco['displayName'] = $this->displayName;
+
+ if (!empty($this->note)) {
+ $poco['note'] = $this->note;
+ }
+
+ if (!empty($this->address)) {
+ $poco['addresses'] = $this->address->asArray();
+ }
+
+ if (!empty($this->urls)) {
+
+ $urls = array();
+
+ foreach ($this->urls as $url) {
+ $urls[] = $url->asArray();
+ }
+
+ $poco['urls'] = $urls;
+ }
+
+ return $poco;
+ }
+
}
+
$xo->elementEnd('poco:address');
}
}
+
+ /**
+ * Return this PoCo address as an array suitable for serializing in JSON
+ *
+ * @return array the address
+ */
+
+ function asArray()
+ {
+ if (!empty($this->formatted)) {
+ return array('formatted' => $this->formatted);
+ }
+ }
}
}
$xo->elementEnd('poco:urls');
}
+
+ /**
+ * Return this PoCo URL as an array suitable for serializing in JSON
+ *
+ * @array $url the url
+ */
+
+ function asArray()
+ {
+ $url = array();
+
+ $url['type'] = $this->type;
+ $url['value'] = $this->value;
+
+ if (!empty($this->primary)) {
+ $url['primary'] = 'true';
+ }
+
+ return $url;
+ }
}