aboutsummaryrefslogtreecommitdiffstats
path: root/includes/content/CssContentHandler.php
Commit message (Collapse)AuthorAgeFilesLines
* Namespace all remaining files in includes/pageJames D. Forrester2025-03-181-1/+1
| | | | | Bug: T353458 Change-Id: I7a9c74f2106655d41ae029742090253f541bd4a6
* content: Improve class docs for various Content classesTimo Tijhof2025-03-121-3/+0
| | | | | | | | | | | | | * Move duplicate brief and ingroup from file doc to class doc. <https://gerrit.wikimedia.org/r/q/message:ingroup+owner:Krinkle> * Ensure methods have an understable brief, separate from other text. <https://www.mediawiki.org/wiki/Manual:Coding_conventions/Documentation> * Remove obsolete `todo` comments. Bug: T364652 Change-Id: I6eebbf20775e73d008ef86c592a7128456abcb06
* Move remaining four classes in includes/content into Content namespaceJames D. Forrester2024-08-101-1/+0
| | | | | Bug: T353458 Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
* Add namespace to CodeContentHandlerEbrahim Byagowi2024-08-061-1/+0
| | | | | | It adds MediaWiki\Content namespace to CodeContentHandler Change-Id: Ie02c727a66af7d0dae568eab67b242d5ffdf6431
* Add namespace and deprecation alias to CssContentHandlerEbrahim Byagowi2024-05-191-1/+9
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to CssContentHandler and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I5504c21b4fabd6ce82c4dac37aacd1c74462c41b
* Add namespace and deprecation alias to CssContentEbrahim Byagowi2024-05-181-0/+1
| | | | | | | | | This patch introduces a namespace declaration for the MediaWiki\Content to CssContent and establishes a class alias marked as deprecated since version 1.43. Bug: T353458 Change-Id: I6ab25787893cb2195f8cd2ba125ed8dd5a60de43
* [ParserOutput] Rename $mText to $mRawText and ::setText() to ::setRawText()C. Scott Ananian2024-02-201-1/+1
| | | | | | | | | | | | | | | | ParserOutput::getText() is not a simple getter, but does transformations on the "text" of the ParserOutput; the simple getter is named ::getRawText(). To maintain consistency, rename ParserOutput::setText() to ::setRawText() and the property name ParserOutput::$mText to ::$mRawText so future readers are not confused. The JSON property name as it appears in the serialized ParserCache is left as 'Text' so that we don't have any forward- or backward- rollback issues. Change-Id: I3ef34814ab9473cc70d0a6806e8c5a4a02b73491
* WikiPage: remove ::suppressTOC hackC. Scott Ananian2024-02-051-0/+4
| | | | | | | | | Instead of overriding the ParserOptions for the page, just clear the section data and set the NO_TOC flag in the resulting ParserOutput. Bug: T307691 Bug: T350626 Change-Id: I6a24edcc5eb5bed50adcfb8648b953afa54ac0f6
* Namespace ParserOutputJames D. Forrester2023-12-141-0/+1
| | | | | | | Most used non-namespaced class! Bug: T353458 Change-Id: I4c2cbb0a808b3881a4d6ca489eee5d8c8ebf26cf
* Remove deprecated methods from Content interfacedaniel2023-11-211-12/+0
| | | | | | | | | | Several methods on the Content interface had been deprecated in 1.35 and 1.36 in favor of corresponding methods on the ContentHandler base class, to allow implementations of these methods to use proper dependency injection. This patch removes backwards compatibility support for subclasses that were overriding these methods. Change-Id: I8e474a1cc4dec760a7f6db25e4b313392f3723b1
* content,maintenance: Use class-string<ClassName> in doc blocksthiemowmde2023-07-311-0/+3
| | | | | | | | Start using `class-string<ClassName>` as a type hint in a few places where the information is really helpful. A lot of tools are able to understand this already. Change-Id: Ide45cae8c7875e664fab1155c6c720e515d8d811
* Reorg: Namespace the Title classJames D. Forrester2023-03-021-0/+1
| | | | | | | | | | | | | | | | | | | This is moderately messy. Process was principally: * xargs rg --files-with-matches '^use Title;' | grep 'php$' | \ xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1' * rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \ xargs rg --files-with-matches 'Title\b' | \ xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1' * composer fix Then manual fix-ups for a few files that don't have any use statements. Bug: T166010 Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
* Reorg: Move HTML-related classes out of includes/ to Html/Amir Sarabadani2023-02-161-0/+1
| | | | | Bug: T321882 Change-Id: I5dc1f7e9c303cd3f5b9dd7010d6bb470d8400a18
* Use canonical parser options when rendering JavaScript/CSS for side effectsC. Scott Ananian2022-07-281-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | In the JavaScript and CSS content handlers we render the page "as wikitext" solely to generate categories, toc, etc, and then throw that output away and replace the generated HTML. Simplify the code paths and the caching by using the canonical options which don't split by user language, etc. Three minor issues with the current patch, which can hopefully be addressed in follow ups: 1. WikiPage::makeParserOptionsFromTitleAndModel() has a very cumbersome name and arguably doesn't belong in WikiPage in the first place. T313455 already exists to find a better place for this/way to do this. 2. Title::isConversionTable() requires a downcast of the page reference to a full title object. This method also probably wants to live somewhere else. 3. It really would be nice to combine this more properly with ContentHandler::getParserOutputForIndexing(), but that method uses a ParserOutputAccess object which requires a PageRecord, and we don't have a PageRecord available in fillParserOutput(). Bug: T307691 Change-Id: I081105741b507ed49e19cb878550ba4293e09413
* Migrate risky callers of MediaWikiServices::getParser()Tim Starling2022-07-051-2/+2
| | | | | | | | Don't call MediaWikiServices::getParser() from ContentHandler. Always use ParserFactory::getInstance(). Bug: T310948 Change-Id: I5fcdc28111e0c5c7d4a76e69b3978402433ebad9
* Clarify generate-html and make ParserOutput behave as expectedBrian Wolff2022-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously: * It was unclear that generate-html is an optional optimization * Most of MediaWiki core was doing $parserOutput->setText('') if html wasn't generated. However this is wrong and will cause $parserOutput->hasText() to return true and also potentially cause cache pollution if a content handler both does that and supports parser cache (Like MassMessage; see T299896) * The default value of mText in the constructor was '', and most of the time MW used that default. This doesn't seem right. If setText() is never called, the ParserOutput should not be considered to have text * It was impossible to set mText to null, as $parserOutput->setText(null) was a no-op. Docs implied you were supposed to do this, so it was very confusing. This patch clarifies docs, changes the default value for ParserOutput::$mText from '' to null, and makes $parserOutput->setText(null) do what you expect it to. The last two are arguably breaking changes, although the previous behaviours were unexpected, mostly undocumented and based on a code search do not appear to be relied on. It seems like the main reason this only broke MassMessage is most content handlers either don't support generateHtml, or they don't support parser cache. Bug: T306591 Change-Id: I49cdf21411c6b02ac9a221a13393bebe17c7871e Depends-On: I68ad491735b2df13951399312a4f9c37b63a08fa
* Use MainConfigNames instead of string literals, #4Aryeh Gregor2022-04-261-1/+3
| | | | | | | | | | | | | | | | | | | | | Now largely automated: VARS=$(grep -o "'[A-Za-z0-9_]*'" includes/MainConfigNames.php | \ tr "\n" '|' | sed "s/|$/\n/;s/'//g") sed -i -E "s/'($VARS)'/MainConfigNames::\1/g" \ $(grep -ERIl "'($VARS)'" includes/) Then git add -p with lots of error-prone manual checking. Then semi-manually add all the necessary "use" lines: vim $(grep -L 'use MediaWiki\\MainConfigNames;' \ $(git diff --cached --name-only --diff-filter=M HEAD^)) I didn't bother fixing lines that were over 100 characters unless they were over 120 and triggered phpcs. Bug: T305805 Change-Id: I74e0ab511abecb276717ad4276a124760a268147
* Refactor global variables to use MediaWikiServices insteadTChin2022-01-101-2/+2
| | | | | | | | | | | | Automatically refactors wg prefixed globals to use MediaWikiServices config using Rector. Doesn't include files that set globals or files that fail CI. Rector Gist: https://gist.github.com/tchin25/7cc54f6d23aedef010b22e4dfbead228 * This patch uses a modified source code rector library for our specific use case and the rector will have different effects without it. A writeup for future reference is here: https://meta.wikimedia.org/wiki/User:TChin_(WMF)/Using_Rector_On_MediaWiki Change-Id: I1a691f01cd82e60bf41207d32501edb4b9835e37
* Move Content::getParserOutput & AbstractContent::fillParserOutput to ↵Roman Stolar2021-09-291-0/+39
| | | | | | | | | | ContentHandler Update/Create override classes of ContentHandler. Soft-deprecate and remove method from Content and classes that override them. Bug: T287158 Change-Id: Idfcfbfe1a196cd69a04ca357281d08bb3d097ce2
* Move Content::preloadTransform to ContentHandlerRoman Stolar2021-08-171-3/+10
| | | | | | | | | | | | | | | | Update ContentTransformer to access ContentHandler::preLoadTransform through the service. Prepare object to hold a data that required for ContentHandler::preLoadTranform params. This is a fully backwards compatible change. We are doing hard deprecation via MWDebug::detectDeprecatedOverride. However, with the ContentHandler calling Content and Content calling ContentHandler, it doesn't matter whether callers use Content or ContentHandler. This will allow us to naturally convert all callers. Bug: T287157 Change-Id: I89537e1e7d24c6e15252b2b51890a0bd81ea3e6b
* Support deprecated Content::preSaveTransform overridePetr Pchelko2021-08-051-0/+5
| | | | | | | | | | | If an exctension ContentHandler overrides one of the subclasses of the core ContentHandler, for example TextContentHandler, when switching calls we no longer call deprecated Content::preSaveTransform for the extension Content model. Bug: T288191 Change-Id: Ie7edc97be9098f3cd188949bd37943c37a0b65ff
* Move Content::preSaveTransform to ContentHandlerPetr Pchelko2021-07-291-0/+28
| | | | | | | | | | | | | | | | | | | Create ContentTransformer to access ContentHandler::preSaveTransform through the service. Prepare object to hold a data that required for ContentHandler::preSaveTranform params. This will require making a semi-backwards-incompatible change no matter what, we don't really have a great way of hard-deprecating overriding methods. However, with the ContentHandler calling Content and Content calling ContentHandler, and with the ProxyContent trick to stop infinite recursion, it doesn't matter whether callers use Content or ContentHandler. This will allow us to naturally convert all callers. But won't really allow hard-deprecation. Bug: T287156 Change-Id: If6a2025868ceca3a3b6f11baec39695e47292e40
* resourceloader: Add wikimedia/minify package and remove local copiesTimo Tijhof2021-02-241-0/+1
| | | | | | | | | | | | | | | | | | | | | | - JavaScriptMinifier: The public interface for this internal class is ResourceLoader::filter which, except for one caller (minify.php) is indeed consistently used already, no other callers need replacing. - CSSMin: Idem for minification, however, this class has some other method as well, which have a number of internal users, but none outside core. These have all been replaced in this commit. - Remove pear/net_url2 as own dependency as this was only used by CSSMin and recently added there. This is now a dependency of wikimedia/minify instead. This was not part of the public API and no longer mentioned here in composer.json or RELEASE-NOTES. (It remains pinned in mediawiki-vendor, however.) Bug: T273247 Depends-On: Iadff8c2112d5e53bd994ab4882006e8c644a2379 Depends-On: Id3c6dcc0b952a9efe34b3a9ed88b716101a51f87 Depends-On: I589be910f57289fd908b22db87241b0e52da60d4 Change-Id: I8d71fc64aeecdb31db218b02e361ae9bb0d19b48
* content: Use "::class" when overriding TextContent::getContentClass()Kunal Mehta2016-08-121-1/+1
| | | | Change-Id: Iea03d2cd24fdb90253145a8abfefe9f8a09e46cd
* Convert all array() syntax to []Kunal Mehta2016-02-171-1/+1
| | | | | | | | | | Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
* CssContentHandler: Fix @return documentationKunal Mehta2015-08-281-1/+1
| | | | | | Missed this when copying the code from JavaScriptContentHandler... Change-Id: I6b232e431b4e997b65a698de42473c9b6deae6b1
* Implement redirects in CssContentKunal Mehta2015-07-281-0/+19
| | | | | | | | | Just like ad9f14d662f959 which was for JavaScript. The redirect will be of the form "/* #REDIRECT */@import url(...);". Bug: T73201 Bug: T35973 Change-Id: I10bae44af4b4923f8797172702974cd45dc25ab4
* CSS/JSON/JavaScript ContentHandler refactoringYuri Astrakhan2014-09-151-30/+1
| | | | | | | | | * All content handlers that deal with code/data tend to have English as their page language & pageview language, so moved common code to the abstract CodeContentHandler class. * Renamed JSONContent & JSONContentHandler into JsonContent* Change-Id: I46819a0572ef5becc211d0d82471ff7102edaa3c
* Make it easier to subclass Content and ContentHandler subclassesKunal Mehta2014-08-161-21/+2
| | | | | | | | | | | | Currently the names of associated Content classes are hardcoded, meaning that any extension that wishes to subclass these implementations must also re-implement that function, usually copying it exactly with just the class name changed. Using "static" avoids that issue. For ContentHandlers, I added a TextContentHandler::getContentClass, which should be used when creating new Content objects. Change-Id: I70f1a3291aec3460120ec20121a23f4cb68e04d1
* Cleanup some docs (includes/[a-d])umherirrender2014-07-241-2/+2
| | | | | | | | | | - Swap "$variable type" to "type $variable" - Added missing types - Fixed spacing inside docs - Makes beginning of @param/@return/@var/@throws in capital - Changed some types to match the more common spelling Change-Id: I7b65fe04db431342cc58b469dc48f41a50c4e891
* Added and updated Doxygen comments in content handler and diff namespacesThiemo Mättig2014-03-061-0/+20
| | | | | | | | | | | | | | | | | | | | | | | Reasons for touching this are: * "@param type $var" were mixed in a lot of places. Both works but the MediaWiki coding conventions suggest that specific order. * Things like String and Bool aren't objects and shouldn't be uppercase. * Tried to fill missing types in "@param $var". * Tried to fill missing descriptions in "@return type" when I could. * Removed duplicate descriptions if a @see is sufficend. * Removed useless descriptions ("isUsefull returns true if usefull"). * Removed useless @return void. * Replaces mixed[] with array (does have the exact same meaning). * Tried to find better replacements for "varargs", phpDocumentor suggest $var,... * Order should be @since, @param, @throws, @return, @see. This is the order Doxygen renders this. There is always more to do but I think this is already much better than before. Please feel free to put more change sets on top of mine or request more changes by adding comments. Change-Id: I05262ce06caabf79f68772302524ac91bbead1c6
* Update documentation and break long linesSiebrand Mazeland2013-11-201-1/+4
| | | | | | Also remove some superfluous newlines. Change-Id: I904d6ddeb976434708d5a22df9e8abd2e6f60a6c
* Improve documentation of content handler stuffAlexandre Emsenhuber2012-12-201-0/+6
| | | | | | | | - Split file and class documentation - Add some missing file/class descriptions - Add missing @ingroup Content Change-Id: I7f7e3056570ca13a92f36a408c9b961c938f09a1
* (bug 26280) all files should have GPL headerAntoine Musso2012-11-181-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | MediaWiki is licensed under GPL so we should really add the header to our PHP code unless reusing code licensed differently. Tested using: ack-grep --php -L 'This program is free software' \ includes/ maintenance/ mw-config/ resources/ skins/ Output the following files: includes/ExternalEdit.php (public domain) Various other licenses: includes/json/Services_JSON.php includes/libs/CSSMin.php includes/libs/IEContentAnalyzer.php includes/libs/JavaScriptMinifier.php includes/libs/jsminplus.php includes/normal/Utf8Case.php includes/objectcache/MemcachedClient.php File autogenerated from a GPL file and Unicode data: includes/ZhConversion.php A few lines coming from stack overflow: maintenance/mwdoc-filter.php Message files do not have any license :-/ Change-Id: I214a988edfa9e2dfcc762612a0f7d47eee8bcb74
* Moved ContentHandler deriving classes into their own files for better ↵jeroendedauw2012-10-161-0/+43
discoverability and more manageable line count per file Change-Id: I37db53e1d1420e61d3af4566322bcdba85ec778b