web/wp-admin/import/blogware.php
branchwordpress
changeset 132 4d4862461b8d
parent 109 03b0d1493584
equal deleted inserted replaced
131:a4642baaf829 132:4d4862461b8d
    38 	function greet() {
    38 	function greet() {
    39 		echo '<div class="narrow">';
    39 		echo '<div class="narrow">';
    40 		echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog.  Pick a Blogware file to upload and click Import.').'</p>';
    40 		echo '<p>'.__('Howdy! This importer allows you to extract posts from Blogware XML export file into your blog.  Pick a Blogware file to upload and click Import.').'</p>';
    41 		wp_import_upload_form("admin.php?import=blogware&amp;step=1");
    41 		wp_import_upload_form("admin.php?import=blogware&amp;step=1");
    42 		echo '</div>';
    42 		echo '</div>';
       
    43 	}
       
    44 
       
    45 	function _normalize_tag( $matches ) {
       
    46 		return '<' . strtolower( $matches[1] );
    43 	}
    47 	}
    44 
    48 
    45 	function import_posts() {
    49 	function import_posts() {
    46 		global $wpdb, $current_user;
    50 		global $wpdb, $current_user;
    47 
    51 
    87 				$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
    91 				$post_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($post_content[1]));
    88 				$post_content = $this->unhtmlentities($post_content);
    92 				$post_content = $this->unhtmlentities($post_content);
    89 			}
    93 			}
    90 
    94 
    91 			// Clean up content
    95 			// Clean up content
    92 			$post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
    96 			$post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
    93 			$post_content = str_replace('<br>', '<br />', $post_content);
    97 			$post_content = str_replace('<br>', '<br />', $post_content);
    94 			$post_content = str_replace('<hr>', '<hr />', $post_content);
    98 			$post_content = str_replace('<hr>', '<hr />', $post_content);
    95 			$post_content = $wpdb->escape($post_content);
    99 			$post_content = $wpdb->escape($post_content);
    96 
   100 
    97 			$post_author = $current_user->ID;
   101 			$post_author = $current_user->ID;
   127 					preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
   131 					preg_match('|<body>(.*?)</body>|is', $comment, $comment_content);
   128 					$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
   132 					$comment_content = str_replace(array ('<![CDATA[', ']]>'), '', trim($comment_content[1]));
   129 					$comment_content = $this->unhtmlentities($comment_content);
   133 					$comment_content = $this->unhtmlentities($comment_content);
   130 
   134 
   131 					// Clean up content
   135 					// Clean up content
   132 					$comment_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $comment_content);
   136 					$comment_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $comment_content);
   133 					$comment_content = str_replace('<br>', '<br />', $comment_content);
   137 					$comment_content = str_replace('<br>', '<br />', $comment_content);
   134 					$comment_content = str_replace('<hr>', '<hr />', $comment_content);
   138 					$comment_content = str_replace('<hr>', '<hr />', $comment_content);
   135 					$comment_content = $wpdb->escape($comment_content);
   139 					$comment_content = $wpdb->escape($comment_content);
   136 
   140 
   137 					preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);
   141 					preg_match('|<pubDate>(.*?)</pubDate>|is', $comment, $comment_date);