]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
show notice title on shownotice page
authorEvan Prodromou <evan@status.net>
Thu, 2 Sep 2010 21:16:10 +0000 (17:16 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 2 Sep 2010 21:16:10 +0000 (17:16 -0400)
plugins/NoticeTitle/NoticeTitlePlugin.php

index f7fb1e4d00129aa0883f62c4fe4959f3cbf64d4c..9f53173db20f3125f4749395672cb1ab99545bfe 100644 (file)
@@ -278,5 +278,54 @@ class NoticeTitlePlugin extends Plugin
 
         return true;
     }
+
+    /**
+     * If a notice has a title, show it in the <title> element
+     *
+     * @param Action $action Action being executed
+     *
+     * @return boolean hook value
+     */
+
+    function onStartShowHeadTitle($action)
+    {
+        $actionName = $action->trimmed('action');
+
+        if ($actionName == 'shownotice') {
+            $title = Notice_title::fromNotice($action->notice);
+            if (!empty($title)) {
+                $action->element('title', null,
+                                 // TRANS: Page title. %1$s is the title, %2$s is the site name.
+                                 sprintf(_("%1\$s - %2\$s"),
+                                         $title,
+                                         common_config('site', 'name')));
+            }
+        }
+
+        return true;
+    }
+
+    /**
+     * If a notice has a title, show it in the <h1> element
+     *
+     * @param Action $action Action being executed
+     *
+     * @return boolean hook value
+     */
+
+    function onStartShowPageTitle($action)
+    {
+        $actionName = $action->trimmed('action');
+
+        if ($actionName == 'shownotice') {
+            $title = Notice_title::fromNotice($action->notice);
+            if (!empty($title)) {
+                $action->element('h1', null, $title);
+                return false;
+            }
+        }
+
+        return true;
+    }
 }