r88109 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88108‎ | r88109 | r88110 >
Date:16:54, 14 May 2011
Author:freakolowsky
Status:ok (Comments)
Tags:
Comment:
discussion with hashar
* moved getInfoBox into Xml.php as infoBox static method
* moved config-infobox* css classes from config to mw-infobox* in shared
* left getInfoBox as a wrapper in the installer
Modified paths:
  • /trunk/phase3/includes/Xml.php (modified) (history)
  • /trunk/phase3/includes/installer/WebInstaller.php (modified) (history)
  • /trunk/phase3/skins/common/config.css (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/common/config.css
@@ -72,22 +72,6 @@
7373 clear: left;
7474 }
7575
76 -.config-warning-box {
77 - border: 2px solid #ff7f00;
78 - margin: 0.4em;
79 - clear: left;
80 -}
81 -
82 -.config-info-left {
83 - margin: 7px;
84 - float: left;
85 - width: 35px;
86 -}
87 -
88 -.config-info-right {
89 - margin: 0.5em 0.5em 0.5em 49px;
90 -}
91 -
9276 .config-page-current {
9377 font-weight: bold;
9478 }
@@ -161,4 +145,4 @@
162146
163147 #config-live-log {
164148 width: 70%;
165 -}
\ No newline at end of file
 149+}
Index: trunk/phase3/skins/common/shared.css
@@ -361,6 +361,23 @@
362362 border: none;
363363 }
364364
 365+/* general info/warning box for SP */
 366+.mw-infobox {
 367+ border: 2px solid #ff7f00;
 368+ margin: 0.4em;
 369+ clear: left;
 370+}
 371+
 372+.mw-infobox-left {
 373+ margin: 7px;
 374+ float: left;
 375+ width: 35px;
 376+}
 377+
 378+.mw-infobox-right {
 379+ margin: 0.5em 0.5em 0.5em 49px;
 380+}
 381+
365382 /* Note on preview page */
366383 .previewnote {
367384 color: #c00;
Index: trunk/phase3/includes/Xml.php
@@ -765,6 +765,47 @@
766766 $s .= Xml::closeElement( 'tr' );
767767 return $s;
768768 }
 769+
 770+ /**
 771+ * Get HTML for an info box with an icon.
 772+ *
 773+ * @param $text String: wikitext, get this with wfMsgNoTrans()
 774+ * @param $icon String: icon name, file in skins/common/images
 775+ * @param $alt String: alternate text for the icon
 776+ * @param $class String: additional class name to add to the wrapper div
 777+ *
 778+ * @return string
 779+ */
 780+ static function infoBox( $text, $icon, $alt, $class = false, $useStypePath = true ) {
 781+ global $wgStylePath;
 782+
 783+ if ( $useStypePath ) {
 784+ $icon = $wgStylePath.'/common/images/'.$icon;
 785+ }
 786+
 787+
 788+ $s = Xml::openElement( 'div', array( 'class' => "mw-infobox $class") );
 789+
 790+ $s .= Xml::openElement( 'div', array( 'class' => 'mw-infobox-left' ) ).
 791+ Html::element( 'img',
 792+ array(
 793+ 'src' => $icon,
 794+ 'alt' => $alt,
 795+ )
 796+ ).
 797+ Xml::closeElement( 'div' );
 798+
 799+ $s .= Xml::openElement( 'div', array( 'class' => 'mw-infobox-right' ) ).
 800+ $text.
 801+ Xml::closeElement( 'div' );
 802+ $s .= Xml::element( 'div', array( 'style' => 'clear: left;' ), ' ' );
 803+
 804+ $s .= Xml::closeElement( 'div' );
 805+
 806+ $s .= Xml::element( 'div', array( 'style' => 'clear: left;' ), ' ' );
 807+
 808+ return $s;
 809+ }
769810 }
770811
771812 class XmlSelect {
Index: trunk/phase3/includes/installer/WebInstaller.php
@@ -611,23 +611,11 @@
612612 *
613613 * @return string
614614 */
615 - public function getInfoBox( $text, $icon = 'info-32.png', $class = false ) {
616 - $s =
617 - "<div class=\"config-info $class\">\n" .
618 - "<div class=\"config-info-left\">\n" .
619 - Html::element( 'img',
620 - array(
621 - 'src' => '../skins/common/images/' . $icon,
622 - 'alt' => wfMsg( 'config-information' ),
623 - )
624 - ) . "\n" .
625 - "</div>\n" .
626 - "<div class=\"config-info-right\">\n" .
627 - $this->parse( $text, true ) . "\n" .
628 - "</div>\n" .
629 - "<div style=\"clear: left;\"></div>\n" .
630 - "</div>\n";
631 - return $s;
 615+ public function getInfoBox( $text, $icon = false, $class = false ) {
 616+ $text = $this->parse( $text, true );
 617+ $icon = ( $icon == false ) ? '../skins/common/images/info-32.png' : '../skins/common/images/'.$icon;
 618+ $alt = wfMsg( 'config-information' );
 619+ return Xml::infoBox( $text, $icon, $alt, $class, false );
632620 }
633621
634622 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r88137* fixed typofreakolowsky09:20, 15 May 2011
r89260* moved infobox to Html (r88109#c16937)freakolowsky13:57, 1 June 2011
r89380Move fixes for config-error-box to mw-infobox in order to apply for warnings ...krinkle02:26, 3 June 2011

Comments

#Comment by Nikerabbit (talk | contribs)   05:54, 15 May 2011

Wouldn't Html class make even more sense?

#Comment by Krinkle (talk | contribs)   07:31, 15 May 2011
+	static function infoBox( [...], $useStypePath = true ) {
+		
+		if ( $useStypePath ) {

Typo ;-)


* moved config-infobox* css classes from config to mw-infobox* in shared
+/* general info/warning box for SP */
+.mw-infobox {

What is SP and is/would/should this be used in articles/skin ? (since it's in shared now..)

#Comment by Freakolowsky (talk | contribs)   08:48, 15 May 2011

@Nikerabbit: not really. Most of the UI stuff like that is in Xml class. Will check with hashar. @Krinkle: SP = SpecialPage. This function is mostly meant for use in special pages. I don't see much use for it in articles, but is good to have some simple way of exposing/warning about tricky parameters and expensive functionality.

#Comment by Nikerabbit (talk | contribs)   09:05, 15 May 2011

They were added before Html class was created.

#Comment by Hashar (talk | contribs)   17:55, 15 May 2011

Freakolowsky > you might actually want to move those methods from Xml to the Html class.

Status & tagging log