http://www.mediawiki.org/wiki/Special:Code/MediaWiki/65334
Revision: 65334
Author: jeroendedauw
Date: 2010-04-20 18:24:03 +0000 (Tue, 20 Apr 2010)
Log Message:
-----------
Fixed title validation on Special:Story
Modified Paths:
--------------
trunk/extensions/Storyboard/api/ApiStoryExists.php
trunk/extensions/Storyboard/specials/Story/Story_body.php
Modified: trunk/extensions/Storyboard/api/ApiStoryExists.php
===================================================================
--- trunk/extensions/Storyboard/api/ApiStoryExists.php 2010-04-20 17:15:12 UTC
(rev 65333)
+++ trunk/extensions/Storyboard/api/ApiStoryExists.php 2010-04-20 18:24:03 UTC
(rev 65334)
@@ -48,10 +48,18 @@
$dbr = wfGetDB( DB_SLAVE );
+ $conditions = array(
+ 'story_title' => str_replace( array( '_', '+' ), ' ',
$params['storytitle'] ),
+ );
+
+ if ( array_key_exists( 'currentid', $params ) && is_integer(
$params['currentid'] ) ) {
+ $conditions[] = "story_id != $params[currentid]";
+ }
+
$story = $dbr->selectRow(
'storyboard',
array( 'story_id' ),
- array( 'story_title' => str_replace( array( '_', '+' ),
' ', $params['storytitle'] ) )
+ $conditions
);
$result = array(
@@ -70,6 +78,9 @@
'storytitle' => array(
ApiBase :: PARAM_TYPE => 'string',
),
+ 'currentid' => array(
+ ApiBase :: PARAM_TYPE => 'integer',
+ ),
);
}
@@ -94,6 +105,7 @@
protected function getExamples() {
return array(
'api.php?action=storyexists&storytitle=oHai there!',
+ 'api.php?action=storyexists&storytitle=oHai
there!¤tid=42',
);
}
Modified: trunk/extensions/Storyboard/specials/Story/Story_body.php
===================================================================
--- trunk/extensions/Storyboard/specials/Story/Story_body.php 2010-04-20
17:15:12 UTC (rev 65333)
+++ trunk/extensions/Storyboard/specials/Story/Story_body.php 2010-04-20
18:24:03 UTC (rev 65334)
@@ -286,8 +286,6 @@
)
) . '</td></tr>';
- // TODO: further fix this
- // Need to extend the validator plugin to work with api
results, and also send over the current srory id to exclude it.
$formBody .= '<tr>' .
'<td width="100%"><label for="storytitle">' .
htmlspecialchars( wfMsg(
'storyboard-storytitle' ) ) .
@@ -302,7 +300,7 @@
'minlength' => 2,
'id' => 'storytitle',
'class' => 'required storytitle',
- 'remote' =>
"$wgScriptPath/api.php?format=json&action=storyexists"
+ 'remote' =>
"$wgScriptPath/api.php?format=json&action=storyexists¤tid=$story->story_id"
)
) . '</td></tr>';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs