File : test2237b.php
... seguecodice:<? class xItem { var $xTitle; var $xLink; var $xDescription; } // class xItem //------------- Parametri del feed class RssParameters { //-------------- Default values var $uFont = "Verdana, Arial, Helvetica, sans-serif"; var $uFontColor = "black"; // a color name or number var $uFontSize = '8'; // a value in points var $bDesc = true; var $rssSize = 200; // in pixels var $rssHeight = 100; // in pixels var $rssBgColor = "white"; // a color name or number var $rssSpeed = 2; // the higher the faster var $rssNewsStyle = ""; // class per le news var $rssLinkStyle = ""; // class per i links var $rssRSSStyle = ""; // class per il feed //-------------- Taglia function setSize($size) { $this->rssSize = $size; } // function setSize($size) //-------------- Altezza function setHeight($height) { $this->rssHeight = $height; } // function setHeight($height) //-------------- Velocità function setSpeed($speed) { $this->rssSpeed = $speed; } // function setHeight($height) //-------------- Sfondo function setBackgroundColor($color) { $this->rssBgColor = $color; } // function setBackgroundColor($color) //-------------- Fonts function setFonts($fontList) { $this->uFont = $fontList; } // function setFonts($fontList) //-------------- Font color function setFontColor($color) { $this->uFontColor = $color; } // function setFontColor($color) //-------------- Font Size function setFontSize($size) { $this->uFontSize = $size; } // function setFontSize($size) //-------------- News style function setNewsClass($class) { $this->rssNewsStyle = $class; } // function setNewsClass($class) //-------------- Links style function setLinksClass($class) { $this->rssLinkStyle = $class; } // function setLinksClass($class) //-------------- RSS style function setRSSClass($class) { $this->rssRSSStyle = $class; } // function setRSSClass($class) } // class RssParameters class RssObjects { //-------------- Array delle RSS var $rss = array(); //-------------- Array del codice JS var $rssJS = array(); //-------------- Array del codice HTML var $rssHTML = array(); //-------------- Array del codice JS populate var $rssPop = array(); //-------------- Array degli id degli elementi var $place = array(); //-------------- Array degli items var $arItems = array(); //-------------- Array dei parametri var $arParams = array(); //-------------- Codice HTML var $htmlCodeToProcess; //-------------- Presenza dello stilo .news var $isNewsStylePresent = true; //-------------- Constructor function RssObjects($htmlCodeToProcess) { $this->htmlCodeToProcess = $htmlCodeToProcess; } // function RssObjects($htmlCodeToProcess) //-------------- Aggiunta delle RSS da trattare function addRSS($rssName,$rssXMLURLFileName,$placeToSeeRSS) { $this->rss[$rssName] = $rssXMLURLFileName; $this->place[$rssName] = $placeToSeeRSS; $this->arParams[$rssName] = new RssParameters; return $this->getRSSByName($rssName); } // function addRSS($rssName,$rssXMLURLFileName) function getRSSByName($rssName) { return $this->arParams[$rssName]; } // function getRSSByName($rssName) //-------------- Parse all files function parseXMLFiles() { foreach($this->rss as $key => $value) { $this->parseXMLFile($value); $this->rssHTML[$key] = $this->createSingleHTML($key); $this->rssJS[$key] = $this->createSingleJS($key); $this->rssPop[$key] = $this->createSinglePopulate($key); } // foreach($this->rss as $key => $value) } // function parseXMLFiles() //-------------- Parse a single files function parseXMLFile($rssXMLURLFileName) { global $keyProcessed, $itemCount; $keyProcessed = 0; $itemCount = 0; $this->arItems = array(); $this->xml_parser = xml_parser_create(); xml_set_object($this->xml_parser,$this); xml_set_element_handler($this->xml_parser,"startElement","endElement"); xml_set_character_data_handler($this->xml_parser,"characterData"); if (!($fp = fopen($rssXMLURLFileName,"r"))) { die ("could not open RSS $rssXMLURLFileName for input"); } // if (!($fp = fopen($rssXMLURLFileName,"r"))) while ($data = fread($fp, 4096)) { if (!xml_parse($this->xml_parser, $data, feof($fp))) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->xml_parser)),xml_get_current_line_number($this->xml_parser))); } // if (!xml_parse($xml_parser, $data, feof($fp))) } // while ($data = fread($fp, 4096)) xml_parser_free($this->xml_parser); } // function parseXMLFile($rssXMLURLFileName) //-------------- Codice HTML da stampare function htmlResult() { $jsCode = ''; $popCode = ''; foreach($this->rss as $key => $value) { //------------- Concatenazione del codice JS $jsCode .= $this->rssJS[$key]."\n"; $popCode .= $this->rssPop[$key]; //------------- Agganciamento del codice HTML generato al body $this->htmlCodeToProcess = preg_replace("|(<body[^>]*>)|s","\\1\n".$this->rssHTML[$key],$this->htmlCodeToProcess); } // foreach($this->rss as $key => $value) //------------- Agganciamento del codice JS generato al head $this->htmlCodeToProcess = preg_replace("|(<head[^>]*>)|s","\\1\n$jsCode",$this->htmlCodeToProcess); //------------- Agganciamento del codice JS generato per l'esecuzione prima del /body $this->htmlCodeToProcess = preg_replace("|(<[/]body[^>]*>)|s","\n$popCode\n\\1",$this->htmlCodeToProcess); return $this->htmlCodeToProcess; } // function htmlResult() //-------------- Crea il codice HTML per un RSS function createSingleHTML($rssName) { ob_start(); //------------ Stilo del RSS $rssStyle = ""; if ($this->arParams[$rssName]->rssRSSStyle != "") { $rssStyle = "class=\"".$this->arParams[$rssName]->rssRSSStyle."\""; } else { $rssStyle = "width=\"".$this->arParams[$rssName]->rssSize."\" "; $rssStyle .= "bgcolor=\"".$this->arParams[$rssName]->rssBgColor."\" "; $rssStyle .= "style=\"color:".$this->arParams[$rssName]->uFontColor."\" "; } // if ($this->arParams[$rssName]->rssRSSStyle != "") ?> <textarea id="txta<? print $rssName ?>" style="position:absolute;top:-1000;left:-1000"> <table border="0" cellspacing="0" cellpadding="0" <? print $rssStyle ?>><?php foreach($this->arItems as $key => $txItem ) { //------------ Stilo del testo $tdStyle = ""; if ($this->arParams[$rssName]->rssNewsStyle == "") { $tdStyle = "font-family:".$this->arParams[$rssName]->uFont.";font-size:".$this->arParams[$rssName]->uFontSize."pt"; $tdStyle = "style=\"$tdStyle\""; } else { $tdStyle = "class=\"".$this->arParams[$rssName]->rssNewsStyle."\""; } // iif ($this->arParams[$rssName]->rssNewsStyle == "") //------------ Stilo del link $aStyle = ""; if ($this->arParams[$rssName]->rssLinkStyle != "") { $aStyle = "class=\"".$this->arParams[$rssName]->rssLinkStyle."\"";; } // if ($this->arParams[$rssName]->rssLinkStyle != "") ?> <tr> <td <? print $tdStyle ?>> <? if (! empty($txItem->xLink)){ ?> <a <? print $aStyle ?> href = "<?php echo($txItem->xLink); ?>" target="_blank"><?php echo($txItem->xTitle); ?> </a> <?php } // if (! empty($txItem->xLink)){ if ($this->arParams[$rssName]->bDesc and !empty($txItem->xDescription)) { echo ($txItem->xDescription." "); } // if ($this->arParams[$rssName]->bDesc and !empty($txItem->xDescription)) ?> </td> </tr><?php } // for ($i=0;$i<count($this->arItems);$i++) ?> </table> </textarea><?php $code = ob_get_contents(); ob_end_clean(); return $code; } // function createSingleHTML($rssName) //-------------- Crea il codice HTML per un RSS function createSingleJS($rssName) { ob_start()?> <script language="JavaScript" type="text/javascript"> <!-- //Specify the marquee's width (in pixels) var marqueewidth<? print $rssName ?>="<? print $this->arParams[$rssName]->rssSize ?>px"; //Specify the marquee's height var marqueeheight<? print $rssName ?>="<? print $this->arParams[$rssName]->rssHeight ?>px"; //Specify the marquee's marquee speed (larger is faster 1-10) var marqueespeed<? print $rssName ?>=<? print $this->arParams[$rssName]->rssSpeed ?>; //Pause marquee onMousever (0=no. 1=yes)? var pauseit<? print $rssName ?> =1; //slow speed down by 1 for NS marqueespeed<? print $rssName ?> = (document.all)? marqueespeed<? print $rssName ?> : Math.max(1, marqueespeed<? print $rssName ?>-1); var copyspeed<? print $rssName ?> = marqueespeed<? print $rssName ?>; var pausespeed<? print $rssName ?> = (pauseit<? print $rssName ?>==0)? copyspeed<? print $rssName ?>: 0; var actualheight<? print $rssName ?> = ''; var iedom=document.all||document.getElementById; var cross_marquee<? print $rssName ?>, ns_marquee<? print $rssName ?>; function populate<? print $rssName ?>(rssLocation){ //--------------- Creo qui il codice HTML e non più sotto rssHTML = ''; if (iedom||document.layers){ if (iedom){ rssHTML += '<div style=" position:relative;width:'+marqueewidth<? print $rssName ?>+';height:'+marqueeheight<? print $rssName ?>+';overflow:hidden" onMouseover="copyspeed<? print $rssName ?>=pausespeed<? print $rssName ?>" onMouseout="copyspeed<? print $rssName ?>=marqueespeed<? print $rssName ?>">'; rssHTML += '<div id="iemarquee<? print $rssName ?>" style=" position:absolute;left:0px;top:0px;width:100%;">'; rssHTML += '</div></div>'; } else { if (document.layers){ rssHTML += '<ilayer width='+marqueewidth<? print $rssName ?>+' height='+marqueeheight<? print $rssName ?>+' name="ns_marquee<? print $rssName ?>">'; rssHTML += '<layer name="ns_marquee2<? print $rssName ?>" width='+marqueewidth<? print $rssName ?>+' height='+marqueeheight<? print $rssName ?>+' left=0 top=0 onMouseover="copyspeed<? print $rssName ?>=pausespeed<? print $rssName ?>" onMouseout="copyspeed<? print $rssName ?>=marqueespeed<? print $rssName ?>"></layer>'; rssHTML += '</ilayer>'; } // if (document.layers) } // if (iedom) } // if (iedom||document.layers) //------------ Assegnazione del codice HTML alla location rssLocation.innerHTML = rssHTML; if (iedom){ cross_marquee<? print $rssName ?> = document.getElementById? document.getElementById("iemarquee<? print $rssName ?>") : document.all.iemarquee<? print $rssName ?>; cross_marquee<? print $rssName ?>.style.top = parseInt(marqueeheight<? print $rssName ?>)+8+"px"; cross_marquee<? print $rssName ?>.innerHTML = marqueecontent<? print $rssName ?>; actualheight<? print $rssName ?> = cross_marquee<? print $rssName ?>.offsetHeight; } else if (document.layers){ ns_marquee<? print $rssName ?> = document.ns_marquee<? print $rssName ?>.document.ns_marquee2<? print $rssName ?>; ns_marquee<? print $rssName ?>.top = parseInt(marqueeheight<? print $rssName ?>)+8; ns_marquee<? print $rssName ?>.document.write(marqueecontent<? print $rssName ?>); ns_marquee<? print $rssName ?>.document.close(); actualheigh<? print $rssName ?> = ns_marquee<? print $rssName ?>.document.height; } // if (iedom) lefttime=setInterval("scrollmarquee<? print $rssName ?>()",20); } // function populate<? print $rssName ?>(rssLocation) function scrollmarquee<? print $rssName ?>(){ if (iedom){ if (parseInt(cross_marquee<? print $rssName ?>.style.top)>(actualheight<? print $rssName ?>*(-1)+8)) cross_marquee<? print $rssName ?>.style.top=parseInt(cross_marquee<? print $rssName ?>.style.top)-copyspeed<? print $rssName ?>+"px"; else cross_marquee<? print $rssName ?>.style.top=parseInt(marqueeheight<? print $rssName ?>)+8+"px"; } else if (document.layers){ if (ns_marquee<? print $rssName ?>.top>(actualheight<? print $rssName ?>*(-1)+8)) ns_marquee<? print $rssName ?>.top-=copyspeed<? print $rssName ?>; else ns_marquee<? print $rssName ?>.top=parseInt(marqueeheight<? print $rssName ?>)+8; } // if (iedom) } // ffunction scrollmarquee<? print $rssName ?>() //--> </script><? $jsCode = ob_get_contents(); ob_end_clean(); return $jsCode; } // function createJSCode()


Rispondi quotando