[Linpha-cvs] SF.net SVN: linpha: [4919] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2008-04-08 20:41:40
|
Revision: 4919 http://linpha.svn.sourceforge.net/linpha/?rev=4919&view=rev Author: fangehrn Date: 2008-04-08 13:41:34 -0700 (Tue, 08 Apr 2008) Log Message: ----------- 2008-04-08 flo * RSS plugin - implemented PicLens compatible rss feed give it a try: https://addons.mozilla.org/de/firefox/addon/5579 Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/lib/classes/linpha.template.class.php trunk/linpha2/lib/classes/linpha.view.album.class.php trunk/linpha2/lib/modules/module.newimg.php trunk/linpha2/templates/default/global.head.php trunk/linpha2/templates/default/home.html.php trunk/linpha2/templates/default/themes/default/css/global.css Added Paths: ----------- trunk/linpha2/lib/plugins/rss/module.rss.php trunk/linpha2/templates/default/rss.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/ChangeLog 2008-04-08 20:41:34 UTC (rev 4919) @@ -1,4 +1,9 @@ +2008-04-08 flo + * RSS plugin + - implemented PicLens compatible rss feed + give it a try: https://addons.mozilla.org/de/firefox/addon/5579 + 2008-04-07 flo * metadata - fixed admin section Modified: trunk/linpha2/lib/classes/linpha.template.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.template.class.php 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/lib/classes/linpha.template.class.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -222,10 +222,14 @@ ); } elseif ( strpos($menuEntry, 'plugins_') !== false ) { $menuEntry = substr($menuEntry, 8); - $this->menuFinal[ $menuEntry ] = array( - 'name' => i18n(ucfirst($menuEntry)), // this will not be detected by the language translater, but thats no problem because this plugin name is for sure somewhere else - 'link' => LINPHA_LINK.'&linCat='.$menuEntry - ); + if (isset($GLOBALS['linpha']->sql->config->value['plugins_'.$menuEntry.'_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_'.$menuEntry.'_enable']) + { + $this->menuFinal[ $menuEntry ] = array( + 'name' => i18n(ucfirst($menuEntry)), // this will not be detected by the language translater, but thats no problem because this plugin name is for sure somewhere else + 'link' => LINPHA_LINK.'&linCat='.$menuEntry + ); + } } elseif ( strpos($menuEntry, 'icon_') !== false ) { if (isset($this->menu[$menuEntry])) { $this->menuFinal[ $menuEntry ] = array( Modified: trunk/linpha2/lib/classes/linpha.view.album.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.view.album.class.php 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/lib/classes/linpha.view.album.class.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -1,4 +1,4 @@ -<?php +<?php /* * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> * Florian Angehrn @@ -163,7 +163,7 @@ { case 'thumb': case 'thumbdetail': - $this->viewThumb(); // will exit() when linJSON is set + $this->viewThumb(); // will exit() if linJSON is set break; case 'basket': $this->viewBasket(); @@ -565,7 +565,7 @@ $days = $GLOBALS['linpha']->sql->config->value['sys_style_home_newimagesage']; $days_in_sec = $days*60*60*24; $lower_date = time()-$days_in_sec; - $this->viewHomeSetImages('new_images','sys_style_home_newimagesnr',' AND time_add > '.LinSql::linAddslashes($lower_date)); + $this->viewHomeSetImages('new_images','sys_style_home_newimagesnr',' AND time_add > '.intval($lower_date)); /** * random images Modified: trunk/linpha2/lib/modules/module.newimg.php =================================================================== --- trunk/linpha2/lib/modules/module.newimg.php 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/lib/modules/module.newimg.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -48,16 +48,16 @@ $days_in_sec = $days*60*60*24; $lower_date = time()-$days_in_sec; - if( $GLOBALS['linpha']->sql->config->value['sys_style_home_newimagesnr'] != 0 ) + if ( $GLOBALS['linpha']->sql->config->value['sys_style_home_newimagesnr'] != 0 ) { $linpha->albumView->photos = $GLOBALS['linpha']->db->GetAssoc("SELECT ".LIN_SELECT_FIELDS." ". - "FROM ".LIN_PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999 AND time_add > ".LinSql::linAddslashes($lower_date)." ". + "FROM ".LIN_PREFIX."photos WHERE img_type <> 0 AND img_type <> 9999999 AND time_add > ".intval($lower_date)." ". "ORDER BY ".$linpha->albumView->orderby); } else { - $linpha->albumView->photos = Array(); + $linpha->albumView->photos = array(); } Added: trunk/linpha2/lib/plugins/rss/module.rss.php =================================================================== --- trunk/linpha2/lib/plugins/rss/module.rss.php (rev 0) +++ trunk/linpha2/lib/plugins/rss/module.rss.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -0,0 +1,160 @@ +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * RSS + * @package Modules + */ + + +if (isset($_GET['rss'])) +{ + $sql = ""; + $host = "http://".$_SERVER["HTTP_HOST"]; + $link = $host.LINPHA_LINK; + $title = $GLOBALS['linpha']->sql->config->value['sys_style_layout_title']; + $urlself = $host.LINPHA_LINK.'&linCat=rss&rss='; + + $albid = intval($GLOBALS['linpha']->template->idCurrent); + + if ($_GET['rss']=='img' && $albid == 0) { + $_GET['rss'] = 'albs'; + } + + switch ($_GET['rss']) + { + case 'newimg': + + $days = $GLOBALS['linpha']->sql->config->value['sys_style_home_newimagesage']; + $days_in_sec = $days*60*60*24; + $lower_date = time()-$days_in_sec; + + $subtitle = i18n("New Images"); + $link .= '&linCat=newimg'; + $sublink = $link.'&linId='; + $urlself .= 'newimg'; + + $sql = "img_type <> '0' AND time_add > ".intval($lower_date); + break; + + case 'albs': + + $subtitle = i18n("Albums"); + $link .= '&linCat=alb'; + $sublink = $link.'&linId='; + $urlself .= 'albs'; + + $sql = "img_type = '0'"; + break; + + case 'img': + + $arrNames = LinSql::getFullFilenameFromId($albid); + $subtitle = implode('/', $arrNames); + $link .= '&linCat=alb&linId='; + $sublink = $link; + $link .= $albid; + $urlself .= 'img&linId='.$albid; + + $sql = "parent_id = '".$albid."' AND img_type <> '0'"; + break; + } + + if (!empty($sql)) { + //echo $subtitle; + //echo $sql; + + $timeBuild = $GLOBALS['linpha']->db->GetOne("SELECT max(time_add) FROM ".LIN_PREFIX."photos WHERE img_type <> '9999999' AND ".$sql); + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name, md5sum FROM ".LIN_PREFIX."photos WHERE img_type <> '9999999' AND ".$sql); + +//header('Content-type: application/xhtml+xml'); +header('Content-type: application/rss+xml'); +//header('Content-type: text/xml'); +echo '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'."\n"; +?> +<rss version="2.0" + xmlns:media="http://search.yahoo.com/mrss/" + xmlns:atom="http://www.w3.org/2005/Atom"> + <channel> + <title><?php echo htmlentities($title.' - '.$subtitle, ENT_QUOTES); ?></title> + <link><?php echo $link; ?></link> + <description><?php echo htmlentities($title.' - '.$subtitle, ENT_QUOTES); ?></description> + <?php /*<language></language>*/ ?> + <?php /*<copyright></copyright>*/ ?> + <lastBuildDate><?php echo date("D, j M Y G:i:s", $timeBuild)." GMT"; /*it does not work if we use date("... T) for the timezone. + if it is CEST the RSS does not validate*/ ?></lastBuildDate> +<?php + while($data = $query->FetchRow()) + { + if (LinSql::photoIsAllowed( $data['id'] )) + { +?> + <item> + <title><?php $arrNames = LinSql::getFullFilenameFromId($data['id']); + echo htmlentities(implode('/', $arrNames), ENT_QUOTES); ?></title> + <link><?php echo $sublink.$data['id']; ?></link> + <?php /*<description>description</description>*/ ?> + <guid isPermaLink="false"><?php echo $data['id'].'_'.$data['md5sum']; ?></guid> + <media:thumbnail url="<?php echo $host.LINPHA_CLIENT.'/get_thumb.php?linId='.$data['id']; + if ($_GET['rss']=='alb') { + echo '&linRss=true'; // add this to prevent PicLens activate on home view + } + ?>"/> + <media:content url="<?php echo $host.LINPHA_CLIENT.'/get_image.php?linId='.$data['id']; ?>"/> + </item> +<?php + } + } + ?> + + <atom:link href="<?php echo $urlself; ?>" rel="self" type="application/rss+xml" /> + </channel> +</rss> +<?php + } + + exit(); +} + + + +function linBuildAlbumTree($id, $text, &$arrData) +{ + $query = $GLOBALS['linpha']->db->Execute("SELECT id, name FROM ".LIN_PREFIX."photos WHERE parent_id = '".$id."' AND img_type = '0' ORDER by name"); + while($data = $query->FetchRow()) + { + $subtext = $text.'/'.htmlentities($data['name'], ENT_QUOTES); + + $arrData[] = array('id'=>$data['id'], 'name' => $subtext); + + linBuildAlbumTree($data['id'], $subtext, $arrData); + } +} + +$linpha->template->output['albumTree'] = array(); + +linBuildAlbumTree(0, '', $linpha->template->output['albumTree']); + + +$linpha->template->setModuleName('rss'); +$linpha->template->URL_full = LINPHA_LINK.'&linCat=rss'; +$linpha->template->output['title'] = i18n("LinPHA RSS Feeds"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); +?> \ No newline at end of file Modified: trunk/linpha2/templates/default/global.head.php =================================================================== --- trunk/linpha2/templates/default/global.head.php 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/templates/default/global.head.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -78,10 +78,10 @@ var linYUILoader = new YAHOO.util.YUILoader({ require: ["logger"/*, "menu"*/], loadOptional: true, - filter: { + /*filter: { 'searchExp': "-min\\.js", 'replaceStr': "-debug.js" - }, + },*/ onSuccess: function() { } }); linYUILoader.addModule({ @@ -104,6 +104,12 @@ </script> <?php } ?> +<?php /* RSS Plugin */ +if (isset($GLOBALS['linpha']->sql->config->value['plugins_rss_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_rss_enable']) { ?> +<link rel="alternate" href="<?php echo LINPHA_LINK.'&linCat=rss&rss=img&linId='.$linTpl->idCurrent; ?>" type="application/rss+xml" title="" /> +<?php } ?> + <?php /* menu must be after myThemePanelBase definition */ $filename = LINPHA_DIR.'/templates/'.$linTpl->template_name.'/menu.head.php'; @@ -115,4 +121,5 @@ if (file_exists($filename)) { include_once( $filename ); } + ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/home.html.php =================================================================== --- trunk/linpha2/templates/default/home.html.php 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/templates/default/home.html.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -15,9 +15,9 @@ ?> <div class="linDivRandomimg"> <?php echo '<a href="'.LINPHA_LINK.'&linCat=alb&linId='.$value['id'].'">' . - '<img class="linImgRandomimg" title="'.htmlentities($value['path']).'" src="'. LINPHA_CLIENT.'/get_thumb.php?linId=' .$value['id'] .'" alt="randomimage"' . - 'width="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'"' . - 'height="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'"/></a>'; ?> + '<img class="linImgRandomimg" title="'.htmlentities($value['path']).'" src="'. LINPHA_CLIENT.'/get_thumb.php?linId=' .$value['id'] .'" alt="randomimage" ' . + 'width="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'" ' . + 'height="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'" /></a>'; ?> <br /><br /> </div> <?php @@ -37,7 +37,7 @@ <div class="linDivNewimg"> <?php echo '<a href="'.LINPHA_LINK.'&linCat=newimg&linId='.$value['id'].'">' . '<img class="linImgNewimg" title="'.htmlspecialchars($value['path'],ENT_QUOTES).'" src="'. LINPHA_CLIENT.'/get_thumb.php?linId=' .$value['id'] .'" alt="newimage" ' . - 'width="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'"' . + 'width="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'" ' . 'height="'.$GLOBALS['linpha']->sql->config->value['sys_style_thumb_size_display'].'"/></a>'; ?> <br /><br /> </div> Added: trunk/linpha2/templates/default/rss.html.php =================================================================== --- trunk/linpha2/templates/default/rss.html.php (rev 0) +++ trunk/linpha2/templates/default/rss.html.php 2008-04-08 20:41:34 UTC (rev 4919) @@ -0,0 +1,38 @@ +<?php echo $linTpl->divRoundCorners('top','main'); ?> + +<br /> +<h1 class="linStyle"> +<img src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/rss/rss.png" alt="RSS" border="0" width="48" /> +<?php echo i18n("LinPHA RSS Feeds"); ?></h1> +<br /> + +<a href="<?php echo $linTpl->URL_full; ?>&rss=newimg"><b><?php echo i18n("New Images"); ?></b></a> +<a href="<?php echo $linTpl->URL_full; ?>&rss=newimg"> +<img src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/rss/rss.png" alt="RSS" border="0" width="20" /> +</a> +<br /><br /> + +<a href="<?php echo $linTpl->URL_full; ?>&rss=albs"><b><?php echo i18n("Albums (without images)"); ?></b></a> +<a href="<?php echo $linTpl->URL_full; ?>&rss=albs"> +<img src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/rss/rss.png" alt="RSS" border="0" width="20" /> +</a> +<br /><br /><br /> + +<b><?php echo i18n("Album including images"); ?></b> +<br /> + +<?php foreach ($linTpl->output['albumTree'] as $album) { ?> + + + <a href="<?php echo $linTpl->URL_full.'&rss=img&linId='.$album['id']; ?>"><?php echo $album['name']; ?></a> + + <a href="<?php echo $linTpl->URL_full.'&rss=img&linId='.$album['id']; ?>"> + <img src="<?php echo LINPHA_CLIENT; ?>/lib/plugins/rss/rss.png" alt="RSS" border="0" width="12" /> + </a> + <br /> + +<?php } ?> + +<br /><br /> + +<?php echo $linTpl->divRoundCorners('bottom','main'); ?> \ No newline at end of file Modified: trunk/linpha2/templates/default/themes/default/css/global.css =================================================================== --- trunk/linpha2/templates/default/themes/default/css/global.css 2008-04-07 20:36:31 UTC (rev 4918) +++ trunk/linpha2/templates/default/themes/default/css/global.css 2008-04-08 20:41:34 UTC (rev 4919) @@ -88,7 +88,7 @@ padding: 0; }*/ #linDivMain { - position: relative; + /*position: relative; do we need this? if enable it breaks linDivRandomimg float: left in IE !! */ min-height: 300px; margin: 0; padding: 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |