Always call the Notice->getRendered() function to get a rendered copy.
We could perhaps put some sanitation there too in the future
'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('content', array('type' => 'html'), $notice->getRendered());
$this->element('updated', null, common_date_w3dtf($notice->created));
$this->element('link', array('type' => 'image/png',
// XXX: Twitter uses rel="image" (not valid)
public function getRendered()
{
+ if (is_null($this->rendered) || $this->rendered === '') {
+ // update to include rendered content on-the-fly, so we don't have to have a fix-up script in upgrade.php
+ $orig = clone($this);
+ $this->rendered = common_render_content($this->getContent(),
+ $this->getProfile(),
+ $this->hasParent() ? $this->getParent() : null);
+ $this->update($orig);
+ }
return $this->rendered;
}
$content = $actobj->content ?: $actobj->summary;
}
$stored->rendered = $actor->isLocal() ? $content : common_purify($content);
+ // yeah, just don't use getRendered() here since it's not inserted yet ;)
$stored->content = common_strip_html($stored->rendered);
// Maybe a missing act-time should be fatal if the actor is not local?
// 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->rendered);
+ $act->content = common_xml_safe_str($this->getRendered());
$profile = $this->getProfile();
$object->id = $this->getUri();
//FIXME: = $object->title ?: sprintf(... because we might get a title from StartActivityObjectFromNotice
$object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $this->getProfile()->getNickname());
- $object->content = $this->rendered;
+ $object->content = $this->getRendered();
$object->link = $this->getUrl();
$object->extra[] = array('status_net', array('notice_id' => $this->id));
// StatusNet-specific
- $twitter_status['statusnet_html'] = $notice->rendered;
+ $twitter_status['statusnet_html'] = $notice->getRendered();
$twitter_status['statusnet_conversation_id'] = intval($notice->conversation);
// The event call to handle NoticeSimpleStatusArray lets plugins add data to the output array
// We trim() to avoid extraneous whitespace in the output
- $entry['content'] = common_xml_safe_str(trim($notice->rendered));
+ $entry['content'] = common_xml_safe_str(trim($notice->getRendered()));
$entry['title'] = $profile->nickname . ': ' . common_xml_safe_str(trim($notice->content));
$entry['link'] = common_local_url('shownotice', array('notice' => $notice->id));
$entry['published'] = common_date_iso8601($notice->created);
$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));
+ if ($notice->getRendered()) {
+ $this->element('content:encoded', null, common_xml_safe_str($notice->getRendered()));
}
$this->element('dc:date', null, common_date_w3dtf($notice->created));
$this->element('dc:creator', null, ($profile->fullname) ? $profile->fullname : $profile->nickname);
$out->elementStart('div', 'system-activity');
- $out->raw($notice->rendered);
+ $out->raw($notice->getRendered());
$out->elementEnd('div');
}
$out->elementStart('div', 'unfollow-activity');
- $out->raw($notice->rendered);
+ $out->raw($notice->getRendered());
$out->elementEnd('div');
}
foreach($props as $prop) {
$stored->$prop = $target->$prop;
}
- //$stored->content = $stored->content ?: _('Notice deleted.');
- //$stored->rendered = $stored->rendered ?: $stored->rendered;
// Let's see if this has been deleted already.
try {
$object->type = $notice->object_type ?: ActivityObject::NOTE;
$object->id = $notice->getUri();
$object->title = sprintf('New %1$s by %2$s', ActivityObject::canonicalType($object->type), $notice->getProfile()->getNickname());
- $object->content = $notice->rendered;
+ $object->content = $notice->getRendered();
$object->link = $notice->getUrl();
$object->extra[] = array('status_net', array('notice_id' => $notice->getID()));
protected function showNoticeContent(Notice $stored, HTMLOutputter $out, Profile $scoped=null)
{
- $out->raw($stored->rendered);
+ $out->raw($stored->getRendered());
}
protected function getActionTitle(ManagedAction $action, $verb, Notice $target, Profile $scoped)
* @param object $notice notice is going to be saved
*/
public function onStartNoticeSave($notice){
+ // don't use getRendered() here since it's not saved yet and thus can't ->update in case that would happen
if(!preg_match('/<span class="rtl">/', $notice->rendered) && self::isRTL($notice->content))
$notice->rendered = '<span class="rtl">'.$notice->rendered.'</span>';
return true;
$out->element('a', array('href' => $profile->profileurl),
$profile->nickname);
$out->text(' ');
- $out->raw($notice->rendered);
+ $out->raw($notice->getRendered());
$out->elementStart('div', array('style' => 'font-size: 0.8em; padding-top: 4px;'));
$noticeurl = $notice->getLocalUrl();
// above should always return an URL
// notice's nickname and %3$s is the content of the favorited notice.)
$act->content = sprintf(_('%1$s favorited something by %2$s: %3$s'),
$actor->getNickname(), $target->getProfile()->getNickname(),
- $target->rendered ?: $target->content);
+ $target->getRendered());
$act->actor = $actor->asActivityObject();
$act->target = $target->asActivityObject();
$act->objects = array(clone($act->target));
// notice's nickname and %3$s is the content of the favorited notice.)
$act->content = sprintf(_('%1$s favorited something by %2$s: %3$s'),
$actor->getNickname(), $target->getProfile()->getNickname(),
- $target->rendered ?: $target->content);
+ $target->getRendered());
$act->actor = $actor->asActivityObject();
$act->target = $target->asActivityObject();
$actobj->objects = array(clone($actobj->target));
$actobj->verb = ActivityVerb::FAVORITE;
$actobj->title = ActivityUtils::verbToTitle($actobj->verb);
- $actobj->content = $this->getTarget()->rendered ?: $this->getTarget()->content;
+ $actobj->content = $this->getTarget()->getRendered();
return $actobj;
}
// notice's nickname and %3$s is the content of the favorited notice.)
$act->content = sprintf(_('%1$s favorited something by %2$s: %3$s'),
$profile->getNickname(), $notice_or_user->getProfile()->getNickname(),
- $notice_or_user->rendered ?: $notice_or_user->content);
+ $notice_or_user->getRendered());
if($entry['rsvp']) {
$act->content = $options['rendered'];
}
$arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->getUrl(true);
- $arr['html'] = $notice->rendered;
+ $arr['html'] = $notice->getRendered();
$arr['source'] = $arr['source'];
if (!empty($notice->reply_to)) {
$oembed['author_name']=$authorname;
$oembed['author_url']=$profile->profileurl;
$oembed['url']=$notice->getUrl();
- $oembed['html']=$notice->rendered;
+ $oembed['html']=$notice->getRendered();
break;
case 'attachment':
$arr = $act->twitterStatusArray($notice, true);
$arr['url'] = $notice->getUrl(true);
- $arr['html'] = htmlspecialchars($notice->rendered);
+ $arr['html'] = htmlspecialchars($notice->getRendered());
$arr['source'] = htmlspecialchars($arr['source']);
$arr['conversation_url'] = $notice->getConversationUrl();
$original = Notice::getKV('id', $notice->repeat_of);
if ($original instanceof Notice) {
$arr['retweeted_status']['url'] = $original->getUrl(true);
- $arr['retweeted_status']['html'] = htmlspecialchars($original->rendered);
+ $arr['retweeted_status']['html'] = htmlspecialchars($original->getRendered());
$arr['retweeted_status']['source'] = htmlspecialchars($original->source);
$originalProfile = $original->getProfile();
$arr['retweeted_status']['user']['profile_url'] = $originalProfile->profileurl;
$object = new Activity();
$object->actor = $stored->getProfile()->asActivityObject();
$object->verb = ActivityVerb::SHARE;
- $object->content = $stored->rendered;
+ $object->content = $stored->getRendered();
$this->extendActivity($stored, $object);
return $object;
{
$options = array('is_local' => Notice::LOCAL_PUBLIC,
'url' => $notice->getUrl(), // pass through the foreign link...
- 'rendered' => $notice->rendered);
+ 'rendered' => $notice->getRendered());
$saved = Notice::saveNew($profile->id,
$notice->content,
// These replace old "fixup_*" scripts
- fixupNoticeRendered();
fixupNoticeConversation();
initConversation();
fixupGroupURI();
printfnq("DONE.\n");
}
-function fixupNoticeRendered()
-{
- printfnq("Ensuring all notices have rendered HTML...");
-
- $notice = new Notice();
-
- $notice->whereAdd('rendered IS NULL');
- $notice->find();
-
- while ($notice->fetch()) {
- $original = clone($notice);
- $notice->rendered = common_render_content($notice->content,
- $notice->getProfile(),
- $notice->hasParent() ? $notice->getParent() : null);
- $notice->update($original);
- }
-
- printfnq("DONE.\n");
-}
-
function fixupNoticeConversation()
{
printfnq("Ensuring all notices have a conversation ID...");