r23645 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23644‎ | r23645 | r23646 >
Date:15:46, 2 July 2007
Author:simetrical
Status:old
Tags:
Comment:
* Add 'editsection-brackets' message to allow localization (or removal) of the brackets in the "[edit]" link for sections.
* rebuildMessages.php no longer adds the ending ?>
* Rebuilt MessagesEn.php
* Added Linker::doEditSectionLink to remove shared code from editSectionLink and editSectionLinkForOther
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messageTypes.inc (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/maintenance/language/writeMessagesArray.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -1060,34 +1060,66 @@
10611061 . "</script>\n";
10621062 }
10631063
1064 - /** @todo document */
 1064+ /**
 1065+ * Used to generate section edit links that point to "other" pages
 1066+ * (sections that are really part of included pages).
 1067+ *
 1068+ * @param $title Title string.
 1069+ * @param $section Integer: section number.
 1070+ */
10651071 public function editSectionLinkForOther( $title, $section ) {
1066 - global $wgContLang;
10671072 $title = Title::newFromText( $title );
1068 - $editurl = '&section='.$section;
1069 - $url = $this->makeKnownLinkObj( $title, wfMsg('editsection'), 'action=edit'.$editurl );
1070 - $result = null;
1071 - wfRunHooks( 'EditSectionLinkForOther', array( &$this, $title, $section, $url, &$result ) );
1072 - return is_null( $result )
1073 - ? "<span class=\"editsection\">[{$url}]</span>"
1074 - : "<span class=\"editsection\">[{$result}]</span>";
 1073+ return $this->doEditSectionLink( $title, $section, '', 'EditSectionLinkForOther' );
10751074 }
10761075
10771076 /**
1078 - * @param $title Title object.
 1077+ * @param $nt Title object.
10791078 * @param $section Integer: section number.
10801079 * @param $hint Link String: title, or default if omitted or empty
10811080 */
1082 - public function editSectionLink( $nt, $section, $hint='' ) {
 1081+ public function editSectionLink( Title $nt, $section, $hint='' ) {
 1082+ if( $hint != '' ) {
 1083+ $hint = wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) );
 1084+ $hint = " title=\"$hint\"";
 1085+ }
 1086+ return $this->doEditSectionLink( $nt, $section, $hint, 'EditSectionLink' );
 1087+ }
 1088+
 1089+ /**
 1090+ * Implement editSectionLink and editSectionLinkForOther.
 1091+ *
 1092+ * @param $nt Title object
 1093+ * @param $section Integer, section number
 1094+ * @param $hint String, for HTML title attribute
 1095+ * @param $hook String, name of hook to run
 1096+ * @return String, HTML to use for edit link
 1097+ */
 1098+ private function doEditSectionLink( Title $nt, $section, $hint, $hook ) {
10831099 global $wgContLang;
10841100 $editurl = '&section='.$section;
1085 - $hint = ( $hint=='' ) ? '' : ' title="' . wfMsgHtml( 'editsectionhint', htmlspecialchars( $hint ) ) . '"';
1086 - $url = $this->makeKnownLinkObj( $nt, wfMsg('editsection'), 'action=edit'.$editurl, '', '', '', $hint );
 1101+ $url = $this->makeKnownLinkObj(
 1102+ $nt,
 1103+ wfMsg('editsection'),
 1104+ 'action=edit'.$editurl,
 1105+ '', '', '', $hint
 1106+ );
10871107 $result = null;
1088 - wfRunHooks( 'EditSectionLink', array( &$this, $nt, $section, $hint, $url, &$result ) );
1089 - return is_null( $result )
1090 - ? "<span class=\"editsection\">[{$url}]</span>"
1091 - : "<span class=\"editsection\">[{$result}]</span>";
 1108+
 1109+ // The two hooks have slightly different interfaces . . .
 1110+ if( $hook == 'EditSectionLink' ) {
 1111+ wfRunHooks( $hook, array( &$this, $nt, $section, $hint, $url, &$result ) );
 1112+ } elseif( $hook == 'EditSectionLinkForOther' ) {
 1113+ wfRunHooks( $hook, array( &$this, $nt, $section, $url, &$result ) );
 1114+ }
 1115+
 1116+ // For reverse compatibility, add the brackets *after* the hook is run,
 1117+ // and even add them to hook-provided text.
 1118+ if( is_null( $result ) ) {
 1119+ $result = wfMsg( 'editsection-brackets', $url );
 1120+ } else {
 1121+ $result = wfMsg( 'editsection-brackets', $result );
 1122+ }
 1123+ return "<span class=\"editsection\">$result</span>";
10921124 }
10931125
10941126 /**
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -682,29 +682,30 @@
683683 'versionrequired' => 'Version $1 of MediaWiki required',
684684 'versionrequiredtext' => 'Version $1 of MediaWiki is required to use this page. See [[Special:Version|version page]].',
685685
686 -'ok' => 'OK',
687 -'sitetitle' => '{{SITENAME}}', # don't translate or duplicate this message to other languages
688 -'pagetitle' => '$1 - {{SITENAME}}',
689 -'sitesubtitle' => '', # don't translate or duplicate this message to other languages
690 -'retrievedfrom' => 'Retrieved from "$1"',
691 -'youhavenewmessages' => 'You have $1 ($2).',
692 -'newmessageslink' => 'new messages',
693 -'newmessagesdifflink' => 'last change',
694 -'editsection' => 'edit',
695 -'editold' => 'edit',
696 -'editsectionhint' => 'Edit section: $1',
697 -'toc' => 'Contents',
698 -'showtoc' => 'show',
699 -'hidetoc' => 'hide',
700 -'thisisdeleted' => 'View or restore $1?',
701 -'viewdeleted' => 'View $1?',
702 -'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
703 -'feedlinks' => 'Feed:',
704 -'feed-invalid' => 'Invalid subscription feed type.',
705 -'feed-atom' => 'Atom', # only translate this message to other languages if you have to change it
706 -'feed-rss' => 'RSS', # only translate this message to other languages if you have to change it
707 -'sitenotice' => '-', # the equivalent to wgSiteNotice; don't translate or duplicate this message to other languages
708 -'anonnotice' => '-', # don't translate or duplicate this message to other languages
 686+'ok' => 'OK',
 687+'sitetitle' => '{{SITENAME}}', # don't translate or duplicate this message to other languages
 688+'pagetitle' => '$1 - {{SITENAME}}',
 689+'sitesubtitle' => '', # don't translate or duplicate this message to other languages
 690+'retrievedfrom' => 'Retrieved from "$1"',
 691+'youhavenewmessages' => 'You have $1 ($2).',
 692+'newmessageslink' => 'new messages',
 693+'newmessagesdifflink' => 'last change',
 694+'editsection' => 'edit',
 695+'editsection-brackets' => '[$1]', # only translate this message to other languages if you have to change it
 696+'editold' => 'edit',
 697+'editsectionhint' => 'Edit section: $1',
 698+'toc' => 'Contents',
 699+'showtoc' => 'show',
 700+'hidetoc' => 'hide',
 701+'thisisdeleted' => 'View or restore $1?',
 702+'viewdeleted' => 'View $1?',
 703+'restorelink' => '{{PLURAL:$1|one deleted edit|$1 deleted edits}}',
 704+'feedlinks' => 'Feed:',
 705+'feed-invalid' => 'Invalid subscription feed type.',
 706+'feed-atom' => 'Atom', # only translate this message to other languages if you have to change it
 707+'feed-rss' => 'RSS', # only translate this message to other languages if you have to change it
 708+'sitenotice' => '-', # the equivalent to wgSiteNotice; don't translate or duplicate this message to other languages
 709+'anonnotice' => '-', # don't translate or duplicate this message to other languages
709710
710711 # Short words for each namespace, by default used in the 'article' tab in monobook
711712 'nstab-main' => 'Article',
@@ -1266,18 +1267,18 @@
12671268 'files' => 'Files',
12681269
12691270 # User rights
1270 -'userrights-lookup-user' => 'Manage user groups',
1271 -'userrights-user-editname' => 'Enter a username:',
1272 -'editusergroup' => 'Edit User Groups',
1273 -'userrights-editusergroup' => 'Edit user groups',
1274 -'saveusergroups' => 'Save User Groups',
1275 -'userrights-groupsmember' => 'Member of:',
1276 -'userrights-groupsavailable' => 'Available groups:',
1277 -'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
 1271+'userrights-lookup-user' => 'Manage user groups',
 1272+'userrights-user-editname' => 'Enter a username:',
 1273+'editusergroup' => 'Edit User Groups',
 1274+'userrights-editusergroup' => 'Edit user groups',
 1275+'saveusergroups' => 'Save User Groups',
 1276+'userrights-groupsmember' => 'Member of:',
 1277+'userrights-groupsavailable' => 'Available groups:',
 1278+'userrights-groupshelp' => 'Select groups you want the user to be removed from or added to.
12781279 Unselected groups will not be changed. You can deselect a group with CTRL + Left Click',
1279 -'userrights-reason' => 'Reason for change:',
1280 -'userrights-available-none' => 'You may not alter group membership.',
1281 -'userrights-available-add' => 'You can add users to $1.',
 1280+'userrights-reason' => 'Reason for change:',
 1281+'userrights-available-none' => 'You may not alter group membership.',
 1282+'userrights-available-add' => 'You can add users to $1.',
12821283 'userrights-available-remove' => 'You can remove users from $1.',
12831284
12841285 # Groups
Index: trunk/phase3/maintenance/language/messages.inc
@@ -248,6 +248,7 @@
249249 'newmessageslink',
250250 'newmessagesdifflink',
251251 'editsection',
 252+ 'editsection-brackets',
252253 'editold',
253254 'editsectionhint',
254255 'toc',
Index: trunk/phase3/maintenance/language/messageTypes.inc
@@ -106,6 +106,7 @@
107107 $wgOptionalMessages = array(
108108 'imgmultigotopost',
109109 'linkprefix',
 110+ 'editsection-brackets',
110111 'feed-atom',
111112 'feed-rss',
112113 'sectionlink',
Index: trunk/phase3/maintenance/language/writeMessagesArray.inc
@@ -29,13 +29,12 @@
3030 $contents = file_get_contents( $filename );
3131 if ( strpos( $contents, '$messages' ) !== false ) {
3232 $contents = explode( '$messages', $contents );
33 - if ( $messagesText . "\n?>\n" == '$messages' . $contents[1] ) {
34 - echo "Generated messages for language $code. Same to the current file.\n";
 33+ if ( $messagesText == '$messages' . $contents[1] ) {
 34+ echo "Generated messages for language $code. Same as the current file.\n";
3535 } else {
3636 if ( $write ) {
3737 $new = $contents[0];
3838 $new .= $messagesText;
39 - $new .= "\n?>\n";
4039 file_put_contents( $filename, $new );
4140 echo "Generated and wrote messages for language $code.\n";
4241 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r23654Merging r23645-50 into apiedit branchcatrope17:10, 2 July 2007
r23662Merged revisions 23581-23661 via svnmerge from...david03:01, 3 July 2007

Status & tagging log