From 7ff7dfb99732dab0ef7cc385d7c4d5d5e469a948 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Thu, 1 Nov 2007 14:05:21 +0000 Subject: [PATCH] issue62, rss feed implemented git-svn-id: file:///var/lib/svn/phpfspot/trunk@279 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 134 ++++++++++++++++++++--- themes/default/templates/photo_index.tpl | 1 + 2 files changed, 118 insertions(+), 17 deletions(-) diff --git a/phpfspot.class.php b/phpfspot.class.php index 14ce0c7..57551f3 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -145,6 +145,19 @@ class PHPFSPOT { $this->tmpl->show("slideshow.tpl"); return; break; + case 'rss': + if(isset($_GET['tags'])) { + $_SESSION['selected_tags'] = $this->extractTags($_GET['tags']); + } + if(isset($_GET['from_date']) && $this->isValidDate($_GET['from_date'])) { + $_SESSION['from_date'] = strtotime($_GET['from_date'] ." 00:00:00"); + } + if(isset($_GET['to_date']) && $this->isValidDate($_GET['to_date'])) { + $_SESSION['to_date'] = strtotime($_GET['to_date'] ." 23:59:59"); + } + $this->getRSSFeed(); + return; + break; } if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) @@ -885,11 +898,14 @@ class PHPFSPOT { $current_tags = $this->getCurrentTags(); $extern_link = "index.php?mode=showpi"; + $rss_link = "index.php?mode=rss"; if($current_tags != "") { $extern_link.= "&tags=". $current_tags; + $rss_link.= "&tags=". $current_tags; } if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) { $extern_link.= "&from_date=". $this->ts2str($_SESSION['from_date']) ."&to_date=". $this->ts2str($_SESSION['to_date']); + $rss_link.= "&from_date=". $this->ts2str($_SESSION['from_date']) ."&to_date=". $this->ts2str($_SESSION['to_date']); } $export_link = "index.php?mode=export"; @@ -898,6 +914,7 @@ class PHPFSPOT { $this->tmpl->assign('extern_link', $extern_link); $this->tmpl->assign('slideshow_link', $slideshow_link); $this->tmpl->assign('export_link', $export_link); + $this->tmpl->assign('rss_link', $rss_link); $this->tmpl->assign('count', $count); $this->tmpl->assign('width', $this->cfg->thumb_width); $this->tmpl->assign('images', $images); @@ -1564,14 +1581,9 @@ class PHPFSPOT { $pictures = $this->getPhotoSelection(); $current_tags = $this->getCurrentTags(); - if(!isset($_SERVER['HTTPS'])) $protocol = "http"; - else $protocol = "https"; - - $server_name = $_SERVER['SERVER_NAME']; - foreach($pictures as $picture) { - $orig_url = $protocol ."://". $server_name . $this->cfg->web_path ."index.php?mode=showp&id=". $picture; + $orig_url = $this->get_phpfspot_url() ."index.php?mode=showp&id=". $picture; if($current_tags != "") { $orig_url.= "&tags=". $current_tags; } @@ -1579,7 +1591,7 @@ class PHPFSPOT { $orig_url.= "&from_date=". $_SESSION['from_date'] ."&to_date=". $_SESSION['to_date']; } - $thumb_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width; + $thumb_url = $this->get_phpfspot_url() ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width; switch($mode) { @@ -1603,6 +1615,74 @@ class PHPFSPOT { } // getExport() + /** + * output RSS feed + */ + public function getRSSFeed() + { + Header("Content-type: text/xml; charset=utf-8"); + print "\n"; +?> + + + phpfspot + phpfspot RSS feed + get_phpfspot_url()); ?> + + phpfspot +getPhotoSelection(); + $current_tags = $this->getCurrentTags(); + + foreach($pictures as $picture) { + + $orig_url = $this->get_phpfspot_url() ."index.php?mode=showp&id=". $picture; + if($current_tags != "") { + $orig_url.= "&tags=". $current_tags; + } + if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) { + $orig_url.= "&from_date=". $_SESSION['from_date'] ."&to_date=". $_SESSION['to_date']; + } + + $details = $this->get_photo_details($picture); + + $thumb_url = $this->get_phpfspot_url() ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width; + $thumb_html = htmlspecialchars(" + +
+". $details['description']); + + $orig_path = $this->translate_path($details['directory_path']) ."/". $details['name']; + $meta = $this->get_meta_informations($orig_path); + $meta_date = isset($meta['FileDateTime']) ? $meta['FileDateTime'] : filemtime($orig_path); + +?> + + <?php print htmlspecialchars($details['name']); ?> + + + + + + + + + +
+
+cfg->web_path ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width; + return $this->get_phpfspot_url() ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width; } // getNextSlideShowImage() @@ -1746,11 +1822,7 @@ class PHPFSPOT { else $_SESSION['slideshow_img']--; - $server_name = $_SERVER['SERVER_NAME']; - if(!isset($_SERVER['HTTPS'])) $protocol = "http"; - else $protocol = "https"; - - return $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width; + return $this->get_phpfspot_url() ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width; } // getPrevSlideShowImage() @@ -1843,6 +1915,34 @@ class PHPFSPOT { } // get_thumb_path() + /** + * returns server's virtual host name + */ + private function get_server_name() + { + return $_SERVER['SERVER_NAME']; + } // get_server_name() + + /** + * returns type of webprotocol which is + * currently used + */ + private function get_web_protocol() + { + if(!isset($_SERVER['HTTPS'])) + return "http"; + else + return "https"; + } // get_web_protocol() + + /** + * return url to this phpfspot installation + */ + private function get_phpfspot_url() + { + return $this->get_web_protocol() ."://". $this->get_server_name() . $this->cfg->web_path; + } // get_phpfspot_url() + } ?> diff --git a/themes/default/templates/photo_index.tpl b/themes/default/templates/photo_index.tpl index 08c8999..4707020 100644 --- a/themes/default/templates/photo_index.tpl +++ b/themes/default/templates/photo_index.tpl @@ -37,6 +37,7 @@ {/if} + -- 2.25.1