Added new success message when CLI Installer completes its work succesfuly.
[lhc/web/wiklou.git] / includes / ListToggle.php
1 <?php
2 /**
3 * Class for generating clickable toggle links for a list of checkboxes.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 */
22
23 /**
24 * Class for generating clickable toggle links for a list of checkboxes.
25 *
26 * This is only supported on clients that have JavaScript enabled; it is hidden
27 * for clients that have it disabled.
28 *
29 * @since 1.27
30 */
31 class ListToggle {
32 /** @var OutputPage */
33 private $output;
34
35 public function __construct( OutputPage $output ) {
36 $this->output = $output;
37
38 $output->addModules( 'mediawiki.checkboxtoggle' );
39 $output->addModuleStyles( 'mediawiki.checkboxtoggle.styles' );
40 }
41
42 private function checkboxLink( $checkboxType ) {
43 return Html::element(
44 // CSS classes: mw-checkbox-all, mw-checkbox-none, mw-checkbox-invert
45 'a', [ 'class' => 'mw-checkbox-' . $checkboxType, 'role' => 'button', 'tabindex' => 0 ],
46 $this->output->msg( 'checkbox-' . $checkboxType )->text()
47 );
48 }
49
50 /**
51 * @return string
52 */
53 public function getHTML() {
54 // Select: All, None, Invert
55 $links = [
56 $this->checkboxLink( 'all' ),
57 $this->checkboxLink( 'none' ),
58 $this->checkboxLink( 'invert' ),
59 ];
60
61 return Html::rawElement( 'div',
62 [
63 'class' => 'mw-checkbox-toggle-controls'
64 ],
65 $this->output->msg( 'checkbox-select' )
66 ->rawParams( $this->output->getLanguage()->commaList( $links ) )->escaped()
67 );
68 }
69 }