2014-05-22 07:33:40 +00:00
|
|
|
<?php
|
2018-04-11 01:29:26 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2014-05-22 07:33:40 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A proxy class that routes a special page to other special pages based on
|
|
|
|
* request parameters
|
|
|
|
*/
|
|
|
|
abstract class ProxySpecialPage extends SpecialPage {
|
|
|
|
/**
|
|
|
|
* @var SpecialPage|null Target page to execute
|
|
|
|
*/
|
|
|
|
private $target = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Instantiate a SpecialPage based on request parameters
|
|
|
|
*
|
|
|
|
* The page returned by this function will be cached and used as
|
|
|
|
* the target page for this proxy object.
|
|
|
|
*
|
|
|
|
* @return SpecialPage
|
|
|
|
*/
|
|
|
|
abstract protected function getTargetPage();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function that initializes the target SpecialPage object
|
|
|
|
*/
|
|
|
|
private function init() {
|
|
|
|
if ( $this->target === null ) {
|
|
|
|
$this->target = $this->getTargetPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Magic function that proxies function calls to the target object
|
|
|
|
*
|
|
|
|
* @param string $method Method name being called
|
|
|
|
* @param array $args Array of arguments
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function __call( $method, $args ) {
|
|
|
|
$this->init();
|
2016-09-16 23:18:35 +00:00
|
|
|
return call_user_func_array( [ $this->target, $method ], $args );
|
2014-05-22 07:33:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function getName() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|bool $subpage
|
|
|
|
* @return Title
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function getPageTitle( $subpage = false ) {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->getPageTitle( $subpage );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function getLocalName() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->getLocalName();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function getRestriction() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->getRestriction();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function isListed() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->isListed();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param bool $listed
|
|
|
|
* @return bool
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function setListed( $listed ) {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->setListed( $listed );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-26 05:10:39 +00:00
|
|
|
* @param bool|null $x
|
2014-05-22 07:33:40 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function listed( $x = null ) {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->listed( $x );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isIncludable() {
|
|
|
|
$this->init();
|
|
|
|
return $this->target->isIncludable();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-05-26 05:10:39 +00:00
|
|
|
* @param bool|null $x
|
2014-05-22 07:33:40 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function including( $x = null ) {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->including( $x );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function isRestricted() {
|
|
|
|
$this->init();
|
|
|
|
return $this->target->isRestricted();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function userCanExecute( User $user ) {
|
|
|
|
$this->init();
|
|
|
|
return $this->target->userCanExecute( $user );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws PermissionsError
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function displayRestrictionError() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
$this->target->displayRestrictionError();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return void
|
|
|
|
* @throws PermissionsError
|
|
|
|
*/
|
|
|
|
public function checkPermissions() {
|
|
|
|
$this->init();
|
|
|
|
$this->target->checkPermissions();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $subPage
|
|
|
|
*/
|
|
|
|
protected function beforeExecute( $subPage ) {
|
|
|
|
$this->init();
|
|
|
|
$this->target->beforeExecute( $subPage );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $subPage
|
|
|
|
*/
|
|
|
|
protected function afterExecute( $subPage ) {
|
|
|
|
$this->init();
|
|
|
|
$this->target->afterExecute( $subPage );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string|null $subPage
|
|
|
|
*/
|
|
|
|
public function execute( $subPage ) {
|
|
|
|
$this->init();
|
|
|
|
$this->target->execute( $subPage );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
2018-11-02 10:26:41 +00:00
|
|
|
public function getDescription() {
|
2014-05-22 07:33:40 +00:00
|
|
|
$this->init();
|
|
|
|
return $this->target->getDescription();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param IContextSource $context
|
|
|
|
*/
|
|
|
|
public function setContext( $context ) {
|
|
|
|
$this->init();
|
|
|
|
$this->target->setContext( $context );
|
|
|
|
parent::setContext( $context );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getRobotPolicy() {
|
|
|
|
$this->init();
|
|
|
|
return $this->target->getRobotPolicy();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
protected function getGroupName() {
|
|
|
|
$this->init();
|
|
|
|
return $this->target->getGroupName();
|
|
|
|
}
|
|
|
|
}
|