diff --git a/EmbedScratch.php b/EmbedScratch.php index 2b8960a..4c98150 100644 --- a/EmbedScratch.php +++ b/EmbedScratch.php @@ -25,29 +25,43 @@ if (!defined('MEDIAWIKI')) { die(); } -error_reporting(0); - -$wgExtensionFunctions[] = 'beginEmbedScratch'; -$wgHooks['ParserFirstCallInit'][] = 'parserEmbedScratch'; - -function parserEmbedScratch (Parser $parser) { - $parser->setHook('scratch', 'renderEmbedScratch'); - return true; -} - -function renderEmbedScratch ($input, array $args, Parser $parser, PPFrame $frame) { - $project = $args["project"]?$args["project"]:""; - if ($project == ""){ - return ""; - } - $o = '
' - . ''; - return $o; -} -function beginEmbedScratch () { - global $wgOut; - $wgOut->addModules('ext.embedScratch'); +class EmbedScratch{ + public static function parserEmbedScratch (&$parser) { + $parser->setHook('scratch', array(__CLASS__,'renderEmbedScratch')); + return true; + } + + function renderEmbedScratch ($input, $argv, $parser) { + $project = ''; + $width = $width_max = 485; + $height = $height_max = 402; + + + if ( !empty( $argv['project'] ) ){ + $project=$argv['project']; + } elseif (!empty($input)){ + $project=$input; + } + if ( + !empty( $argv['width'] ) && + settype( $argv['width'], 'integer' ) && + ( $width_max >= $argv['width'] ) + ) + { + $width = $argv['width']; + } + if ( + !empty( $argv['height'] ) && + settype( $argv['height'], 'integer' ) && + ( $height_max >= $argv['height'] ) + ) + { + $height = $argv['height']; + } + if (!empty($project)) { + return ""; + } else { + return ""; + } + } } - diff --git a/extension.json b/extension.json index 257ede0..6673e59 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { - "name": "embedScratch", - "version": "1.0.0", + "name": "EmbedScratch", + "version": "2.0.0", "author": [ "Apple502j" ], @@ -15,10 +15,10 @@ "ContentHandlers": {}, "ExtensionMessagesFiles": {}, "Hooks": { - "ParserFirstCallInit": "EmbedScratch::parserEmbedScratch" + "ParserFirstCallInit": ["EmbedScratch::parserEmbedScratch"] }, "MessagesDirs": { - "embedScratch": [ + "EmbedScratch": [ "i18n" ] }, diff --git a/i18n/ja.json b/i18n/ja.json index d6dcd60..5976692 100644 --- a/i18n/ja.json +++ b/i18n/ja.json @@ -3,4 +3,4 @@ "author": "apple502j" }, "embedscratch-desc": "Scratchを埋め込もう!" -} +} \ No newline at end of file diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 0000000..f2d894c --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,6 @@ +{ + "@metadata": { + "author": "apple502j" + }, + "embedscratch-desc": "Description of this extension" +}