http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65338

Revision: 65338
Author:   jeroendedauw
Date:     2010-04-20 19:10:13 +0000 (Tue, 20 Apr 2010)

Log Message:
-----------
Follow up to r65334 and r65335 - also fixed title validation in storysubmission 
form

Modified Paths:
--------------
    trunk/extensions/Storyboard/specials/Story/Story_body.php
    trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php

Modified: trunk/extensions/Storyboard/specials/Story/Story_body.php
===================================================================
--- trunk/extensions/Storyboard/specials/Story/Story_body.php   2010-04-20 
19:04:00 UTC (rev 65337)
+++ trunk/extensions/Storyboard/specials/Story/Story_body.php   2010-04-20 
19:10:13 UTC (rev 65338)
@@ -174,7 +174,7 @@
                        ) )
                );
                
-               // FIXME: this is a temporary solution untill the 
SkinTemplateNavigation on special pages issue is fixed.
+               // FIXME: this button is a temporary solution untill the 
SkinTemplateNavigation on special pages issue is fixed.
                if ( $wgUser->isAllowed( 'storyreview' ) ) {
                        $editMsg = htmlspecialchars( wfMsg( 'edit' ) );
                        $editUrl = $this->getTitle( $story->story_title 
)->getLocalURL( 'action=edit' );
@@ -189,8 +189,6 @@
         * Outputs a form to edit the story with. Code based on 
<storysubmission>.
         * 
         * @param $story
-        * 
-        * TODO: Fix the validation for the story title
         */
        private function showStoryForm( $story ) {
                global $wgOut, $wgLang, $wgRequest, $wgUser, $wgJsMimeType, 
$wgScriptPath;

Modified: 
trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php
===================================================================
--- trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php   
2010-04-20 19:04:00 UTC (rev 65337)
+++ trunk/extensions/Storyboard/tags/Storysubmission/Storysubmission_body.php   
2010-04-20 19:10:13 UTC (rev 65338)
@@ -45,24 +45,34 @@
         * 
         * @param Parser $parser
         * @param array $args
+        * 
         * @return HTML
-        * 
-        * TODO: Fix the validation for the story title
         */
        private static function getFrom( Parser $parser, array $args ) {
-               global $wgUser, $wgStyleVersion, $wgJsMimeType, 
$egStoryboardScriptPath, $egStorysubmissionWidth, $egStoryboardMaxStoryLen, 
$egStoryboardMinStoryLen;
+               global $wgUser, $wgStyleVersion, $wgJsMimeType, $wgScriptPath, 
$wgStylePath;
+               global $egStoryboardScriptPath, $egStorysubmissionWidth, 
$egStoryboardMaxStoryLen, $egStoryboardMinStoryLen;
                
                // Loading a seperate JS file would be overkill for just these 
3 lines, and be bad for performance.
                $parser->getOutput()->addHeadItem(
                        <<<EOT
                        <link rel="stylesheet" 
href="$egStoryboardScriptPath/storyboard.css?$wgStyleVersion" />
                        <script type="$wgJsMimeType" 
src="$egStoryboardScriptPath/storyboard.js?$wgStyleVersion"></script>
+                       <script type="$wgJsMimeType" 
src="$wgStylePath/common/jquery.min.js?$wgStyleVersion"></script>
                        <script type="$wgJsMimeType" 
src="$egStoryboardScriptPath/jquery/jquery.validate.js?$wgStyleVersion"></script>
-                       <script type="$wgJsMimeType"> /*<![CDATA[*/
-                       addOnloadHook( function() { 
-                               document.getElementById( 
'storysubmission-button' ).disabled = true;
-                       } );
-                       /*]]>*/ </script>                       
+<script type="$wgJsMimeType"> /*<![CDATA[*/
+addOnloadHook( function() { 
+       document.getElementById( 'storysubmission-button' ).disabled = true;
+} );
+jQuery(document).ready(function() {
+       jQuery("#storyform").validate({
+               messages: {
+                       storytitle: {
+                               remote: jQuery.validator.format("<b>{0}</b> is 
already taken, please choose a different title.") // TODO: i18n
+                       }
+               }
+       });             
+});    
+/*]]>*/ </script>                      
 EOT
                );
                
@@ -149,9 +159,10 @@
                                'text',
                                array(
                                        'size' => $fieldSize,
-                                       'class' => 'required',
+                                       'class' => 'required storytitle',
                                        'maxlength' => 255,
-                                       'minlength' => 2
+                                       'minlength' => 2,
+                                       'remote' => 
"$wgScriptPath/api.php?format=json&action=storyexists"
                                )
                        ) . '</td></tr>';
                
@@ -192,6 +203,7 @@
                
                if ( !array_key_exists( 'language', $args )
                        || !array_key_exists( $args['language'], 
Language::getLanguageNames() ) ) {
+                               global $wgContLanguageCode;
                        $args['language'] = $wgContLanguageCode;
                }
 
@@ -212,6 +224,4 @@
                );
        }
        
-
-       
 }
\ No newline at end of file



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to