2014-09-15 08:17:29 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Content handler for the pages with code, such as CSS, JavaScript, JSON.
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @ingroup Content
|
|
|
|
|
*/
|
|
|
|
|
|
2019-08-26 12:24:37 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2014-09-15 08:17:29 +00:00
|
|
|
/**
|
2020-06-30 16:53:40 +00:00
|
|
|
* Content handler for code content such as CSS, JavaScript, JSON, etc.
|
|
|
|
|
*
|
2020-07-13 09:00:30 +00:00
|
|
|
* @stable to extend
|
2014-09-15 08:17:29 +00:00
|
|
|
* @since 1.24
|
|
|
|
|
* @ingroup Content
|
|
|
|
|
*/
|
|
|
|
|
abstract class CodeContentHandler extends TextContentHandler {
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-14 17:34:10 +00:00
|
|
|
* Returns the English language, because code is English, and should be handled as such.
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-06-30 16:53:40 +00:00
|
|
|
*
|
2014-09-15 08:17:29 +00:00
|
|
|
* @param Title $title
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param Content|null $content
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
2015-12-14 17:34:10 +00:00
|
|
|
* @return Language
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
|
|
|
|
* @see ContentHandler::getPageLanguage()
|
|
|
|
|
*/
|
|
|
|
|
public function getPageLanguage( Title $title, Content $content = null ) {
|
2019-08-26 12:24:37 +00:00
|
|
|
return MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
|
2014-09-15 08:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2015-12-14 17:34:10 +00:00
|
|
|
* Returns the English language, because code is English, and should be handled as such.
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-06-30 16:53:40 +00:00
|
|
|
*
|
2014-09-15 08:17:29 +00:00
|
|
|
* @param Title $title
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param Content|null $content
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
2015-12-14 17:34:10 +00:00
|
|
|
* @return Language
|
2014-09-15 08:17:29 +00:00
|
|
|
*
|
|
|
|
|
* @see ContentHandler::getPageViewLanguage()
|
|
|
|
|
*/
|
|
|
|
|
public function getPageViewLanguage( Title $title, Content $content = null ) {
|
2019-08-26 12:24:37 +00:00
|
|
|
return MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( 'en' );
|
2014-09-15 08:17:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-07-13 08:57:12 +00:00
|
|
|
* @stable to override
|
2020-06-30 16:53:40 +00:00
|
|
|
*
|
2014-09-15 08:17:29 +00:00
|
|
|
* @return string
|
2014-12-24 13:49:20 +00:00
|
|
|
* @throws MWException
|
2014-09-15 08:17:29 +00:00
|
|
|
*/
|
|
|
|
|
protected function getContentClass() {
|
|
|
|
|
throw new MWException( 'Subclass must override' );
|
|
|
|
|
}
|
2016-05-13 00:10:52 +00:00
|
|
|
|
2014-09-15 08:17:29 +00:00
|
|
|
}
|