Index: trunk/extensions/FrontBackMatterForcedWikilinks/FrontBackMatterForcedWikilinks.i18n.php |
— | — | @@ -1,9 +1,17 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Internationalisation for FrontBackMatterForcedWikilinks extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
3 | 10 | $messages = array(); |
4 | 11 | |
5 | 12 | $messages['en'] = array( |
6 | 13 | 'frontbackforced-desc' => 'Prepends front matter and appends back matter to pages and implements forced wikilinks', |
7 | 14 | 'frontbackforced-front' => '_(front_matter)', |
8 | 15 | 'frontbackforced-back' => '_(back_matter)', |
9 | | - 'frontbackforced-forced' => '_(forced_wikilinks)' |
10 | | -); |
\ No newline at end of file |
| 16 | + 'frontbackforced-forced' => '_(forced_wikilinks)', |
| 17 | +); |
| 18 | + |
Index: trunk/extensions/FrontBackMatterForcedWikilinks/FrontBackMatterForcedWikilinks.php |
— | — | @@ -16,19 +16,20 @@ |
17 | 17 | # Alert the user that this is not a valid entry point to MediaWiki if they try to access the |
18 | 18 | # special pages file directly. |
19 | 19 | if (!defined('MEDIAWIKI')) { |
20 | | - echo <<<EOT |
| 20 | + echo <<<EOT |
21 | 21 | To install the Front and Back Matter and Forced Wikilinks extension, put the following line in LocalSettings.php: |
22 | 22 | require_once( "\$IP/extensions/FrontBackMatterForcedWikilinks/FrontBackMatterForcedWikilinks.php" ); |
23 | 23 | EOT; |
24 | | - exit( 1 ); |
| 24 | + exit( 1 ); |
25 | 25 | } |
26 | 26 | |
27 | 27 | $wgExtensionCredits['parserhook'][] = array( |
| 28 | + 'path' => __FILE__, |
28 | 29 | 'name' => 'Front and Back Matter and Forced Wikilinks', |
29 | 30 | 'author' => 'Tisane', |
30 | 31 | 'url' => 'http://www.mediawiki.org/wiki/Extension:FrontBackMatterForcedWikilinks', |
31 | 32 | 'description' => 'Prepends front matter and appends back matter to pages and implements forced wikilinks', |
32 | | - 'descriptionmsg' => 'FrontBackForced-desc', |
| 33 | + 'descriptionmsg' => 'frontbackforced-desc', |
33 | 34 | 'version' => '1.0.0', |
34 | 35 | ); |
35 | 36 | |
— | — | @@ -39,18 +40,18 @@ |
40 | 41 | $wgHooks['ArticleSaveComplete'][] = 'FrontBackForcedArticleSaveCompleteHook'; |
41 | 42 | |
42 | 43 | function FrontBackForcedParserBeforeStripHook( &$parser, &$text, &$strip_state ) { |
43 | | - global $wgLang; |
44 | | - $frontMsg=wfMsg( 'frontbackforced-front'); |
45 | | - $backMsg=wfMsg( 'frontbackforced-back'); |
46 | | - $forcedMsg=wfMsg( 'frontbackforced-forced'); |
47 | | - wfLoadExtensionMessages('FrontBackMatterForcedWikilinks'); |
| 44 | + global $wgLang; |
| 45 | + wfLoadExtensionMessages('FrontBackMatterForcedWikilinks'); |
| 46 | + $frontMsg=wfMsgForContent( 'frontbackforced-front' ); |
| 47 | + $backMsg=wfMsgForContent( 'frontbackforced-back' ); |
| 48 | + $forcedMsg=wfMsgForContent( 'frontbackforced-forced' ); |
48 | 49 | $dbr = wfGetDB( DB_SLAVE ); |
49 | 50 | $title=$parser->getTitle(); |
50 | 51 | if( $title->getNamespace() == NS_SPECIAL |
51 | 52 | || $title->getNamespace() == NS_MEDIA |
52 | 53 | || $title->getNamespace() == NS_FILE |
53 | 54 | || $title->isExternal()) { |
54 | | - return true; |
| 55 | + return true; |
55 | 56 | } |
56 | 57 | $myRevision=Revision::loadFromTitle($dbr,$title); |
57 | 58 | if ($myRevision!=null){ |
— | — | @@ -68,49 +69,49 @@ |
69 | 70 | $backMatterText=$backMatterRev->getRawText(); |
70 | 71 | $text=$text.$backMatterText; |
71 | 72 | } |
72 | | - $forcedMatterTitle=Title::newFromDBkey($title->getPrefixedDBkey().$forcedMsg); |
| 73 | + $forcedMatterTitle=Title::newFromDBkey($title->getPrefixedDBkey().$forcedMsg); |
73 | 74 | $forcedMatterRev=Revision::loadFromTitle($dbr,$forcedMatterTitle); |
74 | 75 | if ($forcedMatterRev!=null){ |
75 | 76 | $forcedMatterText=$forcedMatterRev->getRawText(); |
76 | | - $strPosition=0; |
77 | | - $endPosition=0; |
78 | | - $endSubstPosition=0; |
79 | | - $thisCount=0; |
| 77 | + $strPosition=0; |
| 78 | + $endPosition=0; |
| 79 | + $endSubstPosition=0; |
| 80 | + $thisCount=0; |
80 | 81 | while (1){ |
81 | | - $oldStrPosition=$strPosition; |
82 | | - $strPosition=strpos($forcedMatterText,'>',$strPosition); |
83 | | - if ($strPosition===false || $strPosition<=$oldStrPosition && $thisCount>0){ |
84 | | - break; |
85 | | - } |
86 | | - $oldEndPosition=$endPosition; |
87 | | - $endPosition=strpos($forcedMatterText,'<',$strPosition); |
88 | | - if ($endPosition===false || $endPosition<=$oldEndPosition && $thisCount>0){ |
89 | | - break; |
90 | | - } |
91 | | - $wfyText=substr($forcedMatterText,$strPosition+1,$endPosition-$strPosition-1); |
92 | | - $oldEndSubstPosition=$endSubstPosition; |
93 | | - $endSubstPosition=strpos($forcedMatterText,'#',$endPosition); |
94 | | - if ($endSubstPosition===false || $endSubstPosition-$endPosition==1 || $endSubstPosition<=$oldEndSubstPosition && $thisCount>0){ |
95 | | - $wfyToText=$wfyText; |
96 | | - } else { |
97 | | - $wfyToText=substr($forcedMatterText,$endPosition+1,$endSubstPosition-$endPosition-1); |
98 | | - } |
99 | | - $articleStartPos=strpos($text,$wfyText); |
100 | | - $continueThis=true; |
101 | | - if ($articleStartPos===false){ |
102 | | - $continueThis=false; |
103 | | - } |
104 | | - if ($articleStartPos>2){ |
105 | | - if (substr($text,$articleStartPos-2,2)=='[['){ |
106 | | - $continueThis=false; |
107 | | - } |
108 | | - } |
109 | | - if ($continueThis==true){ |
110 | | - $text=substr($text,0,$articleStartPos).'[['.$wfyToText.'|'.$wfyText.']]'.substr($text,$articleStartPos+strlen($wfyText),strlen($text)-$articleStartPos-strlen($wfyText)); |
111 | | - } |
112 | | - $thisCount++; |
113 | | - $strPosition++; |
114 | | - } |
| 82 | + $oldStrPosition=$strPosition; |
| 83 | + $strPosition=strpos($forcedMatterText,'>',$strPosition); |
| 84 | + if ($strPosition===false || $strPosition<=$oldStrPosition && $thisCount>0){ |
| 85 | + break; |
| 86 | + } |
| 87 | + $oldEndPosition=$endPosition; |
| 88 | + $endPosition=strpos($forcedMatterText,'<',$strPosition); |
| 89 | + if ($endPosition===false || $endPosition<=$oldEndPosition && $thisCount>0){ |
| 90 | + break; |
| 91 | + } |
| 92 | + $wfyText=substr($forcedMatterText,$strPosition+1,$endPosition-$strPosition-1); |
| 93 | + $oldEndSubstPosition=$endSubstPosition; |
| 94 | + $endSubstPosition=strpos($forcedMatterText,'#',$endPosition); |
| 95 | + if ($endSubstPosition===false || $endSubstPosition-$endPosition==1 || $endSubstPosition<=$oldEndSubstPosition && $thisCount>0){ |
| 96 | + $wfyToText=$wfyText; |
| 97 | + } else { |
| 98 | + $wfyToText=substr($forcedMatterText,$endPosition+1,$endSubstPosition-$endPosition-1); |
| 99 | + } |
| 100 | + $articleStartPos=strpos($text,$wfyText); |
| 101 | + $continueThis=true; |
| 102 | + if ($articleStartPos===false){ |
| 103 | + $continueThis=false; |
| 104 | + } |
| 105 | + if ($articleStartPos>2){ |
| 106 | + if (substr($text,$articleStartPos-2,2)=='[['){ |
| 107 | + $continueThis=false; |
| 108 | + } |
| 109 | + } |
| 110 | + if ($continueThis==true){ |
| 111 | + $text=substr($text,0,$articleStartPos).'[['.$wfyToText.'|'.$wfyText.']]'.substr($text,$articleStartPos+strlen($wfyText),strlen($text)-$articleStartPos-strlen($wfyText)); |
| 112 | + } |
| 113 | + $thisCount++; |
| 114 | + $strPosition++; |
| 115 | + } |
115 | 116 | } |
116 | 117 | } |
117 | 118 | } |
— | — | @@ -119,30 +120,30 @@ |
120 | 121 | } |
121 | 122 | |
122 | 123 | function FrontBackForcedArticleSaveCompleteHook (&$article, &$user, $text, $summary, |
123 | | - $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId ){ |
124 | | - global $wgLang; |
125 | | - wfLoadExtensionMessages('FrontBackMatterForcedWikilinks'); |
126 | | - $frontMsg=wfMsg( 'frontbackforced-front'); |
127 | | - $backMsg=wfMsg( 'frontbackforced-back'); |
128 | | - $forcedMsg=wfMsg( 'frontbackforced-forced'); |
129 | | - $myTitle=$article->getTitle()->getPrefixedDBkey(); |
| 124 | + $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId ){ |
| 125 | + global $wgLang; |
| 126 | + wfLoadExtensionMessages('FrontBackMatterForcedWikilinks'); |
| 127 | + $frontMsg=wfMsgForContent( 'frontbackforced-front' ); |
| 128 | + $backMsg=wfMsgForContent( 'frontbackforced-back' ); |
| 129 | + $forcedMsg=wfMsgForContent( 'frontbackforced-forced' ); |
| 130 | + $myTitle=$article->getTitle()->getPrefixedDBkey(); |
130 | 131 | if (substr($myTitle,strlen($myTitle)-strlen($frontMsg),strlen($frontMsg))==$frontMsg){ |
131 | | - $frontBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($frontMsg))); |
132 | | - $frontBaseTitle->invalidateCache(); |
133 | | - Article::onArticleCreate($frontBaseTitle); |
134 | | - Article::onArticleEdit($frontBaseTitle); |
| 132 | + $frontBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($frontMsg))); |
| 133 | + $frontBaseTitle->invalidateCache(); |
| 134 | + Article::onArticleCreate($frontBaseTitle); |
| 135 | + Article::onArticleEdit($frontBaseTitle); |
135 | 136 | } |
136 | | - if (substr($myTitle,strlen($myTitle)-strlen($backMsg),strlen($backMsg))==$backMsg){ |
137 | | - $backBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($backMsg))); |
138 | | - $backBaseTitle->invalidateCache(); |
139 | | - Article::onArticleCreate($backBaseTitle); |
140 | | - Article::onArticleEdit($backBaseTitle); |
| 137 | + if (substr($myTitle,strlen($myTitle)-strlen($backMsg),strlen($backMsg))==$backMsg){ |
| 138 | + $backBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($backMsg))); |
| 139 | + $backBaseTitle->invalidateCache(); |
| 140 | + Article::onArticleCreate($backBaseTitle); |
| 141 | + Article::onArticleEdit($backBaseTitle); |
141 | 142 | } |
142 | | - if (substr($myTitle,strlen($myTitle)-strlen($forcedMsg),strlen($forcedMsg))==$forcedMsg){ |
143 | | - $forcedBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($forcedMsg))); |
144 | | - $forcedBaseTitle->invalidateCache(); |
145 | | - Article::onArticleCreate($forcedBaseTitle); |
146 | | - Article::onArticleEdit($forcedBaseTitle); |
| 143 | + if (substr($myTitle,strlen($myTitle)-strlen($forcedMsg),strlen($forcedMsg))==$forcedMsg){ |
| 144 | + $forcedBaseTitle=Title::newFromDBkey(substr($myTitle,0,strlen($myTitle)-strlen($forcedMsg))); |
| 145 | + $forcedBaseTitle->invalidateCache(); |
| 146 | + Article::onArticleCreate($forcedBaseTitle); |
| 147 | + Article::onArticleEdit($forcedBaseTitle); |
147 | 148 | } |
148 | | - return true; |
| 149 | + return true; |
149 | 150 | } |
\ No newline at end of file |
Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -466,6 +466,9 @@ |
467 | 467 | ignored = framedvideo_max_height, framedvideo_allow_full_screen, framedvideo_force_allow_full_screen, framedvideo_force_frames |
468 | 468 | ignored = framedvideo_force_position |
469 | 469 | |
| 470 | +Front Back Matter Forced Wikilinks |
| 471 | +descmsg = frontbackforced-desc |
| 472 | + |
470 | 473 | Fundraiser Portal |
471 | 474 | |
472 | 475 | Gadgets |