Index: trunk/extensions/RecordAdmin/SpecialRecordAdmin.18n.php |
— | — | @@ -0,0 +1,60 @@ |
| 2 | +<?php |
| 3 | +#Internationalisation message file of Record Admin extension |
| 4 | + |
| 5 | +$messages=array(); |
| 6 | + |
| 7 | +$messages['en'] = array ( |
| 8 | + 'recordadmin' => 'Record Administration', |
| 9 | + 'recordadmin-desc' => 'A special page for finding and editing record articles using a form', |
| 10 | + 'recordadmin-select' => 'Select the type of record to search for ', |
| 11 | + 'recordadmin-newsearch' => 'New $1 search', |
| 12 | + 'recordadmin-newrecord' => 'Select another record type', |
| 13 | + 'recordadmin-submit' => 'Submit', |
| 14 | + 'recordadmin-create' => 'Find or Create a "$1" record', |
| 15 | + 'recordadmin-alreadyexist' => 'Sorry, "$1" already exists!', |
| 16 | + 'recordadmin-createsuccess' => '$1 created successfully', |
| 17 | + 'recordadmin-createerror' => 'An error occurred while attempting to create the $1!', |
| 18 | + 'recordadmin-badtitle' => 'Bad title!', |
| 19 | + 'recordadmin-recordid' => 'Record ID:', |
| 20 | + 'recordadmin-invert' => 'Invert selection', |
| 21 | + 'recordadmin-buttonsearch' => 'Search', |
| 22 | + 'recordadmin-buttoncreate' => 'Create', |
| 23 | + 'recordadmin-buttonreset' => 'Reset', |
| 24 | + 'recordadmin-searchresult' => 'Search results', |
| 25 | + 'recordadmin-nomatch' => 'No matching records found!', |
| 26 | + 'recordadmin-edit' => 'Editing $1', |
| 27 | + 'recordadmin-typeupdated' => '$1 properties updated', |
| 28 | + 'recordadmin-updatesuccess' => '$1 updated successfully', |
| 29 | + 'recordadmin-updateerror' => 'An error occurred during update', |
| 30 | + 'recordadmin-buttonsave' => 'Save', |
| 31 | + 'recordadmin-noform' => 'There is no form associated with "$1" records!', |
| 32 | + 'recordadmin-createlink' => 'click <a href=$1>here</a> to create one', |
| 33 | + 'recordadmin-newcreated' => 'New $type created from public form', |
| 34 | +); |
| 35 | + |
| 36 | +$messages['fr'] = array ( |
| 37 | + 'recordadmin' => 'Gestion des enregistrements', |
| 38 | + 'recordadmin-desc' => 'Une page spéciale pour trouver et modifier l’enregistrement des articles par l’utilisation d’un formulaire', |
| 39 | + 'recordadmin-select' => 'Sélectionner le type d’enregistrement à rechercher pour', |
| 40 | + 'recordadmin-newsearch' => 'Nouvelle recherche $1', |
| 41 | + 'recordadmin-newrecord' => 'Sélectionner un autre type d’enregistrement', |
| 42 | + 'recordadmin-submit' => 'Soumettre', |
| 43 | + 'recordadmin-create' => 'Chercher ou créer un enregistrement « $1 »', |
| 44 | + 'recordadmin-alreadyexist' => 'Désolé, « $1 » existe déjà !', |
| 45 | + 'recordadmin-createsuccess' => '$1 creé avec succès', |
| 46 | + 'recordadmin-createerror' => 'Une erreur est intervenue lors de la tentative de création de $1 !', |
| 47 | + 'recordadmin-badtitle' => 'Mauvais titre!', |
| 48 | + 'recordadmin-recordid' => 'Enregistrement ID :', |
| 49 | + 'recordadmin-invert' => 'Inverser la sélection', |
| 50 | + 'recordadmin-buttonsearch' => 'Rechercher', |
| 51 | + 'recordadmin-buttoncreate' => 'Créer', |
| 52 | + 'recordadmin-buttonreset' => 'Réinitialiser', |
| 53 | + 'recordadmin-nomatch' => 'Aucun enregistrement correspondant de trouvé !', |
| 54 | + 'recordadmin-edit' => 'Modifier $1', |
| 55 | + 'recordadmin-typeupdated' => 'propriété de $1 mises à jour', |
| 56 | + 'recordadmin-updatesuccess' => '$1 mis à jour avec succès', |
| 57 | + 'recordadmin-updateerror' => 'Une erreur a été rencontrée lors de la mise à jour', |
| 58 | + 'recordadmin-buttonsave' => 'Sauvegarder', |
| 59 | + 'recordadmin-noform' => 'Il n’y a aucun formulaire avec l’enregistrement « $1 » !', |
| 60 | + 'recordadmin-createlink' => 'cliquez <a href=$1>ici</a> pour en créer un', |
| 61 | +); |
Property changes on: trunk/extensions/RecordAdmin/SpecialRecordAdmin.18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 62 | + native |
Index: trunk/extensions/RecordAdmin/SpecialRecordAdmin.php |
— | — | @@ -10,19 +10,21 @@ |
11 | 11 | |
12 | 12 | if (!defined('MEDIAWIKI')) die('Not an entry point.'); |
13 | 13 | |
14 | | -define('RECORDADMIN_VERSION','0.1.4, 2008-10-29'); |
| 14 | +define('RECORDADMIN_VERSION','0.2, 2008-10-31'); |
15 | 15 | |
16 | 16 | $wgRecordAdminCategory = 'Records'; # Category which contains the templates used as records and having corresponding forms |
17 | 17 | $wgRecordAdminUseNamespaces = false; # Whether record articles should be in a namespace of the same name as their type |
18 | | - |
| 18 | +$dir = dirname(__FILE__) . '/'; |
| 19 | +$wgExtensionMessagesFiles['RecordAdmin'] = $dir . 'SpecialRecordAdmin.18n.php'; |
19 | 20 | $wgExtensionFunctions[] = 'wfSetupRecordAdmin'; |
20 | 21 | |
21 | 22 | $wgExtensionCredits['specialpage'][] = array( |
22 | | - 'name' => 'Record administration', |
23 | | - 'author' => '[http://www.organicdesign.co.nz/nad User:Nad]', |
24 | | - 'description' => 'A special page for finding and editing record articles using a form', |
25 | | - 'url' => 'http://www.organicdesign.co.nz/Extension:SpecialExample', |
26 | | - 'version' => RECORDADMIN_VERSION |
| 23 | + 'name' => 'Record administration', |
| 24 | + 'author' => '[http://www.organicdesign.co.nz/nad User:Nad]', |
| 25 | + 'description' => 'A special page for finding and editing record articles using a form', |
| 26 | + 'descriptionmsg' => 'recordadmin-desc', |
| 27 | + 'url' => 'http://www.organicdesign.co.nz/Extension:SpecialExample', |
| 28 | + 'version' => RECORDADMIN_VERSION |
27 | 29 | ); |
28 | 30 | |
29 | 31 | require_once "$IP/includes/SpecialPage.php"; |
— | — | @@ -37,7 +39,7 @@ |
38 | 40 | var $guid = ''; |
39 | 41 | |
40 | 42 | function __construct() { |
41 | | - |
| 43 | + wfLoadExtensionMessages ('RecordAdmin'); |
42 | 44 | # Name to use for creating a new record either via RecordAdmin or a public form |
43 | 45 | # todo: should add a hook here for custom default-naming |
44 | 46 | $this->guid = strftime('%Y%m%d', time()).'-'.substr(strtoupper(uniqid()), -5); |
— | — | @@ -68,8 +70,8 @@ |
69 | 71 | if ($wpTitle && !ereg("^$type:.+$", $wpTitle)) $wpTitle = "$type:$wpTitle"; |
70 | 72 | } |
71 | 73 | |
72 | | - $wgOut->addHTML("<div class='center'><a href='".$title->getLocalURL()."/$type'>New $type search</a> | " |
73 | | - . "<a href='".$title->getLocalURL()."'>Select another record type</a></div><br>\n" |
| 74 | + $wgOut->addHTML("<div class='center'><a href='".$title->getLocalURL()."/$type'>".wfMsg('recordadmin-newsearch', $type)."</a> | " |
| 75 | + . "<a href='".$title->getLocalURL()."'>".wfMsg('recordadmin-newrecord')."</a></div><br>\n" |
74 | 76 | ); |
75 | 77 | |
76 | 78 | # Get posted form values if any |
— | — | @@ -87,7 +89,7 @@ |
88 | 90 | |
89 | 91 | # If no type selected, render select list of record types from Category:Records |
90 | 92 | if (empty($type)) { |
91 | | - $wgOut->addWikiText("== Select the type of record to search for ==\n"); |
| 93 | + $wgOut->addWikiText("==".wfMsg('recordadmin-select')."==\n"); |
92 | 94 | |
93 | 95 | # Get titles in Category:Records and build option list |
94 | 96 | $options = ''; |
— | — | @@ -100,14 +102,14 @@ |
101 | 103 | # Render type-selecting form |
102 | 104 | $wgOut->addHTML(wfElement('form', array('action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null) |
103 | 105 | . "<select name='wpType'>$options</select> " |
104 | | - . wfElement('input', array('type' => 'submit', 'value' => 'Submit')) |
| 106 | + . wfElement('input', array('type' => 'submit', 'value' => wfMsg('recordadmin-submit'))) |
105 | 107 | . '</form>' |
106 | 108 | ); |
107 | 109 | } |
108 | 110 | |
109 | 111 | # Record type known, but no record selected, render form for searching or creating |
110 | 112 | elseif (empty($record)) { |
111 | | - $wgOut->addWikiText("== Find or Create a \"$type\" record ==\n"); |
| 113 | + $wgOut->addWikiText("==".wfMsg('recordadmin-create', $type)."==\n"); |
112 | 114 | |
113 | 115 | # Process Create submission |
114 | 116 | if (count($posted) && $wgRequest->getText('wpCreate')) { |
— | — | @@ -117,7 +119,7 @@ |
118 | 120 | } |
119 | 121 | $t = Title::newFromText($wpTitle); |
120 | 122 | if (is_object($t)) { |
121 | | - if ($t->exists()) $wgOut->addHTML("<div class='errorbox'>Sorry, \"$wpTitle\" already exists!</div>\n"); |
| 123 | + if ($t->exists()) $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-alreadyexist' ,$wpTitle)."</div>\n"); |
122 | 124 | else { |
123 | 125 | |
124 | 126 | # Attempt to create the article |
— | — | @@ -132,10 +134,10 @@ |
133 | 135 | $success = $article->doEdit($text, $summary, EDIT_NEW); |
134 | 136 | |
135 | 137 | # Report success or error |
136 | | - if ($success) $wgOut->addHTML("<div class='successbox'>\"$wpTitle\" created successfully</div>\n"); |
137 | | - else $wgOut->addHTML("<div class='errorbox'>An error occurred while attempting to create the $type!</div>\n"); |
| 138 | + if ($success) $wgOut->addHTML("<div class='successbox'>".wfMsg('recordadmin-createsuccess',$wpTitle)."</div>\n"); |
| 139 | + else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-createerror', $type)."</div>\n"); |
138 | 140 | } |
139 | | - } else $wgOut->addHTML("<div class='errorbox'>Bad title!</div>\n"); |
| 141 | + } else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-badtitle')."</div>\n"); |
140 | 142 | $wgOut->addHTML("<br><br><br><br>\n"); |
141 | 143 | } |
142 | 144 | |
— | — | @@ -145,20 +147,20 @@ |
146 | 148 | # Render the form |
147 | 149 | $wgOut->addHTML( |
148 | 150 | wfElement('form', array('class' => 'recordadmin', 'action' => $title->getLocalURL('action=submit'), 'method' => 'post'), null) |
149 | | - .'<b>Record ID:</b> '.wfElement('input', array('name' => 'wpTitle', 'size' => 30, 'value' => $wpTitle)) |
150 | | - .' '.wfElement('input', array('name' => 'wpInvert', 'type' => 'checkbox')).' Invert selection' |
| 151 | + .'<b>'.wfMsg('recordadmin-recordid').'</b> '.wfElement('input', array('name' => 'wpTitle', 'size' => 30, 'value' => $wpTitle)) |
| 152 | + .' '.wfElement('input', array('name' => 'wpInvert', 'type' => 'checkbox')).' '.wfMsg('recordadmin-invert') |
151 | 153 | ."\n<br><br><hr><br>\n{$this->form}" |
152 | 154 | .wfElement('input', array('type' => 'hidden', 'name' => 'wpType', 'value' => $type)) |
153 | 155 | .'<br><hr><br><table width="100%"><tr>' |
154 | | - .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpFind', 'value' => "Search")).'</td>' |
155 | | - .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpCreate', 'value' => "Create")).'</td>' |
156 | | - .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => "Reset")).'</td>' |
| 156 | + .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpFind', 'value' => wfMsg('recordadmin-buttonsearch'))).'</td>' |
| 157 | + .'<td>'.wfElement('input', array('type' => 'submit', 'name' => 'wpCreate', 'value' => wfMsg('recordadmin-buttoncreate'))).'</td>' |
| 158 | + .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => wfMsg('recordadmin-buttonreset'))).'</td>' |
157 | 159 | .'</tr></table></form>' |
158 | 160 | ); |
159 | 161 | |
160 | 162 | # Process Find submission |
161 | 163 | if (count($posted) && $wgRequest->getText('wpFind')) { |
162 | | - $wgOut->addWikiText("<br>\n== Search results ==\n"); |
| 164 | + $wgOut->addWikiText("<br>\n== ".wfMsg('recordadmin-searchresult')." ==\n"); |
163 | 165 | |
164 | 166 | # Select records which use the template and exhibit a matching title and other fields |
165 | 167 | $records = array(); |
— | — | @@ -228,13 +230,13 @@ |
229 | 231 | } |
230 | 232 | $table .= "</table>\n"; |
231 | 233 | $wgOut->addHTML($table); |
232 | | - } else $wgOut->addWikiText("''No matching records found!''\n"); |
| 234 | + } else $wgOut->addWikiText(wfMsg('recordadmin-nomatch')."\n"); |
233 | 235 | } |
234 | 236 | } |
235 | 237 | |
236 | 238 | # A specific record has been selected, render form for updating |
237 | 239 | else { |
238 | | - $wgOut->addWikiText("== Editing \"$record\" ==\n"); |
| 240 | + $wgOut->addWikiText("== ".wfMsg('recordadmin-edit',$record)." ==\n"); |
239 | 241 | $article = new Article(Title::newFromText($record)); |
240 | 242 | $text = $article->fetchContent(); |
241 | 243 | |
— | — | @@ -245,7 +247,7 @@ |
246 | 248 | foreach ($this->examineBraces($text) as $brace) if ($brace['NAME'] == $type) $braces = $brace; |
247 | 249 | |
248 | 250 | # Attempt to save the article |
249 | | - $summary = "[[Special:RecordAdmin/$type|RecordAdmin]]: $type properties updated"; |
| 251 | + $summary = "[[Special:RecordAdmin/$type|RecordAdmin]]: ".wfMsg('recordadmin-typeupdated',$type); |
250 | 252 | $replace = ''; |
251 | 253 | foreach ($posted as $k => $v) if ($v) { |
252 | 254 | if ($this->types[$k] == 'bool') $v = 'yes'; |
— | — | @@ -256,8 +258,8 @@ |
257 | 259 | $success = $article->doEdit($text, $summary, EDIT_UPDATE); |
258 | 260 | |
259 | 261 | # Report success or error |
260 | | - if ($success) $wgOut->addHTML("<div class='successbox'>$type updated successfully</div>\n"); |
261 | | - else $wgOut->addHTML("<div class='errorbox'>An error occurred during update!</div>\n"); |
| 262 | + if ($success) $wgOut->addHTML("<div class='successbox'>".wfMsg('recordadmin-updatesuccess',$type)."</div>\n"); |
| 263 | + else $wgOut->addHTML("<div class='errorbox'>".wfMsg('recordadmin-updateerror')."</div>\n"); |
262 | 264 | $wgOut->addHTML("<br><br><br><br>\n"); |
263 | 265 | } |
264 | 266 | |
— | — | @@ -271,8 +273,8 @@ |
272 | 274 | $wgOut->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'wpType', 'value' => $type))); |
273 | 275 | $wgOut->addHTML(wfElement('input', array('type' => 'hidden', 'name' => 'wpRecord', 'value' => $record))); |
274 | 276 | $wgOut->addHTML('<br><hr><br><table width="100%"><tr>' |
275 | | - .'<td>'.wfElement('input', array('type' => 'submit', 'value' => "Save")).'</td>' |
276 | | - .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => "Reset")).'</td>' |
| 277 | + .'<td>'.wfElement('input', array('type' => 'submit', 'value' => wfMsg('recordadmin-buttonsave'))).'</td>' |
| 278 | + .'<td width="100%" align="left">'.wfElement('input', array('type' => 'reset', 'value' => wfMsg('recordadmin-buttonreset'))).'</td>' |
277 | 279 | .'</tr></table></form>' |
278 | 280 | ); |
279 | 281 | } |
— | — | @@ -297,8 +299,8 @@ |
298 | 300 | |
299 | 301 | # Create a red link to the form if it doesn't exist |
300 | 302 | else { |
301 | | - $form = "<b>There is no form associated with \"$type\" records!</b>" |
302 | | - ."<br><br>click <a href=\"".$title->getLocalURL('action=edit')."\">here</a> to create one</div>"; |
| 303 | + $form = "<b>".wfMsg('recordadmin-noform',$type)."</b>" |
| 304 | + ."<br><br>".wfMsg('recordadmin-createlink',$title->getLocalURL('action=edit') )."</div>"; |
303 | 305 | } |
304 | 306 | $this->form = $form; |
305 | 307 | } |
— | — | @@ -433,7 +435,7 @@ |
434 | 436 | $title = Title::newFromText($title); |
435 | 437 | if (is_object($title) && !$title->exists()) { |
436 | 438 | $article = new Article($title); |
437 | | - $summary = "New $type created from public form"; |
| 439 | + $summary = wfMsg('recordadmin-newcreated'); |
438 | 440 | $text = ''; |
439 | 441 | foreach ($_POST as $k => $v) if ($v && isset($this->types[$k])) { |
440 | 442 | if ($this->types[$k] == 'bool') $v = 'yes'; |
— | — | @@ -458,13 +460,6 @@ |
459 | 461 | function wfSetupRecordAdmin() { |
460 | 462 | global $wgSpecialRecordAdmin, $wgParser, $wgLanguageCode, $wgMessageCache, $wgRequest; |
461 | 463 | |
462 | | - # Add the messages used by the specialpage |
463 | | - if ($wgLanguageCode == 'en') { |
464 | | - $wgMessageCache->addMessages(array( |
465 | | - 'recordadmin' => 'Record administration' |
466 | | - )); |
467 | | - } |
468 | | - |
469 | 464 | # Make a global singleton so methods are accessible as callbacks etc |
470 | 465 | $wgSpecialRecordAdmin = new SpecialRecordAdmin(); |
471 | 466 | |