Pastakhov has uploaded a new change for review. https://gerrit.wikimedia.org/r/323361
Change subject: For testing only ...................................................................... For testing only Change-Id: I6e6ef14e8e1e382e969b0c38ea5090a811dae736 --- A Empty.php A EmptyHooks.php A EmptyTemplate.php A SkinEmpty.php A i18n/en.json A i18n/qqq.json A includes/Empty.json A includes/Skin.php 8 files changed, 739 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Empty refs/changes/61/323361/1 diff --git a/Empty.php b/Empty.php new file mode 100644 index 0000000..9c44e2f --- /dev/null +++ b/Empty.php @@ -0,0 +1,38 @@ +<?php +/** + * Empty skin + * + * @file + * @ingroup Skins + * @author Pavel Astakhov (http://www.mediawiki.org/wiki/User:Pastakhov) + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +if ( !defined( 'MEDIAWIKI' ) ) { + die( 'This is an extension to the MediaWiki package and cannot be run standalone.' ); +} + +const EMPTY_SKIN_VERSION = '0.1'; + +$wgExtensionCredits['skin'][] = array( + 'path' => __FILE__, + 'name' => 'Empty', + 'namemsg' => 'skinname-empty', // used since MW 1.24, see the section on "Localisation messages" below + 'version' => EMPTY_SKIN_VERSION, + 'url' => 'https://www.mediawiki.org/wiki/Skin:Empty', + 'author' => '[https://mediawiki.org/wiki/User:Pastakhov Pavel Astakhov]', + 'descriptionmsg' => 'empty-skin-desc', // see the section on "Localisation messages" below + 'license' => 'GPL-2.0+', +); + +$wgValidSkinNames['empty'] = 'Empty'; + +$wgMessagesDirs['Empty'] = __DIR__ . '/i18n'; + +$wgAutoloadClasses['EmptyTemplate'] = __DIR__ . '/EmptyTemplate.php'; +$wgAutoloadClasses['SkinEmpty'] = __DIR__ . '/SkinEmpty.php'; +$wgAutoloadClasses['EmptyHooks'] = __DIR__ . '/EmptyHooks.php'; +$wgAutoloadClasses['PhpTagsObjects\\Skin'] = __DIR__ . '/includes/Skin.php'; + +$wgHooks['ParserFirstCallInit'][] = 'EmptyHooks::onParserFirstCallInit'; +$wgHooks['PhpTagsRuntimeFirstInit'][] = 'EmptyHooks::onPhpTagsRuntimeFirstInit'; diff --git a/EmptyHooks.php b/EmptyHooks.php new file mode 100644 index 0000000..b3234e5 --- /dev/null +++ b/EmptyHooks.php @@ -0,0 +1,33 @@ +<?php + + +/** + * PhpTags Widgets MediaWiki Hooks. + * + * @file PhpTagsWidgets.hooks.php + * @ingroup PhpTags + * @author Pavel Astakhov <pastak...@yandex.ru> + * @licence GNU General Public Licence 2.0 or later + */ +class EmptyHooks { + + public static function onParserFirstCallInit() { + if ( !defined( 'PHPTAGS_VERSION' ) ) { + throw new MWException( "\n\nYou need to have the PhpTags extension installed in order to use the Empty skin." ); + } + $needVersion = '5.3.0'; + if ( version_compare( PHPTAGS_VERSION, $needVersion, '<' ) ) { + throw new MWException( "\n\nThis version of the Empty skin requires the PhpTags extension $needVersion or above.\n You have " . PHPTAGS_VERSION . ". Please update it." ); + } + if ( PHPTAGS_HOOK_RELEASE != 8 ) { + throw new MWException( "\n\nThis version of the Empty skin is outdated and not compatible with current version of the PhpTags extension.\n Please update it." ); + } + return true; + } + + public static function onPhpTagsRuntimeFirstInit() { + \PhpTags\Hooks::addJsonFile( __DIR__ . '/includes/Empty.json', EMPTY_SKIN_VERSION ); + return true; + } + +} diff --git a/EmptyTemplate.php b/EmptyTemplate.php new file mode 100644 index 0000000..67068e8 --- /dev/null +++ b/EmptyTemplate.php @@ -0,0 +1,169 @@ +<?php +/** + * + * @ingroup Skins + */ +class EmptyTemplate extends BaseTemplate { + /** + * Outputs the entire contents of the page + */ + public function execute() { + // Output HTML Page + $this->html( 'headelement' ); + ?> + +<h1 id="firstHeading" class="firstHeading" lang="<?php + $this->data['pageLanguage'] = + $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); + $this->text( 'pageLanguage' ); + ?>"><?php $this->html( 'title' ) ?></h1> + <?php $this->html( 'prebodyhtml' ) ?> + + <div id="bodyContent" class="mw-body-content"> + <?php + if ( $this->data['isarticle'] ) { + ?> + <div id="siteSub"><?php $this->msg( 'tagline' ) ?></div> + <?php + } + ?> + <div id="contentSub"<?php + $this->html( 'userlangattributes' ) + ?>><?php $this->html( 'subtitle' ) ?></div> + <?php + if ( $this->data['undelete'] ) { + ?> + <div id="contentSub2"><?php $this->html( 'undelete' ) ?></div> + <?php + } + ?> + <?php + if ( $this->data['newtalk'] ) { + ?> + <div class="usermessage"><?php $this->html( 'newtalk' ) ?></div> + <?php + } + ?> + <div id="jump-to-nav" class="mw-jump"> + <?php $this->msg( 'jumpto' ) ?> + <a href="#mw-head"><?php + $this->msg( 'jumptonavigation' ) + ?></a><?php + $this->msg( 'comma-separator' ) + ?> + <a href="#p-search"><?php $this->msg( 'jumptosearch' ) ?></a> + </div> + <?php $this->html( 'bodycontent' ) ?> + <?php + if ( $this->data['printfooter'] ) { + ?> + <div class="printfooter"> + <?php $this->html( 'printfooter' ); ?> + </div> + <?php + } + ?> + <?php + if ( $this->data['catlinks'] ) { + ?> + <?php + $this->html( 'catlinks' ); + ?> + <?php + } + ?> + <?php + if ( $this->data['dataAfterContent'] ) { + ?> + <?php + $this->html( 'dataAfterContent' ); + ?> + <?php + } + ?> + <div class="visualClear"></div> + <?php $this->html( 'debughtml' ); ?> + </div> + </div> + <div id="mw-navigation"> + <h2><?php $this->msg( 'navigation-heading' ) ?></h2> + + <div id="mw-head"> + <?php //$this->renderNavigation( 'PERSONAL' ); ?> + <div id="left-navigation"> + <?php //$this->renderNavigation( array( 'NAMESPACES', 'VARIANTS' ) ); ?> + </div> + <div id="right-navigation"> + <?php //$this->renderNavigation( array( 'VIEWS', 'ACTIONS', 'SEARCH' ) ); ?> + </div> + </div> + <div id="mw-panel"> + <div id="p-logo" role="banner"><a class="mw-wiki-logo" href="<?php + echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) + ?>" <?php + echo Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) ) + ?>></a></div> + <?php //$this->renderPortals( $this->data['sidebar'] ); ?> + </div> + </div> + <div id="footer" role="contentinfo"<?php $this->html( 'userlangattributes' ) ?>> + <?php + foreach ( $this->getFooterLinks() as $category => $links ) { + ?> + <ul id="footer-<?php + echo $category + ?>"> + <?php + foreach ( $links as $link ) { + ?> + <li id="footer-<?php + echo $category + ?>-<?php + echo $link + ?>"><?php + $this->html( $link ) + ?></li> + <?php + } + ?> + </ul> + <?php + } + ?> + <?php $footericons = $this->getFooterIcons( "icononly" ); + if ( count( $footericons ) > 0 ) { + ?> + <ul id="footer-icons" class="noprint"> + <?php + foreach ( $footericons as $blockName => $footerIcons ) { + ?> + <li id="footer-<?php + echo htmlspecialchars( $blockName ); ?>ico"> + <?php + foreach ( $footerIcons as $icon ) { + ?> + <?php + echo $this->getSkin()->makeFooterIcon( $icon ); + ?> + + <?php + } + ?> + </li> + <?php + } + ?> + </ul> + <?php + } + ?> + <div style="clear:both"></div> + </div> + <?php $this->printTrail(); ?> + + </body> +</html> +<?php + } + +} diff --git a/SkinEmpty.php b/SkinEmpty.php new file mode 100644 index 0000000..ab861ab --- /dev/null +++ b/SkinEmpty.php @@ -0,0 +1,100 @@ +<?php + +/** + * SkinTemplate class for Empty skin + * @ingroup Skins + */ +class SkinEmpty extends Skin { + var $skinname = 'empty'; + + /** + * + * @global \Parser $wgParser + * @param \OutputPage $out + */ + public function outputPage( \OutputPage $out = null ) { + global $wgParser; + // copy from SkinTemplate::outputPage() + Profiler::instance()->setTemplated( true ); + + $oldContext = null; + if ( $out !== null ) { + // Deprecated since 1.20, note added in 1.25 + wfDeprecated( __METHOD__, '1.25' ); + $oldContext = $this->getContext(); + $this->setContext( $out->getContext() ); + } + + $out = $this->getOutput(); + + $this->initPage( $out ); + // break copy SkinTemplate::outputPage() + + \PhpTagsObjects\Skin::setSkin( $this ); + $text = wfMessage( 'SkinEmpty' )->plain(); + + $popts = $out->parserOptions(); + $popts->setInterfaceMessage( true ); + //$parserOutput = $wgParser->parse( $text, $out->getTitle(), $popts ); + $parserOutput = $wgParser->parse( $text, $out->getTitle(), $popts ); + $parserOutput->resetParseStartTime(); + $outputHtml = $parserOutput->getText(); + + //$outputHtml = $out->parse( $text, true, true ); + //$outputHtml = wfMessage( 'EmptySkin' )->parse(); // Parse page MediaWiki:EmptySkin as a Skin + echo $out->headElement( $this ); // Add head element + echo $outputHtml; // output text + + // copy from BaseTemplate::printTrail() + echo MWDebug::getDebugHTML( $this->getContext() ); + echo $this->bottomScripts(); + echo wfReportTime(); + // end copy + + $time = round( $parserOutput->getTimeSinceStart( 'cpu' ), 3 ); + echo "\n<!-- Skin time: $time -->\n</body>\n</html>"; + + // continue copy SkinTemplate::outputPage() + if ( $oldContext ) { + $this->setContext( $oldContext ); + } + } + + /** + * It's copy from SkinTemplate class + * Add specific styles for this skin + * + * @param OutputPage $out + */ + function setupSkinUserCss( OutputPage $out ) { + $moduleStyles = array( + 'mediawiki.legacy.shared', + 'mediawiki.legacy.commonPrint', + 'mediawiki.sectionAnchor' + ); + if ( $out->isSyndicated() ) { + $moduleStyles[] = 'mediawiki.feedlink'; + } + + // Deprecated since 1.26: Unconditional loading of mediawiki.ui.button + // on every page is deprecated. Express a dependency instead. + if ( strpos( $out->getHTML(), 'mw-ui-button' ) !== false ) { + $moduleStyles[] = 'mediawiki.ui.button'; + } + + $out->addModuleStyles( $moduleStyles ); + } + + public function afterContentHook() { + return parent::afterContentHook(); + } + + public function generateDebugHTML() { + return parent::generateDebugHTML(); + } + + public function lastModified() { + return parent::lastModified(); + } + +} diff --git a/i18n/en.json b/i18n/en.json new file mode 100644 index 0000000..6834403 --- /dev/null +++ b/i18n/en.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "pastakhov" + ] + }, + "skinname-empty": "Empty", + "empty-skin-desc": "the Empty skin for your imagination" +} diff --git a/i18n/qqq.json b/i18n/qqq.json new file mode 100644 index 0000000..da67630 --- /dev/null +++ b/i18n/qqq.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": [ + "pastakhov" + ] + }, + "skinname-empty": "{{optional}}", + "empty-skin-desc": "{{desc|what=skin|name=Empty|url=https://www.mediawiki.org/wiki/Skin:Empty}}" +} diff --git a/includes/Empty.json b/includes/Empty.json new file mode 100644 index 0000000..f9151ea --- /dev/null +++ b/includes/Empty.json @@ -0,0 +1,100 @@ +{ + "objects": { + "Skin": { + "class": "Skin", + "STATIC METHODS": { + "insertRawHTMLElement": { + "parameters": [ + { "type": "string", "name": "element" }, + { "type": "array", "name": "attribs", "default": "null" }, + { "type": "string", "name": "$content", "default": "null" } + ], + "return": "bool", + "desc": "Insert raw HTML element" + }, + "insertFirstHeading": { + "parameters": [ + { "type": "string", "name": "title", "default": "null" } + ], + "return": "bool", + "desc": "Insert first heading" + }, + "insertIndicators": { + "parameters": [], + "return": "bool", + "desc": "Insert Indicators" + }, + "insertBodyText": { + "parameters": [], + "return": "bool", + "desc": "Insert body text" + }, + "insertBodyContent": { + "parameters": [], + "return": "bool", + "desc": "Insert body content" + }, + "insertCatlinks": { + "parameters": [], + "return": "bool", + "desc": "Insert category links" + }, + "insertDataAfterContent": { + "parameters": [], + "return": "bool", + "desc": "Insert SkinAfterContent hook result" + }, + "insertSiteNotice": { + "parameters": [], + "return": "bool", + "desc": "Insert site notice" + }, + "insertTagLine": { + "parameters": [], + "return": "bool", + "desc": "Insert tag line" + }, + "insertSubtitle": { + "parameters": [], + "return": "bool", + "desc": "Insert subtitle" + }, + "insertUndelete": { + "parameters": [], + "return": "bool", + "desc": "Insert undelete" + }, + "insertNewTalk": { + "parameters": [], + "return": "bool", + "desc": "Insert new talk" + }, + "insertLogoBanner": { + "parameters": [], + "return": "bool", + "desc": "Insert wiki logo" + }, + "getLastModified": { + "parameters": [], + "return": "bool", + "desc": "Returns last modified string" + } + } + } + }, + "functions": { + "foundation5": { + "class": "Foundation", + "parameters": [], + "return": "bool", + "desc": "initializes the Foundation 5" + } + }, + "constants": { + "EMPTY_SKIN_VERSION" : { + "desc": "The current version of the Empty skin as a string", + "type": "string", + "link": "https://www.mediawiki.org/wiki/Skin:Empty" + } + } +} diff --git a/includes/Skin.php b/includes/Skin.php new file mode 100644 index 0000000..4315395 --- /dev/null +++ b/includes/Skin.php @@ -0,0 +1,281 @@ +<?php +namespace PhpTagsObjects; + +/** + * Description of WikiW + * + * @author pastakhov + */ +class Skin extends \PhpTags\GenericObject { + + private static $cache = array(); + + /** + * + * @var \SkinEmpty + */ + private static $skin; + + /** + * + * @var \OutputPage + */ + private static $out; + + public static function setSkin( \Skin $skin ) { + self::$skin = $skin; + self::$out = $skin->getOutput(); + } + + private static function getData( $str ) { + if ( isset( self::$cache[$str] ) ) { + return self::$cache[$str][1]; + } + return self::loadData( $str ); + } + + /** + * + * @param string $str + * @return mixed + */ + private static function loadData( $str ) { + $ret = null; + + switch ( $str ) { + case 'title': + $ret = self::$out->getPageTitle(); + break; + case 'pageLanguage': + $ret = self::$out->getContext()->getTitle()->getPageViewLanguage()->getHtmlCode(); + break; + case 'indicators': + $ret = self::$out->getIndicators(); + break; + case 'printfooter': + $ret = self::$skin->printSource(); + break; + case 'debughtml': + $ret = self::$skin->generateDebugHTML(); + break; + case 'catlinks': + $ret = self::$skin->getCategories(); + break; + case 'dataAfterContent': + $ret = self::$skin->afterContentHook(); + break; + case 'sitenotice': + $ret = self::$skin->getSiteNotice(); + break; + case 'tagline': + $ret = self::$skin->msg( 'tagline' ); + break; + case 'undelete': + $ret = self::$skin->getUndeleteLink(); + if ( $ret !== '' ) { + $ret = '<span class="subpages">' . $ret . '</span>'; + } + break; + case 'newtalk': + $ret = self::$skin->getNewtalks(); + break; + case 'mainpageurl': + $ret = \Skin::makeMainPageUrl(); + break; + case 'lastmod': + if ( self::$out->isArticle() && self::$skin->getTitle()->exists() && self::$skin->isRevisionCurrent() ) { + $ret = self::$skin->lastModified(); + } + break; + } + self::$cache[$str][0] = true; + self::$cache[$str][1] =& $ret; + return $ret; + } + + /** + * copied from SkinTemplate::prepareQuickTemplate() + */ + private static function getUserLangAttributes() { + static $atributes = false; + + if ( $atributes === false ) { + global $userLangCode, $wgContLang, $userLangDir; + if ( $userLangCode !== $wgContLang->getHtmlCode() || $userLangDir !== $wgContLang->getDir() ) { + $atributes = array( 'lang' => $userLangCode, 'dir' => $userLangDir ); + } else { + $atributes = array(); + } + } + + return $atributes; + } + + public static function s_insertFirstHeading( $title = null ) { + if ( self::$skin === null ) { + return false; + } + + $attribs = array( + 'id'=>'firstHeading', + 'class'=>'firstHeading', + 'lang' => self::getData( 'pageLanguage' ), + ); + + return new \PhpTags\outPrint( true, $title ?: self::getData( 'title' ), false, 'h1', $attribs ); + } + + public static function s_insertIndicators() { + if ( self::$skin === null ) { + return false; + } + + $out = ''; + $indicators = self::getData( 'indicators' ); + foreach ( $indicators as $id => $content ) { + $out .= \Html::rawElement( + 'div', + array( + 'id' => \Sanitizer::escapeId( "mw-indicator-$id" ), + 'class' => 'mw-indicator', + ), + $content + ) . "\n"; + } + return new \PhpTags\outPrint( true, $out, true, 'div', array('class'=>'mw-indicators') ); + } + + public static function s_insertBodyContent() { + $output = self::$out; + if ( $output === null ) { + return false; + } + + return new \PhpTags\outPrint( true, $output->mBodytext, true, 'div', array('class'=>'bodycontent') ); + } + + public static function s_insertBodyText() { + $output = self::$out; + if ( $output === null ) { + return false; + } + + $bodyText = $output->mBodytext . + \Html::rawElement( + 'div', + array( 'class' => 'printfooter' ), + "\n" . self::getData( 'printfooter' ) + ) . "\n" . + self::getData( 'debughtml' ); + + return new \PhpTags\outPrint( true, $bodyText, true, 'div', array('class'=>'bodytext') ); + } + + public static function s_insertCatlinks() { + if ( self::$skin === null ) { + return false; + } + + $catlinks = self::getData( 'catlinks' ); + if ( $catlinks ) { + return new \PhpTags\outPrint( true, $catlinks, true, 'div' ); + } + } + + public static function s_insertDataAfterContent() { + if ( self::$skin === null ) { + return false; + } + + $data = self::getData( 'dataAfterContent' ); + if ( $data ) { + return new \PhpTags\outPrint( true, $data, true, 'div', array('class'=>'dataAfterContent') ); + } + } + + public static function s_insertSiteNotice() { + if ( self::$skin === null ) { + return false; + } + + $sitenotice = self::getData( 'sitenotice' ); + if ( $sitenotice ) { + return new \PhpTags\outPrint( true, $sitenotice, true, 'div', array('class'=>'sitenotice') ); + } + } + + public static function s_insertTagLine() { + if ( self::$skin === null ) { + return false; + } + + $tagline = self::getData( 'tagline' ); + if ( $tagline ) { + return new \PhpTags\outPrint( true, $tagline, true, 'div', array('id'=>'siteSub') ); + } + } + + public static function s_insertSubtitle() { + if ( self::$skin === null ) { + return false; + } + + $subtitle = self::getData( 'subtitle' ); + if ( $subtitle ) { + return new \PhpTags\outPrint( true, $subtitle, true, 'div', array('id'=>'contentSub') + self::getUserLangAttributes() ); + } + } + + public static function s_insertUndelete() { + if ( self::$skin === null ) { + return false; + } + + $undelete = self::getData( 'undelete' ); + if ( $undelete ) { + return new \PhpTags\outPrint( true, $undelete, true, 'div', array('id'=>'contentSub2') ); + } + } + + public static function s_insertNewTalk() { + if ( self::$skin === null ) { + return false; + } + + $newtalk = self::getData( 'newtalk' ); + if ( $newtalk ) { + return new \PhpTags\outPrint( true, $newtalk, true, 'div', array('class'=>'usermessage') ); + } + } + + public static function s_insertLogoBanner() { + if ( self::$skin === null ) { + return false; + } + + // copy from MonoBookTemplate.php + $logo = \Html::element( 'a', array( + 'href' =>self::getData( 'mainpageurl' ), + 'class' => 'mw-wiki-logo', + ) + + \Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + ); + return new \PhpTags\outPrint( true, $logo, true, 'div', array('class'=>'portlet', 'id'=>'p-logo', 'role'=>'banner') ); + } + + public static function s_getLastModified() { + if ( self::$skin === null ) { + return false; + } + + return self::getData( 'lastmod' ); + } + + public static function s_insertRawHTMLElement( $element, $attribs = array(), $content = '' ) { + if ( self::$skin === null ) { + return false; + } + + return new \PhpTags\outPrint( true, $content, true, $element, $attribs ); + } +} -- To view, visit https://gerrit.wikimedia.org/r/323361 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6e6ef14e8e1e382e969b0c38ea5090a811dae736 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/skins/Empty Gerrit-Branch: master Gerrit-Owner: Pastakhov <pastak...@yandex.ru> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits