Changeset 5802
- Timestamp:
- 07/15/2007 05:55:12 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wordpress.php
r5718 r5802 86 86 function get_entries() { 87 87 set_magic_quotes_runtime(0); 88 $importdata = array_map('rtrim', file($this->file)); // Read the file into an array89 88 90 89 $this->posts = array(); … … 92 91 $num = 0; 93 92 $doing_entry = false; 94 foreach ($importdata as $importline) { 95 if ( false !== strpos($importline, '<wp:category>') ) { 96 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 97 $this->categories[] = $category[1]; 98 continue; 99 } 100 if ( false !== strpos($importline, '<item>') ) { 101 $this->posts[$num] = ''; 102 $doing_entry = true; 103 continue; 104 } 105 if ( false !== strpos($importline, '</item>') ) { 106 $num++; 107 $doing_entry = false; 108 continue; 109 } 110 if ( $doing_entry ) { 111 $this->posts[$num] .= $importline . "\n"; 112 } 113 } 114 115 foreach ($this->posts as $post) { 116 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 117 if ($post_ID) { 118 $this->posts_processed[$post_ID][0] = &$post; 119 $this->posts_processed[$post_ID][1] = 0; 120 } 93 94 $fp = fopen($this->file, 'r'); 95 if ($fp) { 96 while ( !feof($fp) ) { 97 $importline = rtrim(fgets($fp)); 98 99 if ( false !== strpos($importline, '<wp:category>') ) { 100 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 101 $this->categories[] = $category[1]; 102 continue; 103 } 104 if ( false !== strpos($importline, '<item>') ) { 105 $this->posts[$num] = ''; 106 $doing_entry = true; 107 continue; 108 } 109 if ( false !== strpos($importline, '</item>') ) { 110 $num++; 111 $doing_entry = false; 112 continue; 113 } 114 if ( $doing_entry ) { 115 $this->posts[$num] .= $importline . "\n"; 116 } 117 } 118 119 foreach ($this->posts as $post) { 120 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 121 if ($post_ID) { 122 $this->posts_processed[$post_ID][0] = &$post; 123 $this->posts_processed[$post_ID][1] = 0; 124 } 125 } 126 127 fclose($fp); 121 128 } 122 129 }
Note: See TracChangeset
for help on using the changeset viewer.