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


PHP LocalRepo::newFile方法代码示例

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


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

示例1: checkFiles

 protected function checkFiles(LocalRepo $repo, array $names, $verbose)
 {
     if (!count($names)) {
         return;
     }
     $dbr = $repo->getSlaveDB();
     $imgIN = array();
     $oiWheres = array();
     foreach ($names as $name) {
         if (strpos($name, '!') !== false) {
             if ($verbose) {
                 $this->output("Checking old file {$name}\n");
             }
             list(, $base) = explode('!', $name);
             // <TS_MW>!<img_name>
             $oiWheres[] = $dbr->makeList(array('oi_name' => $base, 'oi_archive_name' => $name), LIST_AND);
         } else {
             if ($verbose) {
                 $this->output("Checking current file {$name}\n");
             }
             $imgIN[] = $name;
         }
     }
     $res = $dbr->query($dbr->unionQueries(array($dbr->selectSQLText('image', array('name' => 'img_name'), array('img_name' => $imgIN)), $dbr->selectSQLText('oldimage', array('name' => 'oi_archive_name'), $dbr->makeList($oiWheres, LIST_OR))), true), __METHOD__);
     $namesFound = array();
     foreach ($res as $row) {
         $namesFound[] = $row->name;
     }
     $namesOrphans = array_diff($names, $namesFound);
     foreach ($namesOrphans as $name) {
         // Print name and public URL to ease recovery
         if (strpos($name, '!') !== false) {
             list(, $base) = explode('!', $name);
             // <TS_MW>!<img_name>
             $file = $repo->newFromArchiveName(Title::makeTitle(NS_FILE, $base), $name);
         } else {
             $file = $repo->newFile($name);
         }
         $this->output($name . "\n" . $file->getUrl() . "\n\n");
     }
 }
开发者ID:pirater,项目名称:mediawiki,代码行数:41,代码来源:findOrphanedFiles.php

示例2: checkFiles

 protected function checkFiles(LocalRepo $repo, array $paths, $verbose)
 {
     if (!count($paths)) {
         return;
     }
     $dbr = $repo->getSlaveDB();
     $curNames = [];
     $oldNames = [];
     $imgIN = [];
     $oiWheres = [];
     foreach ($paths as $path) {
         $name = basename($path);
         if (preg_match('#^archive/#', $path)) {
             if ($verbose) {
                 $this->output("Checking old file {$name}\n");
             }
             $oldNames[] = $name;
             list(, $base) = explode('!', $name, 2);
             // <TS_MW>!<img_name>
             $oiWheres[] = $dbr->makeList(['oi_name' => $base, 'oi_archive_name' => $name], LIST_AND);
         } else {
             if ($verbose) {
                 $this->output("Checking current file {$name}\n");
             }
             $curNames[] = $name;
             $imgIN[] = $name;
         }
     }
     $res = $dbr->query($dbr->unionQueries([$dbr->selectSQLText('image', ['name' => 'img_name', 'old' => 0], $imgIN ? ['img_name' => $imgIN] : '1=0'), $dbr->selectSQLText('oldimage', ['name' => 'oi_archive_name', 'old' => 1], $oiWheres ? $dbr->makeList($oiWheres, LIST_OR) : '1=0')], true), __METHOD__);
     $curNamesFound = [];
     $oldNamesFound = [];
     foreach ($res as $row) {
         if ($row->old) {
             $oldNamesFound[] = $row->name;
         } else {
             $curNamesFound[] = $row->name;
         }
     }
     foreach (array_diff($curNames, $curNamesFound) as $name) {
         $file = $repo->newFile($name);
         // Print name and public URL to ease recovery
         if ($file) {
             $this->output($name . "\n" . $file->getCanonicalUrl() . "\n\n");
         } else {
             $this->error("Cannot get URL for bad file title '{$name}'");
         }
     }
     foreach (array_diff($oldNames, $oldNamesFound) as $name) {
         list(, $base) = explode('!', $name, 2);
         // <TS_MW>!<img_name>
         $file = $repo->newFromArchiveName(Title::makeTitle(NS_FILE, $base), $name);
         // Print name and public URL to ease recovery
         $this->output($name . "\n" . $file->getCanonicalUrl() . "\n\n");
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:55,代码来源:findOrphanedFiles.php

示例3: newFile

	function newFile( $title, $time = false ) {
		if ( empty( $title ) ) {
			return null;
		}
		return parent::newFile( $title, $time );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:6,代码来源:SwiftMedia.body.php


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