Stack2RSS 1.0
A simple web application that creates an RSS feed given an API route.
|
00001 <?php 00002 00003 /// \file rep_change_converter.php Contains the conversion class for rep change objects. 00004 00005 // This class derives from Converter 00006 require_once 'converter.php'; 00007 00008 /// Provides conversion for rep change objects 00009 class RepChangeConverter extends Converter 00010 { 00011 protected function GetTitle($json_item) 00012 { 00013 // Determine whether there was a gain or loss of rep. 00014 $rep = $json_item['positive_rep'] - $json_item['negative_rep']; 00015 $action = ($rep > 0)?'Gained':'Lost'; 00016 $rep = abs($rep); 00017 00018 return "{$action} {$rep} reputation."; 00019 } 00020 00021 protected function GetDescription($json_item) 00022 { 00023 $rep = $json_item['positive_rep'] - $json_item['negative_rep']; 00024 $action = ($rep > 0)?'Gained':'Lost'; 00025 $rep = abs($rep); 00026 00027 if($json_item['post_type'] == 'question') 00028 $type = 'question'; 00029 else 00030 $type = 'answer to'; 00031 00032 return "{$action} {$rep} reputation for {$type} \"{$json_item['title']}\"<br /><b>Up:</b> {$json_item['positive_rep']} <b>Down: </b>{$json_item['negative_rep']}"; 00033 } 00034 00035 protected function GetLink($json_item) 00036 { 00037 return "http://{$_GET['site']}/questions/{$json_item['post_id']}"; 00038 } 00039 00040 protected function GetDate($json_item) 00041 { 00042 return date(DATE_RSS, $json_item['on_date']); 00043 } 00044 } 00045 00046 ?>