[pLog-svn] r649 - plog/trunk

oscar at devel.plogworld.net oscar at devel.plogworld.net
Mon Jan 3 00:57:26 GMT 2005


Author: oscar
Date: 2005-01-03 00:57:26 +0000 (Mon, 03 Jan 2005)
New Revision: 649

Modified:
   plog/trunk/xmlrpc.php
Log:
added support for multiple categories per post via the metaweblog api when adding a new post.


Modified: plog/trunk/xmlrpc.php
===================================================================
--- plog/trunk/xmlrpc.php	2005-01-03 00:49:32 UTC (rev 648)
+++ plog/trunk/xmlrpc.php	2005-01-03 00:57:26 UTC (rev 649)
@@ -174,37 +174,28 @@
             $body = $content["description"];
             $catList = $content["categories"];
             $categoryName = NULL;
-            if ( $catList != NULL )
-            {
-                foreach( $catList as $catName )
-                {
-                    // Only use the first category
-                    $categoryName = $catName;
-                    break;
-                }
-            }
 
+            //
+            // :KLUDGE:
+            // not exactly the smartest and fastest bit of code ever but it seems to work :-)
+            //
             $categories = Array();
-            if ( $categoryName != NULL )
+            $cats = $category->getBlogCategories($blogid);            
+            if ( $catList != NULL )
             {
-                $cats = $category->getBlogCategories($blogid);
-                foreach($cats as $cat)
-                {
-                    if ( strcmp( $cat->_name, $categoryName ) == 0 )
-                    {
-                        $idCategory = $cat->_id;
-                        break;
+                foreach( $catList as $categoryName ) {
+                    foreach( $cats as $blogCategory ) {
+                        if ( strcmp( $categoryName, $blogCategory->getName()) == 0 )
+                        {
+                            $categories[] = $blogCategory->getId();
+                        }
                     }
                 }
             }
+            else {
+                // if no category, let's pick a random one            
+            }
             
-            //
-            // :TODO: 
-            // here we should take into account that users can specify multiple categoires per
-            //post!!!
-            //
-            $categories[] = $idCategory;
-
             $article = new Article(
                 $title,
                 $body, // text




More information about the pLog-svn mailing list