Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv26063/phpslash-ft/class
Modified Files:
functions.inc Block_render_rss.class
Log Message:
[ 528296 ] and [ 528290 ]
Index: functions.inc
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/functions.inc,v
retrieving revision 1.95
retrieving revision 1.96
diff -C2 -d -r1.95 -r1.96
*** functions.inc 8 Mar 2002 20:08:03 -0000 1.95
--- functions.inc 11 Mar 2002 04:20:18 -0000 1.96
***************
*** 166,170 ****
}
! function getFancyBox($width, $title, $contents, $link = "", $box_type="") {
global $_PSL;
--- 166,170 ----
}
! function getFancyBox($width, $title, $contents, $link = "", $box_type="", $var_ary="") {
global $_PSL;
***************
*** 208,215 ****
'WIDTH' => $width,
'ALIGN' => $align,
! 'TITLE' => pslgetText($title),
'CONTENTS' => $contents
));
$templ->parse('FANCYBOX', "fancybox" );
return $templ->get('FANCYBOX');
--- 208,219 ----
'WIDTH' => $width,
'ALIGN' => $align,
! 'TITLE' => pslgetText($title),
'CONTENTS' => $contents
));
+ if( is_array($var_ary)) {
+ $templ->set_var($var_ary);
+ }
+ // debug("templ_var", $templ->varvals);
$templ->parse('FANCYBOX', "fancybox" );
return $templ->get('FANCYBOX');
***************
*** 879,885 ****
--- 883,894 ----
$done = false;
while( ( $i < count($lang_ary)) AND ( !$done) ) {
+ $base_lang = split( "[_-]", trim($lang_ary[$i]));
if (file_exists( $_PSL['localedir'] . "/" . trim($lang_ary[$i]) . ".php3")) {
$lang = $_PSL['localedir'] . "/" . trim($lang_ary[$i]) . ".php3";
$done = true;
+ } elseif (file_exists( $_PSL['localedir'] . "/" . $base_lang[0]. ".php3")) {
+ // no dialect match - so try base language ( "en" for "en-US")
+ $lang = $_PSL['localedir'] . "/" . $base_lang[0] . ".php3";
+ $done = true;
}
$i++;
***************
*** 926,945 ****
while( ( $i < count($lang_ary)) AND ( !$done) ) {
if( strlen($lang_ary[$i]) > 0) {
if (@is_dir( $_PSL['templatedir'] . "/" . trim($lang_ary[$i]))) {
$templatedir = $_PSL['templatedir'] . "/" . trim($lang_ary[$i]);
$done = true;
! }
! }
! $i++;
! }
! // no exact match - so try base language ( "en" for "en-US")
! $i = 0;
! while( ( $i < count($lang_ary)) AND ( !$done) ) {
! $lang = split( "[_-]", $lang_ary[$i]);
! if( strlen($lang_ary[$i]) > 0) {
! if (@is_dir( $_PSL['templatedir'] . "/" . trim($lang[0]))) {
! $templatedir = $_PSL['templatedir'] . "/" . trim($lang[0]);
$done = true;
! }
}
$i++;
--- 935,946 ----
while( ( $i < count($lang_ary)) AND ( !$done) ) {
if( strlen($lang_ary[$i]) > 0) {
+ $base_lang = split( "[_-]", trim($lang_ary[$i]));
if (@is_dir( $_PSL['templatedir'] . "/" . trim($lang_ary[$i]))) {
$templatedir = $_PSL['templatedir'] . "/" . trim($lang_ary[$i]);
$done = true;
! } elseif (@is_dir( $_PSL['templatedir'] . "/" . $base_lang[0])) {
! $templatedir = $_PSL['templatedir'] . "/" . $base_lang[0];
$done = true;
! }
}
$i++;
Index: Block_render_rss.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Block_render_rss.class,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Block_render_rss.class 6 Feb 2002 18:47:43 -0000 1.5
--- Block_render_rss.class 11 Mar 2002 04:20:18 -0000 1.6
***************
*** 1,381 ****
! <?php
! /* Block_render_rss.class -> Methods for parsing RSS 0.91 data */
! /* CHANGES: 4Jan02 - RSS title stored */
! /* $Id$ */
! /*
! * VARAIBLES USED
! * target = [_blank],_self etc
! * max = 10
! * tpl = alternate template ( no .tpl extension) [rssblock.tpl]
! * title = none - dont display title or image, even if they are available
! * image - force display of image (if tag present - else show no title)
! * text - force display of title text (if tag present - else show no title)
! * both - display both image and text if available
! * best (default) - display image if tags present, else display title if possible
! *
! * NOTES
! * - image width and height are not used since most sites seem not to give this info anyway
! * - rdfparser ignores max_items - it pulls everything it can from the RDF file
! */
! class rdfparser {
!
! // Settings
! var $max_items;
! var $tags; // tags to process (all others are ignored)
!
! // Output information
! var $channel;
! var $image;
! var $items;
!
! var $error_str = ""; /* if you got an error reading a file this will store an error */
!
! // Private
! var $xml;
! var $node;
! var $current;
! var $count;
!
! /***************************************
! ** Constructor function. See parse_setup
! ***************************************/
! function rdfparser() {
! }
!
! /***************************************
! ** Start element function.
! ***************************************/
! function start_element($xml, $element, $attributes) {
!
! $this->current = $element;
!
! switch ($element) {
! case $this->tags["item"]:
! case $this->tags["image"]:
! case $this->tags["channel"]:
! $this->node = $element; // Should be a stack really, but nesting is only one deep
! // debug("rdf:start element+node","$element+".$this->node);
! break;
!
! default:
! }
!
! }
!
! /***************************************
! ** End element function.
! ***************************************/
! function end_element($xml, $element) {
! $this->current = "";
!
! switch ($element) {
! case $this->tags["item"]:
! $this->node = "";
! $this->count++;
! break;
! case $this->tags["channel"]:
! case $this->tags["image"]:
! $this->node = "";
! break;
! }
! }
!
! function character_data($xml, $data) {
!
! switch ($this->node) {
!
! case $this->tags["item"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->items[$this->count]["title"] .= $data;
! break;
! case $this->tags["link"]:
! $this->items[$this->count]["link"] .= $data;
! break;
! case $this->tags["description"]:
! $this->items[$this->count]["description"] .= $data;
! break;
! default:
! }
! break;
!
! case $this->tags["image"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->image["title"] .= $data;
! break;
! case $this->tags["link"]:
! $this->image["link"] .= $data;
! break;
! case $this->tags["url"]:
! $this->image["url"] .= $data;
! break;
! default:
! }
! break;
!
! case $this->tags["channel"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->channel["title"] .= $data;
! break;
! case $this->tags["link"]:
! $this->channel["link"] .= $data;
! break;
! case $this->tags["description"]:
! $this->channel["description"] .= $data;
! break;
! default:
! }
! break;
!
! default:
! }
! }
!
! function parse_setup($tags="",$max_items="") {
!
! if (is_array($tags)) {
! $this->tags = $tags;
! } else {
! // standard rdf setup - must be upper case (assuming case-folding is on which is PHP's default)
! $this->tags = array("channel" => "CHANNEL",
! "image" => "IMAGE",
! "item" => "ITEM",
! "title" => "TITLE",
! "link" => "LINK",
! "url" => "URL",
! "description" => "DESCRIPTION" );
! }
!
! // Internal initialisation
! $this->count = 0;
! $this->node = ""; // can be "" (ie channel), "item" or "image"
! $this->current = array(); // element stack
!
! $this->error_str = "";
!
! $this->channel = array("title"=>"", "link"=>"", "description" => "");
! $this->image = array("title"=>"", "link"=>"");
! $this->items = array();
!
! $this->xml = xml_parser_create();
! xml_set_object($this->xml, &$this);
! }
!
! function parse_file($url) {
! // debug("rdfparser::parse_file", "Now parsing $url");
!
! xml_parser_set_option($this->xml, XML_OPTION_CASE_FOLDING, true);
! xml_set_element_handler($this->xml, "start_element", "end_element");
! xml_set_character_data_handler($this->xml, "character_data");
!
! $fpread = @fopen($url, "r");
! if ( !($fpread) ) {
! // error in opening url
! $this->error_str = "rdfparser::parse_file could not open $url";
! // debug("rdfparser::parse_file", $this->error_str);
!
! // Where does $err* come from?
! // debug("rdfparser::parse_file", "$errstr $errno");
! } else {
! while (($this->error_str == "") && ($data = fread($fpread, 4096))) {
! if (!xml_parse($this->xml, $data, feof($fpread))) {
! // error
! $this->error_str = xml_error_string(xml_get_error_code($this->xml)) . " at line " . xml_get_current_line_number($this->xml);
! debug("rdfparser::parse_file", $this->error_str);
! }
! }
! fclose($fpread);
! if ($this->error_str == "") {
! // debug("rdfparser::parse_file", "Data parsed successfully!");
! }
! }
! }
! }
!
! class Block_render_rss {
! var $type;
! var $output;
! var $rdf;
!
! /* constructor */
! function Block_render_rss() {
! global $_PSL;
!
! $this->type = "rss"; /* set the 'type' */
! $this->output = ""; /* clear the output */
! $this->rdf = new rdfparser;
! $this->psl = $_PSL;
! }
!
! /* returns the TYPE of this class */
! function getType() {
! return $this->type;
! }
!
! function parse($block_info) {
! global $_PSL;
! // debug("Block_render_rss::parse", "Starting RDF Block parsing");
!
! $default_tpl = "rssblock.tpl";
!
!
! $titletype = "best";
! $target = "_self";
! $max_items = 10;
! $tpl = $default_tpl;
!
! if (is_array($block_info["block_options"])) {
! if (is_string($block_info["block_options"]["max_items"])) {
! $max_items = $block_info["block_options"]["max_items"];
! }
! if (is_string($block_info["block_options"]["target"])) {
! $target = $block_info["block_options"]["target"];
! }
! if (is_string($block_info["block_options"]["title"])) {
! $titletype = $block_info["block_options"]["title"];
! }
! if (is_string($block_info["block_options"]["tpl"])) {
! if (@file_exists($this->psl['templatedir'] . "/" . basename($block_info['block_options']['tpl']) . ".tpl") ) {
! // should be secure as path directives are discarded and extension added
! $tpl = basename($block_info["block_options"]["tpl"]) . ".tpl";
! }
! }
! }
!
! // debug("Block_render_rss::parse", "setting parser with $item_element, $title_element, $link_element");
! $this->rdf->parse_setup(); //$item_element, $title_element, $link_element);
! $this->rdf->parse_file($block_info['source_url']);
!
! if (empty($this->rdf->error_str)) {
! // debug("Block_render_rss::parse", "xml has no errors, making block");
! // debug("rss::parse::channel",$this->rdf->channel);
! // debug("rss::parse::image",$this->rdf->image);
! // debug("rss::parse::items", $this->rdf->items);
!
! $template = new Template($this->psl["templatedir"]);
! $template->set_file ("block", $tpl);
!
! $template->set_block ("block", "channel_title","title_block");
! $template->set_block ("block", "channel_image","image_block");
! $template->set_block ("block", "channel_description","channeldescription_block");
! $template->set_block ("block", "each_query", "query_block");
! $template->set_block ("block", "each_description", "description_block");
!
! switch ($titletype) {
! case "none":
! break;
!
! case "text":
! if ( !empty( $this->rdf->channel["title"]) ) {
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! break;
!
! case "image":
! if ( !empty( $this->rdf->channel["image"]) ) {
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! break;
!
! case "both":
! if ( !empty( $this->rdf->channel["title"]) ) {
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! if ( !empty( $this->rdf->channel["image"]) ) {
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! break;
!
! case "best":
! default:
! // <title> and <image> tags seem to hold identical description and link info in most sites
! // ... so use an image if possible, else show title
! if (empty($this->rdf->image["url"])) {
! if ( !empty( $this->rdf->channel["title"]) ) { // No image, but there is a title
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! } else { // ...we can show the image
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! }
!
! if ( !empty( $this->rdf->channel["description"]) ) {
! $template->set_var("CHANNEL_DESCRIPTION", $this->rdf->channel["description"]);
! $template->parse("channeldescription_block","channel_description",true);
! }
!
! $numitems = min($max_items, $this->rdf->count);
! // debug("rss::numitems",$numitems);
! for ($items = 0; $items < $numitems; $items++ ) {
! $template->set_var(array(
! "TITLE" => $this->rdf->items[$items]["title"],
! "LINK" => $this->rdf->items[$items]["link"]
! ));
! $template->parse ("query_block", "each_query", true);
!
! if (!empty($this->rdf->items[$items]["description"] )) {
! $template->set_var("DESCRIPTION",$this->rdf->items[$items]["description"] );
! $template->parse ("query_block", "each_description", true);
! }
! }
!
! $template->set_var(array(
! "TARGET" => $target,
! "ROOTDIR" => $this->psl["rooturl"],
! "IMAGEDIR" => $this->psl["imageurl"]
! ));
! $this->output = $template->parse(OUT,"block");
! $this->title = $this->rdf->channel["title"];
!
! return true;
!
! } else {
!
! debug("Block_render_rss::parse error", $this->rdf->error_str);
! $this->output = error("Error in source file:".$this->rdf->error_str);
!
! return false;
! }
!
! }
!
! function getFinal() {
! return $this->output;
! }
!
! function getTitle() {
! // Note: This wont work until object values are saved between the two stages of rendering a block
! // debug("rss::parse::getTitle", $this->title);
! return $this->title;
! }
! }
! ?>
--- 1,512 ----
! <?php
! /* Block_render_rss.class -> Methods for parsing RSS 0.91 data */
! /* $Id$ */
!
! /*
! * BLOCK OPTIONS USED
! * target = [_blank],_self etc
! * max_items = 10
! * tpl = alternate template ( no .tpl extension) [rssblock]
! * title = none - dont display title or image, even if they are available
! * image - force display of image (if tag present - else show no title)
! * text - force display of title text (if tag present - else show no title)
! * both - display both image and text if available
! * best (default) - display image if tags present, else display title if possible
! */
!
! /**
! * Class to interpret and render a newsfeed (eg RSS 0.91).
! *
! * Works with RSS 0.91 to 1.0. Extendable to be able to interpret similar files
! * - eg as used by moreover.com
! * NB Ignores max_items - it pulls everything it can from the RDF file
! *
! * @access private
! * @author ??. Code amended by Peter Cruickshank, Feb 2002
! * @version 0.65
! * @since version 0.65
! * @package phpslash
! */
! class rdfparser {
!
! // Settings
!
! /**
! * Maximum number of items to read in from source (not used)
! * @access public
! */
! var $max_items;
! /**
! * Array listing tags to process (channel, image, item). All others are ignored
! * @access public
! */
! var $tags;
!
! // Output information
!
! /**
! * Output array of channel information (title, link, description)
! * @access public
! */
! var $channel;
! /**
! * Output array of information on image (title, link, url)
! * Image width and height are not used since most sites seem not to give this info anyway
! * @access public
! */
! var $image;
! /**
! * Output array of items (title, link, description)
! * @access public
! */
! var $items;
!
! /**
! * Output errir message - if you got an error reading a file this will store an error
! * @access public
! */
! var $error_str = "";
!
! // Private
!
! /**
! * XML processor object
! * @access private
! */
! var $xml;
! /**
! * Current container-element can be "" (ie channel), "item" or "image" (Should be a stack really, but nesting is only one deep)
! * @access private
! */
! var $node;
! /**
! * Element stack(array)
! * @access private
! */
! var $current;
! /**
! * Number of items
! * @access private
! */
! var $count;
!
! /**
! * Empty constructor function.
! * @See parse_setup()
! */
! function rdfparser() {
! }
!
! /**
! * Notes start of container-element
! *
! * @param xml_parser $xml xml object (not used)
! * @param string $element element encountered by the xml parser
! * @param string $attributes (not used)
! * @access private
! */
! function start_element($xml, $element, $attributes) {
!
! $this->current = $element;
!
! switch ($element) {
! case $this->tags["item"]:
! case $this->tags["image"]:
! case $this->tags["channel"]:
! $this->node = $element;
! // debug("rdf:start element+node","$element+".$this->node);
! break;
!
! default:
! }
!
! }
!
! /**
! * End element function - clear node if necessary
! *
! * @param xml_parser $xml xml object (not used)
! * @param string $element element encountered by the xml parser
! * @access private
! */
! function end_element($xml, $element) {
! $this->current = "";
!
! switch ($element) {
! case $this->tags["item"]:
! $this->node = "";
! $this->count++;
! break;
! case $this->tags["channel"]:
! case $this->tags["image"]:
! $this->node = "";
! break;
! }
! }
!
! /**
! * Store xml character data in appropriate place (items, image, channel)
! *
! * @param xml_parser $xml xml object (not used)
! * @param string $data xml content
! * @access private
! */
! function character_data($xml, $data) {
!
! switch ($this->node) {
!
! case $this->tags["item"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->items[$this->count]["title"] .= $data;
! break;
! case $this->tags["link"]:
! $this->items[$this->count]["link"] .= $data;
! break;
! case $this->tags["description"]:
! $this->items[$this->count]["description"] .= $data;
! break;
! default:
! }
! break;
!
! case $this->tags["image"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->image["title"] .= $data;
! if (empty($this->channel["title"])) {
! $this->channel["title"] .= $data;
! }
! break;
! case $this->tags["link"]:
! $this->image["link"] .= $data;
! break;
! case $this->tags["url"]:
! $this->image["url"] .= $data;
! break;
! default:
! }
! break;
!
! case $this->tags["channel"]:
! switch ($this->current) {
! case $this->tags["title"]:
! $this->channel["title"] .= $data;
! break;
! case $this->tags["link"]:
! $this->channel["link"] .= $data;
! break;
! case $this->tags["description"]:
! $this->channel["description"] .= $data;
! break;
! default:
! }
! break;
!
! default:
! }
! }
!
! /**
! * Initialise class before it is called (allows for reuse of class if necessary)
! *
! * @param array $tags values of tags to parse. Default: CHANNEL,IMAGE, ITEM,TITLE, LINK,URL,DESCRIPTION
! * @param string $max_items (not used)
! * @access public
! */
! function parse_setup($tags="",$max_items="") {
!
! if (is_array($tags)) {
! $this->tags = $tags;
! } else {
! // standard rdf setup - must be upper case (assuming case-folding is on which is PHP's default)
! $this->tags = array("channel" => "CHANNEL",
! "image" => "IMAGE",
! "item" => "ITEM",
! "title" => "TITLE",
! "link" => "LINK",
! "url" => "URL",
! "description" => "DESCRIPTION" );
! }
!
! // Internal initialisation
! $this->count = 0;
! $this->node = ""; // can be "" (ie channel), "item" or "image"
! $this->current = array(); // element stack
!
! $this->error_str = "";
!
! $this->channel = array("title"=>"", "link"=>"", "description" => "");
! $this->image = array("title"=>"", "link"=>"");
! $this->items = array();
!
! $this->xml = xml_parser_create();
! xml_set_object($this->xml, &$this);
! }
!
! /**
! * Carry out parse of rss source defined by parse_setup()
! *
! * @param array $tags values of tags to parse. Default: CHANNEL,IMAGE, ITEM,TITLE, LINK,URL,DESCRIPTION
! * @param string $max_items (not used)
! * @access public
! */
! function parse_file($url) {
! // debug("rdfparser::parse_file", "Now parsing $url");
!
! xml_parser_set_option($this->xml, XML_OPTION_CASE_FOLDING, true);
! xml_set_element_handler($this->xml, "start_element", "end_element");
! xml_set_character_data_handler($this->xml, "character_data");
!
! $fpread = @fopen($url, "r");
! if ( !($fpread) ) {
! // error in opening url
! $this->error_str = "rdfparser::parse_file could not open $url";
! // debug("rdfparser::parse_file", $this->error_str);
!
! // Where does $err* come from?
! // debug("rdfparser::parse_file", "$errstr $errno");
! } else {
! while (($this->error_str == "") && ($data = fread($fpread, 4096))) {
! if (!xml_parse($this->xml, $data, feof($fpread))) {
! // error
! $this->error_str = xml_error_string(xml_get_error_code($this->xml)) . " at line " . xml_get_current_line_number($this->xml);
! debug("rdfparser::parse_file", $this->error_str);
! }
! }
! fclose($fpread);
! if ($this->error_str == "") {
! // debug("rdfparser::parse_file", "Data parsed successfully!");
! }
! }
! }
! }
!
! /**
! * Class to display a newsfeed
! *
! * @access public
! * @author ?? - code amended by Peter Cruickshank, Feb 2002
! * @version 0.65
! * @since version 0.65
! * @package phpslash
! */
!
! class Block_render_rss {
! /**
! * Blcok type = "rss"
! * @access public
! */
! var $type;
! /**
! * Output
! * @access public
! */
! var $output;
! /**
! * rdfparser object
! * @access private
! */
! var $rdf;
!
! /**
! * constructor
! */
! function Block_render_rss() {
! global $_PSL;
!
! $this->type = "rss"; /* set the 'type' */
! $this->output = ""; /* clear the output */
! $this->rdf = new rdfparser;
! $this->psl = $_PSL;
! }
!
! /**
! * returns the TYPE of this class
! * @return string
! */
! function getType() {
! return $this->type;
! }
!
!
! /**
! * Generates and stores html code
! * @param array $block_info block options and other info supplied by caller
! */
! function parse($block_info) {
! global $_PSL;
! // debug("Block_render_rss::parse", "Starting RDF Block parsing");
!
! $default_tpl = "rssblock.tpl";
!
!
! $titletype = "best";
! $target = "_self";
! $max_items = 10;
! $tpl = $default_tpl;
!
! if (is_array($block_info["block_options"])) {
! if (is_string($block_info["block_options"]["max_items"])) {
! $max_items = $block_info["block_options"]["max_items"];
! }
! if (is_string($block_info["block_options"]["target"])) {
! $target = $block_info["block_options"]["target"];
! }
! if (is_string($block_info["block_options"]["title"])) {
! $titletype = $block_info["block_options"]["title"];
! }
! if (is_string($block_info["block_options"]["tpl"])) {
! if (@file_exists($this->psl['templatedir'] . "/" . basename($block_info['block_options']['tpl']) . ".tpl") ) {
! // should be secure as path directives are discarded and extension added
! $tpl = basename($block_info["block_options"]["tpl"]) . ".tpl";
! }
! }
! }
!
! // debug("Block_render_rss::parse", "setting parser with $item_element, $title_element, $link_element");
! $this->rdf->parse_setup(); //$item_element, $title_element, $link_element);
! $this->rdf->parse_file($block_info['source_url']);
!
! if (empty($this->rdf->error_str)) {
! // debug("Block_render_rss::parse", "xml has no errors, making block");
! // debug("rss::parse::channel",$this->rdf->channel);
! // debug("rss::parse::image",$this->rdf->image);
! // debug("rss::parse::items", $this->rdf->items);
!
! $template = new Template($this->psl["templatedir"]);
! $template->set_file ("block", $tpl);
!
! $template->set_block ("block", "channel_title","title_block");
! $template->set_block ("block", "channel_image","image_block");
! $template->set_block ("block", "channel_description","channeldescription_block");
! $template->set_block ("block", "each_query", "query_block");
! $template->set_block ("block", "each_description", "description_block");
!
! switch ($titletype) {
! case "none":
! break;
!
! case "text":
! if ( !empty( $this->rdf->channel["title"]) ) {
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! break;
!
! case "image":
! if ( !empty( $this->rdf->channel["image"]) ) {
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! break;
!
! case "both":
! if ( !empty( $this->rdf->channel["title"]) ) {
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! if ( !empty( $this->rdf->channel["image"]) ) {
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! break;
!
! case "best":
! default:
! // <title> and <image> tags seem to hold identical description and link info in most sites
! // ... so use an image if possible, else show title
! if (empty($this->rdf->image["url"])) {
! if ( !empty( $this->rdf->channel["title"]) ) { // No image, but there is a title
! $template->set_var(array(
! "CHANNEL_TITLE" => $this->rdf->channel["title"],
! "CHANNEL_LINK" => empty($this->rdf->channel["link"])?"#":$this->rdf->channel["link"]
! ));
! $template->parse("title_block","channel_title");
! }
! } else { // ...we can show the image
! $template->set_var(array(
! "IMAGE_URL" => $this->rdf->image["url"],
! "IMAGE_TITLE" => $this->rdf->image["title"],
! "IMAGE_LINK" => $this->rdf->image["link"],
! ));
! $template->parse("image_block","channel_image");
! }
! }
!
! if ( !empty( $this->rdf->channel["description"]) ) {
! $template->set_var("CHANNEL_DESCRIPTION", $this->rdf->channel["description"]);
! $template->parse("channeldescription_block","channel_description",true);
! }
!
! $numitems = min($max_items, $this->rdf->count);
! // debug("rss::numitems",$numitems);
! for ($items = 0; $items < $numitems; $items++ ) {
! $template->set_var(array(
! "TITLE" => $this->rdf->items[$items]["title"],
! "LINK" => $this->rdf->items[$items]["link"]
! ));
! $template->parse ("query_block", "each_query", true);
!
! if (!empty($this->rdf->items[$items]["description"] )) {
! $template->set_var("DESCRIPTION",$this->rdf->items[$items]["description"] );
! $template->parse ("query_block", "each_description", true);
! }
! }
!
! $template->set_var(array(
! "TARGET" => $target,
! "ROOTDIR" => $this->psl["rooturl"],
! "IMAGEDIR" => $this->psl["imageurl"]
! ));
! $this->output = $template->parse(OUT,"block");
! $this->title = $this->rdf->channel["title"];
!
! return true;
!
! } else {
!
! debug("Block_render_rss::parse error", $this->rdf->error_str);
! $this->output = error("Error in source file:".$this->rdf->error_str);
!
! return false;
! }
!
! }
!
! /**
! * Returns output
! * @return htmlstring
! */
! function getFinal() {
! return $this->output;
! }
!
! /**
! * Returns block title (for use with dynamic blcok titles)
! *
! * This wont work until object values are saved between the two stages of rendering a block.
! * - it currently returns an empty string
! *
! * @return htmlstring
! */
! function getTitle() {
! // debug("rss::parse::getTitle", $this->title);
! return $this->title;
! }
! }
! ?>
|