]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
common_render_content doesn't require a Profile now
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Jan 2016 17:40:11 +0000 (18:40 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 1 Jan 2016 17:40:58 +0000 (18:40 +0100)
classes/Notice.php
lib/dofollowlistitem.php
lib/noticelistitem.php
lib/util.php
plugins/QnA/actions/qnanewanswer.php
plugins/Xmpp/XmppPlugin.php
scripts/fixup_hashtags.php
scripts/upgrade.php

index e53ce8f77bcb61caba1af87ef179fa128662856c..06edceddab86a968d8e2c5e211e861130e69885a 100644 (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)) {
index f3e2420677a8cc24f5b18892847aa42fa2e41b06..f65f7b4cbbe25b3e633261d00292548d39803069 100644 (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
index 8c27ae4e84fd9d87db42501e0d40077a7fd1777e..52dcbc1f6777507ae659d83c3cd3d8a3d191fbcd 100644 (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()));
         }
index 6e01860ee259873d4485378172e2b74e05e4e95e..3b5bb2de08aa2dde81822e7fd27d2b49b52ab7a3 100644 (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;
 }
 
index 94561a154861908a0e73a5d98bd0dc1112b99934..0cdaa62f1935ac5c7e7f7d1fe466ffe89f9d748d 100644 (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);
index 8c700bae8b67d40ddcc246a61d4444d474c856a6..6867eb093e73724739cd1bfffa96009c8c8fa02a 100644 (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',
index ac6522f3d91d157775954bb030207057125a0b21..b5cdb764982a223f89b8db5ccd9e4f48b53f338e 100755 (executable)
@@ -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__);
index d2bc403b5ee2b80dc1af1193d5cbd414190cf6fa..977cb1b5bd037efcd9e603b47d62b34ee0035437 100755 (executable)
@@ -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);
     }