Index: branches/Gadgets-work/Gadgets_body.php |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | } |
206 | 206 | |
207 | 207 | public function getScriptsAndStyles() { |
208 | | - return $this->scripts + $this->styles; |
| 208 | + return array_merge( $this->scripts, $this->styles ); |
209 | 209 | } |
210 | 210 | |
211 | 211 | public function getModule() { |
Index: branches/Gadgets-work/SpecialGadgets.php |
— | — | @@ -51,7 +51,7 @@ |
52 | 52 | $wgOut->setPagetitle( wfMsg( "gadgets-title" ) ); |
53 | 53 | $wgOut->addWikiMsg( 'gadgets-pagetext' ); |
54 | 54 | |
55 | | - $gadgets = wfLoadGadgetsStructured(); |
| 55 | + $gadgets = Gadget::loadStructuredList(); |
56 | 56 | if ( !$gadgets ) return; |
57 | 57 | |
58 | 58 | $lang = ""; |
— | — | @@ -84,17 +84,17 @@ |
85 | 85 | $wgOut->addHTML( Html::rawElement( 'h2', array(), $ttext . $lnk ) . "\n" ); |
86 | 86 | } |
87 | 87 | |
88 | | - foreach ( $entries as $gname => $code ) { |
89 | | - $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$gname$lang" ); |
| 88 | + foreach ( $entries as $gadget ) { |
| 89 | + $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$gadget->getName()}$lang" ); |
90 | 90 | if ( !$t ) continue; |
91 | 91 | |
92 | 92 | $links = array(); |
93 | 93 | if ( $editInterfaceAllowed ) { |
94 | 94 | $links[] = $skin->link( $t, wfMsgHTML( 'edit' ), array(), array( 'action' => 'edit' ) ); |
95 | 95 | } |
96 | | - $links[] = $skin->link( $this->getTitle( "export/$gname" ), wfMsgHtml( 'gadgets-export' ) ); |
| 96 | + $links[] = $skin->link( $this->getTitle( "export/{$gadget->getName()}" ), wfMsgHtml( 'gadgets-export' ) ); |
97 | 97 | |
98 | | - $ttext = wfMsgExt( "gadget-$gname", $msgOpt ); |
| 98 | + $ttext = wfMsgExt( "gadget-{$gadget->getName()}", $msgOpt ); |
99 | 99 | |
100 | 100 | if( !$listOpen ) { |
101 | 101 | $listOpen = true; |
— | — | @@ -107,8 +107,8 @@ |
108 | 108 | ); |
109 | 109 | |
110 | 110 | $lnk = array(); |
111 | | - foreach ( $code as $codePage ) { |
112 | | - $t = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-$codePage" ); |
| 111 | + foreach ( $gadget->getScriptsAndStyles() as $codePage ) { |
| 112 | + $t = Title::makeTitleSafe( NS_MEDIAWIKI, $codePage ); |
113 | 113 | if ( !$t ) continue; |
114 | 114 | |
115 | 115 | $lnk[] = $skin->link( $t, htmlspecialchars( $t->getText() ) ); |
— | — | @@ -123,6 +123,10 @@ |
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
| 127 | + private static function stripName( $name ) { |
| 128 | + return preg_replace( '/Gadget-/i', '', $name ); |
| 129 | + } |
| 130 | + |
127 | 131 | /** |
128 | 132 | * Exports a gadget with its dependencies in a serialized form |
129 | 133 | * @param $gadget String Name of gadget to export |
— | — | @@ -130,20 +134,23 @@ |
131 | 135 | public function showExportForm( $gadget ) { |
132 | 136 | global $wgOut, $wgScript; |
133 | 137 | |
134 | | - $gadgets = wfLoadGadgets(); |
| 138 | + $gadgets = Gadget::loadList(); |
135 | 139 | if ( !isset( $gadgets[$gadget] ) ) { |
136 | 140 | $wgOut->showErrorPage( 'error', 'gadgets-not-found', array( $gadget ) ); |
137 | 141 | return; |
138 | 142 | } |
139 | 143 | |
140 | | - $ourDefinition = "* $gadget|" . implode('|', $gadgets[$gadget] ); |
| 144 | + $g = $gadgets[$gadget]; |
| 145 | + $pages = $g->getScriptsAndStyles(); |
| 146 | + $pages = array_map( 'SpecialGadgets::stripName', $pages ); |
| 147 | + $ourDefinition = "* $gadget|" . implode('|', $pages ); |
141 | 148 | $this->setHeaders(); |
142 | 149 | $wgOut->setPagetitle( wfMsg( "gadgets-export-title" ) ); |
143 | 150 | $wgOut->addWikiMsg( 'gadgets-export-text', $gadget, $ourDefinition ); |
144 | 151 | |
145 | 152 | $exportList = "MediaWiki:gadget-$gadget\n"; |
146 | | - foreach ( $gadgets[$gadget] as $page ) { |
147 | | - $exportList .= "MediaWiki:gadget-$page\n"; |
| 153 | + foreach ( $g->getScriptsAndStyles() as $page ) { |
| 154 | + $exportList .= "MediaWiki:$page\n"; |
148 | 155 | } |
149 | 156 | |
150 | 157 | $wgOut->addHTML( Html::openElement( 'form', array( 'method' => 'GET', 'action' => $wgScript ) ) |