summaryrefslogtreecommitdiff
path: root/Toha.skin.php
diff options
context:
space:
mode:
Diffstat (limited to 'Toha.skin.php')
-rw-r--r--Toha.skin.php395
1 files changed, 395 insertions, 0 deletions
diff --git a/Toha.skin.php b/Toha.skin.php
new file mode 100644
index 0000000..45ad911
--- /dev/null
+++ b/Toha.skin.php
@@ -0,0 +1,395 @@
+<?php
+/**
+ * Skin file for the Toha skin.
+ *
+ * @file
+ * @ingroup Skins
+ * @ref https://git.wikimedia.org/summary/mediawiki%2Fskins%2FExample.git
+ */
+
+/**
+ * SkinTemplate class for the Toha skin
+ *
+ * @ingroup Skins
+ */
+class SkinToha extends SkinTemplate {
+
+ public $skinname = 'Toha', $stylename = 'Toha',
+ $template = 'TohaTemplate', $useHeadElement = true;
+
+ /**
+ * initialize the page
+ */
+ public function initPage( OutputPage $out ) {
+ parent::initPage( $out );
+ $out->addModuleScripts( array(
+ 'skins.toha'
+ ) );
+ }
+
+ /**
+ * Add CSS via ResourceLoader
+ *
+ * @param $out OutputPage
+ */
+ function setupSkinUserCss( OutputPage $out ) {
+ parent::setupSkinUserCss( $out );
+ $out->addModuleStyles( array(
+ 'skins.toha'
+ ) );
+ }
+
+ /**
+ * initialize various variables and generate the template
+ *
+ * @since 1.23
+ * @return QuickTemplate The template to be executed by outputPage
+ */
+ function prepareQuickTemplate( ) {
+ global $wgSmallLogo;
+ $tpl = parent::prepareQuickTemplate( );
+ $tpl->setRef( 'smalllogopath', $wgSmallLogo );
+ return $tpl;
+
+ }
+
+}
+
+/**
+ * BaseTemplate class for the Toha skin
+ *
+ * @ingroup Skins
+ */
+class TohaTemplate extends BaseTemplate {
+
+ /**
+ * Outputs a single sidebar portlet of any kind.
+ */
+ private function outputPortlet( $box ) {
+ if ( !$box['content'] ) {
+ return;
+ }
+
+ ?>
+ <div
+ role="navigation"
+ class="mw-portlet"
+ id="<?php echo Sanitizer::escapeId( $box['id'] ) ?>"
+ <?php echo Linker::tooltip( $box['id'] ) ?>
+ >
+ <h3>
+ <?php
+ if ( isset( $box['headerMessage'] ) ) {
+ $this->msg( $box['headerMessage'] );
+ } else {
+ echo htmlspecialchars( $box['header'] );
+ }
+ ?>
+ </h3>
+
+ <?php
+ if ( is_array( $box['content'] ) ) {
+ echo '<ul>';
+
+ $wrapper = array( 'text-wrapper' => array(
+ array( 'tag' => 'div',
+ 'attributes' => array( 'class' => 'link_icon' ) ),
+ array( 'tag' => 'span' )
+ ) );
+
+ foreach ( $box['content'] as $key => $item ) {
+ echo $this->makeListItem( $key, $item, $wrapper );
+ }
+ echo '</ul>';
+ } else {
+ echo $box['content'];
+ }?>
+ </div>
+ <?php
+ }
+
+ /**
+ * Prepare links for submenus.
+ */
+ private function outputRawLinks( $name, $links ) {
+
+ echo 'var inner_' . $name . ' = \'';
+
+ if ( is_array( $links ) ) {
+
+ foreach ( $links as $key => $item )
+ echo $this->makeLink( $key, $item );
+
+ } else {
+
+ echo $links;
+
+ }
+
+ echo '\';' . "\n";
+
+ echo 'addMenuToID(\'n-' . $name . '-desc\', inner_' . $name . ');';
+
+ echo "\n\n";
+
+ }
+
+ /**
+ * Define menus on the left and on the right.
+ */
+ private function renderPortletAsSideButtons( $required, $boxes ) {
+
+ foreach ( $required as $req ) {
+
+ if ( ! array_key_exists( $req, $boxes ) )
+ continue;
+
+ $box = $boxes[$req];
+
+ if ( ! $box['content'] )
+ continue;
+
+ ?>
+ <ul id="<?php echo Sanitizer::escapeId( $box['id'] ) ?>">
+ <?php
+
+ if ( is_array( $box['content'] ) ) {
+
+ foreach ( $box['content'] as $key => $item )
+ echo $this->makeListItem( $key, $item,
+ array( 'text-wrapper' => array( 'tag' => 'span' ) ) );
+
+ } else {
+
+ echo $box['content'];
+
+ }
+
+ ?>
+ </ul>
+ <?php
+
+ }
+
+ }
+
+ /**
+ * Outputs the entire contents of the page.
+ */
+ public function execute() {
+
+ $this->html( 'headelement' ) ?>
+
+ <header>
+
+ <a
+ id="p-logo"
+ role="banner"
+ href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>"
+ <?php echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) ?>
+ >
+ <img class="big"
+ src="<?php $this->text( 'logopath' ) ?>"
+ alt="<?php $this->text( 'sitename' ) ?>"
+ />
+ <img class="small"
+ src="<?php $this->text( 'smalllogopath' ) ?>"
+ alt="<?php $this->text( 'sitename' ) ?>"
+ />
+ </a>
+
+ <?php
+ $sideboxes = $this->getSidebar();
+ $this->outputPortlet( $sideboxes['navigation'] );
+ ?>
+
+ </header>
+
+ <div class="extender"></div>
+
+ <script>
+
+ function toggleExtender() {
+
+ header = document.getElementsByTagName("header")[0];
+
+ if (document.body.scrollTop > 105 || document.documentElement.scrollTop > 105)
+ header.className = "sticky";
+
+ else
+ header.className = "";
+
+ }
+
+ window.onscroll = toggleExtender;
+
+ </script>
+
+ <div id="mw-wrapper">
+
+ <script>
+
+ function buildDynMenus() {
+
+ <?php
+
+ foreach ( $sideboxes as $boxName => $box ) {
+
+ $parts = explode( '-', $boxName );
+
+ if ( count( $parts ) != 2 ) continue;
+
+ if ($parts[1] != 'submenu' ) break;
+
+ $this->outputRawLinks( $parts[0], $box['content'] );
+
+ }
+
+ ?>
+
+ }
+
+ document.body.onload = buildDynMenus;
+
+ </script>
+
+ <div class="mw-body" role="main">
+ <?php if ( $this->data['sitenotice'] ) { ?>
+ <div id="siteNotice"><?php $this->html( 'sitenotice' ) ?></div>
+ <?php } ?>
+
+ <?php if ( $this->data['newtalk'] ) { ?>
+ <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div>
+ <?php } ?>
+
+ <?php
+ if (false/* && !$this->getSkin()->getTitle()->isMainPage()*/) {
+ ?>
+ <h1 class="firstHeading">
+ <?php $this->html( 'title' ) ?>
+ </h1>
+ <?php
+ }
+ ?>
+
+ <div class="mw-body-content">
+ <div id="contentSub">
+ <?php if ( $this->data['subtitle'] ) { ?>
+ <p><?php $this->html( 'subtitle' ) ?></p>
+ <?php } ?>
+ <?php if ( $this->data['undelete'] ) { ?>
+ <p><?php $this->html( 'undelete' ) ?></p>
+ <?php } ?>
+ </div>
+
+ <?php $this->html( 'bodytext' ) ?>
+
+ <?php $this->html( 'catlinks' ) ?>
+
+ <?php $this->html( 'dataAfterContent' ); ?>
+
+ </div>
+ </div>
+
+ <div id="mw-footer">
+
+ <ul id="poweredby">
+ <?php foreach ( $this->getFooterIcons( 'icononly' ) as $blockName => $footerIcons ) { ?>
+ <li>
+ <?php
+ foreach ( $footerIcons as $icon ) {
+ echo $this->getSkin()->makeFooterIcon( $icon );
+ }
+ ?>
+ </li>
+ <?php } ?>
+ </ul>
+
+ <ul id="lastmod">
+ <li><?php $this->html( 'lastmod' ) ?></li>
+ </ul>
+
+ <?php global $wgFooterImages; ?>
+
+ <ul id="links">
+ <?php foreach ( $wgFooterImages as $category => $params ) { ?>
+ <li>
+ <a href="<?= $params['url'] ?>">
+ <?php if ( isset( $params['src'] ) ) { ?>
+ <img alt="<?= $params['alt'] ?>" src="<?= $params['src'] ?>" onmouseover="this.src='<?= $params['hsrc'] ?>'" onmouseout="this.src='<?= $params['src'] ?>'">
+ <?php } else { ?>
+ <img alt="<?= $params['alt'] ?>" src="<?= $params['src'] ?>">
+ <?php } ?>
+ </a>
+ </li>
+ <?php } ?>
+ </ul>
+
+ <div style="clear: both;"></div>
+
+ </div>
+
+ <div id="mw-navigation" class="left-navigation">
+
+ <div>
+ <?php
+
+ $this->renderPortletAsSideButtons( array ( 'TOOLBOX', 'LANGUAGES' ), $sideboxes );
+
+ ?>
+ </div>
+
+ </div>
+
+ <div id="mw-navigation" class="right-navigation">
+
+ <div>
+ <?php
+
+ $navigations = $this->data['content_navigation'];
+
+ if ( array_key_exists('view', $navigations['views']) )
+ unset( $navigations['views']['view'] );
+
+ $rboxes = array(
+
+ 'personal' => array(
+
+ 'id' => 'p-personal',
+ 'content' => $this->getPersonalTools()
+
+ ),
+
+ 'views' => array(
+
+ 'id' => 'p-views',
+ 'content' => $navigations['views']
+
+ ),
+
+ 'actions' => array(
+
+ 'id' => 'p-actions',
+ 'content' => $navigations['actions']
+
+ )
+
+ );
+
+ $this->renderPortletAsSideButtons( array ( 'personal', 'views', 'actions' ), $rboxes );
+
+ ?>
+ </div>
+
+ </div>
+
+ </div>
+
+ <?php $this->printTrail() ?>
+
+ </body></html>
+
+ <?php
+ }
+
+}