WordpressImporter::import PHP Method

import() public method

public import ( DOMDocument $doc, $commitChannels = true )
$doc DOMDocument
    function import(DOMDocument $doc, $commitChannels = true)
    {
        $this->doc = $doc;
        $count = 0;
        $exception = null;
        $timer = microtime(1);
        try {
            foreach ($doc->getElementsByTagName('channel') as $channel) {
                if ($channel->nodeType !== XML_ELEMENT_NODE) {
                    continue;
                }
                $this->importChannel($channel, $commitChannels);
                $count++;
            }
        } catch (Exception $e) {
            $exception = $e;
        }
        if ($exception !== null) {
            throw $exception;
        }
        $timer = microtime(1) - $timer;
        $this->report('Imported ' . counted($count, 'channel', 'channels', 'zero', 'one') . ' in ' . gb_format_duration($timer));
    }

Usage Example

コード例 #1
0
ファイル: import-wordpress.php プロジェクト: rsms/gitblog
		}
		p.failure {
			font-size:200%;
			text-align:center;
			padding:50px 0 30px 0;
			color:#946;
		}
		p.failure pre {
			text-align:left;
			font-size:50%;
		}
	</style><?php 
    if (!gb::$errors) {
        echo '<h2>Importing ' . h(basename($_FILES['wpxml']['name'])) . '</h2>';
        try {
            $importer->import(DOMDocument::load($_FILES['wpxml']['tmp_name']));
            ?>
			<p class="done">
				Yay! I've imported <?php 
            echo counted($importer->importedObjectsCount, 'object', 'objects', 'zero', 'one');
            ?>
.
			</p>
			<p class="donelink">
				<a href="<?php 
            echo gb::$site_url;
            ?>
">Have a look at your blog &rarr;</a>
			</p>
			<?php 
        } catch (Exception $e) {