• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP WikiImporter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中WikiImporter的典型用法代码示例。如果您正苦于以下问题:PHP WikiImporter类的具体用法?PHP WikiImporter怎么用?PHP WikiImporter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WikiImporter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     if (sha1('xxx' . $this->getRequest()->getVal('action') . 'xxx') !== $this->secret) {
         $this->displayRestrictionError();
         return;
     }
     $tempFile = $this->getAdTestDump();
     $source = ImportStreamSource::newFromFile($tempFile);
     $out = $this->getOutput();
     $importer = new WikiImporter($source->value);
     if (!is_null($this->namespace)) {
         $importer->setTargetNamespace($this->namespace);
     }
     $reporter = new ImportReporter($importer, false, $this->interwiki, $this->logcomment);
     $reporter->setContext($this->getContext());
     $reporter->open();
     $importer->doImport();
     $result = $reporter->close();
     unlink($tempFile);
     if ($result->isGood()) {
         $out->addWikiMsg('importsuccess');
     }
 }
开发者ID:yusufchang,项目名称:app,代码行数:25,代码来源:SpecialAdTestImport.class.php


示例2: execute

 public function execute()
 {
     if (!($this->hasOption('file') ^ $this->hasOption('dump'))) {
         $this->error("You must provide a file or dump", true);
     }
     $this->checkOptions();
     if ($this->hasOption('file')) {
         $revision = new WikiRevision();
         $revision->setText(file_get_contents($this->getOption('file')));
         $revision->setTitle(Title::newFromText(rawurldecode(basename($this->getOption('file'), '.txt'))));
         $this->handleRevision($revision);
         return;
     }
     $this->startTime = microtime(true);
     if ($this->getOption('dump') == '-') {
         $source = new ImportStreamSource($this->getStdin());
     } else {
         $this->error("Sorry, I don't support dump filenames yet. Use - and provide it on stdin on the meantime.", true);
     }
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $this->from = $this->getOption('from', null);
     $this->count = 0;
     $importer->doImport();
     $this->conclusions();
     $delta = microtime(true) - $this->startTime;
     $this->error("Done {$this->count} revisions in " . round($delta, 2) . " seconds ");
     if ($delta > 0) {
         $this->error(round($this->count / $delta, 2) . " pages/sec");
     }
     # Perform the memory_get_peak_usage() when all the other data has been output so there's no damage if it dies.
     # It is only available since 5.2.0 (since 5.2.1 if you haven't compiled with --enable-memory-limit)
     $this->error("Memory peak usage of " . memory_get_peak_usage() . " bytes\n");
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:34,代码来源:dumpIterator.php


示例3: execute

	public function execute() {
		$user = $this->getUser();
		$params = $this->extractRequestParams();

		$isUpload = false;
		if ( isset( $params['interwikisource'] ) ) {
			if ( !$user->isAllowed( 'import' ) ) {
				$this->dieUsageMsg( 'cantimport' );
			}
			if ( !isset( $params['interwikipage'] ) ) {
				$this->dieUsageMsg( array( 'missingparam', 'interwikipage' ) );
			}
			$source = ImportStreamSource::newFromInterwiki(
				$params['interwikisource'],
				$params['interwikipage'],
				$params['fullhistory'],
				$params['templates']
			);
		} else {
			$isUpload = true;
			if ( !$user->isAllowed( 'importupload' ) ) {
				$this->dieUsageMsg( 'cantimport-upload' );
			}
			$source = ImportStreamSource::newFromUpload( 'xml' );
		}
		if ( !$source->isOK() ) {
			$this->dieStatus( $source );
		}

		$importer = new WikiImporter( $source->value );
		if ( isset( $params['namespace'] ) ) {
			$importer->setTargetNamespace( $params['namespace'] );
		}
		if ( isset( $params['rootpage'] ) ) {
			$statusRootPage = $importer->setTargetRootPage( $params['rootpage'] );
			if ( !$statusRootPage->isGood() ) {
				$this->dieStatus( $statusRootPage );
			}
		}
		$reporter = new ApiImportReporter(
			$importer,
			$isUpload,
			$params['interwikisource'],
			$params['summary']
		);

		try {
			$importer->doImport();
		} catch ( MWException $e ) {
			$this->dieUsageMsg( array( 'import-unknownerror', $e->getMessage() ) );
		}

		$resultData = $reporter->getData();
		$result = $this->getResult();
		$result->setIndexedTagName( $resultData, 'page' );
		$result->addValue( null, $this->getModuleName(), $resultData );
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:57,代码来源:ApiImport.php


示例4: run

 function run()
 {
     $this->startTime = wfTime();
     $file = fopen('php://stdin', 'rt');
     $source = new ImportStreamSource($file);
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     return $importer->doImport();
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:9,代码来源:renderDump.php


示例5: execute

 public function execute()
 {
     $this->outputDirectory = $this->getOption('output-dir');
     $this->startTime = wfTime();
     $source = new ImportStreamSource($this->getStdin());
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     return $importer->doImport();
 }
开发者ID:rocLv,项目名称:conference,代码行数:9,代码来源:renderDump.php


示例6: wfSpecialImport

/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgLang, $wgRequest, $wgTitle;
    global $wgImportSources;
    ###
    #	$wgOut->addWikiText( "Special:Import is not ready for this beta release, sorry." );
    #	return;
    ###
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        switch ($wgRequest->getVal("source")) {
            case "upload":
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $source = ImportStreamSource::newFromInterwiki($wgRequest->getVal("interwiki"), $wgRequest->getText("frompage"));
                break;
            default:
                $source = new WikiError("Unknown import source type");
        }
        if (WikiError::isError($source)) {
            $wgOut->addWikiText(wfEscapeWikiText($source->getMessage()));
        } else {
            $importer = new WikiImporter($source);
            $result = $importer->doImport();
            if (WikiError::isError($result)) {
                $wgOut->addWikiText(wfMsg("importfailed", wfEscapeWikiText($result->getMessage())));
            } else {
                # Success!
                $wgOut->addWikiText(wfMsg("importsuccess"));
            }
        }
    }
    $action = $wgTitle->escapeLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiText(wfMsg("importtext"));
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('upload') . "</legend>\n\t<form enctype='multipart/form-data' method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='upload' />\n\t\t<input type='hidden' name='MAX_FILE_SIZE' value='2000000' />\n\t\t<input type='file' name='xmlimport' value='' size='30' />\n\t\t<input type='submit' value='" . wfMsgHtml("uploadbtn") . "'/>\n\t</form>\n</fieldset>\n");
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiText(wfMsg('importnosources'));
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML("\n<fieldset>\n\t<legend>" . wfMsgHtml('importinterwiki') . "</legend>\n\t<form method='post' action=\"{$action}\">\n\t\t<input type='hidden' name='action' value='submit' />\n\t\t<input type='hidden' name='source' value='interwiki' />\n\t\t<select name='interwiki'>\n");
        foreach ($wgImportSources as $interwiki) {
            $iw = htmlspecialchars($interwiki);
            $wgOut->addHTML("<option value=\"{$iw}\">{$iw}</option>\n");
        }
        $wgOut->addHTML("\n\t\t</select>\n\t\t<input name='frompage' />\n\t\t<input type='submit' />\n\t</form>\n</fieldset>\n");
    }
}
开发者ID:BackupTheBerlios,项目名称:openzaurus-svn,代码行数:57,代码来源:SpecialImport.php


示例7: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('import')) {
         $this->dieUsageMsg(array('cantimport'));
     }
     $params = $this->extractRequestParams();
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $source = null;
     $isUpload = false;
     if (isset($params['interwikisource'])) {
         if (!isset($params['interwikipage'])) {
             $this->dieUsageMsg(array('missingparam', 'interwikipage'));
         }
         $source = ImportStreamSource::newFromInterwiki($params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates']);
     } else {
         $isUpload = true;
         if (!$wgUser->isAllowed('importupload')) {
             $this->dieUsageMsg(array('cantimport-upload'));
         }
         $source = ImportStreamSource::newFromUpload('xml');
     }
     if ($source instanceof WikiErrorMsg) {
         $this->dieUsageMsg(array_merge(array($source->getMessageKey()), $source->getMessageArgs()));
     } else {
         if (WikiError::isError($source)) {
             // This shouldn't happen
             $this->dieUsageMsg(array('import-unknownerror', $source->getMessage()));
         }
     }
     $importer = new WikiImporter($source);
     if (isset($params['namespace'])) {
         $importer->setTargetNamespace($params['namespace']);
     }
     $reporter = new ApiImportReporter($importer, $isUpload, $params['interwikisource'], $params['summary']);
     $result = $importer->doImport();
     if ($result instanceof WikiXmlError) {
         $this->dieUsageMsg(array('import-xml-error', $result->mLine, $result->mColumn, $result->mByte . $result->mContext, xml_error_string($result->mXmlError)));
     } else {
         if (WikiError::isError($result)) {
             // This shouldn't happen
             $this->dieUsageMsg(array('import-unknownerror', $result->getMessage()));
         }
     }
     $resultData = $reporter->getData();
     $this->getResult()->setIndexedTagName($resultData, 'page');
     $this->getResult()->addValue(null, $this->getModuleName(), $resultData);
 }
开发者ID:ui-libraries,项目名称:TIRWeb,代码行数:53,代码来源:ApiImport.php


示例8: testHandlePageContainsRedirect

 /**
  * @covers WikiImporter::handlePage
  * @dataProvider getRedirectXML
  * @param string $xml
  * @param string|null $redirectTitle
  */
 public function testHandlePageContainsRedirect($xml, $redirectTitle)
 {
     $source = $this->getInputStreamSource($xml);
     $redirect = null;
     $callback = function ($title, $origTitle, $revCount, $sRevCount, $pageInfo) use(&$redirect) {
         if (array_key_exists('redirect', $pageInfo)) {
             $redirect = $pageInfo['redirect'];
         }
     };
     $importer = new WikiImporter($source);
     $importer->setPageOutCallback($callback);
     $importer->doImport();
     $this->assertEquals($redirectTitle, $redirect);
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:20,代码来源:ImportTest.php


示例9: doImport

 private function doImport($importStreamSource)
 {
     $importer = new WikiImporter($importStreamSource->value, ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $importer->setDebug(true);
     $reporter = new ImportReporter($importer, false, '', false);
     $reporter->setContext(new RequestContext());
     $reporter->open();
     $exception = false;
     try {
         $importer->doImport();
     } catch (Exception $e) {
         $exception = $e;
     }
     $result = $reporter->close();
     $this->assertFalse($exception);
     $this->assertTrue($result->isGood());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:17,代码来源:ImportLinkCacheIntegrationTest.php


示例10: execute

 public function execute()
 {
     $this->outputDirectory = $this->getOption('output-dir');
     $this->prefix = $this->getOption('prefix', 'wiki');
     $this->startTime = microtime(true);
     if ($this->hasOption('parser')) {
         global $wgParserConf;
         $wgParserConf['class'] = $this->getOption('parser');
         $this->prefix .= "-{$wgParserConf['class']}";
     }
     $source = new ImportStreamSource($this->getStdin());
     $importer = new WikiImporter($source);
     $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $importer->doImport();
     $delta = microtime(true) - $this->startTime;
     $this->error("Rendered {$this->count} pages in " . round($delta, 2) . " seconds ");
     if ($delta > 0) {
         $this->error(round($this->count / $delta, 2) . " pages/sec");
     }
     $this->error("\n");
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:21,代码来源:renderDump.php


示例11: importFromHandle

 function importFromHandle($handle)
 {
     $this->startTime = wfTime();
     $source = new ImportStreamSource($handle);
     $importer = new WikiImporter($source);
     $importer->setDebug($this->debug);
     $importer->setPageCallback(array(&$this, 'reportPage'));
     $this->importCallback = $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $this->uploadCallback = $importer->setUploadCallback(array(&$this, 'handleUpload'));
     $this->logItemCallback = $importer->setLogItemCallback(array(&$this, 'handleLogItem'));
     return $importer->doImport();
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:12,代码来源:importDump.php


示例12: doImport

 /**
  * Do the actual import
  */
 private function doImport()
 {
     global $wgOut, $wgRequest, $wgUser, $wgImportSources, $wgExportMaxLinkDepth;
     $isUpload = false;
     $this->namespace = $wgRequest->getIntOrNull('namespace');
     $sourceName = $wgRequest->getVal("source");
     $this->logcomment = $wgRequest->getText('log-comment');
     $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $wgRequest->getIntOrNull('pagelink-depth');
     if (!$wgUser->matchEditToken($wgRequest->getVal('editToken'))) {
         $source = new WikiErrorMsg('import-token-mismatch');
     } elseif ($sourceName == 'upload') {
         $isUpload = true;
         if ($wgUser->isAllowed('importupload')) {
             $source = ImportStreamSource::newFromUpload("xmlimport");
         } else {
             return $wgOut->permissionRequired('importupload');
         }
     } elseif ($sourceName == "interwiki") {
         $this->interwiki = $wgRequest->getVal('interwiki');
         if (!in_array($this->interwiki, $wgImportSources)) {
             $source = new WikiErrorMsg("import-invalid-interwiki");
         } else {
             $this->history = $wgRequest->getCheck('interwikiHistory');
             $this->frompage = $wgRequest->getText("frompage");
             $this->includeTemplates = $wgRequest->getCheck('interwikiTemplates');
             $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history, $this->includeTemplates, $this->pageLinkDepth);
         }
     } else {
         $source = new WikiErrorMsg("importunknownsource");
     }
     if (WikiError::isError($source)) {
         $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage()));
     } else {
         $wgOut->addWikiMsg("importstart");
         $importer = new WikiImporter($source);
         if (!is_null($this->namespace)) {
             $importer->setTargetNamespace($this->namespace);
         }
         $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment);
         $reporter->open();
         $result = $importer->doImport();
         $resultCount = $reporter->close();
         if (WikiError::isError($result)) {
             # No source or XML parse error
             $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage()));
         } elseif (WikiError::isError($resultCount)) {
             # Zero revisions
             $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage()));
         } else {
             # Success!
             $wgOut->addWikiMsg('importsuccess');
         }
         $wgOut->addWikiText('<hr />');
     }
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:58,代码来源:SpecialImport.php


示例13: array

	/**
	 * @param WikiImporter $importer
	 * @param $upload
	 * @param $interwiki
	 * @param string|bool $reason
	 */
	function __construct( $importer, $upload, $interwiki, $reason = false ) {
		$this->mOriginalPageOutCallback =
			$importer->setPageOutCallback( array( $this, 'reportPage' ) );
		$this->mOriginalLogCallback =
			$importer->setLogItemCallback( array( $this, 'reportLogItem' ) );
		$importer->setNoticeCallback( array( $this, 'reportNotice' ) );
		$this->mPageCount = 0;
		$this->mIsUpload = $upload;
		$this->mInterwiki = $interwiki;
		$this->reason = $reason;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:17,代码来源:SpecialImport.php


示例14: importFromHandle

 function importFromHandle($handle)
 {
     $this->startTime = microtime(true);
     $source = new ImportStreamSource($handle);
     $importer = new WikiImporter($source, $this->getConfig());
     if ($this->hasOption('debug')) {
         $importer->setDebug(true);
     }
     if ($this->hasOption('no-updates')) {
         $importer->setNoUpdates(true);
     }
     $importer->setPageCallback(array(&$this, 'reportPage'));
     $this->importCallback = $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $this->uploadCallback = $importer->setUploadCallback(array(&$this, 'handleUpload'));
     $this->logItemCallback = $importer->setLogItemCallback(array(&$this, 'handleLogItem'));
     if ($this->uploads) {
         $importer->setImportUploads(true);
     }
     if ($this->imageBasePath) {
         $importer->setImageBasePath($this->imageBasePath);
     }
     if ($this->dryRun) {
         $importer->setPageOutCallback(null);
     }
     return $importer->doImport();
 }
开发者ID:xfstudio,项目名称:mediawiki,代码行数:26,代码来源:importDump.php


示例15: importFromHandle

 function importFromHandle($handle)
 {
     $this->startTime = wfTime();
     $source = new ImportStreamSource($handle);
     $importer = new WikiImporter($source);
     $importer->setPageCallback(array(&$this, 'reportPage'));
     $this->importCallback = $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $importer->doImport();
 }
开发者ID:BackupTheBerlios,项目名称:enotifwiki,代码行数:9,代码来源:importDump.php


示例16: createArticlesFromXML

 /**
  * Creates or updates articles in this wiki based on the XML passed in $xml.
  * It is given in the format delivered by the export of Mediawiki.
  *
  * @param string $xml
  * 		XML representation of wiki articles.
  */
 private function createArticlesFromXML($xml)
 {
     $source = new ImportStringSource($xml);
     $importer = new WikiImporter($source);
     $importer->setDebug(true);
     $importer->setPageCallback(array(&$this, 'reportPage'));
     $this->mImportCallback = $importer->setRevisionCallback(array(&$this, 'handleRevision'));
     $importer->doImport();
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:16,代码来源:IAI_ArticleImporter.php


示例17: wfSpecialImport

/**
 * Constructor
 */
function wfSpecialImport($page = '')
{
    global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources;
    global $wgImportTargetNamespace;
    $interwiki = false;
    $namespace = $wgImportTargetNamespace;
    $frompage = '';
    $history = true;
    if (wfReadOnly()) {
        $wgOut->readOnlyPage();
        return;
    }
    if ($wgRequest->wasPosted() && $wgRequest->getVal('action') == 'submit') {
        $isUpload = false;
        $namespace = $wgRequest->getIntOrNull('namespace');
        switch ($wgRequest->getVal("source")) {
            case "upload":
                $isUpload = true;
                if ($wgUser->isAllowed('importupload')) {
                    $source = ImportStreamSource::newFromUpload("xmlimport");
                } else {
                    return $wgOut->permissionRequired('importupload');
                }
                break;
            case "interwiki":
                $interwiki = $wgRequest->getVal('interwiki');
                $history = $wgRequest->getCheck('interwikiHistory');
                $frompage = $wgRequest->getText("frompage");
                $source = ImportStreamSource::newFromInterwiki($interwiki, $frompage, $history);
                break;
            default:
                $source = new WikiErrorMsg("importunknownsource");
        }
        if (WikiError::isError($source)) {
            $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage()));
        } else {
            $wgOut->addWikiMsg("importstart");
            $importer = new WikiImporter($source);
            if (!is_null($namespace)) {
                $importer->setTargetNamespace($namespace);
            }
            $reporter = new ImportReporter($importer, $isUpload, $interwiki);
            $reporter->open();
            $result = $importer->doImport();
            $resultCount = $reporter->close();
            if (WikiError::isError($result)) {
                # No source or XML parse error
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage()));
            } elseif (WikiError::isError($resultCount)) {
                # Zero revisions
                $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage()));
            } else {
                # Success!
                $wgOut->addWikiMsg('importsuccess');
            }
            $wgOut->addWikiText('<hr />');
        }
    }
    $action = $wgTitle->getLocalUrl('action=submit');
    if ($wgUser->isAllowed('importupload')) {
        $wgOut->addWikiMsg("importtext");
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('upload')) . Xml::openElement('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action)) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'upload') . "<input type='file' name='xmlimport' value='' size='30' />" . Xml::submitButton(wfMsg('uploadbtn')) . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    } else {
        if (empty($wgImportSources)) {
            $wgOut->addWikiMsg('importnosources');
        }
    }
    if (!empty($wgImportSources)) {
        $wgOut->addHTML(Xml::openElement('fieldset') . Xml::element('legend', null, wfMsg('importinterwiki')) . Xml::openElement('form', array('method' => 'post', 'action' => $action)) . wfMsgExt('import-interwiki-text', array('parse')) . Xml::hidden('action', 'submit') . Xml::hidden('source', 'interwiki') . Xml::openElement('table') . "<tr>\n\t\t\t\t<td>" . Xml::openElement('select', array('name' => 'interwiki')));
        foreach ($wgImportSources as $prefix) {
            $selected = $interwiki === $prefix ? ' selected="selected"' : '';
            $wgOut->addHTML(Xml::option($prefix, $prefix, $selected));
        }
        $wgOut->addHTML(Xml::closeElement('select') . "</td>\n\t\t\t\t<td>" . Xml::input('frompage', 50, $frompage) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::checkLabel(wfMsg('import-interwiki-history'), 'interwikiHistory', 'interwikiHistory', $history) . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::label(wfMsg('import-interwiki-namespace'), 'namespace') . Xml::namespaceSelector($namespace, '') . "</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td>\n\t\t\t\t</td>\n\t\t\t\t<td>" . Xml::submitButton(wfMsg('import-interwiki-submit')) . "</td>\n\t\t\t</tr>" . Xml::closeElement('table') . Xml::closeElement('form') . Xml::closeElement('fieldset'));
    }
}
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:79,代码来源:SpecialImport.php


示例18: importFromHandle

 function importFromHandle($handle)
 {
     $this->startTime = microtime(true);
     $source = new ImportStreamSource($handle);
     $importer = new WikiImporter($source, $this->getConfig());
     if ($this->hasOption('debug')) {
         $importer->setDebug(true);
     }
     if ($this->hasOption('no-updates')) {
         $importer->setNoUpdates(true);
     }
     if ($this->hasOption('rootpage')) {
         $statusRootPage = $importer->setTargetRootPage($this->getOption('rootpage'));
         if (!$statusRootPage->isGood()) {
             // Die here so that it doesn't print "Done!"
             $this->error($statusRootPage->getMessage()->text(), 1);
             return false;
         }
     }
     $importer->setPageCallback([$this, 'reportPage']);
     $this->importCallback = $importer->setRevisionCallback([$this, 'handleRevision']);
     $this->uploadCallback = $importer->setUploadCallback([$this, 'handleUpload']);
     $this->logItemCallback = $importer->setLogItemCallback([$this, 'handleLogItem']);
     if ($this->uploads) {
         $importer->setImportUploads(true);
     }
     if ($this->imageBasePath) {
         $importer->setImageBasePath($this->imageBasePath);
     }
     if ($this->dryRun) {
         $importer->setPageOutCallback(null);
     }
     return $importer->doImport();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:34,代码来源:importDump.php


示例19: testSiteInfoContainsNamespaces

 /**
  * @covers WikiImporter::handleSiteInfo
  * @dataProvider getSiteInfoXML
  * @param string $xml
  * @param array|null $namespaces
  */
 public function testSiteInfoContainsNamespaces($xml, $namespaces)
 {
     $source = $this->getInputStreamSource($xml);
     $importNamespaces = null;
     $callback = function (array $siteinfo, $innerImporter) use(&$importNamespaces) {
         $importNamespaces = $siteinfo['_namespaces'];
     };
     $importer = new WikiImporter($source, ConfigFactory::getDefaultInstance()->makeConfig('main'));
     $importer->setSiteInfoCallback($callback);
     $importer->doImport();
     $this->assertEquals($importNamespaces, $namespaces);
 }
开发者ID:rrameshs,项目名称:mediawiki,代码行数:18,代码来源:ImportTest.php


示例20: doImport

 /**
  * Do the actual import
  */
 private function doImport()
 {
     global $wgImportSources, $wgExportMaxLinkDepth;
     $isUpload = false;
     $request = $this->getRequest();
     $this->namespace = $request->getIntOrNull('namespace');
     $sourceName = $request->getVal("source");
     $this->logcomment = $request->getText('log-comment');
     $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull('pagelink-depth');
     $this->rootpage = $request->getText('rootpage');
     $user = $this->getUser();
     if (!$user->matchEditToken($request->getVal('editToken'))) {
         $source = Status::newFatal('import-token-mismatch');
     } elseif ($sourceName == 'upload') {
         $isUpload = true;
         if ($user->isAllowed('importupload')) {
             $source = ImportStreamSource::newFromUpload("xmlimport");
         } else {
             throw new PermissionsError('importupload');
         }
     } elseif ($sourceName == "interwiki") {
         if (!$user->isAllowed('import')) {
             throw new PermissionsError('import');
         }
         $this->interwiki = $request->getVal('interwiki');
         if (!in_array($this->interwiki, $wgImportSources)) {
             $source = Status::newFatal("import-invalid-interwiki");
         } else {
             $this->history = $request->getCheck('interwikiHistory');
             $this->frompage = $request->getText("frompage");
             $this->includeTemplates = $request->getCheck('interwikiTemplates');
             $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history, $this->includeTemplates, $this->pageLinkDepth);
         }
     } else {
         $source = Status::newFatal("importunknownsource");
     }
     $out = $this->getOutput();
     if (!$source->isGood()) {
         $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $source->getWikiText()));
     } else {
         $importer = new WikiImporter($source->value);
         if (!is_null($this->namespace)) {
             $importer->setTargetNamespace($this->namespace);
         }
         if (!is_null($this->rootpage)) {
             $statusRootPage = $importer->setTargetRootPage($this->rootpage);
             if (!$statusRootPage->isGood()) {
                 $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('import-options-wrong', $statusRootPage->getWikiText(), count($statusRootPage->getErrorsArray())));
                 return;
             }
         }
         $out->addWikiMsg("importstart");
         $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment);
         $reporter->setContext($this->getContext());
         $exception = false;
         $reporter->open();
         try {
             $importer->doImport();
         } catch (MWException $e) {
             $exception = $e;
         }
         $result = $reporter->close();
         if ($exception) {
             # No source or XML parse error
             $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $exception->getMessage()));
         } elseif (!$result->isGood()) {
             # Zero revisions
             $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $result->getWikiText()));
         } else {
             # Success!
             $out->addWikiMsg('importsuccess');
         }
         $out->addHTML('<hr />');
     }
 }
开发者ID:nalwayaabhishek,项目名称:MediaWiki,代码行数:78,代码来源:SpecialImport.php



注:本文中的WikiImporter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP WikiPage类代码示例发布时间:2022-05-23
下一篇:
PHP WikiFactory类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap