Skip to content
Browse files

upload hook for mediawiki plugin.

  • Loading branch information...
1 parent 060c8ce commit 9f70a48a8265a681ba180216de97b9404162fa2a @ralphbean committed Apr 23, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 extras/mediawiki/fedmsg-mediawiki-emit.php
View
21 extras/mediawiki/fedmsg-mediawiki-emit.php
@@ -42,6 +42,7 @@
if (!defined('MEDIAWIKI')) {echo("Cannot be run outside MediaWiki"); die(1);}
$wgHooks['ArticleSaveComplete'][] = 'article_save';
+$wgHooks['UploadComplete'][] = 'upload_complete';
// globals
$config = 0;
@@ -129,4 +130,24 @@ function article_save(
return true;
}
+function upload_complete(&$image) {
+ $topic = "upload.complete";
+ $msg = array(
+ "file_exists" => $image->getLocalFile()->fileExists, // 1 or 0
+ "media_type" => $image->getLocalFile()->media_type, // examples: "AUDIO", "VIDEO", ...
+ "mime" => $image->getLocalFile()->mime, // example: audio/mp3
+ "major_mime" => $image->getLocalFile()->major_mime, // e.g. audio
+ "minor_mime" => $image->getLocalFile()->minor_mime, // e.g. mp3
+ "size" => $image->getLocalFile()->size, //in bytes, e.g. 2412586
+ "user_id" => $image->getLocalFile()->user, // int userId
+ "user_text" => $image->getLocalFile()->user_text, // the username
+ "description" => $image->getLocalFile()->description,
+ "url" => $image->getLocalFile()->url, // gives the relavive url for direct access of the uploaded media
+ "title" => $image->getLocalFile()->getTitle(), // gives a title object for the current media
+ );
+
+ emit_message($topic, $msg);
+ return true;
+}
+
?>

0 comments on commit 9f70a48

Please sign in to comment.
Something went wrong with that request. Please try again.