This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathSkinLiquiFlow.php
113 lines (95 loc) · 3.94 KB
/
SkinLiquiFlow.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
namespace Liquipedia\LiquiFlow;
use Hooks;
use OutputPage;
use SkinTemplate;
/**
* SkinTemplate class for LiquiFlow skin
* @ingroup Skins
*/
class Skin extends SkinTemplate {
public $skinname = 'liquiflow';
public $stylename = 'LiquiFlow';
public $template = 'Liquipedia\\LiquiFlow\\Template';
/**
* Initializes output page and sets up skin-specific parameters
* @param OutputPage $out Object to initialize
*/
public function initPage( OutputPage $out ) {
parent::initPage( $out );
$config = $out->getConfig();
// Edge compatibility mode (don't run in outdated compat)
$out->addHeadItem( 'ie-edge', '<meta http-equiv="X-UA-Compatible" content="IE=edge">' );
// Meta tags for mobile
$out->addHeadItem( 'responsive', '<meta name="viewport" content="width=device-width, initial-scale=1.0">' );
$out->addHeadItem( 'theme-color', '<meta name="theme-color" content="' . Colors::getSkinColors( substr( $config->get( 'ScriptPath' ), 1 ), 'wiki-dark' ) . '">' );
Hooks::run( 'LiquiFlowStartCode', [ &$out ] );
$scripts = [ 'skins.liquiflow.scripts' ];
$out->addModuleScripts( $scripts );
if ( $this->getSkin()->getUser()->getOption( 'liquiflow-prefs-show-dropdown-on-hover' ) == true ) {
$out->addModuleScripts( 'skins.liquiflow.hoverdropdown' );
}
if ( $out->msg( 'liquiflow-js-urls' )->exists() ) {
$urlScripts = $out->msg( 'liquiflow-js-urls' )->plain();
$urlScripts = explode( "\n", $urlScripts );
foreach ( $urlScripts as $urlId => $urlScript ) {
if ( strpos( trim( $urlScript ), '*' ) !== 0 ) {
continue;
}
$urlScript = str_replace( $out->msg( 'liquiflow-cache-version-placeholder' )->text(), $out->msg( 'liquiflow-cache-version' )->text(), str_replace( '|', '%7C', ltrim( trim( $urlScript ), '* ' ) ) );
$out->addHeadItem( 'liquiflow-script-' . $urlId, "<script src=\"" . $urlScript . "\"></script>\n" );
}
}
}
/**
* Loads skin and user CSS files.
* @param OutputPage $out
*/
function setupSkinUserCss( OutputPage $out ) {
parent::setupSkinUserCss( $out );
$scriptPath = $out->getConfig()->get( 'ScriptPath' );
$user = $this->getSkin()->getUser();
$out->addStyle( 'https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,700,700italic%7CDroid+Sans+Mono%7CRoboto:500%7CSource+Code+Pro:400,700&display=swap' );
$styles = [ 'mediawiki.skinning.interface' ];
$out->addModuleStyles( $styles );
if ( $out->getResourceLoader()->isModuleRegistered( 'skins.liquiflow.theme.' . substr( $scriptPath, 1 ) ) ) {
$out->addModuleStyles( 'skins.liquiflow.theme.' . substr( $scriptPath, 1 ) );
} else {
$out->addModuleStyles( 'skins.liquiflow.theme.default' );
}
if ( $user->isLoggedIn() ) {
$out->addModuleStyles( 'skins.liquiflow.loggedin' );
}
$liquiflowCssUrls = $out->msg( 'liquiflow-css-urls' );
if ( $liquiflowCssUrls->exists() ) {
$urlStyles = $liquiflowCssUrls->plain();
$urlStyles = explode( "\n", $urlStyles );
foreach ( $urlStyles as $urlStyle ) {
if ( strpos( trim( $urlStyle ), '*' ) !== 0 ) {
continue;
}
$urlStyle = str_replace( $out->msg( 'liquiflow-cache-version-placeholder' )->text(), $out->msg( 'liquiflow-cache-version' )->text(), str_replace( '|', '%7C', ltrim( trim( $urlStyle ), '* ' ) ) );
if ( !empty( $urlStyle ) && strlen( $urlStyle ) > 0 ) {
$out->addStyle( $urlStyle );
}
}
}
}
/**
* Return values for <html> element
* @return array Array of associative name-to-value elements for <html> element
*/
public function getHtmlElementAttributes() {
$attributes = parent::getHtmlElementAttributes();
$class = 'Send_pizza_to_FO-nTTaX All_glory_to_Liquipedia';
if ( array_key_exists( 'class', $attributes ) ) {
$attributes[ 'class' ] .= ' ' . $class;
} else {
$attributes[ 'class' ] = $class;
}
$attributes[ 'prefix' ] = 'og: http://ogp.me/ns#';
return $attributes;
}
}
// MediaWiki can't handle a namespaced \SkinTemplate without an alias
class_alias( Skin::class, 'SkinLiquiFlow' );