mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 11:59:56 +00:00
DAT-3147 assets entry point added
This commit is contained in:
parent
8e6bffbb7f
commit
9b020ee4fb
|
@ -55,6 +55,7 @@ $wgAutoloadClasses[ 'ApiPortableInfobox' ] = $dir . 'controllers/ApiPortableInfo
|
|||
$wgAutoloadClasses[ 'ApiQueryPortableInfobox' ] = $dir . 'controllers/ApiQueryPortableInfobox.class.php';
|
||||
$wgAutoloadClasses[ 'PortableInfoboxHooks' ] = $dir . 'PortableInfoboxHooks.class.php';
|
||||
$wgAutoloadClasses[ 'ApiQueryAllinfoboxes' ] = $dir . 'controllers/ApiQueryAllinfoboxes.class.php';
|
||||
$wgAutoloadClasses[ 'PortableInfoboxBuilderController' ] = $dir . 'controllers/PortableInfoboxBuilderController.class.php';
|
||||
|
||||
// query pages
|
||||
$wgAutoloadClasses[ 'AllinfoboxesQueryPage' ] = $dir . 'querypage/AllinfoboxesQueryPage.php';
|
||||
|
|
16
controllers/PortableInfoboxBuilderController.class.php
Normal file
16
controllers/PortableInfoboxBuilderController.class.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
class PortableInfoboxBuilderController extends WikiaController {
|
||||
|
||||
public function getAssets() {
|
||||
$dir = PortableInfoboxRenderService::getTemplatesDir();
|
||||
$result = array_map( function ( $template ) use ( $dir ) {
|
||||
return file_get_contents( "{$dir}/{$template}" );
|
||||
}, PortableInfoboxRenderService::getTemplates() );
|
||||
|
||||
$response = $this->getResponse();
|
||||
$response->setFormat( WikiaResponse::FORMAT_JSON );
|
||||
$response->setVal( "css", AssetsManager::getInstance()->getURL( "portable_infobox_scss" ) );
|
||||
$response->setVal( "templates", $result );
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
use \Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper;
|
||||
use Wikia\PortableInfobox\Helpers\PortableInfoboxRenderServiceHelper;
|
||||
|
||||
class PortableInfoboxRenderService extends WikiaService {
|
||||
const MOBILE_TEMPLATE_POSTFIX = '-mobile';
|
||||
|
||||
private $templates = [
|
||||
private static $templates = [
|
||||
'wrapper' => 'PortableInfoboxWrapper.mustache',
|
||||
'title' => 'PortableInfoboxItemTitle.mustache',
|
||||
'header' => 'PortableInfoboxItemHeader.mustache',
|
||||
|
@ -21,7 +21,15 @@ class PortableInfoboxRenderService extends WikiaService {
|
|||
|
||||
function __construct() {
|
||||
$this->templateEngine = ( new Wikia\Template\MustacheEngine )
|
||||
->setPrefix( dirname( __FILE__ ) . '/../templates' );
|
||||
->setPrefix( self::getTemplatesDir() );
|
||||
}
|
||||
|
||||
public static function getTemplatesDir() {
|
||||
return dirname( __FILE__ ) . '/../templates';
|
||||
}
|
||||
|
||||
public static function getTemplates() {
|
||||
return self::$templates;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +75,7 @@ class PortableInfoboxRenderService extends WikiaService {
|
|||
|
||||
if ( !empty( $infoboxHtmlContent ) ) {
|
||||
$output = $this->renderItem( 'wrapper', [ 'content' => $infoboxHtmlContent, 'theme' => $theme,
|
||||
'layout' => $layout ] );
|
||||
'layout' => $layout ] );
|
||||
} else {
|
||||
$output = '';
|
||||
}
|
||||
|
@ -134,6 +142,7 @@ class PortableInfoboxRenderService extends WikiaService {
|
|||
*
|
||||
* @param string $type
|
||||
* @param array $data
|
||||
*
|
||||
* @return bool|string - HTML
|
||||
*/
|
||||
private function renderItem( $type, array $data ) {
|
||||
|
|
Loading…
Reference in a new issue