本文整理汇总了PHP中ArchivedFile::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP ArchivedFile::getName方法的具体用法?PHP ArchivedFile::getName怎么用?PHP ArchivedFile::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArchivedFile
的用法示例。
在下文中一共展示了ArchivedFile::getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkWarnings
/**
* Check for non fatal problems with the file.
*
* This should not assume that mTempPath is set.
*
* @return Array of warnings
*/
public function checkWarnings()
{
global $wgLang;
wfProfileIn(__METHOD__);
$warnings = array();
$localFile = $this->getLocalFile();
$filename = $localFile->getName();
/**
* Check whether the resulting filename is different from the desired one,
* but ignore things like ucfirst() and spaces/underscore things
*/
$comparableName = str_replace(' ', '_', $this->mDesiredDestName);
$comparableName = Title::capitalize($comparableName, NS_FILE);
if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
$warnings['badfilename'] = $filename;
// Debugging for bug 62241
wfDebugLog('upload', "Filename: '{$filename}', mDesiredDestName: '{$this->mDesiredDestName}', comparableName: '{$comparableName}'");
}
// Check whether the file extension is on the unwanted list
global $wgCheckFileExtensions, $wgFileExtensions;
if ($wgCheckFileExtensions) {
$extensions = array_unique($wgFileExtensions);
if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
$warnings['filetype-unwanted-type'] = array($this->mFinalExtension, $wgLang->commaList($extensions), count($extensions));
}
}
global $wgUploadSizeWarning;
if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
$warnings['large-file'] = array($wgUploadSizeWarning, $this->mFileSize);
}
if ($this->mFileSize == 0) {
$warnings['emptyfile'] = true;
}
$exists = self::getExistsWarning($localFile);
if ($exists !== false) {
$warnings['exists'] = $exists;
}
// Check dupes against existing files
$hash = $this->getTempFileSha1Base36();
$dupes = RepoGroup::singleton()->findBySha1($hash);
$title = $this->getTitle();
// Remove all matches against self
foreach ($dupes as $key => $dupe) {
if ($title->equals($dupe->getTitle())) {
unset($dupes[$key]);
}
}
if ($dupes) {
$warnings['duplicate'] = $dupes;
}
// Check dupes against archives
$archivedImage = new ArchivedFile(null, 0, "{$hash}.{$this->mFinalExtension}");
if ($archivedImage->getID() > 0) {
if ($archivedImage->userCan(File::DELETED_FILE)) {
$warnings['duplicate-archive'] = $archivedImage->getName();
} else {
$warnings['duplicate-archive'] = '';
}
}
wfProfileOut(__METHOD__);
return $warnings;
}
示例2: checkWarnings
/**
* Check for non fatal problems with the file
*
* @return Array of warnings
*/
public function checkWarnings()
{
$warnings = array();
$localFile = $this->getLocalFile();
$filename = $localFile->getName();
$n = strrpos($filename, '.');
/**
* Check whether the resulting filename is different from the desired one,
* but ignore things like ucfirst() and spaces/underscore things
*/
$comparableName = str_replace(' ', '_', $this->mDesiredDestName);
$comparableName = Title::capitalize($comparableName, NS_FILE);
if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
$warnings['badfilename'] = $filename;
}
// Check whether the file extension is on the unwanted list
global $wgCheckFileExtensions, $wgFileExtensions;
if ($wgCheckFileExtensions) {
if (!$this->checkFileExtension($this->mFinalExtension, $wgFileExtensions)) {
$warnings['filetype-unwanted-type'] = $this->mFinalExtension;
}
}
global $wgUploadSizeWarning;
if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
$warnings['large-file'] = $wgUploadSizeWarning;
}
if ($this->mFileSize == 0) {
$warnings['emptyfile'] = true;
}
$exists = self::getExistsWarning($localFile);
if ($exists !== false) {
$warnings['exists'] = $exists;
}
// Check dupes against existing files
$hash = File::sha1Base36($this->mTempPath);
$dupes = RepoGroup::singleton()->findBySha1($hash);
$title = $this->getTitle();
// Remove all matches against self
foreach ($dupes as $key => $dupe) {
if ($title->equals($dupe->getTitle())) {
unset($dupes[$key]);
}
}
if ($dupes) {
$warnings['duplicate'] = $dupes;
}
// Check dupes against archives
$archivedImage = new ArchivedFile(null, 0, "{$hash}.{$this->mFinalExtension}");
if ($archivedImage->getID() > 0) {
$warnings['duplicate-archive'] = $archivedImage->getName();
}
return $warnings;
}
示例3: scrubVersion
protected function scrubVersion(ArchivedFile $archivedFile)
{
$key = $archivedFile->getStorageKey();
$name = $archivedFile->getName();
$ts = $archivedFile->getTimestamp();
$repo = RepoGroup::singleton()->getLocalRepo();
$path = $repo->getZonePath('deleted') . '/' . $repo->getDeletedHashPath($key) . $key;
if ($this->hasOption('delete')) {
$status = $repo->getBackend()->delete(['src' => $path]);
if ($status->isOK()) {
$this->output("Deleted version '{$key}' ({$ts}) of file '{$name}'\n");
} else {
$this->output("Failed to delete version '{$key}' ({$ts}) of file '{$name}'\n");
$this->output(print_r($status->getErrorsArray(), true));
}
} else {
$this->output("Would delete version '{$key}' ({$ts}) of file '{$name}'\n");
}
}
示例4: checkWarnings
/**
* Check for non fatal problems with the file.
*
* This should not assume that mTempPath is set.
*
* @return array Array of warnings
*/
public function checkWarnings()
{
global $wgLang;
$warnings = [];
$localFile = $this->getLocalFile();
$localFile->load(File::READ_LATEST);
$filename = $localFile->getName();
/**
* Check whether the resulting filename is different from the desired one,
* but ignore things like ucfirst() and spaces/underscore things
*/
$comparableName = str_replace(' ', '_', $this->mDesiredDestName);
$comparableName = Title::capitalize($comparableName, NS_FILE);
if ($this->mDesiredDestName != $filename && $comparableName != $filename) {
$warnings['badfilename'] = $filename;
}
// Check whether the file extension is on the unwanted list
global $wgCheckFileExtensions, $wgFileExtensions;
if ($wgCheckFileExtensions) {
$extensions = array_unique($wgFileExtensions);
if (!$this->checkFileExtension($this->mFinalExtension, $extensions)) {
$warnings['filetype-unwanted-type'] = [$this->mFinalExtension, $wgLang->commaList($extensions), count($extensions)];
}
}
global $wgUploadSizeWarning;
if ($wgUploadSizeWarning && $this->mFileSize > $wgUploadSizeWarning) {
$warnings['large-file'] = [$wgUploadSizeWarning, $this->mFileSize];
}
if ($this->mFileSize == 0) {
$warnings['empty-file'] = true;
}
$hash = $this->getTempFileSha1Base36();
$exists = self::getExistsWarning($localFile);
if ($exists !== false) {
$warnings['exists'] = $exists;
// check if file is an exact duplicate of current file version
if ($hash === $localFile->getSha1()) {
$warnings['no-change'] = $localFile;
}
// check if file is an exact duplicate of older versions of this file
$history = $localFile->getHistory();
foreach ($history as $oldFile) {
if ($hash === $oldFile->getSha1()) {
$warnings['duplicate-version'][] = $oldFile;
}
}
}
if ($localFile->wasDeleted() && !$localFile->exists()) {
$warnings['was-deleted'] = $filename;
}
// Check dupes against existing files
$dupes = RepoGroup::singleton()->findBySha1($hash);
$title = $this->getTitle();
// Remove all matches against self
foreach ($dupes as $key => $dupe) {
if ($title->equals($dupe->getTitle())) {
unset($dupes[$key]);
}
}
if ($dupes) {
$warnings['duplicate'] = $dupes;
}
// Check dupes against archives
$archivedFile = new ArchivedFile(null, 0, '', $hash);
if ($archivedFile->getID() > 0) {
if ($archivedFile->userCan(File::DELETED_FILE)) {
$warnings['duplicate-archive'] = $archivedFile->getName();
} else {
$warnings['duplicate-archive'] = '';
}
}
return $warnings;
}
示例5: getDupeWarning
/**
* Check for duplicate files and throw up a warning before the upload
* completes.
*/
function getDupeWarning($tempfile, $extension, $destinationTitle)
{
$hash = File::sha1Base36($tempfile);
$dupes = RepoGroup::singleton()->findBySha1($hash);
$archivedImage = new ArchivedFile(null, 0, $hash . ".{$extension}");
if ($dupes) {
global $wgOut;
$msg = "<gallery>";
foreach ($dupes as $file) {
$title = $file->getTitle();
# Don't throw the warning when the titles are the same, it's a reupload
# and highly redundant.
if (!$title->equals($destinationTitle) || !$this->mForReUpload) {
$msg .= $title->getPrefixedText() . "|" . $title->getText() . "\n";
}
}
$msg .= "</gallery>";
return "<li>" . wfMsgExt("file-exists-duplicate", array("parse"), count($dupes)) . $wgOut->parse($msg) . "</li>\n";
} elseif ($archivedImage->getID() > 0) {
global $wgOut;
$name = Title::makeTitle(NS_FILE, $archivedImage->getName())->getPrefixedText();
return Xml::tags('li', null, wfMsgExt('file-deleted-duplicate', array('parseinline'), array($name)));
} else {
return '';
}
}