made some changes getting ready to release it
author<mako@atdot.cc> <>
Mon, 11 Aug 2008 23:45:25 +0000 (19:45 -0400)
committer<mako@atdot.cc> <>
Mon, 11 Aug 2008 23:45:25 +0000 (19:45 -0400)
EditImage.i18n.php
EditImage.php
EditImage_body.php

index f19659c7ee8f5ed7baaf10e58babe39d95cd617b..4731333424787dfaa7bfe1f3a0f3c58942359b4b 100644 (file)
@@ -2,6 +2,7 @@
 $messages = array();
 $messages['en'] = array( 
     'editimage' => 'Edit Image',
 $messages = array();
 $messages['en'] = array( 
     'editimage' => 'Edit Image',
-    'cropimage' => 'Crop Image'
+    'cropimage' => 'Crop Image',
+    'editimage-instructions' => 'Use your mouse to select an area in the image below and then click "Crop Image" to crop the image to the size.'
 );
 ?>
 );
 ?>
index af64e8dde84a7a5ade15577bbc579833c82ae67e..10e51e0b2571068bec49c6c820cb14cc8a48e916 100644 (file)
@@ -38,8 +38,6 @@ $wgExtensionCredits['specialpage'][] = array(
     'description' => 'This extension provides a way for Mediawiki users to edit images from the web.'
 );
 
     'description' => 'This extension provides a way for Mediawiki users to edit images from the web.'
 );
 
-
-
 function wfAddActionContentHook( &$content_actions ) {
     global $wgRequest, $wgRequest, $wgTitle;
     
 function wfAddActionContentHook( &$content_actions ) {
     global $wgRequest, $wgRequest, $wgTitle;
     
index 6315b85a07c84ebbc8746f3d29153b015cad0403..294a07ddb8a9ab9a016279665b728adbbc68e2b0 100644 (file)
@@ -18,7 +18,7 @@ function resizeImage ( $srcpath, $x1, $y1, $x2, $y2) {
     # specify white background color, will be used for transparent images
     # in internet explorer/windows instead of default black.
     $cmd  =  wfescapeshellarg($wgImageMagickConvertCommand) .
     # specify white background color, will be used for transparent images
     # in internet explorer/windows instead of default black.
     $cmd  =  wfescapeshellarg($wgImageMagickConvertCommand) .
-        " -background white ".
+        " -background white " .
         wfescapeshellarg($srcpath) .
         // coalesce is needed to scale animated gifs properly (bug 1017).
         ' -coalesce ' .
         wfescapeshellarg($srcpath) .
         // coalesce is needed to scale animated gifs properly (bug 1017).
         ' -coalesce ' .
@@ -41,10 +41,7 @@ function uploadNewFile ($old_file, $new_filename) {
     $form->mSessionKey     = false;
     $form->mStashed        = false;
     $form->mUploadClicked  = true;
     $form->mSessionKey     = false;
     $form->mStashed        = false;
     $form->mUploadClicked  = true;
-    //$form->mReUpload       = true;
 
 
-    // PHP won't auto-cleanup the file
-    $form->mRemoveTempFile = file_exists( $local_file);
     $form->execute();
 }
  
     $form->execute();
 }
  
@@ -59,13 +56,9 @@ class EditImage extends SpecialPage {
 
         global $wgContLang;
         global $wgUser;
 
         global $wgContLang;
         global $wgUser;
-        # add the javascript
-        global $wgJsMimeType, $wgScriptPath ;
-        $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/prototype.js\"></script>\n");
-        $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/scriptaculous.js\"></script>\n");
-        $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/cropper.js\"></script>\n");
-        $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/EditImage.js\"></script>\n");
-
+        # globals for javascript
+        global $wgJsMimeType, $wgScriptPath; 
+        
         # try to find the image that the user entered
         $image = $wgRequest->getText('image');
         $title = Title::newFromText( $image, NS_IMAGE );
         # try to find the image that the user entered
         $image = $wgRequest->getText('image');
         $title = Title::newFromText( $image, NS_IMAGE );
@@ -84,10 +77,21 @@ class EditImage extends SpecialPage {
                 $resized_fn = resizeImage($file->getFullPath(), $x1, $y1, $x2, $y2);
                 uploadNewFile($file, $resized_fn);
 
                 $resized_fn = resizeImage($file->getFullPath(), $x1, $y1, $x2, $y2);
                 uploadNewFile($file, $resized_fn);
 
+                # delete the file if it still exists
+                if (file_exists($resized_fn)) { unlink($resized_fn); }
+
             } else {
 
                 if ( $file && $file->exists() ) {
             } else {
 
                 if ( $file && $file->exists() ) {
-                    $wgOut->addHTML("<p>Use your mouse to select the new area on the image below. When you are done, press crop.</p>\n");
+                    # add the javascript
+                    $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/prototype.js\"></script>\n");
+                    $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/lib/scriptaculous.js\"></script>\n");
+                    $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/cropper.js\"></script>\n");
+                    $wgOut->addScript( "<script type=\"{$wgJsMimeType}\" src=\"$wgScriptPath/extensions/EditImage/EditImage.js\"></script>\n");
+
+                    $instructions = wfMsg('editimage-instructions');
+                    $crop_text = wfMsg('cropimage');
+                    $wgOut->addHTML("<p>{$instructions}</p>\n");
 
                     # add image
                     $wgOut->addHTML("<div><img src=\"{$file->getUrl()}\" alt=\"source image\" id=\"sourceImage\" /></div>\n");
 
                     # add image
                     $wgOut->addHTML("<div><img src=\"{$file->getUrl()}\" alt=\"source image\" id=\"sourceImage\" /></div>\n");
@@ -119,18 +123,15 @@ class EditImage extends SpecialPage {
                                        </td>
                                      </tr><table>
 
                                        </td>
                                      </tr><table>
 
-                                     <p><input type=\"submit\" value=\"Crop Image\" /></p>
+                                     <p><input type=\"submit\" value=\"{$crop_text}\" /></p>
                                      </form>");
 
                 } else {
                     $wgOut->setStatusCode( 404 );
                 }
             }
                                      </form>");
 
                 } else {
                     $wgOut->setStatusCode( 404 );
                 }
             }
-
         }
         }
-
     }
     }
-
 }
 
 ?>
 }
 
 ?>

Benjamin Mako Hill || Want to submit a patch?