[pLog-svn] r3686 - plog/trunk

oscar at devel.lifetype.net oscar at devel.lifetype.net
Wed Jul 5 12:03:11 GMT 2006


Author: oscar
Date: 2006-07-05 12:03:10 +0000 (Wed, 05 Jul 2006)
New Revision: 3686

Modified:
   plog/trunk/xmlrpc.php
Log:
fixed issue 975 (http://bugs.lifetype.net/view.php?id=975), and another issue with ecto embedding the title of the post (when using the Blogger API) in a funny way


Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php	2006-07-04 21:44:46 UTC (rev 3685)
+++ plog/trunk/xmlrpc.php	2006-07-05 12:03:10 UTC (rev 3686)
@@ -72,26 +72,38 @@
 
             // Get the default category
             $cats = $category->getBlogCategories($blogid);
+
+			// some protection again blogs without categories
+			if( !$cats ) {				
+				return new IXR_Error(-1, 'This blog does not have categories!');				
+			}
+
             foreach($cats as $cat)
             {
-                $idCategory = $cat->_id;
+                $idCategory = $cat->getId();
                 // Stop here, we have a category
                 break;
             }
 
-            // fake topic
-            $dummy = explode("\n", $content);
-            $title = $dummy[0];
-            unset($dummy[0]);
-            $content = implode("\n", $dummy);
-            unset($dummy);
+			// ecto sends the topic as <title>blah blah</title>rest of the body
+			if( preg_match( "/<title>(.*)<\/title>(.*)/i", $content, $matches )) {
+				$title = $matches[1];
+				$content = $matches[2];
+			}
+			else {
+	            $dummy = explode("\n", $content);
+	            $title = $dummy[0];
+	            unset($dummy[0]);
+	            $content = implode("\n", $dummy);
+	            unset($dummy);
+			}
 
             $userInfo = $users->getUserInfoFromUsername( $username );
 
             $article = new Article(
                 $title,
                 $content, // text
-                $idCategory, // catid
+                Array( $idCategory ), // catid
                 $userInfo->getId(), // userid
                 $blogid, // blogid
                 $status,
@@ -103,7 +115,6 @@
             
             $blogInfo = $blogsG->getBlogInfo( $blogid );
 
-
             // Get the plugin manager
             $plugMgr =& PluginManager::getPluginManager();
             $plugMgr->setBlogInfo( $blogInfo);
@@ -189,6 +200,12 @@
             //
             $categories = Array();
             $cats = $category->getBlogCategories($blogid);            
+
+			// some protection again blogs without categories
+			if( !$cats ) {
+				return new IXR_Error(-1, 'This blog does not have categories!');				
+			}
+
             if ( $catList != NULL )
             {
                 foreach( $catList as $categoryName ) {



More information about the pLog-svn mailing list