public function allcommentAction() { $request = $this->getRequest(); $post_id = $request->getParam('id'); $comment_mapper = new Application_Model_CommentMapper(); $comments = $comment_mapper->getComments($post_id, false); $xml_text = '<?xml version="1.0" encoding="UTF-8"?>'; $xml_text .= '<comments>'; foreach ($comments as $comment) { $xml_text .= "<comment>"; $xml_text .= "<text>" . $comment['content'] . "</text>"; $xml_text .= "<image>" . get_profile_path($comment['user_id']) . "</image>"; $xml_text .= "<date>" . gmdate("Y/m/d H:i", $comment['created_at']) . "</date>"; $xml_text .= "<name>" . $comment['username'] . "</name>"; $xml_text .= "</comment>"; } $xml_text .= '</comments>'; header("Content-type: text/xml"); $xml = new SimpleXMLElement($xml_text); echo $xml->asXML(); exit; }
public function viewxmlAction() { $request = $this->getRequest(); $user_id = get_user_id(); $follower_mapper = new Application_Model_FollowMapper(); $friends = $follower_mapper->findAllByColumn('follower_id', $user_id); $user_mapper = new Application_Model_UserMapper(); $persons = array(); foreach ($friends as $friend) { $friends_of_friend = $follower_mapper->findAllByColumn('followed_id', $friend['followed_id']); foreach ($friends_of_friend as $ff) { $person_id = $ff['follower_id']; $image = get_profile_path($person_id); $person = $user_mapper->find($person_id); $name = $person['username']; $about = $person['about']; $matual = $user_mapper->find($friend['followed_id']); $matual_name = $matual['username']; if ($name != get_username()) { $f = $follower_mapper->findAllByTwoColumns('followed_id', $ff['follower_id'], 'follower_id', get_user_id()); if (empty($f)) { $persons[] = array('image' => $image, 'name' => $name, 'about' => $about, 'matual_friend' => $matual_name); } } } } $note = '<?xml version="1.0" encoding="UTF-8"?>'; $note .= "<people>"; foreach ($persons as $item) { $note .= "<person>"; $note .= "<image>"; $note .= $item['image']; $note .= "</image>"; $note .= "<name>"; $note .= $item['name']; $note .= "</name>"; $note .= "<about>"; $note .= $item['about']; $note .= "</about>"; $note .= "<matualFriend>"; $note .= $item['matual_friend']; $note .= "</matualFriend>"; $note .= "</person>"; } $note .= "</people>"; header("Content-type: text/xml"); $xml = new SimpleXMLElement($note); echo $xml->asXML(); exit; }