Beispiel #1
0
 /**
  * Format a particular search response as HTML.
  */
 public function searchHTML($text, $qty)
 {
     $result = $this->search($text, $qty);
     $html = '<table class="' . htmlspecialchars($this->tableClass) . '">';
     foreach ($result->items as $activity) {
         $image_url = $activity->actor->image->url;
         $html .= '<tr>';
         if (strlen($image_url) > 14) {
             // if actor->image->url is this short, it's probably bunk data, and we are too
             // lazy to go digging through the rest of the stuff in the response looking
             // for a valid one:
             $html .= '<td><img height=50 width=50 src="' . htmlspecialchars($image_url) . '"></td>';
         } else {
             $html .= '<td></td>';
         }
         $html .= '<td><a href="' . htmlspecialchars($activity->actor->url) . '">' . htmlspecialchars($activity->actor->displayName) . '</a> ';
         if (isset($activity->title)) {
             $html .= $activity->title;
         }
         if (isset($activity->object->attachments)) {
             foreach ($activity->object->attachments as $attached) {
                 if (isset($attached->displayName)) {
                     $displayname = Text::truncate($attached->displayName, 140);
                     $html .= '<br><a href="' . htmlspecialchars($attached->url) . '">' . htmlspecialchars($displayname) . '</a>';
                 }
             }
         }
         $html .= '<br><i><small><a href="' . htmlspecialchars($activity->url) . '">' . $activity->published . '</a></small></i></td></tr>';
     }
     $html .= '</table>';
     return $html;
 }
Beispiel #2
0
 /**
  * Format a particular search response as HTML.
  */
 public function searchHTML($text, $qty)
 {
     $result = $this->search($text, $qty);
     $html = '<table class="' . htmlspecialchars($this->tableClass) . '">';
     $count = 0;
     foreach ($result->data as $activity) {
         if ($count++ > $qty) {
             break;
         }
         $html .= '<tr>';
         if (isset($activity->picture)) {
             $html .= '<td><img src="' . htmlspecialchars($activity->picture) . '" height=50 width=50></td>';
         } elseif (isset($activity->icon)) {
             $html .= '<td><img src="' . htmlspecialchars($activity->icon) . '"></td>';
         } else {
             $html .= "<td></td>";
         }
         $html .= '<td>[' . htmlspecialchars($activity->from->name) . '] ';
         if (isset($activity->message)) {
             $html .= Text::truncate(htmlspecialchars($activity->message), 50);
         } elseif (isset($activity->story)) {
             $html .= Text::truncate(htmlspecialchars($activity->story), 50);
         }
         $html .= '<br>';
         $time = '<small><i>' . htmlspecialchars($activity->created_time) . "</i></small>";
         if (isset($activity->link)) {
             $html .= '<a href="' . htmlspecialchars($activity->link) . '">' . $time . '</a>';
         } else {
             $html .= $time;
         }
         $html .= "</td></tr>";
     }
     $html .= '</table>';
     return $html;
 }