if (!empty($rendered)) {
$notice->rendered = $rendered;
} else {
- $notice->rendered = common_render_content($final, $notice);
+ $notice->rendered = common_render_content($final,
+ $notice->getProfile(),
+ $notice->hasParent() ? $notice->getParent() : null);
}
if (empty($verb)) {
// FIXME: URL, image, video, audio
$this->out->elementStart('article', array('class' => 'e-content'));
- if (!empty($this->notice->rendered)) {
- $html = $this->notice->rendered;
- } else {
- $html = common_render_content($this->notice->content, $this->notice);
- }
+ $html = $this->notice->getRendered();
if (common_config('nofollow', 'external') == 'sometimes') {
// remove the nofollow part
if (Event::handle('StartShowNoticeContent', array($this->notice, $this->out, $this->out->getScoped()))) {
if ($this->maxchars > 0 && mb_strlen($this->notice->content) > $this->maxchars) {
$this->out->text(mb_substr($this->notice->content, 0, $this->maxchars) . '[…]');
- } elseif ($this->notice->rendered) {
- $this->out->raw($this->notice->rendered);
} else {
- // XXX: may be some uncooked notices in the DB,
- // we cook them right now. This should probably disappear in future
- // versions (>> 0.4.x)
- $this->out->raw(common_render_content($this->notice->content, $this->notice));
+ $this->out->raw($this->notice->getRendered());
}
Event::handle('EndShowNoticeContent', array($this->notice, $this->out, $this->out->getScoped()));
}
/**
* Partial notice markup rendering step: build links to !group references.
*
- * @param string $text partially rendered HTML
- * @param Notice $notice in whose context we're working
+ * @param string $text partially rendered HTML
+ * @param Profile $author the Profile that is composing the current notice
+ * @param Notice $parent the Notice this is sent in reply to, if any
* @return string partially rendered HTML
*/
-function common_render_content($text, Notice $notice)
+function common_render_content($text, Profile $author, Notice $parent=null)
{
$text = common_render_text($text);
- $text = common_linkify_mentions($text, $notice->getProfile(), $notice->hasParent() ? $notice->getParent() : null);
+ $text = common_linkify_mentions($text, $author, $parent);
return $text;
}
function showContent()
{
$this->out->elementStart('p', array('class' => 'e-content answer-content'));
- if ($this->notice->rendered) {
- $this->out->raw($this->notice->rendered);
- } else {
- // XXX: may be some uncooked notices in the DB,
- // we cook them right now. This should probably disappear in future
- // versions (>> 0.4.x)
- $this->out->raw(common_render_content($this->notice->content, $this->notice));
- }
+ $this->out->raw($this->notice->getRendered());
if (!empty($this->answer)) {
$form = new QnashowanswerForm($this->out, $this->answer);
// Parent notice was probably deleted.
$xs->text(": ");
}
- if (!empty($notice->rendered)) {
- $notice->rendered = str_replace("\t", "", $notice->rendered);
- $xs->raw($notice->rendered);
- } else {
- $xs->raw(common_render_content($notice->content, $notice));
- }
+ // FIXME: Why do we replace \t with ''? is it just to make it pretty? shouldn't whitespace be handled well...?
+ $xs->raw(str_replace("\t", "", $notice->getRendered()));
$xs->text(" ");
$xs->element('a', array(
'href'=>common_local_url('conversation',
common_log(LOG_INFO, 'Getting tags for notice #' . $notice->id);
$notice->saveTags();
$original = clone($notice);
- $notice->rendered = common_render_content($notice->content, $notice);
+ $notice->rendered = common_render_content($notice->content,
+ $notice->getProfile(),
+ $notice->hasParent() ? $notice->getParent() : null);
$result = $notice->update($original);
if (!$result) {
common_log_db_error($notice, 'UPDATE', __FILE__);
while ($notice->fetch()) {
$original = clone($notice);
- $notice->rendered = common_render_content($notice->content, $notice);
+ $notice->rendered = common_render_content($notice->content,
+ $notice->getProfile(),
+ $notice->hasParent() ? $notice->getParent() : null);
$notice->update($original);
}