function doEndTag($application, $parentHandler, $args) { $this->loadTopicsAndSuggestions($application); $lasttopic = ''; $count = 0; if (!empty($this->suggestions)) { $iids = array(); foreach ($this->suggestions as $suggestion) { $topic = $suggestion['topic']; if (!isset($args['topic']) || $args['topic'] == 'all' || $args['topic'] == $topic) { try { $names = $application->getClient()->users_getInfo($suggestion['uid'], "first_name"); $name = $names[0]; $firstname = $name['first_name']; } catch (Exception $e) { $firstname = 'Friend of Friend'; } // Checking for topic switches if ($topic != $lasttopic) { if ($count > 0) { echo '</table>'; } echo '<br />'; echo '<table border="0" width="500px" cellpadding="5">'; $colspan = isset($this->style) ? 3 : 2; echo ' <tr><td width="500px" colspan="' . $colspan . '" bgcolor="#f7931d">Topic: ' . $topic . '</td></tr>'; $lasttopic = $topic; } echo ' <tr>'; if (isset($this->style)) { $rest = new RingsideRestClient($application->getClient()); $iids[] = $suggestion['sid']; $rest->items_setInfo($suggestion['sid'], 'trail6', 'trail6', null); //Now get ratings $ratings = array(); if (count($iids) > 0) { $ratings = $rest->ratings_get($iids); if (!$ratings) { $ratings = array(); } } $yes = 'black'; $no = 'black'; foreach ($ratings as $rating) { $iid = $rating['iid']; if ($iid == $suggestion['sid']) { $vote = $rating['vote']; if ($vote == 1) { $yes = 'green'; } else { $no = 'red'; } } } $vote_string = '<a href="index.php?action=rate&vote=1&iid=' . $suggestion['sid'] . '"><font color="' . $yes . '">yes</font></a>|<a href="index.php?action=rate&vote=0&iid=' . $suggestion['sid'] . '"><font color="' . $no . '">no</font></a> '; echo ' <td width="5%" bgcolor="#eeeeee">' . $vote_string . '</td>'; } echo ' <td width="30%" bgcolor="#fdc589">' . $suggestion['suggestion'] . '</td>'; echo ' <td width="65%" bgcolor="#eeeeee">posted by ' . $firstname . ' at ' . $suggestion['created'] . '</td>'; echo ' </tr>'; $count++; } } } if ($count > 0) { echo '</table>'; } }
/** * Queries for a list of suggestions and then includes the list page * * @param int $topic Topic ID, optional parameter. */ function showSuggestions(RingsideRestClient $rest, $uid) { $friends = $rest->delegate->friends_get(); $friends[] = $uid; $suggestions = SuggestionUtils::getSuggestions($friends); // Now get ratings $iids = array(); foreach ($suggestions as $suggestion) { $iids[] = $suggestion['sid']; $rest->items_setInfo($suggestion['sid'], 'trail4', 'trail4', null); } $ratings = array(); if (sizeof($iids) > 0) { $ratings = $rest->ratings_get($iids); } include_once 'list.php'; }