&1"; wfDebug( __METHOD__.": running ImageMagick: $cmd\n"); wfProfileIn( 'convert' ); $err = wfShellExec( $cmd, $retval ); wfProfileOut( 'convert' ); return($dstpath); } function uploadNewFile ($old_file, $new_filename) { global $wgRequest; $form = new UploadForm($wgRequest); $form->mTempPath = $new_filename; $form->mSrcName = $old_file->getName(); $form->mFileSize = filesize($new_filename); $form->mSessionKey = false; $form->mStashed = false; $form->mUploadClicked = true; $form->execute(); } class EditImage extends SpecialPage { function EditImage() { SpecialPage::SpecialPage("EditImage", '', true, 'efRunEditImage'); wfLoadExtensionMessages('EditImage'); } function run( $par ) { global $wgRequest, $wgOut; global $wgContLang; global $wgUser; # 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 ); $file = wfFindFile( $title ); if ( ! $title instanceof Title || $title->getNamespace() != NS_IMAGE ) { $wgOut->addWikiText("Sorry, can't find that image!"); } else { # see if we're passed editing information if ($wgRequest->wasPosted()) { $x1 = $wgRequest->getInt(x1); $x2 = $wgRequest->getInt(x2); $y1 = $wgRequest->getInt(y1); $y2 = $wgRequest->getInt(y2); $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() ) { # add the javascript $wgOut->addScript( "\n"); $wgOut->addScript( "\n"); $wgOut->addScript( "\n"); $wgOut->addScript( "\n"); $instructions = wfMsg('editimage-instructions'); $crop_text = wfMsg('cropimage'); $wgOut->addHTML("

{$instructions}

\n"); # add image $wgOut->addHTML("
getUrl()}\" alt=\"source image\" id=\"sourceImage\" />
\n"); # add bottom of the template $encComment = htmlspecialchars($wgRequest->getText('wpUploadDescription')); $align1 = $wgContLang->isRTL() ? 'left' : 'right'; $align2 = $wgContLang->isRTL() ? 'right' : 'left'; $cols = intval($wgUser->getOption('cols')); if( $wgUser->getOption( 'editwidth' ) ) { $width = " style=\"width:100%\""; } else { $width = ''; } $summary = wfMsgExt( 'fileuploadsummary', 'parseinline' ); $wgOut->addHTML("

"); } else { $wgOut->setStatusCode( 404 ); } } } } } ?>