2019-04-08 17:08:57 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MediaWiki\Minerva\Menu\Main;
|
|
|
|
|
|
|
|
use FatalError;
|
2019-07-22 20:58:34 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Definitions;
|
2019-04-08 17:08:57 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Group;
|
2020-01-26 19:26:31 +00:00
|
|
|
use MWException;
|
2019-04-08 17:08:57 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A menu builder that provides additional menu entries that match
|
|
|
|
* Advanced Mobile Contributions project requirements. This menu
|
|
|
|
* is used when AMC SkinOption flag is set to true.
|
|
|
|
*
|
|
|
|
* @package MediaWiki\Minerva\Menu\Main
|
|
|
|
*/
|
2019-08-02 09:00:18 +00:00
|
|
|
final class AdvancedMainMenuBuilder implements IMainMenuBuilder {
|
2019-07-22 20:58:34 +00:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
private $showMobileOptions;
|
|
|
|
|
2020-06-25 21:06:46 +00:00
|
|
|
/**
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
private $showDonateLink;
|
|
|
|
|
2019-07-22 20:58:34 +00:00
|
|
|
/**
|
|
|
|
* @var Definitions
|
|
|
|
*/
|
|
|
|
private $definitions;
|
2019-04-08 17:08:57 +00:00
|
|
|
|
|
|
|
/**
|
2019-07-22 20:58:34 +00:00
|
|
|
* Initialize the Default Main Menu builder
|
|
|
|
*
|
|
|
|
* @param bool $showMobileOptions Show MobileOptions instead of Preferences
|
2020-06-25 21:06:46 +00:00
|
|
|
* @param bool $showDonateLink whether to show the donate link
|
2019-07-22 20:58:34 +00:00
|
|
|
* @param Definitions $definitions A menu items definitions set
|
|
|
|
*/
|
2021-12-17 17:16:49 +00:00
|
|
|
public function __construct( $showMobileOptions, $showDonateLink, Definitions $definitions ) {
|
2019-07-22 20:58:34 +00:00
|
|
|
$this->showMobileOptions = $showMobileOptions;
|
2020-06-25 21:06:46 +00:00
|
|
|
$this->showDonateLink = $showDonateLink;
|
2019-07-22 20:58:34 +00:00
|
|
|
$this->definitions = $definitions;
|
|
|
|
}
|
|
|
|
|
2022-05-12 17:58:08 +00:00
|
|
|
/**
|
|
|
|
* @return Group
|
|
|
|
*/
|
|
|
|
public function getSettingsGroup(): Group {
|
|
|
|
return new Group( 'pt-preferences' );
|
|
|
|
}
|
|
|
|
|
2019-07-22 20:58:34 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
2019-04-08 17:08:57 +00:00
|
|
|
*/
|
2022-01-13 00:38:16 +00:00
|
|
|
public function getPersonalToolsGroup( array $personalTools ): Group {
|
|
|
|
return BuilderUtil::getConfigurationTools( $this->definitions, $this->showMobileOptions );
|
|
|
|
}
|
2020-06-25 21:06:46 +00:00
|
|
|
|
2022-01-13 00:38:16 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2022-01-18 23:36:30 +00:00
|
|
|
public function getDiscoveryGroup( array $navigationTools ): Group {
|
|
|
|
return BuilderUtil::getDiscoveryTools( $this->definitions, $navigationTools );
|
2022-01-13 00:38:16 +00:00
|
|
|
}
|
2020-06-25 21:06:46 +00:00
|
|
|
|
2022-01-13 00:38:16 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getDonateGroup(): Group {
|
|
|
|
return BuilderUtil::getDonateGroup( $this->definitions, $this->showDonateLink );
|
2019-04-08 17:08:57 +00:00
|
|
|
}
|
|
|
|
|
2019-07-22 20:58:34 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
* @throws FatalError
|
|
|
|
* @throws MWException
|
|
|
|
*/
|
|
|
|
public function getSiteLinks(): Group {
|
|
|
|
return BuilderUtil::getSiteLinks( $this->definitions );
|
|
|
|
}
|
|
|
|
|
2019-04-08 17:08:57 +00:00
|
|
|
/**
|
|
|
|
* Prepares a list of links that have the purpose of discovery in the main navigation menu
|
|
|
|
* @return Group
|
|
|
|
* @throws FatalError
|
|
|
|
* @throws MWException
|
|
|
|
*/
|
2022-01-13 00:38:16 +00:00
|
|
|
public function getInteractionToolsGroup(): Group {
|
2019-10-23 18:30:55 +00:00
|
|
|
$group = new Group( 'p-interaction' );
|
2019-04-08 17:08:57 +00:00
|
|
|
|
2019-07-30 17:27:34 +00:00
|
|
|
$this->definitions->insertRecentChanges( $group );
|
2019-04-08 17:08:57 +00:00
|
|
|
$this->definitions->insertSpecialPages( $group );
|
|
|
|
$this->definitions->insertCommunityPortal( $group );
|
|
|
|
|
|
|
|
return $group;
|
|
|
|
}
|
|
|
|
}
|