Changeset 4495 for trunk/wp-includes/rss.php
- Timestamp:
- 11/19/2006 07:56:05 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/rss.php (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/rss.php
r4399 r4495 12 12 define('MAGPIE_USER_AGENT', 'WordPress/' . $wp_version); 13 13 14 class MagpieRSS { 14 class MagpieRSS { 15 15 var $parser; 16 16 var $current_item = array(); // item currently being parsed … … 26 26 var $inchannel = false; 27 27 var $initem = false; 28 var $incontent = false; // if in Atom <content mode="xml"> field 28 var $incontent = false; // if in Atom <content mode="xml"> field 29 29 var $intextinput = false; 30 30 var $inimage = false; … … 55 55 # 56 56 xml_set_object( $this->parser, $this ); 57 xml_set_element_handler($this->parser, 57 xml_set_element_handler($this->parser, 58 58 'feed_start_element', 'feed_end_element' ); 59 59 60 xml_set_character_data_handler( $this->parser, 'feed_cdata' ); 60 xml_set_character_data_handler( $this->parser, 'feed_cdata' ); 61 61 62 62 $status = xml_parse( $this->parser, $source ); … … 86 86 $ns = false; 87 87 if ( strpos( $element, ':' ) ) { 88 list($ns, $el) = split( ':', $element, 2); 88 list($ns, $el) = split( ':', $element, 2); 89 89 } 90 90 if ( $ns and $ns != 'rdf' ) { … … 112 112 } 113 113 114 if ( $el == 'channel' ) 114 if ( $el == 'channel' ) 115 115 { 116 116 $this->inchannel = true; 117 117 } 118 elseif ($el == 'item' or $el == 'entry' ) 118 elseif ($el == 'item' or $el == 'entry' ) 119 119 { 120 120 $this->initem = true; … … 126 126 // if we're in the default namespace of an RSS feed, 127 127 // record textinput or image fields 128 elseif ( 129 $this->feed_type == RSS and 130 $this->current_namespace == '' and 131 $el == 'textinput' ) 128 elseif ( 129 $this->feed_type == RSS and 130 $this->current_namespace == '' and 131 $el == 'textinput' ) 132 132 { 133 133 $this->intextinput = true; … … 135 135 136 136 elseif ( 137 $this->feed_type == RSS and 138 $this->current_namespace == '' and 139 $el == 'image' ) 137 $this->feed_type == RSS and 138 $this->current_namespace == '' and 139 $el == 'image' ) 140 140 { 141 141 $this->inimage = true; … … 156 156 157 157 // if inside an Atom content construct (e.g. content or summary) field treat tags as text 158 elseif ($this->feed_type == ATOM and $this->incontent ) 158 elseif ($this->feed_type == ATOM and $this->incontent ) 159 159 { 160 160 // if tags are inlined, then flatten 161 $attrs_str = join(' ', 162 array_map('map_attrs', 163 array_keys($attrs), 161 $attrs_str = join(' ', 162 array_map('map_attrs', 163 array_keys($attrs), 164 164 array_values($attrs) ) ); 165 165 … … 173 173 // as being equivalent to RSS's simple link element. 174 174 // 175 elseif ($this->feed_type == ATOM and $el == 'link' ) 176 { 177 if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) 175 elseif ($this->feed_type == ATOM and $el == 'link' ) 176 { 177 if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' ) 178 178 { 179 179 $link_el = 'link'; … … 195 195 function feed_cdata ($p, $text) { 196 196 197 if ($this->feed_type == ATOM and $this->incontent) 197 if ($this->feed_type == ATOM and $this->incontent) 198 198 { 199 199 $this->append_content( $text ); … … 208 208 $el = strtolower($el); 209 209 210 if ( $el == 'item' or $el == 'entry' ) 210 if ( $el == 'item' or $el == 'entry' ) 211 211 { 212 212 $this->items[] = $this->current_item; … … 214 214 $this->initem = false; 215 215 } 216 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 216 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' ) 217 217 { 218 218 $this->intextinput = false; 219 219 } 220 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 220 elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' ) 221 221 { 222 222 $this->inimage = false; … … 226 226 $this->incontent = false; 227 227 } 228 elseif ($el == 'channel' or $el == 'feed' ) 228 elseif ($el == 'channel' or $el == 'feed' ) 229 229 { 230 230 $this->inchannel = false; … … 233 233 // balance tags properly 234 234 // note: i don't think this is actually neccessary 235 if ( $this->stack[0] == $el ) 235 if ( $this->stack[0] == $el ) 236 236 { 237 237 $this->append_content("</$el>"); … … 271 271 return; 272 272 } 273 if ( $this->current_namespace ) 273 if ( $this->current_namespace ) 274 274 { 275 275 if ( $this->initem ) { … … 396 396 return false; 397 397 } 398 } 398 } 399 399 // else cache is ON 400 400 else { … … 473 473 # compensate for Snoopy's annoying habbit to tacking 474 474 # on '\n' 475 $http_error = substr($resp->error, 0, -2); 475 $http_error = substr($resp->error, 0, -2); 476 476 $errormsg .= "(HTTP Error: $http_error)"; 477 477 } … … 614 614 } 615 615 616 function is_info ($sc) { 617 return $sc >= 100 && $sc < 200; 618 } 619 620 function is_success ($sc) { 621 return $sc >= 200 && $sc < 300; 622 } 623 624 function is_redirect ($sc) { 625 return $sc >= 300 && $sc < 400; 626 } 627 628 function is_error ($sc) { 629 return $sc >= 400 && $sc < 600; 630 } 631 632 function is_client_error ($sc) { 633 return $sc >= 400 && $sc < 500; 634 } 635 636 function is_server_error ($sc) { 637 return $sc >= 500 && $sc < 600; 616 function is_info ($sc) { 617 return $sc >= 100 && $sc < 200; 618 } 619 620 function is_success ($sc) { 621 return $sc >= 200 && $sc < 300; 622 } 623 624 function is_redirect ($sc) { 625 return $sc >= 300 && $sc < 400; 626 } 627 628 function is_error ($sc) { 629 return $sc >= 400 && $sc < 600; 630 } 631 632 function is_client_error ($sc) { 633 return $sc >= 400 && $sc < 500; 634 } 635 636 function is_server_error ($sc) { 637 return $sc >= 500 && $sc < 600; 638 638 } 639 639 … … 686 686 687 687 if ( ! get_option( $cache_option ) ) { 688 $this->debug( 688 $this->debug( 689 689 "Cache doesn't contain: $url (cache option: $cache_option)" 690 690 ); … … 758 758 function error ($errormsg, $lvl=E_USER_WARNING) { 759 759 // append PHP's error message if track_errors enabled 760 if ( isset($php_errormsg) ) { 760 if ( isset($php_errormsg) ) { 761 761 $errormsg .= " ($php_errormsg)"; 762 762 } … … 782 782 783 783 if ( preg_match( $pat, $date_str, $match ) ) { 784 list( $year, $month, $day, $hours, $minutes, $seconds) = 784 list( $year, $month, $day, $hours, $minutes, $seconds) = 785 785 array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]); 786 786
Note: See TracChangeset
for help on using the changeset viewer.