common_render_content doesn't require a Profile now

This commit is contained in:
Mikael Nordfeldth 2016-01-01 18:40:11 +01:00
parent 54325e266f
commit e02c10a589
8 changed files with 19 additions and 32 deletions

View File

@ -621,7 +621,9 @@ class Notice extends Managed_DataObject
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)) {

View File

@ -68,11 +68,7 @@ class DoFollowListItem extends NoticeListItem
// 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

View File

@ -343,13 +343,8 @@ class NoticeListItem extends Widget
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()));
}

View File

@ -606,14 +606,15 @@ function common_remove_unicode_formatting($text)
/**
* 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;
}

View File

@ -327,14 +327,7 @@ class NoticeAnswerListItem extends NoticeListItem
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);

View File

@ -355,12 +355,8 @@ class XmppPlugin extends ImPlugin
// 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',

View File

@ -39,7 +39,9 @@ while ($notice->fetch()) {
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__);

View File

@ -105,7 +105,9 @@ function fixupNoticeRendered()
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);
}