本文整理汇总了PHP中WikiImporter::setRevisionCallback方法的典型用法代码示例。如果您正苦于以下问题:PHP WikiImporter::setRevisionCallback方法的具体用法?PHP WikiImporter::setRevisionCallback怎么用?PHP WikiImporter::setRevisionCallback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiImporter
的用法示例。
在下文中一共展示了WikiImporter::setRevisionCallback方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
示例2: 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();
}
示例3: 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();
}
示例4: 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");
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
示例8: restoreText
function restoreText($revIds, $xml)
{
global $wgTmpDirectory, $wgDBname;
if (!count($revIds)) {
return;
}
print "Restoring text from XML backup...\n";
$revFileName = "{$wgTmpDirectory}/broken-revlist-{$wgDBname}";
$filteredXmlFileName = "{$wgTmpDirectory}/filtered-{$wgDBname}.xml";
// Write revision list
if (!file_put_contents($revFileName, implode("\n", $revIds))) {
echo "Error writing revision list, can't restore text\n";
return;
}
// Run mwdumper
echo "Filtering XML dump...\n";
$exitStatus = 0;
passthru('mwdumper ' . wfEscapeShellArg("--output=file:{$filteredXmlFileName}", "--filter=revlist:{$revFileName}", $xml), $exitStatus);
if ($exitStatus) {
echo "mwdumper died with exit status {$exitStatus}\n";
return;
}
$file = fopen($filteredXmlFileName, 'r');
if (!$file) {
echo "Unable to open filtered XML file\n";
return;
}
$dbr =& wfGetDB(DB_SLAVE);
$dbw =& wfGetDB(DB_MASTER);
$dbr->ping();
$dbw->ping();
$source = new ImportStreamSource($file);
$importer = new WikiImporter($source);
$importer->setRevisionCallback(array(&$this, 'importRevision'));
$importer->doImport();
}
示例9: 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();
}
示例10: 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();
}