2 function efRunEditImage( $par ) {
3 EditImage::run( $par );
6 function resizeImage ( $x1, $y1, $x2, $y2 ) {
9 class EditImage extends SpecialPage {
10 function EditImage() {
11 SpecialPage::SpecialPage("EditImage", '', true, 'efRunEditImage');
12 wfLoadExtensionMessages('EditImage');
15 function run( $par ) {
16 global $wgRequest, $wgOut;
19 global $wgJsMimeType, $wgScriptPath ;
20 $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/prototype.js\"></script>\n");
21 $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/scriptaculous.js\"></script>\n");
22 $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/cropper.js\"></script>\n");
23 $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/EditImage.js\"></script>\n");
25 # try to find the image that the user entered
26 $image = $wgRequest->getText('image');
27 $title = Title::newFromText( $image, NS_IMAGE );
29 if ( ! $title instanceof Title || $title->getNamespace() != NS_IMAGE ) {
30 $wgOut->addWikiText("Sorry, can't find that image!");
32 # see if we're passed editing information
33 if ($wgRequest->wasPosted()) {
34 $x1 = $wgRequest->getInt(x1);
35 $x2 = $wgRequest->getInt(x2);
36 $y1 = $wgRequest->getInt(x1);
37 $y2 = $wgRequest->getInt(y2);
39 resizeImage($x1, $y1, $x2, $y2);
40 $wgOut->addHTML("x1: $x1<br />x2: $x2<br />");
44 $file = wfFindFile( $title );
45 if ( $file && $file->exists() ) {
46 $wgOut->addHTML("<p>Use your mouse to select the new area on the image below. When you are done, press crop.</p>\n");
49 $wgOut->addHTML("<div><img src=\"{$file->getUrl()}\" alt=\"source image\" id=\"sourceImage\" width=\"500\" height=\"333\" /></div>\n");
51 # add bottom of the template
52 $wgOut->addHTML("<form action=\"\" method=\"POST\">
53 <input type=\"hidden\" name=\"image\" value=\"{$image}\" />
54 <input type=\"hidden\" name=\"x1\" id=\"x1\" />
55 <input type=\"hidden\" name=\"y1\" id=\"y1\" />
56 <input type=\"hidden\" name=\"x2\" id=\"x2\" />
57 <input type=\"hidden\" name=\"y2\" id=\"y2\" />
58 <input type=\"hidden\" name=\"width\" id=\"width\" />
59 <input type=\"hidden\" name=\"height\" id=\"height\" />
60 <p><input type=\"submit\" value=\"Save\" /></p>
64 $wgOut->setStatusCode( 404 );