/** * Converts a struct returned by the webservice to * a Services_Blogging_Post object * * @param array $arStruct Struct to convert * * @return Services_Blogging_Post Converted post */ protected function convertStructToPost($arStruct) { $post = new Services_Blogging_Post($this); $post->{Services_Blogging_Post::CONTENT} = $arStruct['description']; $post->{Services_Blogging_Post::TITLE} = $arStruct['title']; //0123456789012345678 //20060514T09:19:33 $post->{Services_Blogging_Post::DATE} = mktime(substr($arStruct['dateCreated'], 9, 2), substr($arStruct['dateCreated'], 12, 2), substr($arStruct['dateCreated'], 15, 2), substr($arStruct['dateCreated'], 4, 2), substr($arStruct['dateCreated'], 6, 2), substr($arStruct['dateCreated'], 0, 4)); $post->{Services_Blogging_Post::URL} = $arStruct['link']; if (!isset($arStruct['categories'])) { $arStruct['categories'] = array(); } $post->{Services_Blogging_Post::CATEGORIES} = $arStruct['categories']; $post->setId($arStruct['postid']); return $post; }
/** * Save a new post into the blog. * * @param Services_Blogging_Post $post Post object to put online * * @return void * * @throws Services_Blogging_Exception If an error occured */ public function savePost(Services_Blogging_Post $post) { if ($post->id === null) { //post is new and has no Id => create new one $request = new XML_RPC_Message('blogger.newPost', array($this->userdata['rpc_key'], $this->userdata['rpc_blogid'], $this->userdata['rpc_user'], $this->userdata['rpc_pass'], new XML_RPC_Value($post->{Services_Blogging_Post::CONTENT}, 'string'), new XML_RPC_Value(true, 'boolean'))); $nPostId = Services_Blogging_XmlRpc::sendRequest($request, $this->rpc_client); $post->setId($nPostId); } else { //edit the post; it already exists $request = new XML_RPC_Message('blogger.editPost', array($this->userdata['rpc_key'], new XML_RPC_Value($post->id, 'string'), $this->userdata['rpc_user'], $this->userdata['rpc_pass'], new XML_RPC_Value($post->{Services_Blogging_Post::CONTENT}, 'string'), new XML_RPC_Value(true, 'boolean'))); Services_Blogging_XmlRpc::sendRequest($request, $this->rpc_client); } }
/** * Converts a struct returned by the webservice to * a Services_Blogging_Post object * * @param array $arStruct Struct to convert * * @return Services_Blogging_Post Converted post */ protected function convertStructToPost($arStruct) { $post = new Services_Blogging_Post($this); $post->{Services_Blogging_Post::CONTENT} = $arStruct['event']; $post->{Services_Blogging_Post::TITLE} = $arStruct['subject']; //0123456789012345678 //2006-05-13 21:42:00 $post->{Services_Blogging_Post::DATE} = mktime(substr($arStruct['eventtime'], 11, 2), substr($arStruct['eventtime'], 14, 2), substr($arStruct['eventtime'], 17, 2), substr($arStruct['eventtime'], 5, 2), substr($arStruct['eventtime'], 8, 2), substr($arStruct['eventtime'], 0, 4)); $post->{Services_Blogging_Post::URL} = $arStruct['url']; if ($arStruct['props']) { $props = $arStruct['props']; if ($props['taglist']) { $post->{Services_Blogging_Post::CATEGORIES} = explode(',', $props['taglist']); } foreach ($this->field_correspondence as $post_field => $lj_field) { if (isset($props[$lj_field])) { $post->{$post_field} = $props[$lj_field]; } } if ($props['opt_nocomments'] !== NULL) { $post->{Services_Blogging_Post::ALLOW_COMMENTS} = !$props['opt_nocomments']; } if ($props['opt_preformatted'] !== NULL) { $post->{Services_Blogging_Post::AUTO_FORMAT} = !$props['opt_preformatted']; } } $post->setId($arStruct['itemid']); return $post; }
/** * Converts a struct returned by the webservice to * a Services_Blogging_Post object * * @param array $arStruct Struct to convert * * @return Services_Blogging_Post Converted post */ protected function convertStructToPost($arStruct) { $post = new Services_Blogging_Post($this); $post->{Services_Blogging_Post::CONTENT} = $arStruct['event']; $post->{Services_Blogging_Post::TITLE} = $arStruct['subject']; //0123456789012345678 //2006-05-13 21:42:00 $post->{Services_Blogging_Post::DATE} = mktime(substr($arStruct['eventtime'], 11, 2), substr($arStruct['eventtime'], 14, 2), substr($arStruct['eventtime'], 17, 2), substr($arStruct['eventtime'], 5, 2), substr($arStruct['eventtime'], 8, 2), substr($arStruct['eventtime'], 0, 4)); $post->{Services_Blogging_Post::URL} = $arStruct['url']; $post->setId($arStruct['itemid']); return $post; }