当前位置: 首页>>代码示例>>PHP>>正文


PHP WikiImporter::setTargetRootPage方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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


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