Changeset 10336
- Timestamp:
- Jan 23, 2009, 3:18:06 PM (14 years ago)
- Location:
- OpenPNE3/plugins/opWebAPIPlugin/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE3/plugins/opWebAPIPlugin/trunk/apps/api/modules/feeds/actions/actions.class.php
r10328 r10336 56 56 $this->result = $this->api->entry(); 57 57 $this->forward404Unless($this->result); 58 return $this->renderText($this->result); 58 $entry = $this->api->createEntryByInstance($this->result); 59 return $this->renderText($entry->publish()); 59 60 } 60 61 … … 66 67 public function executeInsertEntry($request) 67 68 { 68 $this->result = $this->api->insert( );69 $this->result = $this->api->insert($this->api->getEntryXMLFromRequestBody()); 69 70 $this->forward404Unless($this->result); 70 71 71 72 $this->getResponse()->setStatusCode(201); 72 return $this->renderText($this->result); 73 $entry = $this->api->createEntryByInstance($this->result); 74 return $this->renderText($entry->publish()); 73 75 } 74 76 … … 80 82 public function executeUpdateEntry($request) 81 83 { 82 $this->result = $this->api->update( );84 $this->result = $this->api->update($this->api->getEntryXMLFromRequestBody()); 83 85 $this->forward404Unless($this->result); 84 return $this->renderText($this->result); 86 $entry = $this->api->createEntryByInstance($this->result); 87 return $this->renderText($entry->publish()); 85 88 } 86 89 -
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPI.class.php
r10334 r10336 65 65 } 66 66 67 p rotectedfunction createEntryByInstance(BaseObject $obj, SimpleXMLElement $entry = null)67 public function createEntryByInstance(BaseObject $obj, SimpleXMLElement $entry = null) 68 68 { 69 69 $entry = new opAtomPubDocumentEntry($entry); … … 75 75 } 76 76 77 p rotectedfunction getEntryXMLFromRequestBody()77 public function getEntryXMLFromRequestBody() 78 78 { 79 79 $input = file_get_contents('php://input'); -
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPICommunityTopic.class.php
r10334 r10336 49 49 $id = $this->getRequiredParameter('id'); 50 50 $topic = CommunityTopicPeer::retrieveByPk($id); 51 if (!$topic) 52 { 53 return false; 54 } 55 56 $entry = $this->createEntryByInstance($topic); 57 return $entry->publish(); 51 return $topic; 58 52 } 59 53 60 public function insert( )54 public function insert(SimpleXMLElement $xml) 61 55 { 62 $elements = $this->getEntryXMLFromRequestBody();63 56 $communityId = $this->getRequiredParameter('community_id'); 64 57 65 58 $community = CommunityPeer::retrieveByPk($communityId); 66 $member = MemberPeer::retrieveByPk($ elements->author->id);59 $member = MemberPeer::retrieveByPk($xml->author->id); 67 60 if (!$community || !$member) 68 61 { … … 73 66 $topic->setMember($member); 74 67 $topic->setCommunity($community); 75 $topic->setName($ elements->title);68 $topic->setName($xml->title); 76 69 $topic->save(); 77 70 78 $responseEntry = $this->createEntryByInstance($topic); 79 return $responseEntry->publish(); 71 return $topic; 80 72 } 81 73 82 public function update( )74 public function update(SimpleXMLElement $xml) 83 75 { 84 $elements = $this->getEntryXMLFromRequestBody();85 86 76 $id = $this->getRequiredParameter('id'); 87 77 $topic = CommunityTopicPeer::retrieveByPk($id); 88 78 89 if (!$topic || $this->generateEntryId($topic) != $ elements->id)79 if (!$topic || $this->generateEntryId($topic) != $xml->id) 90 80 { 91 81 return false; 92 82 } 93 83 94 $topic->setName($ elements->title);84 $topic->setName($xml->title); 95 85 $topic->save(); 96 86 97 $responseEntry = $this->createEntryByInstance($topic); 98 return $responseEntry->publish(); 87 return $topic; 99 88 } 100 89 … … 112 101 } 113 102 114 p rotectedfunction createEntryByInstance(BaseObject $topic, SimpleXMLElement $entry = null)103 public function createEntryByInstance(BaseObject $topic, SimpleXMLElement $entry = null) 115 104 { 116 105 $entry = parent::createEntryByInstance($topic, $entry); -
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPICommunityTopicComment.class.php
r10334 r10336 49 49 $id = $this->getRequiredParameter('id'); 50 50 $comment = CommunityTopicCommentPeer::retrieveByPk($id); 51 if (!$comment) 52 { 53 return false; 54 } 55 56 $entry = $this->createEntryByInstance($comment); 57 return $entry->publish(); 51 return $comment; 58 52 } 59 53 60 public function insert( )54 public function insert(SimpleXMLElement $xml) 61 55 { 62 $elements = $this->getEntryXMLFromRequestBody();63 56 $communityTopicId = $this->getRequiredParameter('topic_id'); 64 57 65 58 $communityTopic = CommunityTopicPeer::retrieveByPk($communityTopicId); 66 $member = MemberPeer::retrieveByPk($ elements->author->id);59 $member = MemberPeer::retrieveByPk($xml->author->id); 67 60 if (!$communityTopic || !$member) 68 61 { … … 70 63 } 71 64 72 $elements = $this->getEntryXMLFromRequestBody();73 74 65 $comment = new CommunityTopicComment(); 75 66 $comment->setMember($member); 76 67 $comment->setCommunityTopic($communityTopic); 77 $comment->setBody($ elements->content);68 $comment->setBody($xml->content); 78 69 $comment->save(); 79 70 80 $responseEntry = $this->createEntryByInstance($comment); 81 return $responseEntry->publish(); 71 return $comment; 82 72 } 83 73 84 public function update( )74 public function update(SimpleXMLElement $xml) 85 75 { 86 $elements = $this->getEntryXMLFromRequestBody();87 88 76 $id = $this->getRequiredParameter('id'); 89 77 $comment = CommunityTopicCommentPeer::retrieveByPk($id); 90 if (!$comment || $this->generateEntryId($comment) != $ elements->id)78 if (!$comment || $this->generateEntryId($comment) != $xml->id) 91 79 { 92 80 return false; 93 81 } 94 82 95 $comment->setBody($ elements->content);83 $comment->setBody($xml->content); 96 84 $comment->save(); 97 85 98 $responseEntry = $this->createEntryByInstance($comment); 99 return $responseEntry->publish(); 86 return $comment; 100 87 } 101 88 … … 113 100 } 114 101 115 p rotectedfunction createEntryByInstance(BaseObject $comment, SimpleXMLElement $entry = null)102 public function createEntryByInstance(BaseObject $comment, SimpleXMLElement $entry = null) 116 103 { 117 104 $entry = parent::createEntryByInstance($comment, $entry); -
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPIDiary.class.php
r10334 r10336 49 49 $id = $this->getRequiredParameter('id'); 50 50 $diary = DiaryPeer::retrieveByPk($id); 51 if (!$diary) 52 { 53 return false; 54 } 55 56 $entry = $this->createEntryByInstance($diary); 57 return $entry->publish(); 51 return $diary; 58 52 } 59 53 60 public function insert( )54 public function insert(SimpleXMLElement $xml) 61 55 { 62 $elements = $this->getEntryXMLFromRequestBody(); 63 $member = MemberPeer::retrieveByPk($elements->author->id); 56 $member = MemberPeer::retrieveByPk($xml->author->id); 64 57 if (!$member) 65 58 { … … 68 61 69 62 $diary = new Diary(); 70 $diary->setTitle($ elements->title);71 $diary->setBody($ elements->content);63 $diary->setTitle($xml->title); 64 $diary->setBody($xml->content); 72 65 $diary->setMember($member); 73 66 $diary->save(); 74 67 75 $responseEntry = $this->createEntryByInstance($diary); 76 return $responseEntry->publish(); 68 return $diary; 77 69 } 78 70 79 public function update( )71 public function update(SimpleXMLElement $xml) 80 72 { 81 $elements = $this->getEntryXMLFromRequestBody();82 83 73 $id = $this->getRequiredParameter('id'); 84 74 $diary = DiaryPeer::retrieveByPk($id); 85 if (!$diary || $this->generateEntryId($diary) != $ elements->id)75 if (!$diary || $this->generateEntryId($diary) != $xml->id) 86 76 { 87 77 return false; 88 78 } 89 79 90 $diary->setTitle($ elements->title);91 $diary->setBody($ elements->content);80 $diary->setTitle($xml->title); 81 $diary->setBody($xml->content); 92 82 $diary->save(); 93 83 94 $responseEntry = $this->createEntryByInstance($diary); 95 return $responseEntry->publish(); 84 return $diary; 96 85 } 97 86 … … 109 98 } 110 99 111 p rotectedfunction createEntryByInstance(BaseObject $diary, SimpleXMLElement $entry = null)100 public function createEntryByInstance(BaseObject $diary, SimpleXMLElement $entry = null) 112 101 { 113 102 $entry = parent::createEntryByInstance($diary, $entry); -
OpenPNE3/plugins/opWebAPIPlugin/trunk/lib/api/opAPIInterface.class.php
r10328 r10336 20 20 public function feed(); 21 21 public function entry(); 22 public function insert( );23 public function update( );22 public function insert(SimpleXMLElement $xml); 23 public function update(SimpleXMLElement $xml); 24 24 public function delete(); 25 25 }
Note: See TracChangeset
for help on using the changeset viewer.