DGE_InlineRSS 0.92. Version: 0.31 Author: Dave E Author URI: http://dave.stufftoread.net/ */ // This is the main slideshow function that does the real work. See // dge_ss_contentFilter() below for what to put in the $params // array. Just use corresponding keys and values in $params to get the // same result, e.g. // // DGE_SlideShow('ss1','http://blah.com/feed', array('limit'=>5)); // function DGE_SlideShow($ssid, $url, $params=array()) { // Steal these settings from inlinerss $cacheprefix = get_option('dge_irss_cacheprefix'); $cachepath = get_option('dge_irss_cachepath'); // Some other variables. $xsltParams = array(); $xsltParams['ssid'] = $ssid; $inlineRSSname = 'dge-ss-'.$ssid; $cachefile = ABSPATH . $cachepath . '/' . $cacheprefix . $inlineRSSname . '.html'; $stage1xsl = "dge-slideshow/rssfeed.xsl"; $stage2xsl = "dge-slideshow/dge-slideshow.xsl"; // First up must be a check for a preset so that other parameters // passed to this function can override the preset. if (array_key_exists('preset', $params)) { if (($presets = get_option('dge_ss_presets')) && ($preset = $presets[$params['preset']])) { $params = array_merge($preset, $params); } } if (array_key_exists('timeout', $params)) $timeout = intval($params['timeout']); else $timeout = get_option('dge_ss_def_timeout'); if (array_key_exists('reverse', $params)) $xsltParams['order'] = "descending"; if (array_key_exists('limit', $params)) $xsltParams['limit'] = $params['limit']; if (array_key_exists('delay', $params)) $xsltParams['delay'] = $params['delay']; if (array_key_exists('repeat', $params)) $xsltParams['repeat'] = '1'; if (array_key_exists('norepeat', $params)) $xsltParams['repeat'] = '0'; if (array_key_exists('play', $params)) $xsltParams['play'] = '1'; if (array_key_exists('pause', $params)) $xsltParams['play'] = '0'; // This must go last, to override any preset xsl files if (array_key_exists('xslt', $params)) $stage1xsl = $params['xslt']; // Look for an existing cache and find out how old it is if ( file_exists($cachefile)) { $age = time() - filectime($cachefile); $exists = TRUE; } else { $age = 0; $exists = FALSE; } // If there's no file, or the existing one's old, run through // inlineRSS and create a new cache file. if ( $exists == FALSE or $age > $timeout * 60 ) { $stage1xml = "\n"; $stage1xml .= DGE_InlineRSS($inlineRSSname, $url, array('timeout'=>0, 'xslt'=>$stage1xsl)); $stage2xml = DGE_InlineRSS($inlineRSSname, '', array('xml'=>$stage1xml, 'xslt'=>$stage2xsl), $xsltParams); if (empty($stage2xml)) { if ($exists == FALSE) { return "\n"; } $writefile = FALSE; } else { // This is a hack to replace the _m.jpg in the filenames // supplied in the feed with just .jpg. This is so that we // get a bigger, better quality image in the slideshow. // The _o.jpg filter cuts out loading of enormous original // photos from Flickr streams. if (get_option('dge_ss_mo_snip')) $output = preg_replace('/_[mo]\.jpg/', '.jpg', $stage2xml); else $output = $stage2xml; $writefile = TRUE; } if ($writefile) { if (!($handle = fopen($cachefile,'w'))) return "\n"; fwrite($handle,$output); fclose($handle); } } else { // We have a local copy, so fetch it. $output = file_get_contents($cachefile); } return "".$output; } // This is a Wordpress content filter that replaces occurrences of the // following format: // // !slideshow!![!