2015-09-01 15:10:02 +00:00
|
|
|
<?php
|
2015-09-07 13:00:00 +00:00
|
|
|
|
2015-09-01 15:10:02 +00:00
|
|
|
/**
|
|
|
|
* Class WikiaMapsSpecialController
|
|
|
|
* @desc Special:Maps controller
|
|
|
|
*/
|
|
|
|
class PortableInfoboxBuilderSpecialController extends WikiaSpecialPageController {
|
|
|
|
const PAGE_NAME = 'PortableInfoboxBuilder';
|
|
|
|
const PAGE_RESTRICTION = 'editinterface';
|
|
|
|
const INFOBOX_BUILDER_MERCURY_ROUTE = 'infoboxBuilder';
|
2015-09-07 13:00:00 +00:00
|
|
|
const PATH_SEPARATOR = '/';
|
|
|
|
const EXPLODE_LIMIT = 2;
|
2015-09-01 15:10:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Special page constructor
|
|
|
|
*
|
|
|
|
* @param null $name
|
|
|
|
* @param string $restriction
|
|
|
|
* @param bool $listed
|
|
|
|
* @param bool $function
|
|
|
|
* @param string $file
|
|
|
|
* @param bool $includable
|
|
|
|
*/
|
|
|
|
public function __construct( $name = null, $restriction = '', $listed = true, $function = false, $file = 'default', $includable = false ) {
|
|
|
|
parent::__construct( self::PAGE_NAME, self::PAGE_RESTRICTION, $listed, $function, $file, $includable );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Infobox Builder special page
|
|
|
|
*/
|
|
|
|
public function index() {
|
|
|
|
$this->wg->SuppressPageHeader = true;
|
2015-09-07 10:46:00 +00:00
|
|
|
$this->wg->out->setHTMLTitle( wfMessage( 'portable-infobox-builder-title' )->text() );
|
2015-09-01 15:10:02 +00:00
|
|
|
|
2015-09-07 13:00:00 +00:00
|
|
|
// extract base title from path
|
|
|
|
$title = explode( self::PATH_SEPARATOR, $this->getPar(), self::EXPLODE_LIMIT )[0];
|
2015-09-02 11:02:33 +00:00
|
|
|
$noTemplateSet = empty( $title ) ? true : false;
|
|
|
|
|
|
|
|
if ( $noTemplateSet ) {
|
2015-09-07 13:00:00 +00:00
|
|
|
$this->response->setVal( 'noTemplateSet', true );
|
|
|
|
$this->response->setVal( 'setTemplateNameCallToAction', wfMessage(
|
2015-09-03 14:00:53 +00:00
|
|
|
'portable-infobox-builder-no-template-title-set' )->text() );
|
2015-09-02 11:02:33 +00:00
|
|
|
} else {
|
2015-09-07 13:00:00 +00:00
|
|
|
$url = implode( self::PATH_SEPARATOR, [ $this->wg->server, self::INFOBOX_BUILDER_MERCURY_ROUTE, $title ] );
|
2015-09-02 11:02:33 +00:00
|
|
|
$this->response->setVal( 'iframeUrl', $url );
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response->setTemplateEngine( WikiaResponse::TEMPLATE_ENGINE_MUSTACHE );
|
|
|
|
}
|
|
|
|
|
2015-09-02 11:06:31 +00:00
|
|
|
/**
|
|
|
|
* renders HTML for create new template page entry point
|
|
|
|
*/
|
2015-09-02 11:02:33 +00:00
|
|
|
public function renderCreateTemplateEntryPoint() {
|
|
|
|
$this->response->setVal( 'createInfobox', wfMessage(
|
2015-09-03 14:00:53 +00:00
|
|
|
'portable-infobox-builder-create-template-entry-point-create-infobox' )->text() );
|
2015-09-02 11:02:33 +00:00
|
|
|
$this->response->setVal( 'createTemplate', wfMessage(
|
2015-09-03 14:00:53 +00:00
|
|
|
'portable-infobox-builder-create-template-entry-point-create-regular-template' )->text() );
|
2015-09-07 13:00:00 +00:00
|
|
|
$this->response->setVal( 'title', $this->request->getVal( 'title' ), '' );
|
2015-09-01 15:10:02 +00:00
|
|
|
|
|
|
|
$this->response->setTemplateEngine( WikiaResponse::TEMPLATE_ENGINE_MUSTACHE );
|
|
|
|
}
|
|
|
|
}
|