r18903 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r18902‎ | r18903 | r18904 >
Date:02:15, 7 January 2007
Author:hashar
Status:old
Tags:
Comment:
New way to display the extensions and hooks. Pending css tweaking.
Modified paths:
  • /trunk/phase3/includes/SpecialVersion.php (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/monobook/main.css
@@ -1513,6 +1513,29 @@
15141514 text-align: center;
15151515 }
15161516
 1517+/** Special:Version */
 1518+
 1519+table#sv-ext, table#sv-hooks {
 1520+ margin: 1em;
 1521+ padding:0em;
 1522+}
 1523+
 1524+#sv-ext td, #sv-hooks td,
 1525+#sv-ext th, #sv-hooks th {
 1526+ border: 1px solid #A0A0A0;
 1527+ padding: 0 0.15em 0 0.15em;
 1528+}
 1529+#sv-ext th, #sv-hooks th {
 1530+ background-color: #F0F0F0;
 1531+ color: black;
 1532+ padding: 0 0.15em 0 0.15em;
 1533+}
 1534+tr.sv-space{
 1535+ height: 0.8em;
 1536+ border:none;
 1537+}
 1538+tr.sv-space td { display: none; }
 1539+
15171540 /*
15181541 Table pager (e.g. Special:Imagelist)
15191542 - remove underlines from the navigation link
@@ -1543,4 +1566,4 @@
15441567 }
15451568 #toolbar { clear: both; }
15461569
1547 -.mw-plusminus-null { color: #aaa; }
\ No newline at end of file
 1570+.mw-plusminus-null { color: #aaa; }
Index: trunk/phase3/includes/SpecialVersion.php
@@ -21,6 +21,8 @@
2222 }
2323
2424 class SpecialVersion {
 25+ private $firstExtOpened = true;
 26+
2527 /**
2628 * main()
2729 */
@@ -79,7 +81,7 @@
8082 * [http://www.php.net/ PHP]: " . phpversion() . " (" . php_sapi_name() . ")
8183 * " . $dbr->getSoftwareLink() . ": " . $dbr->getServerVersion();
8284
83 - return str_replace( "\t\t", '', $ret );
 85+ return str_replace( "\t\t", '', $ret ) . "\n";
8486 }
8587
8688 /** Return a string of the MediaWiki version with SVN revision if available */
@@ -104,10 +106,12 @@
105107 );
106108 wfRunHooks( 'SpecialVersionExtensionTypes', array( &$this, &$extensionTypes ) );
107109
108 - $out = "\n* Extensions:\n";
 110+ $out = "<h2>Extensions</h2>\n";
 111+ $out .= wfOpenElement('table', array('id' => 'sv-ext') );
 112+
109113 foreach ( $extensionTypes as $type => $text ) {
110114 if ( count( @$wgExtensionCredits[$type] ) ) {
111 - $out .= "** $text:\n";
 115+ $out .= $this->openExtType( $text );
112116
113117 usort( $wgExtensionCredits[$type], array( $this, 'compare' ) );
114118
@@ -126,27 +130,27 @@
127131 }
128132
129133 if ( count( $wgExtensionFunctions ) ) {
130 - $out .= "** Extension functions:\n";
131 - $out .= '***' . $this->listToText( $wgExtensionFunctions ) . "\n";
 134+ $out .= $this->openExtType('Extension functions');
 135+ $out .= '<tr><td colspan="3">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n";
132136 }
133137
134138 if ( $cnt = count( $tags = $wgParser->getTags() ) ) {
135139 for ( $i = 0; $i < $cnt; ++$i )
136140 $tags[$i] = "&lt;{$tags[$i]}&gt;";
137 - $out .= "** Parser extension tags:\n";
138 - $out .= '***' . $this->listToText( $tags ). "\n";
 141+ $out .= $this->openExtType('Parser extension tags');
 142+ $out .= '<tr><td colspan="3">' . $this->listToText( $tags ). "</td></tr>\n";
139143 }
140144
141145 if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) {
142 - $out .= "** Parser function hooks:\n";
143 - $out .= '***' . $this->listToText( $fhooks ) . "\n";
 146+ $out .= $this->openExtType('Parser function hooks');
 147+ $out .= '<tr><td colspan="3">' . $this->listToText( $fhooks ) . "</td></tr>\n";
144148 }
145149
146150 if ( count( $wgSkinExtensionFunction ) ) {
147 - $out .= "** Skin extension functions:\n";
148 - $out .= '***' . $this->listToText( $wgSkinExtensionFunction ) . "\n";
 151+ $out .= $this->openExtType('Skin extension functions');
 152+ $out .= '<tr><td colspan="3">' . $this->listToText( $wgSkinExtensionFunction ) . "</td></tr>\n";
149153 }
150 -
 154+ $out .= wfCloseElement( 'table' );
151155 return $out;
152156 }
153157
@@ -159,7 +163,7 @@
160164 }
161165
162166 function formatCredits( $name, $version = null, $author = null, $url = null, $description = null) {
163 - $ret = '*** ';
 167+ $ret = '<tr><td>';
164168 if ( isset( $url ) )
165169 $ret .= "[$url ";
166170 $ret .= "''$name";
@@ -168,13 +172,10 @@
169173 $ret .= "''";
170174 if ( isset( $url ) )
171175 $ret .= ']';
172 - if ( isset( $description ) )
173 - $ret .= ', ' . $description;
174 - if ( isset( $description ) && isset( $author ) )
175 - $ret .= ', ';
176 - if ( isset( $author ) )
177 - $ret .= ' by ' . $this->listToText( (array)$author );
178 -
 176+ $ret .= '</td>';
 177+ $ret .= "<td>$description</td>";
 178+ $ret .= "<td>" . $this->listToText( (array)$author ) . "</td>";
 179+ $ret .= '</tr>';
179180 return "$ret\n";
180181 }
181182
@@ -188,15 +189,34 @@
189190 $myWgHooks = $wgHooks;
190191 ksort( $myWgHooks );
191192
192 - $ret = "* Hooks:\n";
 193+ $ret = "<h2>Hooks</h2>\n"
 194+ . wfOpenElement('table', array('id' => 'sv-hooks') )
 195+ . "<tr><th>Hook name</th><th>Subscribed by</th></tr>\n";
 196+
193197 foreach ($myWgHooks as $hook => $hooks)
194 - $ret .= "** $hook: " . $this->listToText( $hooks ) . "\n";
 198+ $ret .= "<tr><td>$hook</td><td>" . $this->listToText( $hooks ) . "</td></tr>\n";
195199
196200 return $ret;
197201 } else
198202 return '';
199203 }
200204
 205+ private function openExtType($text, $name = null) {
 206+ $opt = array( 'colspan' => 3 );
 207+ $out = '';
 208+
 209+ if(!$this->firstExtOpened) {
 210+ // Insert a spacing line
 211+ $out .= '<tr class="sv-space">' . wfElement( 'td', $opt ) . "</tr>\n";
 212+ }
 213+ $this->firstExtOpened = false;
 214+
 215+ if($name) { $opt['id'] = "sv-$name"; }
 216+
 217+ $out .= "<tr>" . wfElement( 'th', $opt, $text) . "</tr>\n";
 218+ return $out;
 219+ }
 220+
201221 /**
202222 * @static
203223 *