add/edit bug UI improvements
[couchdbimport.git] / CouchProjects / Demos / php / BugShrink / feed.php
blobbfbdafdc326ec1ae45aee01f9d0b50cdad53a862
1 <?php
2 header ("Content-type: text/xml");
3 include 'Library/CouchDb/Couch.php';
4 include 'Library/Shrink.php';
5 $couch = new Couch('localhost', 'bugshrink');
7 if(!$couch->running() || !$couch->db_exists()) {
8 die();
10 $lastUpdate = '';
12 $bugs = $couch->get_all('allfull', $options = array('reverse' => 'true'));
13 if(($bugs !== false) && (count($bugs) > 0)) {
15 $lastUpdate = '';
16 foreach($bugs AS $id => $bug) {
17 if(strlen($bug->get('Subject')) == 0) {continue;}
19 //get newest bug
20 if($bug->get('CreationDate') > $lastUpdate) {
21 $lastUpdate = $bug->get('CreationDate');
26 function get_iso_8601_date($int_date) {
27 //$int_date: current date in UNIX timestamp
28 $date_mod = date('Y-m-d\TH:i:s', $int_date);
29 $pre_timezone = date('O', $int_date);
30 $time_zone = substr($pre_timezone, 0, 3).":".substr($pre_timezone, 3, 2);
31 $date_mod .= $time_zone;
32 return $date_mod;
34 //var_dump( strtotime(str_replace(':', '', $lastUpdate)));
35 $lastUpdate = get_iso_8601_date(strtotime(str_replace(':', '', $lastUpdate)));
37 echo '<?xml version="1.0" encoding="utf-8"?>';
38 ?><feed xmlns="http://www.w3.org/2005/Atom">
40 <title>BugShrink Feed</title>
41 <link href="http://demos.couchdb.com/BugShrink2/"/>
42 <updated><?=$lastUpdate?></updated>
43 <author>
44 <name>BugShrink Bug Tracking Demo for CouchDb</name>
45 </author>
46 <id>urn:uuid:<?=md5('http://demos.couchdb.com/BugShrink2/')?></id>
48 <?php
49 foreach($bugs AS $id => $bug) {
50 if(strlen($bug->get('Subject')) == 0) {continue;}
51 $Subject = $bug->get('Subject');
52 $Link = 'http://demos.couchdb.com/BugShrink2/?id='.$id;
53 $updated = get_iso_8601_date(strtotime(str_replace(':', '', $bug->get('CreationDate'))));
54 $Body = shrink_format_body($bug->get('Body'));
55 $By = $bug->get('Author');
56 echo <<<EOD
57 <entry>
58 <title>$Subject</title>
59 <author>$By</author>
60 <link href="$Link"/>
61 <id>urn:uuid:$id</id>
62 <updated>$updated</updated>
63 <published>$updated</published>
64 <content type="xhtml">$Body</content>
65 </entry>
67 EOD;
71 </feed>