Manual:フック/UploadComplete

From MediaWiki.org
Jump to navigation Jump to search
This page is a translated version of the page Manual:Hooks/UploadComplete and the translation is 33% complete.

Other languages:
Deutsch • ‎English • ‎polski • ‎中文 • ‎日本語
UploadComplete
version 1.6.4 から利用可能
Called when a file upload has completed.
関数の定義:
public static function onUploadComplete( &$image ) { ... }
フックのアタッチ:

In extension.json:

{
	"Hooks": {
		"UploadComplete": "MyExtensionHooks::onUploadComplete"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UploadComplete'][] = 'MyExtensionHooks::onUploadComplete';
呼び出し元:ファイル: UploadBase.php

フックの付け方の詳細はManual:フックの情報を参照してください。
このフックを使用する拡張機能の例については、Category:UploadComplete extensions/ja を参照してください。

詳細

  • $image: the file (object) saved UploadForm object (since 1.16.0? UploadBase)
  • 戻り値: True, if other hooks shall be evaluated. False if evaluation shall stop. If no return value is given, an Error occurs.

Example Methods

It you want to know, what methods an upload form object has. includes/SpecialUpload.php を参照してください。

例:

// older versions (?untill 1.16?)
$image->mLocalFile; // LocalFile Object
$image->mLocalFile->fileExists; // 1 or 0
$image->mLocalFile->media_type; // examples: "AUDIO", "VIDEO", ...
$image->mLocalFile->mime; // example: audio/mp3
$image->mLocalFile->major_mime; // e.g. audio
$image->mLocalFile->minor_mime; // e.g. mp3
$image->mLocalFile->size; //in bytes, e.g. 2412586
$image->mLocalFile->user; // int userId 
$image->mLocalFile->user_text; // the username
$image->mLocalFile->description;
$image->mLocalFile->url; // gives the relavive url for direct access of the uploaded media
$image->mLocalFile->getTitle(); // gives a title object for the current media

// new MW versions (since ??)
$image->getLocalFile(); // LocalFile Object
$image->getLocalFile()->fileExists; // 1 or 0
$image->getLocalFile()->media_type; // examples: "AUDIO", "VIDEO", ...
$image->getLocalFile()->mime; // example: audio/mp3
$image->getLocalFile()->major_mime; // e.g. audio
$image->getLocalFile()->minor_mime; // e.g. mp3
$image->getLocalFile()->size; //in bytes, e.g. 2412586
$image->getLocalFile()->user; // int userId
$image->getLocalFile()->user_text; // the username
$image->getLocalFile()->description;
$image->getLocalFile()->url; // gives the relavive url for direct access of the uploaded media
$image->getLocalFile()->getTitle(); // gives a title object for the current media


/**
  * Do existence checks on a file and produce a warning
  * This check is static and can be done pre-upload via AJAX
  * Returns an HTML fragment consisting of one or more LI elements if there is a warning
  * Returns an empty string if there is no warning
  */
static function getExistsWarning( $file );

 /**
  * Split a file into a base name and all dot-delimited 'extensions'
  * on the end. Some web server configurations will fall back to
  * earlier pseudo-'extensions' to determine type and execute
  * scripts, so the blacklist needs to check them all.
  *
  * @return array
  */
function splitExtensions( $filename );