r101812 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101811‎ | r101812 | r101813 >
Date:14:32, 3 November 2011
Author:hashar
Status:resolved (Comments)
Tags:
Comment:
implements Special:VipTest form
Modified paths:
  • /trunk/extensions/VipsScaler/SpecialVipsTest.php (modified) (history)
  • /trunk/extensions/VipsScaler/VipsScaler.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/VipsScaler/VipsScaler.i18n.php
@@ -13,6 +13,13 @@
1414 'vipsscaler-invalid-file' => 'Invalid file: could not process requested file (does it exist on this wiki?)',
1515 'vipsscaler-invalid-width' => 'You must specify a width (integer > 0)',
1616 'vipsscaler-thumb-error' => 'VIPS could not generate a thumbnail with given parameters',
 17+
 18+ # Vipscaler test form:
 19+ 'vipsscaler-form-legend' => 'VIPS scaling',
 20+ 'vipsscaler-form-width' => 'Thumbnail width: ',
 21+ 'vipsscaler-form-file' => 'File on this wiki: ',
 22+ 'vipsscaler-form-params' => 'VIPS parameters: ',
 23+ 'vipsscaler-form-submit' => 'Generate thumbnail',
1724 );
1825
1926 /** Message documentation (Message documentation)
@@ -23,6 +30,13 @@
2431 'vipsscaler-invalid-file' => 'Error message when SpecialVipsTest was given a non existent or invalid file name',
2532 'vipsscaler-invalid-width' => 'Error message when SpecialVipsTest did not get a valid width parameter',
2633 'vipsscaler-thumb-error' => 'Error message when VIPS did not manage to generate a thumbnail',
 34+
 35+ # Vipscaler test form:
 36+ 'vipsscaler-form-legend' => 'Special:VipsTest form: legend at top of the form',
 37+ 'vipsscaler-form-width' => 'Special:VipsTest form: label for the width input box',
 38+ 'vipsscaler-form-file' => 'Special:VipsTest form: label for the file input box',
 39+ 'vipsscaler-form-params' => 'Special:VipsTest form: label for the VIPS parameters box',
 40+ 'vipsscaler-form-submit' => 'Special:VipsTest form: submit button text. The page will then attempt to generate a thumbnail with the given parameters.',
2741 );
2842
2943 /** Afrikaans (Afrikaans)
Index: trunk/extensions/VipsScaler/SpecialVipsTest.php
@@ -79,18 +79,79 @@
8080 $this->getOutput()->addWikiMsg( 'vipsscaler-thumb-error' );
8181 }
8282
83 - $vipsThumbUrl = $this->makeUrl( $file, $width );
84 -
 83+ $this->makeUrl( $file, $width );
8584 }
8685
8786 /**
8887 * TODO
8988 */
9089 protected function showForm() {
 90+ $form = new HTMLForm( $this->getFormFields(), $this->getContext() );
 91+ $form->setWrapperLegend( wfMsg( 'vipsscaler-form-legend' ) );
 92+ $form->setSubmitText( wfMsg( 'vipsscaler-form-submit' ) );
 93+ $form->setSubmitCallback( array( __CLASS__, 'processForm' ) );
9194
 95+ // Looks like HTMLForm does not actually show the form if submission
 96+ // was correct. So we have to show it again.
 97+ // See HTMLForm::show()
 98+ $result = $form->show();
 99+ if( $result === true or $result instanceof Status && $result->isGood() ) {
 100+ $form->displayForm( $result );
 101+ }
92102 }
93103
94104 /**
 105+ * [[Special:VipsTest]] form structure for HTMLForm
 106+ * @return Array A form structure using the HTMLForm system
 107+ */
 108+ protected function getFormFields() {
 109+ $fields = array(
 110+ 'Width' => array(
 111+ 'name' => 'width',
 112+ 'class' => 'HTMLIntField',
 113+ 'default' => '640',
 114+ 'size' => '5',
 115+ 'required' => true,
 116+ 'label-message' => 'vipsscaler-form-width',
 117+ ),
 118+ 'File' => array(
 119+ 'name' => 'file',
 120+ 'class' => 'HTMLTextField',
 121+ 'required' => true,
 122+ 'label-message' => 'vipsscaler-form-file',
 123+ 'validation-callback' => array( __CLASS__, 'validateFileInput' ),
 124+ ),
 125+ 'Params' => array(
 126+ 'name' => 'params',
 127+ 'class' => 'HTMLTextField',
 128+ 'label-message' => 'vipsscaler-form-params',
 129+ ),
 130+ );
 131+ return $fields;
 132+ }
 133+
 134+ public static function validateFileInput( $input, $alldata ) {
 135+ $title = Title::makeTitleSafe( NS_FILE, $input );
 136+ if( is_null( $title ) ) {
 137+ return wfMsg( 'vipsscaler-invalid-file' );
 138+ }
 139+ $file = wfFindFile( $title ); # TODO what does it do?
 140+ if ( !$file || !$file->exists() ) {
 141+ return wfMsg( 'vipsscaler-invalid-file' );
 142+ }
 143+
 144+ // Looks sane enough.
 145+ return true;
 146+ }
 147+
 148+ /**
 149+ * Process data submitted by the form.
 150+ */
 151+ public static function processForm( array $data ) {
 152+ return Status::newGood();
 153+ }
 154+
 155+ /**
95156 *
96157 */
97158 protected function streamThumbnail() {

Follow-up revisions

RevisionCommit summaryAuthorDate
r101824remove trailing whitespace in i18n messages...hashar15:45, 3 November 2011

Comments

#Comment by Nikerabbit (talk | contribs)   15:28, 3 November 2011

Trailing whitespace is not allowed in i18n messages.

Status & tagging log