Index: trunk/extensions/Storyboard/specials/Story/Story_body.php |
— | — | @@ -286,8 +286,6 @@ |
287 | 287 | ) |
288 | 288 | ) . '</td></tr>'; |
289 | 289 | |
290 | | - // TODO: further fix this |
291 | | - // Need to extend the validator plugin to work with api results, and also send over the current srory id to exclude it. |
292 | 290 | $formBody .= '<tr>' . |
293 | 291 | '<td width="100%"><label for="storytitle">' . |
294 | 292 | htmlspecialchars( wfMsg( 'storyboard-storytitle' ) ) . |
— | — | @@ -302,7 +300,7 @@ |
303 | 301 | 'minlength' => 2, |
304 | 302 | 'id' => 'storytitle', |
305 | 303 | 'class' => 'required storytitle', |
306 | | - 'remote' => "$wgScriptPath/api.php?format=json&action=storyexists" |
| 304 | + 'remote' => "$wgScriptPath/api.php?format=json&action=storyexists¤tid=$story->story_id" |
307 | 305 | ) |
308 | 306 | ) . '</td></tr>'; |
309 | 307 | |
Index: trunk/extensions/Storyboard/api/ApiStoryExists.php |
— | — | @@ -48,10 +48,18 @@ |
49 | 49 | |
50 | 50 | $dbr = wfGetDB( DB_SLAVE ); |
51 | 51 | |
| 52 | + $conditions = array( |
| 53 | + 'story_title' => str_replace( array( '_', '+' ), ' ', $params['storytitle'] ), |
| 54 | + ); |
| 55 | + |
| 56 | + if ( array_key_exists( 'currentid', $params ) && is_integer( $params['currentid'] ) ) { |
| 57 | + $conditions[] = "story_id != $params[currentid]"; |
| 58 | + } |
| 59 | + |
52 | 60 | $story = $dbr->selectRow( |
53 | 61 | 'storyboard', |
54 | 62 | array( 'story_id' ), |
55 | | - array( 'story_title' => str_replace( array( '_', '+' ), ' ', $params['storytitle'] ) ) |
| 63 | + $conditions |
56 | 64 | ); |
57 | 65 | |
58 | 66 | $result = array( |
— | — | @@ -70,6 +78,9 @@ |
71 | 79 | 'storytitle' => array( |
72 | 80 | ApiBase :: PARAM_TYPE => 'string', |
73 | 81 | ), |
| 82 | + 'currentid' => array( |
| 83 | + ApiBase :: PARAM_TYPE => 'integer', |
| 84 | + ), |
74 | 85 | ); |
75 | 86 | } |
76 | 87 | |
— | — | @@ -94,6 +105,7 @@ |
95 | 106 | protected function getExamples() { |
96 | 107 | return array( |
97 | 108 | 'api.php?action=storyexists&storytitle=oHai there!', |
| 109 | + 'api.php?action=storyexists&storytitle=oHai there!¤tid=42', |
98 | 110 | ); |
99 | 111 | } |
100 | 112 | |