Changeset 6
- Timestamp:
- 10/22/04 11:25:23
- Files:
-
- trunk/include/patXMLRenderer.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/include/patXMLRenderer.php
r2 r6 221 221 222 222 /** 223 * stores which tags are cacheable 224 * @var array 225 */ 226 var $cacheAble = array(); 227 228 /** 223 229 * set the urls that should not be logged in the referer log 224 230 * … … 625 631 function autoAddExtension( $ns ) 626 632 { 627 $ns = strtoupper( $ns ); 628 629 if( $this->extensions[$ns] ) 633 $ns = strtoupper( $ns ); 634 if( isset( $this->extensions[$ns] ) ) { 630 635 return true; 631 632 $filename = $this->getExtensionDir() ? $this->getExtensionDir()."/".$this->knownExtensions[$ns]["phpfile"] : $this->knownExtensions[$ns]["phpfile"]; 633 634 if( !class_exists( $this->knownExtensions[$ns]["extension"] ) && file_exists( $filename ) ) 636 } 637 638 $filename = $this->getExtensionDir() ? $this->getExtensionDir()."/".$this->knownExtensions[$ns]["phpfile"] : $this->knownExtensions[$ns]["phpfile"]; 639 640 if( !class_exists( $this->knownExtensions[$ns]["extension"] ) && file_exists( $filename ) ) { 635 641 include_once( $filename ); 636 637 if( class_exists( $this->knownExtensions[$ns]["extension"] ) )638 {639 $tmp = new$this->knownExtensions[$ns]["extension"];642 } 643 644 if( class_exists( $this->knownExtensions[$ns]["extension"] ) ) { 645 $tmp = new $this->knownExtensions[$ns]["extension"]; 640 646 $this->addExtension( $ns, $tmp ); 641 647 } … … 694 700 else 695 701 { 702 $lastUpdated = 'Unknown'; 703 696 704 if( !$this->xmlFile ) 697 705 $this->setXMLFile( $this->defaultFile ); … … 702 710 if( !file_exists( $file ) ) 703 711 { 704 $this->requestedFile =$this->xmlFile;712 $this->requestedFile = $this->xmlFile; 705 713 $this->setXMLFile( $this->errorFile ); 706 $file =( $this->xmlDir!="" ) ? $this->xmlDir."/".$this->xmlFile : $this->xmlFile;714 $file = ( $this->xmlDir!="" ) ? $this->xmlDir."/".$this->xmlFile : $this->xmlFile; 707 715 708 716 if( $this->getOption( "log" ) == "on" ) 709 717 $this->logger->writeErrorLog( $this->requestedFile ); 710 718 } 719 else 720 { 721 $lastUpdated = date( "Y-m-d H:i:s", filemtime( $file ) ); 722 } 711 723 712 724 // add global variables 713 $this->tmpl->addGlobalVar( "XMLS RING", "" );725 $this->tmpl->addGlobalVar( "XMLSTRING", "" ); 714 726 $this->tmpl->addGlobalVar( "XMLFILE", $this->xmlFile ); 715 727 $this->tmpl->addGlobalVar( "XMLSOURCE", $file ); 716 $this->tmpl->addGlobalVar( "PAGE_LAST_UPDATED", date( "Y-m-d H:i:s", filemtime( $file ) ) ); 717 718 $this->xmlSource = $file; 728 $this->tmpl->addGlobalVar( "PAGE_LAST_UPDATED", $lastUpdated ); 729 730 731 $this->xmlSource = $file; 719 732 } 720 733 … … 825 838 else 826 839 $data = $this->parseString( $this->xmlString ); 827 840 828 841 return str_replace( "[RANDY_SELF]", $randyUrl, $data ); 829 842 } … … 884 897 { 885 898 // auto-add extensions activated and namespace is known? 886 if( $this->getOption( "autoadd" ) == "on" && isset( $this->knownExtensions[$ns] ) ) 899 if( $this->getOption( "autoadd" ) == "on" && isset( $this->knownExtensions[$ns] ) ) { 887 900 $this->autoAddExtension( $ns ); 901 } 888 902 } 889 903 … … 1012 1026 function characterData( $parser, $data ) 1013 1027 { 1014 $tagDepth = count( $this->tagStack[$this->parsers] ) - 1; 1015 $ns = $this->nsStack[$this->parsers][$tagDepth]; 1016 1017 if( $this->getOption( "replaceentities" ) == "on" ) 1018 $data = htmlspecialchars( $data ); 1019 1020 $this->data[$this->parsers][$tagDepth] .= $data; 1028 $tagDepth = count( $this->tagStack[$this->parsers] ) - 1; 1029 1030 if( $this->getOption( "replaceentities" ) == "on" ) { 1031 $data = htmlspecialchars( $data ); 1032 } 1033 1034 if( !isset( $this->data[$this->parsers][$tagDepth] ) ) { 1035 $this->data[$this->parsers][$tagDepth] = ''; 1036 } 1037 1038 $this->data[$this->parsers][$tagDepth] .= $data; 1021 1039 } 1022 1040 … … 1028 1046 function getData( $parser = false ) 1029 1047 { 1030 if( $parser === false ) 1031 $parser = $this->parsers; 1048 if( $parser === false ) { 1049 $parser = $this->parsers; 1050 } 1032 1051 1033 $tagDepth = count( $this->tagStack[$this->parsers] ) - 1; 1052 $tagDepth = count( $this->tagStack[$this->parsers] ) - 1; 1053 1054 if( !isset( $this->data[$parser][$tagDepth] ) ) { 1055 return ''; 1056 } 1057 1034 1058 return trim( $this->data[$parser][$tagDepth] ); 1035 1059 } … … 1102 1126 $parser = $this->createParser(); 1103 1127 1104 if( !( $fp = fopen( $file, "r" ) ) )1105 die( "patXMLRenderer could not open XML file :".$file);1128 if( !( @$fp = fopen( $file, "r" ) ) ) 1129 die( 'patXMLRenderer could not open the XML file "'.$file.'"' ); 1106 1130 1107 1131 flock( $fp, LOCK_SH ); … … 1121 1145 flock( $fp, LOCK_UN ); 1122 1146 1123 if( $this->cacheAble[$this->parsers] || $this->getOption( "cache" ) == "force" )1147 if( isset( $this->cacheAble[$this->parsers] ) || $this->getOption( "cache" ) == "force" ) { 1124 1148 $this->writeCache( $file, $data ); 1125 else1149 } else { 1126 1150 $this->deleteCache( $file ); 1151 } 1127 1152 1128 1153 $this->parsers--; … … 1374 1399 function getSelfUrl() 1375 1400 { 1376 $self = $ GLOBALS["PHP_SELF"]."?";1401 $self = $_SERVER["PHP_SELF"]."?"; 1377 1402 for( $i=0; $i<count( $this->keepVars ); $i++ ) 1378 1403 if( $GLOBALS[$this->keepVars[$i]] )
