]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add ProfileNoticeList[Item] as separate lib class files
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 14:53:28 +0000 (15:53 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 12 Mar 2015 14:53:28 +0000 (15:53 +0100)
lib/profilenoticelist.php [new file with mode: 0644]
lib/profilenoticelistitem.php [new file with mode: 0644]

diff --git a/lib/profilenoticelist.php b/lib/profilenoticelist.php
new file mode 100644 (file)
index 0000000..d95709e
--- /dev/null
@@ -0,0 +1,11 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+class ProfileNoticeList extends NoticeList
+{
+    function newListItem($notice)
+    {
+        return new ProfileNoticeListItem($notice, $this->out);
+    }
+}
diff --git a/lib/profilenoticelistitem.php b/lib/profilenoticelistitem.php
new file mode 100644 (file)
index 0000000..d7773ca
--- /dev/null
@@ -0,0 +1,49 @@
+<?php
+
+if (!defined('GNUSOCIAL')) { exit(1); }
+
+// We don't show the author for a profile, since we already know who it is!
+
+/**
+ * Slightly modified from standard list; the author & avatar are hidden
+ * in CSS. We used to remove them here too, but as it turns out that
+ * confuses the inline reply code... and we hide them in CSS anyway
+ * since realtime updates come through in original form.
+ *
+ * Remaining customization right now is for the repeat marker, where
+ * it'll list who the original poster was instead of who did the repeat
+ * (since the repeater is you, and the repeatee isn't shown!)
+ * This will remain inconsistent if realtime updates come through,
+ * since those'll get rendered as a regular NoticeListItem.
+ */
+class ProfileNoticeListItem extends DoFollowListItem
+{
+    /**
+     * show a link to the author of repeat
+     *
+     * @return void
+     */
+    function showRepeat()
+    {
+        if (!empty($this->repeat)) {
+
+            // FIXME: this code is almost identical to default; need to refactor
+
+            $attrs = array('href' => $this->profile->profileurl,
+                           'class' => 'url');
+
+            if (!empty($this->profile->fullname)) {
+                $attrs['title'] = $this->profile->getFancyName();
+            }
+
+            $this->out->elementStart('span', 'repeat');
+
+            $text_link = XMLStringer::estring('a', $attrs, $this->profile->nickname);
+
+            // TRANS: Link to the author of a repeated notice. %s is a linked nickname.
+            $this->out->raw(sprintf(_('Repeat of %s'), $text_link));
+
+            $this->out->elementEnd('span');
+        }
+    }
+}