本文整理汇总了PHP中common_xml_safe_str函数的典型用法代码示例。如果您正苦于以下问题:PHP common_xml_safe_str函数的具体用法?PHP common_xml_safe_str怎么用?PHP common_xml_safe_str使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_xml_safe_str函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputTo
function outputTo($xo)
{
if (!empty($this->formatted)) {
$xo->elementStart('poco:address');
$xo->element('poco:formatted', null, common_xml_safe_str($this->formatted));
$xo->elementEnd('poco:address');
}
}
示例2: asString
function asString()
{
if (!empty($this->formatted)) {
$xs = new XMLStringer(true);
$xs->elementStart('poco:address');
$xs->element('poco:formatted', null, common_xml_safe_str($this->formatted));
$xs->elementEnd('poco:address');
return $xs->getString();
}
return null;
}
示例3: asActivity
/**
* Convert a notice into an activity for export.
*
* @param Profile $scoped The currently logged in/scoped profile
*
* @return Activity activity object representing this Notice.
*/
function asActivity(Profile $scoped = null)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:' . $this->id));
if ($act instanceof Activity) {
return $act;
}
$act = new Activity();
if (Event::handle('StartNoticeAsActivity', array($this, $act, $scoped))) {
$act->id = $this->uri;
$act->time = strtotime($this->created);
try {
$act->link = $this->getUrl();
} catch (InvalidUrlException $e) {
// The notice is probably a share or similar, which don't
// have a representational URL of their own.
}
$act->content = common_xml_safe_str($this->getRendered());
$profile = $this->getProfile();
$act->actor = $profile->asActivityObject();
$act->actor->extra[] = $profile->profileInfo($scoped);
$act->verb = $this->verb;
if (!$this->repeat_of) {
$act->objects[] = $this->asActivityObject();
}
// XXX: should this be handled by default processing for object entry?
// Categories
$tags = $this->getTags();
foreach ($tags as $tag) {
$cat = new AtomCategory();
$cat->term = $tag;
$act->categories[] = $cat;
}
// Enclosures
// XXX: use Atom Media and/or File activity objects instead
$attachments = $this->attachments();
foreach ($attachments as $attachment) {
// Include local attachments in Activity
if (!empty($attachment->filename)) {
$act->enclosures[] = $attachment->getEnclosure();
}
}
$ctx = new ActivityContext();
try {
$reply = $this->getParent();
$ctx->replyToID = $reply->getUri();
$ctx->replyToUrl = $reply->getUrl(true);
// true for fallback to local URL, less messy
} catch (NoParentNoticeException $e) {
// This is not a reply to something
} catch (NoResultException $e) {
// Parent notice was probably deleted
}
try {
$ctx->location = Notice_location::locFromStored($this);
} catch (ServerException $e) {
$ctx->location = null;
}
$conv = null;
if (!empty($this->conversation)) {
$conv = Conversation::getKV('id', $this->conversation);
if ($conv instanceof Conversation) {
$ctx->conversation = $conv->uri;
}
}
// This covers the legacy getReplies and getGroups too which get their data
// from entries stored via Notice::saveNew (which we want to move away from)...
foreach ($this->getAttentionProfiles() as $target) {
// User and group profiles which get the attention of this notice
$ctx->attention[$target->getUri()] = $target->getObjectType();
}
switch ($this->scope) {
case Notice::PUBLIC_SCOPE:
$ctx->attention[ActivityContext::ATTN_PUBLIC] = ActivityObject::COLLECTION;
break;
case Notice::FOLLOWER_SCOPE:
$surl = common_local_url("subscribers", array('nickname' => $profile->nickname));
$ctx->attention[$surl] = ActivityObject::COLLECTION;
break;
}
$act->context = $ctx;
$source = $this->getSource();
if ($source instanceof Notice_source) {
$act->generator = ActivityObject::fromNoticeSource($source);
}
// Source
$atom_feed = $profile->getAtomFeed();
if (!empty($atom_feed)) {
$act->source = new ActivitySource();
// XXX: we should store the actual feed ID
$act->source->id = $atom_feed;
// XXX: we should store the actual feed title
$act->source->title = $profile->getBestName();
$act->source->links['alternate'] = $profile->profileurl;
//.........这里部分代码省略.........
示例4: rssDirectMessageArray
function rssDirectMessageArray($message)
{
$entry = array();
$from = $message->getFrom();
$entry['title'] = sprintf('Message from %1$s to %2$s', $from->nickname, $message->getTo()->nickname);
$entry['content'] = common_xml_safe_str($message->rendered);
$entry['link'] = common_local_url('showmessage', array('message' => $message->id));
$entry['published'] = common_date_iso8601($message->created);
$taguribase = TagURI::base();
$entry['id'] = "tag:{$taguribase}:{$entry['link']}";
$entry['updated'] = $entry['published'];
$entry['author-name'] = $from->getBestName();
$entry['author-uri'] = $from->homepage;
$entry['avatar'] = $from->avatarUrl(AVATAR_STREAM_SIZE);
try {
$avatar = $from->getAvatar(AVATAR_STREAM_SIZE);
$entry['avatar-type'] = $avatar->mediatype;
} catch (Exception $e) {
$entry['avatar-type'] = 'image/png';
}
// RSS item specific
$entry['description'] = $entry['content'];
$entry['pubDate'] = common_date_rfc2822($message->created);
$entry['guid'] = $entry['link'];
return $entry;
}
示例5: outputTo
function outputTo($xo, $tag = 'activity:object')
{
if (!empty($tag)) {
$xo->elementStart($tag);
}
if (Event::handle('StartActivityObjectOutputAtom', array($this, $xo))) {
$xo->element('activity:object-type', null, $this->type);
// <author> uses URI
if ($tag == 'author') {
$xo->element(self::URI, null, $this->id);
} else {
$xo->element(self::ID, null, $this->id);
}
if (!empty($this->title)) {
$name = common_xml_safe_str($this->title);
if ($tag == 'author') {
// XXX: Backward compatibility hack -- atom:name should contain
// full name here, instead of nickname, i.e.: $name. Change
// this in the next version.
$xo->element(self::NAME, null, $this->poco->preferredUsername);
} else {
$xo->element(self::TITLE, null, $name);
}
}
if (!empty($this->summary)) {
$xo->element(self::SUMMARY, null, common_xml_safe_str($this->summary));
}
if (!empty($this->content)) {
// XXX: assuming HTML content here
$xo->element(ActivityUtils::CONTENT, array('type' => 'html'), common_xml_safe_str($this->content));
}
if (!empty($this->link)) {
$xo->element('link', array('rel' => 'alternate', 'type' => 'text/html', 'href' => $this->link), null);
}
if (!empty($this->owner)) {
$owner = $this->owner->asActivityNoun(self::AUTHOR);
$xo->raw($owner);
}
if ($this->type == ActivityObject::PERSON || $this->type == ActivityObject::GROUP) {
foreach ($this->avatarLinks as $alink) {
$xo->element('link', array('rel' => 'avatar', 'type' => $alink->type, 'media:width' => $alink->width, 'media:height' => $alink->height, 'href' => $alink->url), null);
}
}
if (!empty($this->geopoint)) {
$xo->element('georss:point', null, $this->geopoint);
}
if (!empty($this->poco)) {
$this->poco->outputTo($xo);
}
// @fixme there's no way here to make a tree; elements can only contain plaintext
// @fixme these may collide with JSON extensions
foreach ($this->extra as $el) {
list($extraTag, $attrs, $content) = array_pad($el, 3, null);
$xo->element($extraTag, $attrs, $content);
}
Event::handle('EndActivityObjectOutputAtom', array($this, $xo));
}
if (!empty($tag)) {
$xo->elementEnd($tag);
}
return;
}
示例6: showEntry
/**
* Build an Atom entry similar to search.twitter.com's based on
* a given notice
*
* @param Notice $notice the notice to use
*
* @return void
*/
function showEntry($notice)
{
$server = common_config('site', 'server');
$profile = $notice->getProfile();
$nurl = common_local_url('shownotice', array('notice' => $notice->id));
$this->elementStart('entry');
$taguribase = TagURI::base();
$this->element('id', null, "tag:{$taguribase}:{$notice->id}");
$this->element('published', null, common_date_w3dtf($notice->created));
$this->element('link', array('type' => 'text/html', 'rel' => 'alternate', 'href' => $nurl));
$this->element('title', null, common_xml_safe_str(trim($notice->content)));
$this->element('content', array('type' => 'html'), $notice->rendered);
$this->element('updated', null, common_date_w3dtf($notice->created));
$this->element('link', array('type' => 'image/png', 'rel' => 'related', 'href' => $profile->avatarUrl()));
// TODO: Here is where we'd put in a link to an atom feed for threads
$this->element("twitter:source", null, htmlentities($this->sourceLink($notice->source)));
$this->elementStart('author');
$name = $profile->nickname;
if ($profile->fullname) {
$name .= ' (' . $profile->fullname . ')';
}
$this->element('name', null, $name);
$this->element('uri', null, common_profile_uri($profile));
$this->elementEnd('author');
$this->elementEnd('entry');
}
示例7: asString
function asString()
{
$xs = new XMLStringer(true);
$xs->element('poco:preferredUsername', null, $this->preferredUsername);
$xs->element('poco:displayName', null, $this->displayName);
if (!empty($this->note)) {
$xs->element('poco:note', null, common_xml_safe_str($this->note));
}
if (!empty($this->address)) {
$xs->raw($this->address->asString());
}
foreach ($this->urls as $url) {
$xs->raw($url->asString());
}
return $xs->getString();
}
示例8: asActivity
/**
* Convert a notice into an activity for export.
*
* @param User $cur Current user
*
* @return Activity activity object representing this Notice.
*/
function asActivity($cur)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:' . $this->id));
if (!empty($act)) {
return $act;
}
$act = new Activity();
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
$profile = $this->getProfile();
$act->actor = ActivityObject::fromProfile($profile);
$act->actor->extra[] = $profile->profileInfo($cur);
$act->verb = ActivityVerb::POST;
$act->objects[] = ActivityObject::fromNotice($this);
// XXX: should this be handled by default processing for object entry?
$act->time = strtotime($this->created);
$act->link = $this->bestUrl();
$act->content = common_xml_safe_str($this->rendered);
$act->id = $this->uri;
$act->title = common_xml_safe_str($this->content);
// Categories
$tags = $this->getTags();
foreach ($tags as $tag) {
$cat = new AtomCategory();
$cat->term = $tag;
$act->categories[] = $cat;
}
// Enclosures
// XXX: use Atom Media and/or File activity objects instead
$attachments = $this->attachments();
foreach ($attachments as $attachment) {
$enclosure = $attachment->getEnclosure();
if ($enclosure) {
$act->enclosures[] = $enclosure;
}
}
$ctx = new ActivityContext();
if (!empty($this->reply_to)) {
$reply = Notice::staticGet('id', $this->reply_to);
if (!empty($reply)) {
$ctx->replyToID = $reply->uri;
$ctx->replyToUrl = $reply->bestUrl();
}
}
$ctx->location = $this->getLocation();
$conv = null;
if (!empty($this->conversation)) {
$conv = Conversation::staticGet('id', $this->conversation);
if (!empty($conv)) {
$ctx->conversation = $conv->uri;
}
}
$reply_ids = $this->getReplies();
foreach ($reply_ids as $id) {
$profile = Profile::staticGet('id', $id);
if (!empty($profile)) {
$ctx->attention[] = $profile->getUri();
}
}
$groups = $this->getGroups();
foreach ($groups as $group) {
$ctx->attention[] = $group->getUri();
}
// XXX: deprecated; use ActivityVerb::SHARE instead
$repeat = null;
if (!empty($this->repeat_of)) {
$repeat = Notice::staticGet('id', $this->repeat_of);
$ctx->forwardID = $repeat->uri;
$ctx->forwardUrl = $repeat->bestUrl();
}
$act->context = $ctx;
// Source
$atom_feed = $profile->getAtomFeed();
if (!empty($atom_feed)) {
$act->source = new ActivitySource();
// XXX: we should store the actual feed ID
$act->source->id = $atom_feed;
// XXX: we should store the actual feed title
$act->source->title = $profile->getBestName();
$act->source->links['alternate'] = $profile->profileurl;
$act->source->links['self'] = $atom_feed;
$act->source->icon = $profile->avatarUrl(AVATAR_PROFILE_SIZE);
$notice = $profile->getCurrentNotice();
if (!empty($notice)) {
$act->source->updated = self::utcDate($notice->created);
}
$user = User::staticGet('id', $profile->id);
if (!empty($user)) {
$act->source->links['license'] = common_config('license', 'url');
}
}
if ($this->isLocal()) {
$act->selfLink = common_local_url('ApiStatusesShow', array('id' => $this->id, 'format' => 'atom'));
$act->editLink = $act->selfLink;
//.........这里部分代码省略.........
示例9: showItem
function showItem($notice)
{
$profile = Profile::staticGet($notice->profile_id);
$nurl = common_local_url('shownotice', array('notice' => $notice->id));
$creator_uri = common_profile_uri($profile);
$this->elementStart('item', array('rdf:about' => $notice->uri, 'rdf:type' => 'http://rdfs.org/sioc/types#MicroblogPost'));
$title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
$this->element('title', null, $title);
$this->element('link', null, $nurl);
$this->element('description', null, $profile->nickname . "'s status on " . common_exact_date($notice->created));
if ($notice->rendered) {
$this->element('content:encoded', null, common_xml_safe_str($notice->rendered));
}
$this->element('dc:date', null, common_date_w3dtf($notice->created));
$this->element('dc:creator', null, $profile->fullname ? $profile->fullname : $profile->nickname);
$this->element('foaf:maker', array('rdf:resource' => $creator_uri));
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri . '#acct'));
$location = $notice->getLocation();
if ($location && isset($location->lat) && isset($location->lon)) {
$location_uri = $location->getRdfURL();
$attrs = array('geo:lat' => $location->lat, 'geo:long' => $location->lon);
if (strlen($location_uri)) {
$attrs['rdf:resource'] = $location_uri;
}
$this->element('statusnet:origin', $attrs);
}
$this->element('statusnet:postIcon', array('rdf:resource' => $profile->avatarUrl()));
$this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
if ($notice->reply_to) {
$replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to));
$this->element('sioc:reply_of', array('rdf:resource' => $replyurl));
}
if (!empty($notice->conversation)) {
$conversationurl = common_local_url('conversation', array('id' => $notice->conversation));
$this->element('sioc:has_discussion', array('rdf:resource' => $conversationurl));
}
$attachments = $notice->attachments();
if ($attachments) {
foreach ($attachments as $attachment) {
$enclosure = $attachment->getEnclosure();
if ($enclosure) {
$attribs = array('rdf:resource' => $enclosure->url);
if ($enclosure->title) {
$attribs['dc:title'] = $enclosure->title;
}
if ($enclosure->modified) {
$attribs['dc:date'] = common_date_w3dtf($enclosure->modified);
}
if ($enclosure->size) {
$attribs['enc:length'] = $enclosure->size;
}
if ($enclosure->mimetype) {
$attribs['enc:type'] = $enclosure->mimetype;
}
$this->element('enc:enclosure', $attribs);
}
$this->element('sioc:links_to', array('rdf:resource' => $attachment->url));
}
}
$tag = new Notice_tag();
$tag->notice_id = $notice->id;
if ($tag->find()) {
$entry['tags'] = array();
while ($tag->fetch()) {
$tagpage = common_local_url('tag', array('tag' => $tag->tag));
if (in_array($tag, $this->tags_already_output)) {
$this->element('ctag:tagged', array('rdf:resource' => $tagpage . '#concept'));
continue;
}
$tagrss = common_local_url('tagrss', array('tag' => $tag->tag));
$this->elementStart('ctag:tagged');
$this->elementStart('ctag:Tag', array('rdf:about' => $tagpage . '#concept', 'ctag:label' => $tag->tag));
$this->element('foaf:page', array('rdf:resource' => $tagpage));
$this->element('rdfs:seeAlso', array('rdf:resource' => $tagrss));
$this->elementEnd('ctag:Tag');
$this->elementEnd('ctag:tagged');
$this->tags_already_output[] = $tag->tag;
}
}
$this->elementEnd('item');
$this->creators[$creator_uri] = $profile;
}
示例10: showItem
function showItem($notice)
{
$profile = Profile::staticGet($notice->profile_id);
$nurl = common_local_url('shownotice', array('notice' => $notice->id));
$creator_uri = common_profile_uri($profile);
$this->elementStart('item', array('rdf:about' => $notice->uri));
$title = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
$this->element('title', null, $title);
$this->element('link', null, $nurl);
$this->element('description', null, $profile->nickname . "'s status on " . common_exact_date($notice->created));
$this->element('dc:date', null, common_date_w3dtf($notice->created));
$this->element('dc:creator', null, $profile->fullname ? $profile->fullname : $profile->nickname);
$this->element('sioc:has_creator', array('rdf:resource' => $creator_uri));
$this->element('laconica:postIcon', array('rdf:resource' => $profile->avatarUrl()));
$this->element('cc:licence', array('rdf:resource' => common_config('license', 'url')));
$this->elementEnd('item');
$this->creators[$creator_uri] = $profile;
}
示例11: asActivity
/**
* Convert a notice into an activity for export.
*
* @param User $cur Current user
*
* @return Activity activity object representing this Notice.
*/
function asActivity($cur)
{
$act = self::cacheGet(Cache::codeKey('notice:as-activity:' . $this->id));
if (!empty($act)) {
return $act;
}
$act = new Activity();
if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
$act->id = TagURI::mint("post:" . $this->id);
$act->time = strtotime($this->created);
$act->content = common_xml_safe_str($this->rendered);
$profile = $this->getProfile();
$act->actor = ActivityObject::fromProfile($profile);
$act->actor->extra[] = $profile->profileInfo($cur);
$act->verb = $this->verb;
if ($this->repeat_of) {
$repeated = Notice::staticGet('id', $this->repeat_of);
if (!empty($repeated)) {
$act->objects[] = $repeated->asActivity($cur);
}
} else {
$act->objects[] = ActivityObject::fromNotice($this);
}
// XXX: should this be handled by default processing for object entry?
// Categories
$tags = $this->getTags();
foreach ($tags as $tag) {
$cat = new AtomCategory();
$cat->term = $tag;
$act->categories[] = $cat;
}
// Enclosures
// XXX: use Atom Media and/or File activity objects instead
$attachments = $this->attachments();
foreach ($attachments as $attachment) {
// Save local attachments
if (!empty($attachment->filename)) {
$act->attachments[] = ActivityObject::fromFile($attachment);
}
}
$ctx = new ActivityContext();
if (!empty($this->reply_to)) {
$reply = Notice::staticGet('id', $this->reply_to);
if (!empty($reply)) {
$ctx->replyToID = $reply->uri;
$ctx->replyToUrl = $reply->bestUrl();
}
}
$ctx->location = $this->getLocation();
$conv = null;
if (!empty($this->conversation)) {
$conv = Conversation::staticGet('id', $this->conversation);
if (!empty($conv)) {
$ctx->conversation = $conv->uri;
}
}
$reply_ids = $this->getReplies();
foreach ($reply_ids as $id) {
$rprofile = Profile::staticGet('id', $id);
if (!empty($rprofile)) {
$ctx->attention[] = $rprofile->getUri();
$ctx->attentionType[$rprofile->getUri()] = ActivityObject::PERSON;
}
}
$groups = $this->getGroups();
foreach ($groups as $group) {
$ctx->attention[] = $group->getUri();
$ctx->attentionType[$group->getUri()] = ActivityObject::GROUP;
}
switch ($this->scope) {
case Notice::PUBLIC_SCOPE:
$ctx->attention[] = "http://activityschema.org/collection/public";
$ctx->attentionType["http://activityschema.org/collection/public"] = ActivityObject::COLLECTION;
break;
case Notice::FOLLOWER_SCOPE:
$surl = common_local_url("subscribers", array('nickname' => $profile->nickname));
$ctx->attention[] = $surl;
$ctx->attentionType[$surl] = ActivityObject::COLLECTION;
break;
}
// XXX: deprecated; use ActivityVerb::SHARE instead
$repeat = null;
if (!empty($this->repeat_of)) {
$repeat = Notice::staticGet('id', $this->repeat_of);
if (!empty($repeat)) {
$ctx->forwardID = $repeat->uri;
$ctx->forwardUrl = $repeat->bestUrl();
}
}
$act->context = $ctx;
$source = $this->getSource();
if ($source) {
$act->generator = ActivityObject::fromNoticeSource($source);
//.........这里部分代码省略.........
示例12: asString
function asString($tag = 'activity:object')
{
$xs = new XMLStringer(true);
$xs->elementStart($tag);
$xs->element('activity:object-type', null, $this->type);
$xs->element(self::ID, null, $this->id);
if (!empty($this->title)) {
$xs->element(self::TITLE, null, common_xml_safe_str($this->title));
}
if (!empty($this->summary)) {
$xs->element(self::SUMMARY, null, common_xml_safe_str($this->summary));
}
if (!empty($this->content)) {
// XXX: assuming HTML content here
$xs->element(ActivityUtils::CONTENT, array('type' => 'html'), common_xml_safe_str($this->content));
}
if (!empty($this->link)) {
$xs->element('link', array('rel' => 'alternate', 'type' => 'text/html', 'href' => $this->link), null);
}
if ($this->type == ActivityObject::PERSON || $this->type == ActivityObject::GROUP) {
foreach ($this->avatarLinks as $avatar) {
$xs->element('link', array('rel' => 'avatar', 'type' => $avatar->type, 'media:width' => $avatar->width, 'media:height' => $avatar->height, 'href' => $avatar->url), null);
}
}
if (!empty($this->geopoint)) {
$xs->element('georss:point', null, $this->geopoint);
}
if (!empty($this->poco)) {
$xs->raw($this->poco->asString());
}
$xs->elementEnd($tag);
return $xs->getString();
}
示例13: outputTo
function outputTo($xo)
{
$xo->element('poco:preferredUsername', null, $this->preferredUsername);
$xo->element('poco:displayName', null, $this->displayName);
if (!empty($this->note)) {
$xo->element('poco:note', null, common_xml_safe_str($this->note));
}
if (!empty($this->address)) {
$this->address->outputTo($xo);
}
foreach ($this->urls as $url) {
$url->outputTo($xo);
}
}
示例14: show_twitter_xml_dmsg
function show_twitter_xml_dmsg($twitter_dm)
{
$this->elementStart('direct_message');
foreach ($twitter_dm as $element => $value) {
switch ($element) {
case 'sender':
case 'recipient':
$this->show_twitter_xml_user($value, $element);
break;
case 'text':
$this->element($element, null, common_xml_safe_str($value));
break;
default:
$this->element($element, null, $value);
}
}
$this->elementEnd('direct_message');
}
示例15: showAtomGroups
function showAtomGroups($group, $title, $id, $link, $subtitle = null, $selfuri = null)
{
$this->initDocument('atom');
$this->element('title', null, common_xml_safe_str($title));
$this->element('id', null, $id);
$this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null);
if (!is_null($selfuri)) {
$this->element('link', array('href' => $selfuri, 'rel' => 'self', 'type' => 'application/atom+xml'), null);
}
$this->element('updated', null, common_date_iso8601('now'));
$this->element('subtitle', null, common_xml_safe_str($subtitle));
if (is_array($group)) {
foreach ($group as $g) {
$this->raw($g->asAtomEntry());
}
} else {
while ($group->fetch()) {
$this->raw($group->asAtomEntry());
}
}
$this->endDocument('atom');
}