| 87 | | $importdata = file($this->file); // Read the file into an array |
| 88 | | $importdata = implode('', $importdata); // squish it |
| 89 | | $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); |
| 90 | | preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); |
| 91 | | $this->posts = $this->posts[1]; |
| | 87 | $importdata = array_map('rtrim', file($this->file)); // Read the file into an array |
| | 88 | |
| | 89 | $this->posts = array(); |
| | 90 | $this->categories = array(); |
| | 91 | $num = 0; |
| | 92 | $doing_entry = false; |
| | 93 | foreach ($importdata as $importline) { |
| | 94 | if ( false !== strpos($importline, '<wp:category>') ) { |
| | 95 | preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); |
| | 96 | $this->categories[] = $category[1]; |
| | 97 | continue; |
| | 98 | } |
| | 99 | if ( false !== strpos($importline, '<item>') ) { |
| | 100 | $this->posts[$num] = ''; |
| | 101 | $doing_entry = true; |
| | 102 | continue; |
| | 103 | } |
| | 104 | if ( false !== strpos($importline, '</item>') ) { |
| | 105 | $num++; |
| | 106 | $doing_entry = false; |
| | 107 | continue; |
| | 108 | } |
| | 109 | if ( $doing_entry ) { |
| | 110 | $this->posts[$num] .= $importline . "\n"; |
| | 111 | } |
| | 112 | } |
| | 113 | |