Index: trunk/extensions/BookManager/BookManager.body.php |
— | — | @@ -1,77 +1,13 @@ |
2 | 2 | <?php |
3 | | -/**** All the BookManager Variables Functions ****/ |
4 | 3 | class BookManagerFunctions { |
| 4 | +/** |
| 5 | +* BookManager private functions [Core] |
| 6 | +*/ |
5 | 7 | const VERSION = "0.1.6 "; |
6 | | - |
7 | | - static function register( $parser ) { |
8 | | - # optional SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}} |
9 | | - # instead of {{#int:...}}) |
10 | | - $parser->setFunctionHook( 'prevpagename', array( __CLASS__, 'prevpagename' ), SFH_NO_HASH ); |
11 | | - $parser->setFunctionHook( 'prevpagenamee', array( __CLASS__, 'prevpagenamee' ), SFH_NO_HASH ); |
12 | | - $parser->setFunctionHook( 'nextpagename', array( __CLASS__, 'nextpagename' ), SFH_NO_HASH ); |
13 | | - $parser->setFunctionHook( 'nextpagenamee', array( __CLASS__, 'nextpagenamee' ), SFH_NO_HASH ); |
14 | | - $parser->setFunctionHook( 'rootpagename', array( __CLASS__, 'rootpagename' ), SFH_NO_HASH ); |
15 | | - $parser->setFunctionHook( 'rootpagenamee', array( __CLASS__, 'rootpagenamee' ), SFH_NO_HASH ); |
16 | | - $parser->setFunctionHook( 'chaptername', array( __CLASS__, 'chaptername' ), SFH_NO_HASH ); |
17 | | - $parser->setFunctionHook( 'chapternamee', array( __CLASS__, 'chapternamee' ), SFH_NO_HASH ); |
18 | | - |
19 | | - return true; |
20 | | - } |
21 | | - /**** All the BookManager functions to declare magicword id ****/ |
22 | | - static function DeclareVarIds( &$aCustomVariableIds ) { |
23 | | - # aCustomVariableIds is where MediaWiki wants to store its |
24 | | - # list of custom variable ids. We oblige by adding ours: |
25 | | - $aCustomVariableIds[] = 'prevpagename'; |
26 | | - $aCustomVariableIds[] = 'prevpagenamee'; |
27 | | - $aCustomVariableIds[] = 'nextpagename'; |
28 | | - $aCustomVariableIds[] = 'nextpagenamee'; |
29 | | - $aCustomVariableIds[] = 'rootpagename'; |
30 | | - $aCustomVariableIds[] = 'rootpagenamee'; |
31 | | - $aCustomVariableIds[] = 'chaptername'; |
32 | | - $aCustomVariableIds[] = 'chapternamee'; |
33 | | - return true; |
34 | | - } |
35 | | - /**** All the BookManager functions to declare magicwords ****/ |
36 | | - static function LanguageGetMagic( &$magicWords, $langCode = "en" ) { |
37 | | - # PREVPAGENAME |
38 | | - $magicWords['prevpagename'] = array ( 0, 'PREVPAGENAME' ); |
39 | | - # PREVPAGENAME |
40 | | - $magicWords['prevpagenamee'] = array ( 0, 'PREVPAGENAMEE' ); |
41 | | - # NEXTPAGENAME |
42 | | - $magicWords['nextpagename'] = array ( 0, 'NEXTPAGENAME' ); |
43 | | - # NEXTPAGENAMEE |
44 | | - $magicWords['nextpagenamee'] = array ( 0, 'NEXTPAGENAMEE' ); |
45 | | - # ROOTPAGENAME |
46 | | - $magicWords['rootpagename'] = array ( 0, 'ROOTPAGENAME' , 'BOOKNAME' ); |
47 | | - # ROOTPAGENAMEE |
48 | | - $magicWords['rootpagenamee'] = array ( 0, 'ROOTPAGENAMEE' , 'BOOKNAMEE' ); |
49 | | - # CHAPTERNAME |
50 | | - $magicWords['chaptername'] = array ( 0, 'CHAPTERNAME' ); |
51 | | - # CHAPTERNAMEE |
52 | | - $magicWords['chapternamee'] = array ( 0, 'CHAPTERNAMEE' ); |
53 | | - |
54 | | - return true; |
55 | | - } |
56 | | -/**** All the BookManager private functions ****/ |
57 | | - |
58 | | - |
59 | | - /* |
60 | | - * Check if action is suported |
61 | | - * @return Bool |
62 | | - */ |
63 | | - private static function isViewAction() { |
64 | | - global $wgRequest; |
65 | | - $action = $wgRequest->getVal( 'action', 'view' ); |
66 | | - if( $action == 'view' || $action == 'purge' ){ |
67 | | - return true; |
68 | | - } |
69 | | - else{ |
70 | | - return false; |
71 | | - } |
72 | | - } |
73 | | - |
74 | | - /* |
| 8 | + private static $chapterList; |
| 9 | + /** |
75 | 10 | * Get Title |
| 11 | + * @return Object |
76 | 12 | */ |
77 | 13 | private static function newTitleObject( &$parser, $text = null ) { |
78 | 14 | $t = Title::newFromText( $text ); |
— | — | @@ -82,7 +18,7 @@ |
83 | 19 | } |
84 | 20 | |
85 | 21 | |
86 | | - /* |
| 22 | + /** |
87 | 23 | * Adaptation of the function "getBookPagePrefixes" from collection extension |
88 | 24 | * (http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Collection/Collection.body.php?revision=79895&view=markup#l440) |
89 | 25 | */ |
— | — | @@ -115,7 +51,7 @@ |
116 | 52 | return $result; |
117 | 53 | } |
118 | 54 | |
119 | | - /* |
| 55 | + /** |
120 | 56 | * Simplification of the function "parseCollectionLine" from collection extension |
121 | 57 | * (http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Collection/Collection.body.php?revision=79895&view=markup#l709) |
122 | 58 | */ |
— | — | @@ -142,7 +78,7 @@ |
143 | 79 | return null; |
144 | 80 | } |
145 | 81 | |
146 | | - /* |
| 82 | + /** |
147 | 83 | * Adaptation of the function "loadCollection" from collection extension |
148 | 84 | * (http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Collection/Collection.body.php?revision=79895&view=markup#l780) |
149 | 85 | */ |
— | — | @@ -162,19 +98,20 @@ |
163 | 99 | } |
164 | 100 | return $caps; |
165 | 101 | } |
166 | | - |
167 | | - #Get the book or chapter name |
168 | | - private static function bookparts( &$parser, $text = null, $part = 1) { |
| 102 | + /** |
| 103 | + * Get the book or chapter name |
| 104 | + */ |
| 105 | + private static function bookparts( &$parser, $text = null, $part = 1 ) { |
169 | 106 | $t = self::newTitleObject( $parser, $text ); |
170 | 107 | // No book should have '/' in it's name, so... |
171 | 108 | $book = explode( "/", $t->getText(), 2 ); // ...given a page with title like 'Foo/Bar/Baz'... |
172 | | - if ( count($book) > 1 ) { |
173 | | - return $book[$part];//... $book[0] is Foo, the book name, and $book[1] is Bar/Baz, the chapter name. |
| 109 | + if ( count( $book ) > 1 ) { |
| 110 | + return $book[$part];// ... $book[0] is Foo, the book name, and $book[1] is Bar/Baz, the chapter name. |
174 | 111 | } |
175 | | - else{ |
| 112 | + else { |
176 | 113 | return $t; |
177 | 114 | } |
178 | | - |
| 115 | + |
179 | 116 | } |
180 | 117 | /** |
181 | 118 | * Get the prefixed title of a page near the given page. |
— | — | @@ -186,26 +123,77 @@ |
187 | 124 | private static function pageText( &$parser, $text = null, $n = 0 ) { |
188 | 125 | $pagetitle = self::newTitleObject( $parser, $text ); |
189 | 126 | $prefixes = self::getBookPagePrefixes(); |
190 | | - $booktitle = Title::newFromText( $prefixes['community-prefix'] . self::bookparts( $parser, $text, 0) ); // ...the book name will be 'Foo'. |
| 127 | + $booktitle = Title::newFromText( $prefixes['community-prefix'] . self::bookparts( $parser, $text, 0 ) ); // ...the book name will be 'Foo'. |
191 | 128 | |
192 | | - $cap = self::loadListFromCollection( $booktitle ); |
193 | | - if ( $cap === false ) { |
| 129 | + if ( !self::$chapterList ) { |
| 130 | + self::$chapterList = self::loadListFromCollection( $booktitle ); |
| 131 | + } |
| 132 | + if ( self::$chapterList === false ) { |
194 | 133 | return ''; |
195 | 134 | } |
196 | | - $current = array_search( $pagetitle, $cap ); |
197 | | - if ( $current === false || !isset( $cap[ $current + $n ] ) ) { |
| 135 | + $current = array_search( $pagetitle, self::$chapterList ); |
| 136 | + if ( $current === false || !isset( self::$chapterList[ $current + $n ] ) ) { |
198 | 137 | return ''; |
199 | 138 | } |
200 | | - $otherpagetitle = Title::newFromText( $cap[ $current + $n ] ); |
| 139 | + $otherpagetitle = Title::newFromText( self::$chapterList[ $current + $n ] ); |
201 | 140 | if ( is_null( $otherpagetitle ) ) { |
202 | 141 | return ''; |
203 | 142 | } |
204 | 143 | return wfEscapeWikiText( $otherpagetitle->getText() ); |
205 | 144 | } |
| 145 | +/** |
| 146 | +* BookManager Functions [Variables] |
| 147 | +*/ |
| 148 | + static function register( $parser ) { |
| 149 | + # optional SFH_NO_HASH to omit the hash from calls (e.g. {{int:...}} |
| 150 | + # instead of {{#int:...}}) |
| 151 | + $parser->setFunctionHook( 'prevpagename', array( __CLASS__, 'prevpagename' ), SFH_NO_HASH ); |
| 152 | + $parser->setFunctionHook( 'prevpagenamee', array( __CLASS__, 'prevpagenamee' ), SFH_NO_HASH ); |
| 153 | + $parser->setFunctionHook( 'nextpagename', array( __CLASS__, 'nextpagename' ), SFH_NO_HASH ); |
| 154 | + $parser->setFunctionHook( 'nextpagenamee', array( __CLASS__, 'nextpagenamee' ), SFH_NO_HASH ); |
| 155 | + $parser->setFunctionHook( 'rootpagename', array( __CLASS__, 'rootpagename' ), SFH_NO_HASH ); |
| 156 | + $parser->setFunctionHook( 'rootpagenamee', array( __CLASS__, 'rootpagenamee' ), SFH_NO_HASH ); |
| 157 | + $parser->setFunctionHook( 'chaptername', array( __CLASS__, 'chaptername' ), SFH_NO_HASH ); |
| 158 | + $parser->setFunctionHook( 'chapternamee', array( __CLASS__, 'chapternamee' ), SFH_NO_HASH ); |
206 | 159 | |
207 | | -/**** All the BookManager values functions ****/ |
| 160 | + return true; |
| 161 | + } |
| 162 | + # Function to declare magicword id |
| 163 | + static function DeclareVarIds( &$aCustomVariableIds ) { |
| 164 | + # aCustomVariableIds is where MediaWiki wants to store its |
| 165 | + # list of custom variable ids. We oblige by adding ours: |
| 166 | + $aCustomVariableIds[] = 'prevpagename'; |
| 167 | + $aCustomVariableIds[] = 'prevpagenamee'; |
| 168 | + $aCustomVariableIds[] = 'nextpagename'; |
| 169 | + $aCustomVariableIds[] = 'nextpagenamee'; |
| 170 | + $aCustomVariableIds[] = 'rootpagename'; |
| 171 | + $aCustomVariableIds[] = 'rootpagenamee'; |
| 172 | + $aCustomVariableIds[] = 'chaptername'; |
| 173 | + $aCustomVariableIds[] = 'chapternamee'; |
| 174 | + return true; |
| 175 | + } |
| 176 | + # Function to declare magicwords |
| 177 | + static function LanguageGetMagic( &$magicWords, $langCode = "en" ) { |
| 178 | + # PREVPAGENAME |
| 179 | + $magicWords['prevpagename'] = array ( 0, 'PREVPAGENAME' ); |
| 180 | + # PREVPAGENAME |
| 181 | + $magicWords['prevpagenamee'] = array ( 0, 'PREVPAGENAMEE' ); |
| 182 | + # NEXTPAGENAME |
| 183 | + $magicWords['nextpagename'] = array ( 0, 'NEXTPAGENAME' ); |
| 184 | + # NEXTPAGENAMEE |
| 185 | + $magicWords['nextpagenamee'] = array ( 0, 'NEXTPAGENAMEE' ); |
| 186 | + # ROOTPAGENAME |
| 187 | + $magicWords['rootpagename'] = array ( 0, 'ROOTPAGENAME' , 'BOOKNAME' ); |
| 188 | + # ROOTPAGENAMEE |
| 189 | + $magicWords['rootpagenamee'] = array ( 0, 'ROOTPAGENAMEE' , 'BOOKNAMEE' ); |
| 190 | + # CHAPTERNAME |
| 191 | + $magicWords['chaptername'] = array ( 0, 'CHAPTERNAME' ); |
| 192 | + # CHAPTERNAMEE |
| 193 | + $magicWords['chapternamee'] = array ( 0, 'CHAPTERNAMEE' ); |
208 | 194 | |
209 | | - |
| 195 | + return true; |
| 196 | + } |
| 197 | + # Values functions |
210 | 198 | static function prevpagename( &$parser, $text = null ) { |
211 | 199 | $t = self::pageText( $parser, $text, - 1 ); |
212 | 200 | return $t; |
— | — | @@ -217,7 +205,7 @@ |
218 | 206 | } |
219 | 207 | |
220 | 208 | static function nextpagename( &$parser, $text = null ) { |
221 | | - |
| 209 | + |
222 | 210 | $t = self::pageText( $parser, $text, + 1 ); |
223 | 211 | return $t; |
224 | 212 | } |
— | — | @@ -227,24 +215,23 @@ |
228 | 216 | return wfUrlEncode( $t ); |
229 | 217 | } |
230 | 218 | static function rootpagename( &$parser, $text = null ) { |
231 | | - $t = self::bookparts( $parser, $text, 0); |
| 219 | + $t = self::bookparts( $parser, $text, 0 ); |
232 | 220 | return $t; |
233 | 221 | } |
234 | 222 | static function rootpagenamee( &$parser, $text = null ) { |
235 | | - $t = self::bookparts( $parser, $text, 0); |
| 223 | + $t = self::bookparts( $parser, $text, 0 ); |
236 | 224 | return wfUrlEncode( $t ); |
237 | 225 | } |
238 | 226 | static function chaptername( &$parser, $text = null ) { |
239 | | - $t = self::bookparts( $parser, $text, 1); |
| 227 | + $t = self::bookparts( $parser, $text, 1 ); |
240 | 228 | return $t; |
241 | 229 | } |
242 | 230 | static function chapternamee( &$parser, $text = null ) { |
243 | | - $t = self::bookparts( $parser, $text, 1); |
| 231 | + $t = self::bookparts( $parser, $text, 1 ); |
244 | 232 | return wfUrlEncode( $t ); |
245 | 233 | } |
246 | 234 | |
247 | | -/**** All the BookManagerFunctions for use with MW Variables on the current page ****/ |
248 | | - |
| 235 | + # Function for use with MW Variables on the current page |
249 | 236 | static function AssignAValue( &$parser, &$cache, &$magicWordId, &$ret ) { |
250 | 237 | switch( $magicWordId ) { |
251 | 238 | case 'prevpagename': |
— | — | @@ -274,75 +261,91 @@ |
275 | 262 | } |
276 | 263 | return false; |
277 | 264 | } |
278 | | - |
279 | | - |
| 265 | + |
280 | 266 | /** |
281 | | -* Function that adds navigation bar |
| 267 | +* BookManager Functions [Navigation Bar] |
282 | 268 | * inspired by PageNotice extension |
283 | | -* (http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PageNotice/PageNotice.php) |
| 269 | +* (http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/PageNotice/PageNotice.php&view=markup) |
284 | 270 | */ |
285 | 271 | |
| 272 | + |
286 | 273 | static function addText( &$out, &$text ) { |
287 | | - global $wgParser, $wgBookManagerNamespaces, $wgBookManagerNavbar; |
| 274 | + global $wgRequest, $wgBookManagerNamespaces, $wgBookManagerNavBar; |
288 | 275 | $ns = $out->getTitle()->getNamespace(); |
| 276 | + # Return True if action is suported |
| 277 | + $action = $wgRequest->getVal( 'action', 'view' ); |
| 278 | + $isViewAction = ( $action == 'view' || $action == 'purge' ); |
| 279 | + if ( !$wgBookManagerNavBar || !in_array( $ns, $wgBookManagerNamespaces ) || !$isViewAction ) { |
| 280 | + return true; |
| 281 | + } |
289 | 282 | $opt = array( |
290 | 283 | 'parseinline', |
291 | 284 | ); |
| 285 | + # Get $out title |
292 | 286 | $currenttitletext = $out->getTitle()->getText(); |
293 | | - $prev = self::pageText( $wgParser, $currenttitletext, - 1 ); |
294 | | - $base = Title::newFromText($currenttitletext)->getBaseText(); |
295 | | - $next = self::pageText( $wgParser, $currenttitletext, + 1 ); |
296 | | - $prevtext = ( $prev !== '' ) ? Title::newFromText( $prev )->getSubpageText(): '' ; |
297 | | - $basetext = Title::newFromText( $base )->getSubpageText(); |
298 | | - $nexttext = ( $next !== '' ) ? Title::newFromText( $next )->getSubpageText(): '' ; |
299 | | - $prevlink = ( $prev !== '' ) ? Title::newFromText( $prev )->getLocalURL(): '' ; |
300 | | - $baselink = Title::newFromText( $base )->getLocalURL(); |
301 | | - $nextlink = ( $next !== '' ) ? Title::newFromText( $next )->getLocalURL(): '' ; |
302 | | - $bar = Xml::openElement('ul',array('class'=>'mw-book-navigation') ); |
303 | | - $bar .= ( $prev !== '' ) ? Xml::openElement('li',array('class'=>'mw-prev') ): '' ; |
304 | | - $bar .= ( $prev !== '' ) ? Xml::element('a',array('href'=>$prevlink,'title'=>$prev ),$prevtext): '' ; |
305 | | - $bar .= ( $prev !== '' ) ? Xml::closeElement('li'): '' ; |
306 | | - $bar .= Xml::openElement('li',array('class'=>'mw-index') ); |
307 | | - $bar .= Xml::element('a',array('href'=>$baselink,'title'=>$base ),$basetext); |
308 | | - $bar .= Xml::closeElement('li'); |
309 | | - $bar .= ( $next !== '' ) ? Xml::openElement('li',array('class'=>'mw-next') ): '' ; |
310 | | - $bar .= ( $next !== '' ) ? Xml::element('a',array('href'=>$nextlink,'title'=>$next ),$nexttext): '' ; |
311 | | - $bar .= ( $next !== '' ) ? Xml::closeElement('li'): '' ; |
312 | | - $bar .= Xml::closeElement('ul'); |
313 | | - $is_inBookList = ( $prev !== '' || $next !== '' ) ? true : false ; |
314 | | - #adds system messages or html |
315 | | - if ( $wgBookManagerNavbar && in_array($ns,$wgBookManagerNamespaces) && self::isViewAction() && $is_inBookList ) { |
316 | | - $BookManager = wfMsgExt( "BookManager", $opt, $prev, $prevtext, $base, $basetext, $next, $nexttext); |
317 | | - $BookManagerTop = wfMsgExt( "BookManager-top", $opt, $prev, $prevtext, $base, $basetext, $next, $nexttext ); |
318 | | - $BookManagerBottom = wfMsgExt( "BookManager-bottom", $opt, $prev, $prevtext, $base, $basetext, $next, $nexttext ); |
319 | | - if ( !wfEmptyMsg( "BookManager-top", $BookManagerTop ) ) { |
320 | | - $text = "<div>$BookManagerTop</div>\n$text"; |
| 287 | + # Get: prev, next and base chapter from the list |
| 288 | + $prev = self::pageText( $parser, $currenttitletext, - 1 ); |
| 289 | + |
| 290 | + $next = self::pageText( $parser, $currenttitletext, + 1 ); |
| 291 | + if ( $prev === '' && $next === '' ) { |
| 292 | + return true; |
| 293 | + } |
| 294 | + # Return True if page exists in the chapter list |
| 295 | + $is_inChapterList = ( $prev !== '' || $next !== '' ); |
| 296 | + # Return True if Message is non empty |
| 297 | + $MsgIsEmpty = ( wfEmptyMsg( "BookManager" ) |
| 298 | + && wfEmptyMsg( "BookManager-top" ) |
| 299 | + && wfEmptyMsg( "BookManager-bottom" )); |
| 300 | + # Generate HTML or system messages values( $1 for $prev, $2 for $prevtext, $3 for $base, $4 for $basetext, $5 for $next and $6 for $nexttext ). |
| 301 | + $prevtext = ( $prev !== '' ) ? Title::newFromText( $prev )->getSubpageText(): '' ; |
| 302 | + $nexttext = ( $next !== '' ) ? Title::newFromText( $next )->getSubpageText(): '' ; |
| 303 | + if ( $MsgIsEmpty ) { |
| 304 | + $defaultBar = Xml::openElement( 'ul', array( 'class' => 'mw-book-navigation' ) ); |
| 305 | + if ( $prev !== '' ) { |
| 306 | + $prevlink = Title::newFromText( $prev )->getLocalURL(); |
| 307 | + $defaultBar .= Xml::openElement( 'li', array( 'class' => 'mw-prev' ) ); |
| 308 | + $defaultBar .= Xml::element( 'a', array( 'href' => $prevlink, 'title' => $prev ), $prevtext ); |
| 309 | + $defaultBar .= Xml::closeElement( 'li' ); |
321 | 310 | } |
322 | | - elseif ( !wfEmptyMsg( "BookManager", $BookManager ) ) { |
323 | | - $text = "<div>$BookManager</div>\n$text"; |
| 311 | + $base = Title::newFromText( $currenttitletext )->getBaseText(); |
| 312 | + $basetext = Title::newFromText( $base )->getSubpageText(); |
| 313 | + $baselink = Title::newFromText( $base )->getLocalURL(); |
| 314 | + $defaultBar .= Xml::openElement( 'li', array( 'class' => 'mw-index' ) ); |
| 315 | + $defaultBar .= Xml::element( 'a', array( 'href' => $baselink, 'title' => $base ), $basetext ); |
| 316 | + $defaultBar .= Xml::closeElement( 'li' ); |
| 317 | + if ( $next !== '' ) { |
| 318 | + $nextlink = Title::newFromText( $next )->getLocalURL(); |
| 319 | + $defaultBar .= Xml::openElement( 'li', array( 'class' => 'mw-next' ) ); |
| 320 | + $defaultBar .= Xml::element( 'a', array( 'href' => $nextlink, 'title' => $next ), $nexttext ); |
| 321 | + $defaultBar .= Xml::closeElement( 'li' ); |
324 | 322 | } |
325 | | - #This part adds directly to the html by default when the messages are not defined ... |
326 | | - else { |
327 | | - $text = "$bar\n$text"; |
328 | | - } |
329 | | - if ( !wfEmptyMsg( "BookManager-bottom", $BookManagerBottom ) ) { |
330 | | - $text = "$text\n<div>$BookManagerBottom</div>"; |
331 | | - } |
332 | | - elseif ( !wfEmptyMsg( "BookManager", $BookManager ) ) { |
333 | | - $text = "$text\n<div>$BookManager</div>"; |
334 | | - } |
335 | | - #This part adds directly to the html by default when the messages are not defined ... |
336 | | - else { |
337 | | - $text = "$text\n$bar"; |
338 | | - } |
339 | | - } |
340 | | - return true; |
341 | | - } |
342 | | - #adds CSS and JS to navigation bar |
| 323 | + $defaultBar .= Xml::closeElement( 'ul' ); |
| 324 | + } |
| 325 | + # Gets navigation bar from custom system messages or from default defined above |
| 326 | + $customBoth = wfEmptyMsg( 'BookManager' ) ? false : 'BookManager'; |
| 327 | + $customTop = wfEmptyMsg( 'BookManager-top' ) ? $customBoth : 'BookManager-top'; |
| 328 | + $customBottom = wfEmptyMsg( 'BookManager-bottom' ) ? $customBoth : 'BookManager-bottom'; |
| 329 | + $opt = array( |
| 330 | + 'parseinline', |
| 331 | + ); |
| 332 | + if ( $customTop ) { |
| 333 | + $top = wfMsgExt( $customTop, $opt, $prev, $prevtext, $base, $basetext, $next, $nexttext ); |
| 334 | + } else { |
| 335 | + $top = $defaultBar; |
| 336 | + } |
| 337 | + if ( $customBottom ) { |
| 338 | + $bottom = wfMsgExt( $customBottom, $opt, $prev, $prevtext, $base, $basetext, $next, $nexttext ); |
| 339 | + } else { |
| 340 | + $bottom = $defaultBar; |
| 341 | + } |
| 342 | + # Adds navigation before and after the page text |
| 343 | + $text = "<div>$top</div>\n$text\n<div>$bottom</div>"; |
| 344 | + return true; |
| 345 | + } |
| 346 | + # adds CSS and JS to navigation bar |
343 | 347 | static function injectStyleAndJS( &$out, &$sk ) { |
344 | | - $out->addModuleStyles('ext.BookManager'); |
345 | | - $out->addModules( 'ext.BookManager'); |
| 348 | + $out->addModuleStyles( 'ext.BookManager' ); |
| 349 | + $out->addModules( 'ext.BookManager' ); |
346 | 350 | return true; |
347 | 351 | } |
348 | 352 | } |
349 | | - |
Index: trunk/extensions/BookManager/BookManager.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | if ( !defined( 'MEDIAWIKI' ) ) { |
37 | 37 | die( 'This file is a MediaWiki extension, it is not a valid entry point' ); |
38 | 38 | } |
39 | | -$dir = dirname( __FILE__ ); |
| 39 | +$dir = dirname( __FILE__ ); |
40 | 40 | $wgAutoloadClasses['BookManagerFunctions'] = $dir . '/BookManager.body.php'; |
41 | 41 | |
42 | 42 | /**** extension basics ****/ |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | 'path' => __FILE__, |
45 | 45 | 'name' => 'BookManager', |
46 | 46 | 'version' => BookManagerFunctions::VERSION, |
47 | | - 'author' => array('Raylton P. Sousa', 'Helder.wiki'), |
| 47 | + 'author' => array( 'Raylton P. Sousa', 'Helder.wiki' ), |
48 | 48 | 'url' => 'http://www.mediawiki.org/wiki/Extension:BookManager', |
49 | 49 | 'description' => 'Tools for books', |
50 | 50 | ); |
— | — | @@ -52,12 +52,12 @@ |
53 | 53 | 'scripts' => 'bookmanager.js', |
54 | 54 | 'styles' => 'bookmanager.css', |
55 | 55 | 'messages' => array( 'BookManager', 'BookManager-top', 'BookManager-bottom' ), |
56 | | - 'dependencies' => array( 'jquery', 'mediawiki.util'), |
| 56 | + 'dependencies' => array( 'jquery', 'mediawiki.util' ), |
57 | 57 | 'localBasePath' => $dir, |
58 | 58 | 'remoteExtPath' => 'BookManager' |
59 | 59 | ); |
60 | | -$wgBookManagerNamespaces = array( NS_MAIN ); |
61 | | -$wgBookManagerNavbar = true; |
| 60 | +$wgBookManagerNamespaces = array( NS_MAIN ); |
| 61 | +$wgBookManagerNavBar = true; |
62 | 62 | /* Copyied from extensions/Collection/Collection.php */ |
63 | 63 | /** Namespace for "community books" */ |
64 | 64 | $wgCommunityCollectionNamespace = NS_PROJECT; |
— | — | @@ -75,3 +75,4 @@ |
76 | 76 | |
77 | 77 | $wgHooks['BeforePageDisplay'][] = 'BookManagerFunctions::injectStyleAndJS'; |
78 | 78 | |
| 79 | + |