Stack2RSS 1.0
A simple web application that creates an RSS feed given an API route.

src/converters/user_timeline_converter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 /// \file user_timeline_converter.php Contains the conversion class for user timeline objects.
00004 
00005 // This class derives from Converter
00006 require_once 'converter.php';
00007 
00008 /// Provides conversion for user timeline objects
00009 class UserTimelineConverter extends Converter
00010 {
00011     protected function GetTitle($json_item)
00012     {
00013         switch($json_item['timeline_type'])
00014         {
00015             case 'askoranswered':
00016                 if($json_item['post_type'] == 'question')
00017                     return "Asked question \"{$json_item['description']}\"";
00018                 else
00019                     return "Answered question \"{$json_item['description']}\"";
00020             case 'accepted':
00021                 return "Accepted answer to \"{$json_item['description']}\"";
00022             case 'badge':
00023                 return "Awarded {$json_item['description']} badge.";
00024             case 'comment':
00025                 if($json_item['post_type'] == 'question')
00026                     return "Commented on question \"{$json_item['description']}\"";
00027                 else
00028                     return "Commented on answer to \"{$json_item['description']}\"";
00029             case 'revision':
00030                 return "Made revision to \"{$json_item['description']}\"";
00031             default:
00032                 return '[Unknown]';
00033         }
00034     }
00035     
00036     protected function GetDescription($json_item)
00037     {
00038         return ($json_item['timeline_type'] == 'askoranswered')?'<i>No data.</i>':$json_item['detail'];
00039     }
00040     
00041     protected function GetLink($json_item)
00042     {
00043         switch($json_item['timeline_type'])
00044         {
00045             case 'badge':         return "http://{$_GET['site']}/users/{$json_item['user_id']}";
00046             case 'askoranswered':
00047             case 'accepted':
00048             case 'comment':       return "http://{$_GET['site']}/questions/{$json_item['post_id']}";
00049             case 'revision':      return "http://{$_GET['site']}/posts/{$json_item['post_id']}/revisions";
00050             default:              return '[Unknown]';
00051         }
00052     }
00053     
00054     protected function GetDate($json_item)
00055     {
00056         return date(DATE_RSS, $json_item['creation_date']);
00057     }
00058 }
00059 
00060 ?>
 All Classes Files Functions Enumerations