]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fine-tuning Blog_entry class
authorEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 14:48:02 +0000 (10:48 -0400)
committerEvan Prodromou <evan@status.net>
Mon, 20 Jun 2011 14:48:02 +0000 (10:48 -0400)
Gave it a different object type (Article), fine-tuned the summary process, and
made sure to return the saved Notice in saveNew().

plugins/Blog/Blog_entry.php

index 0e4df28b82cb0472eb90b94a90281d252709e816..54bd445930069bd2f75f57e10742888b04dc7347 100644 (file)
@@ -59,7 +59,7 @@ class Blog_entry extends Managed_DataObject
     public $created; // datetime
     public $modified; // datetime
 
-    const TYPE = 'http://activitystrea.ms/schema/1.0/blog-entry';
+    const TYPE = ActivityObject::ARTICLE;
     
     function staticGet($k, $v=null)
     {
@@ -170,20 +170,26 @@ class Blog_entry extends Managed_DataObject
 
         // XXX: this might be too long.
 
-        $options['rendered'] = $be->summary . ' ' . 
-            XMLStringer::estring('a', array('href' => $shortUrl,
-                                            'class' => 'blog-entry'),
-                                 _('More...'));
+        if (!empty($be->summary)) {
+            $options['rendered'] = $be->summary . ' ' . 
+                XMLStringer::estring('a', array('href' => $url,
+                                                'class' => 'blog-entry'),
+                                     _('More...'));
+            $content = html_entity_decode(strip_tags($text), ENT_QUOTES, 'UTF-8');
+
+        } else {
+            $options['rendered'] = $be->content . ' ' . 
+                XMLStringer::estring('a', array('href' => $url,
+                                                'class' => 'blog-entry'),
+                                     _('More...'));
+        }
 
-        $summaryText = html_entity_decode(strip_tags($summary), ENT_QUOTES, 'UTF-8');
 
-        if (Notice::contentTooLong($summaryText)) {
-            $summaryText = substr($summaryText, 0, Notice::maxContent() - mb_strlen($shortUrl) - 2) .
+        if (Notice::contentTooLong($content)) {
+            $content = substr($content, 0, Notice::maxContent() - mb_strlen($shortUrl) - 2) .
                 '… ' . $shortUrl;
         }
 
-        $content = $summaryText;
-
         // Override this no matter what.
         
         $options['object_type'] = self::TYPE;
@@ -191,7 +197,9 @@ class Blog_entry extends Managed_DataObject
         $source = array_key_exists('source', $options) ?
                                     $options['source'] : 'web';
         
-        Notice::saveNew($profile->id, $content, $source, $options);
+        $saved = Notice::saveNew($profile->id, $content, $source, $options);
+
+        return $saved;
     }
 
     /**