From 513dc49f33f087c554a373e981e803f1d4cb260d Mon Sep 17 00:00:00 2001 From: iad2003 Date: Mon, 26 Oct 2009 16:13:33 +0000 Subject: [PATCH] 2nd release :) - added easy configuration with wordpress like schema + wlwmanifest.php file do describe admin url page, comments management page and directly edit of post from WLW - added mt_keywords aka tags for news - implemented new function getTags (although not really usefull :) ) --- e107_plugins/metaweblog/metaweblog.php | 152 ++++++++++++++++++++++--- e107_plugins/metaweblog/todo.txt | 15 --- 2 files changed, 138 insertions(+), 29 deletions(-) delete mode 100644 e107_plugins/metaweblog/todo.txt diff --git a/e107_plugins/metaweblog/metaweblog.php b/e107_plugins/metaweblog/metaweblog.php index b78389fdc..e0ea9aa9c 100644 --- a/e107_plugins/metaweblog/metaweblog.php +++ b/e107_plugins/metaweblog/metaweblog.php @@ -1,5 +1,6 @@ '; ?> + + + e107 + http://www.e107.org/ + + + + + + + + + + new xmlrpcval(true, 'boolean'), 'url'=> new xmlrpcval(SITEURL, 'string'), 'blogid'=> new xmlrpcval(eXMLRPC_BLOG_ID_LOC, 'string'), 'blogName'=> new xmlrpcval(eXMLRPC_BLOG_NAME_LOC, 'string'), 'xmlrpc'=> new xmlrpcval(eXMLRPC_BLOG_XMLRPC, 'string')), 'struct'); + $structArray[] = new xmlrpcval(array( + 'isAdmin'=> new xmlrpcval(true, 'boolean'), + 'url'=> new xmlrpcval(SITEURL, 'string'), + 'blogid'=> new xmlrpcval(eXMLRPC_BLOG_ID_LOC, 'string'), + 'blogName'=> new xmlrpcval(eXMLRPC_BLOG_NAME_LOC, 'string'), + 'xmlrpc'=> new xmlrpcval(eXMLRPC_BLOG_XMLRPC, 'string') + ),'struct'); return new xmlrpcresp(new xmlrpcval($structArray, 'array')); } @@ -140,6 +168,13 @@ function newPost($xmlrpcmsg) $mt_allow_comments = $content->structMem('mt_allow_comments')->scalarval(); } + //26/10/2009 14.30.41 added mt_keywords ie tags + //check if we have something... + $tempKeywords = checkXmlElementS($content->serialize(), 'mt_keywords'); + if($tempKeywords == 1){ + $mt_keywords = $content->structMem('mt_keywords')->scalarval(); + } + //author from e107 $query = 'SELECT u.user_id FROM `#user` AS u WHERE u.user_loginname = \''.$username.'\' AND u.user_password = \''.md5($password).'\''; $sql = e107::getDb(); @@ -197,7 +232,7 @@ function newPost($xmlrpcmsg) $data['_FIELD_TYPES']['news_thumbnail'] = 'todb'; $data['data']['news_sticky'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? $data['_FIELD_TYPES']['news_sticky'] = 'int'; - $data['data']['news_meta_keywords'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? + $data['data']['news_meta_keywords'] = $mt_keywords; $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb'; $data['data']['news_meta_description'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? $data['_FIELD_TYPES']['news_meta_description'] = 'todb'; @@ -269,6 +304,13 @@ function editPost($xmlrpcmsg) $mt_allow_comments = $content->structMem('mt_allow_comments')->scalarval(); } + //26/10/2009 14.30.41 added mt_keywords ie tags + //check if we have something... + $tempKeywords = checkXmlElementS($content->serialize(), 'mt_keywords'); + if($tempKeywords == 1){ + $mt_keywords = $content->structMem('mt_keywords')->scalarval(); + } + //author from e107 $query = 'SELECT u.user_id FROM `#user` AS u WHERE u.user_loginname = \''.$username.'\' AND u.user_password = \''.md5($password).'\''; $sql = new db(); @@ -327,7 +369,7 @@ function editPost($xmlrpcmsg) $data['_FIELD_TYPES']['news_thumbnail'] = 'todb'; $data['data']['news_sticky'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? $data['_FIELD_TYPES']['news_sticky'] = 'int'; - $data['data']['news_meta_keywords'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? + $data['data']['news_meta_keywords'] = $mt_keywords; $data['_FIELD_TYPES']['news_meta_keywords'] = 'todb'; $data['data']['news_meta_description'] = ''; //NOT AVAIBLE MAKE A CUSTOM FIELD? $data['_FIELD_TYPES']['news_meta_description'] = 'todb'; @@ -375,6 +417,7 @@ function getPost($xmlrpcmsg) 'dateCreated'=> new xmlrpcval(iso8601_encode($row['news_datestamp']),'dateTime.iso8601'), 'title'=> new xmlrpcval($row['news_title'], 'string'), 'mt_excerpt'=> new xmlrpcval($row['news_summary'], 'string'), + 'mt_keywords'=> new xmlrpcval($row['news_meta_keywords'], 'string'), 'mt_allow_comments'=> new xmlrpcval($row['news_allow_comments'], 'string'), 'description'=> new xmlrpcval(str_replace('[html]', '', str_replace('[/html]', '', $row['news_body'])), 'string'), 'mt_text_more'=> new xmlrpcval(str_replace('[html]', '', str_replace('[/html]', '', $row['news_extended'])), 'string'), @@ -452,6 +495,7 @@ function getRecentPosts($xmlrpcmsg) 'dateCreated'=> new xmlrpcval(iso8601_encode($row['news_datestamp']),'dateTime.iso8601'), 'title'=> new xmlrpcval($row['news_title'], 'string'), 'mt_excerpt'=> new xmlrpcval($row['news_summary'], 'string'), + 'mt_keywords'=> new xmlrpcval($row['news_meta_keywords'], 'string'), 'mt_allow_comments'=> new xmlrpcval($row['news_allow_comments'], 'string'), 'description'=> new xmlrpcval(str_replace('[html]', '', str_replace('[/html]', '', $row['news_body'])), 'string'), 'mt_text_more'=> new xmlrpcval(str_replace('[html]', '', str_replace('[/html]', '', $row['news_extended'])), 'string'), @@ -1153,6 +1197,58 @@ function getPostCategories($xmlrpcmsg) return new xmlrpcresp(0, $xmlrpcerruser + 1, 'Login Failed'); } } +/* + ************************* + ***** GET TAGS ********** + ************************* + */ +$getTags_sig = array(array($xmlrpcBoolean, $xmlrpcString, $xmlrpcString, $xmlrpcString)); +$getTags_doc = 'Set the categories on blog.'; +function getTags($xmlrpcmsg) +{ + $sql = e107::getDb(); + + $blogid = $xmlrpcmsg->getParam(0)->scalarval(); + $username = $xmlrpcmsg->getParam(1)->scalarval(); + $password = $xmlrpcmsg->getParam(2)->scalarval(); + + if (userLogin($username, $password, 'H') == true) + { + // get set post categories + $query = "SELECT + GROUP_CONCAT( n.news_meta_keywords SEPARATOR ',') AS meta_keys + FROM `#news` AS n + WHERE news_meta_keywords != '' ;"; + + $sql->db_Select_gen($query); + $row = $sql->db_Fetch(); + + //explode data in array and remove duplicates + $meta_tags = array(); + $meta_tags = explode(',', $row['meta_keys']); + $meta_tags = array_unique( $meta_tags ); + + foreach ($meta_tags as $key => $value) + { + $structArray[] = new xmlrpcval(array( + 'tag_id' => new xmlrpcval($key, 'string'), + 'name' => new xmlrpcval($value, 'string'), + 'count' => new xmlrpcval('1', 'string'), //NOT SENSE IN e107 for now?? + 'slug' => new xmlrpcval('1', 'string'), //NOT SENSE IN e107 for now?? + 'html_url' => new xmlrpcval('1', 'string'), //NOT SENSE IN e107 for now?? + 'rss_url' => new xmlrpcval('1', 'string') //NOT SENSE IN e107 for now?? + + ), 'struct'); + } + + return new xmlrpcresp( new xmlrpcval($structArray, 'array')); // Return type is struct[] (array of struct) + } + else + { + return new xmlrpcresp(0, $xmlrpcerruser + 1, 'Login Failed'); + } +} + // //METHODS DECLARATION // @@ -1179,19 +1275,32 @@ $a = array( 'wp.getCategories' => array('function'=>'getCategories', 'signature'=>$getCategories_sig, 'docstring'=>$getCategories_doc), - /* TO BE IMPLEMENTED - 'wp.getTags' => array( - 'function' => 'getTags', - 'signature' => $getTags_sig, - 'docstring' => $getTags_doc - ),*/ - 'wp.newCategory'=>array('function'=>'newCategory', 'signature'=>$newCategory_sig, 'docstring'=>$newCategory_doc), 'wp.deleteCategory'=>array('function'=>'deleteCategory', 'signature'=>$deleteCategory_sig, 'docstring'=>$deleteCategory_doc), /*TO BE IMPLEMENTED + + 'wp.getTags' => array( + 'function' => 'getTags', + 'signature' => $getTags_sig, + 'docstring' => $getTags_doc + ), + 'wp.newCategory'=>array( + 'function'=>'newCategory', + 'signature'=>$newCategory_sig, + 'docstring'=>$newCategory_doc + ), + 'wp.deleteCategory'=>array('function'=>'deleteCategory', + 'signature'=>$deleteCategory_sig, + 'docstring'=>$deleteCategory_doc + ), + 'wp.uploadFile'=>array( + 'function'=>'newMediaObject', + 'signature'=>$newMediaObject_sig, + 'docstring'=>$newMediaObject_doc + ), + /* TO BE IMPLEMENTED 'wp.suggestCategories' => array( 'function' => 'suggestCategories', 'signature' => $suggestCategories_sig, 'docstring' => $suggestCategories_doc - ),*/ - 'wp.uploadFile'=>array('function'=>'newMediaObject', 'signature'=>$newMediaObject_sig, 'docstring'=>$newMediaObject_doc), /*TO BE IMPLEMENTED + ), 'wp.getCommentCount' => array( 'function' => 'getCommentCount', 'signature' => $getCommentCount_sig, @@ -1252,7 +1361,22 @@ $a = array( 'signature' => $getCommentStatusList_sig, 'docstring' => $getCommentStatusList_doc )*/ - 'mt.getCategoryList'=>array('function'=>'getCategoryList', 'signature'=>$getCategoryList_sig, 'docstring'=>$getCategoryList_doc), 'mt.setPostCategories'=>array('function'=>'setPostCategories', 'signature'=>$setPostCategories_sig, 'docstring'=>$setPostCategories_doc), 'mt.getPostCategories'=>array('function'=>'getPostCategories', 'signature'=>$getPostCategories_sig, 'docstring'=>$getPostCategories_doc)); + 'mt.getCategoryList'=>array( + 'function'=>'getCategoryList', + 'signature'=>$getCategoryList_sig, + 'docstring'=>$getCategoryList_doc + ), + 'mt.setPostCategories'=>array( + 'function'=>'setPostCategories', + 'signature'=>$setPostCategories_sig, + 'docstring'=>$setPostCategories_doc + ), + 'mt.getPostCategories'=>array( + 'function'=>'getPostCategories', + 'signature'=>$getPostCategories_sig, + 'docstring'=>$getPostCategories_doc + ) + ); $s = new xmlrpc_server($a, false); $s->setdebug(1); $s->service(); diff --git a/e107_plugins/metaweblog/todo.txt b/e107_plugins/metaweblog/todo.txt deleted file mode 100644 index 216e6f15a..000000000 --- a/e107_plugins/metaweblog/todo.txt +++ /dev/null @@ -1,15 +0,0 @@ -9.47 21/10/2009 -METAWELOG PLUGIN TODO LIST DRAFT - -- admin log implementation to log out all the traffic -- error handling (not really sure how can be done, at least in log) -- better ACL configuration (getperms) and admin panel to configure ACL (example this user has rw access to news?) wraps ACL configuration -- custom content plugin support -- sintax to write in custom field of custom (ie sort of: {field_name:value}) this one need WLW customization OR use the wordpress plugin -- better admin preferences panel (for example to choise to use content plugin instead of pages) -- full manual to explain configuration of plugin and WLW - - - - -