X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLicenses.php;h=4d2229f0a084793d99b544635d4dc4ba48bc5635;hb=e2e6b161239ece68d1f95a0d548c0498b324b8ba;hp=c498a5786221cc5004681ca4640bb9da22d78183;hpb=ad8b234b1bf30dc342284b1a8fc39a4b27ce0840;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Licenses.php b/includes/Licenses.php index c498a57862..4d2229f0a0 100644 --- a/includes/Licenses.php +++ b/includes/Licenses.php @@ -52,7 +52,7 @@ class Licenses extends HTMLFormField { public function __construct( $params ) { parent::__construct( $params ); - $this->msg = empty( $params['licenses'] ) ? wfMsgForContent( 'licenses' ) : $params['licenses']; + $this->msg = empty( $params['licenses'] ) ? wfMessage( 'licenses' )->inContentLanguage()->plain() : $params['licenses']; $this->selected = null; $this->makeLicenses(); @@ -117,10 +117,10 @@ class Licenses extends HTMLFormField { * @param $depth int */ protected function makeHtml( $tagset, $depth = 0 ) { - foreach ( $tagset as $key => $val ) + foreach ( $tagset as $key => $val ) { if ( is_array( $val ) ) { $this->html .= $this->outputOption( - $this->msg( $key ), '', + $key, '', array( 'disabled' => 'disabled', 'style' => 'color: GrayText', // for MSIE @@ -130,37 +130,33 @@ class Licenses extends HTMLFormField { $this->makeHtml( $val, $depth + 1 ); } else { $this->html .= $this->outputOption( - $this->msg( $val->text ), $val->template, + $val->text, $val->template, array( 'title' => '{{' . $val->template . '}}' ), $depth ); } + } } /** - * @param $text + * @param $message * @param $value * @param $attribs null * @param $depth int * @return string */ - protected function outputOption( $text, $value, $attribs = null, $depth = 0 ) { + protected function outputOption( $message, $value, $attribs = null, $depth = 0 ) { + $msgObj = $this->msg( $message ); + $text = $msgObj->exists() ? $msgObj->text() : $message; $attribs['value'] = $value; - if ( $value === $this->selected ) + if ( $value === $this->selected ) { $attribs['selected'] = 'selected'; + } + $val = str_repeat( /*   */ "\xc2\xa0", $depth * 2 ) . $text; return str_repeat( "\t", $depth ) . Xml::element( 'option', $attribs, $val ) . "\n"; } - /** - * @param $str string - * @return String - */ - protected function msg( $str ) { - $msg = wfMessage( $str ); - return $msg->exists() ? $msg->text() : $str; - } - /**#@-*/ /** @@ -182,7 +178,7 @@ class Licenses extends HTMLFormField { public function getInputHTML( $value ) { $this->selected = $value; - $this->html = $this->outputOption( wfMsg( 'nolicense' ), '', + $this->html = $this->outputOption( wfMessage( 'nolicense' )->text(), '', (bool)$this->selected ? null : array( 'selected' => 'selected' ) ); $this->makeHtml( $this->getLicenses() );