Commit graph

54 commits

Author SHA1 Message Date
Fomafix e492044e44 Inject service LinkRenderer into CategoryTree
Change-Id: Id70e9b26229332889de009b55837dbab6ecbb163
2023-10-29 09:28:03 +00:00
Fomafix e81f6fe15e Move option handling from CategorieTree into new class OptionManager
Change-Id: I0327f7ea6751cdb714308f1ffaf0ab7ac44a3aac
2023-10-29 09:26:56 +00:00
Fomafix 75c2c5580a Simplify PHP code
Change-Id: Ia1bd08cd972b2f5792d24d5fbc383c3c63b000db
2023-10-03 19:38:03 +00:00
Fomafix 8bd82c12f6 Use namespaced classes
Change-Id: I9fabf791aae691dfa7d071a1d99d17f4f7379682
2023-10-03 09:36:31 +00:00
Fomafix b2ef67d9c8 Replace deprecated wfGetDB( DB_REPLICA )
Bug: T330641
Change-Id: Ic2dc694bbb29c3ff315f2be32c24ee6995f9b964
2023-09-20 20:42:06 +00:00
gerritbot 6d296c41ce Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I004e02c6b719be1bbfa1fa19f53e4fab2a7aeca1
2023-08-16 01:54:29 +00:00
gerritbot 0cf8b3dfe5 Update moved class Category
See T321882. Moved in I0b86acfdea

Bug: T321681
Change-Id: If48e9163bcfcfe03098f61b7cc52137e4ecaae82
2023-05-12 14:33:05 +00:00
Umherirrender 8b4ab1fd43 Use LinkBatchFactory to create LinkBatch objects
Bug: T325591
Change-Id: I3c529e62e45a38e6752f37b6bf36a1e727511e46
2022-12-19 21:37:43 +01:00
Fomafix 828566ef60 Optimize PHP code semantic
* Mark $mOptions as private. There is no external reference.
* CategoryTree::makeTitle don't return false. A check for false is not
  needed.
* A class attribute should not start with a space.
* $title->isExternal() is equivalent to $title->getInterwiki() !== ''.
* Use $title->inNamespace( NS_CATEGORY ) instead of
  $title->getNamespace() === NS_CATEGORY.

Change-Id: Iddad84ff5a18080d1216346ec2a906c955a644a4
2022-11-12 19:08:16 +00:00
jenkins-bot ba6e585427 Merge "Check for null after Title::newFromText" 2022-11-12 17:31:19 +00:00
Fomafix c5b34028e3 Remove phpcs exclude rules and update PHP code
Consistently use single line @var declararation.

Change-Id: I02210ddcc1c523bda6e26adb17e7b6bd38db752d
2022-11-10 20:15:44 +00:00
Fomafix cf8538086c Check for null after Title::newFromText
Title::newFromText returns null on invalid title.

Change-Id: Iaef69584eff33b1b13669f8d0a3b8eeeba3755cc
2022-11-10 19:27:54 +00:00
Ammarpad de9a92c7a3 CategoryTree: Use Category::getMemberCount from core
Core now provides all-member count separately with type guarantee.

Also bump core requirement to >= 1.38.0

Change-Id: I2b489e690ad05462a553e424bd9495593a8d2b1b
2022-02-21 23:15:47 +01:00
Fomafix 49453bbfde Avoid default value style="display:block" in HTML
This change makes the HTML smaller.

Change-Id: Ie90eb8c85bb530de634bd190290e9aa303018073
2021-09-17 08:55:50 +00:00
Fomafix ed87adce49 Optimize PHP code
* Use ' instead of ".
* Use === instead of ==.
* Use !== instead of !=.
* Use explicit type cast.
* Combine array assignment.
* Use null coalescing operator.

Change-Id: Ic2fe4f62556df77262915b5bcbe1b11a1d907e6d
2021-09-11 21:42:45 +00:00
Fomafix 509745aaaa Simplify by using Html::element and Html::rawElement
Use element/rawElement instead of openElement and closeElement.

Change-Id: I7229200f073326e66e6bc3c0907da6817777110a
2021-09-11 21:01:03 +00:00
Fomafix a887e226e0 Replace PHP use of Xml class by Html class
Change-Id: I5d98f875566a2ad5da31c707873f3af6d984de34
2021-09-11 21:00:45 +00:00
Fomafix 480ff35722 Add output encoding to $category in not found message
This change outputs the not found category as plain text and prevents
parser processing of the category name like '''bold''' or ''italic''.

This affects the root category of the category tree in the sidebar
like on
$wgCategoryTreeSidebarRoot = "Lista d''e Paise d''o munno"
for a situation without parser and
{{#categorytree:Lista d''e Paise d''o munno}}
or
<categorytree>Lista d''e Paise d''o munno</categorytree>
in the content for situations with parser.

A separation for with and without parser is not needed anymore.
Problem described in T18744 which was the reason for change r49471
(9700e2d5) is not reproducible.

This change also prevents that the value in the parameter `target` on
Special:CategoryTree gets interpreted as wikitext and outputs the value
with an output encoding.

  Special:CategoryTree?target=B%27%27%27o%27%27%27ld%20un%3Cu%20onclick%3d%22alert(%27XSS%27)%22%3Eder%3C/u%3Eline

was rendered as

  B<b>o</b>ld un<u>der</u>line

and is now rendered as

  B'''o'''ld un&lt;u onclick="alert('XSS')"&gt;der&lt;/u&gt;line

The parser prevented already JavaScript injection, so there was no
security issue.

Change-Id: I592b23ba965c15b81a2f97686161a4d590331c87
2021-09-11 20:54:11 +00:00
Umherirrender a892ae21f7 Improve string handling around trim()
trim() would always return a string, even with null as input
Keep the strval to make visible that this gets unsafe input

Change-Id: I6ff0ce307f6a8ac21669d6db693e5ff27767a55d
2021-09-02 21:29:25 +02:00
jenkins-bot 6cba244a94 Merge "Simplify CategoryTree::capDepth" 2021-08-24 09:30:11 +00:00
Fomafix 0bfff67aac Move bullets from HTML to CSS
This allows better to style the buttons.

The complicated CSS selector for the direction supports a categorytree
in the user interface language like in the sidebar or on
Special:CategoryTree and in the content language like on category pages
and with <categorytree> in the content.

The CSS selector :dir( rtl ) would be a short version for this but it is
currently only supported by Firefox:
https://developer.mozilla.org/en-US/docs/Web/CSS/:dir

Bug: T288910
Change-Id: Ibfb0cb28f0086fb1b7d0997be2246bc120eea85e
2021-08-21 14:50:15 +00:00
Matěj Suchánek c7b79338d5 Simplify CategoryTree::capDepth
Current master of CategoryTree requires MW 1.35, which requires PHP 7.3.

Change-Id: Ibec271bf45465cd61ac383595041e0475304f31c
2021-07-07 12:42:08 +00:00
Reedy 03685efdba Namespace extension
Change-Id: Idf4fbb9ff0c11b9da0b48b3843b2c87c155a4c36
2021-04-08 01:28:21 +01:00
libraryupgrader 44c2059ac3 build: Updating mediawiki/mediawiki-phan-config to 0.10.5
Change-Id: I839cd5acfdd3022551f77a4f432bdce7920150dd
2020-12-09 21:47:40 -08:00
Yuukin256 b3fa4441a0 Fixed a bug that double percent-encoding on Special:CategoryTree
Special:CategoryTree shows wrong link to parent category that containing string that need percent-encoding.
Changed getPartialURL() to getDBkey() on CategoryTree.php. getPartialURL() returns a percent-encoded URL and getDBkey() returns no encoded URL.

Bug: T253621
Change-Id: Idffb8ffece88a1d726075ffee9d64e6e05ed4e52
2020-05-27 22:36:50 +09:00
libraryupgrader 4180323699 build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: I5f4050a13d1ac8db56adebe8d4bf13b84da5545a
2020-01-14 03:58:43 +00:00
Umherirrender 0365b1bdea Fix doc of CategoryTree::getOptionsAsCacheKey
The depth is a number and provided as int

Change-Id: I884279bf69fc3661ad8279965a02d38867a85868
2019-12-08 22:11:08 +01:00
jenkins-bot e60b968434 Merge "Suppress page translations and render only the default page(s)" 2019-11-08 14:04:52 +00:00
Derick Alangi 87ddb7f735 Suppress page translations and render only the default page(s)
This feature add an option `notranslations` that allows the category
tree only to show the default pages and not include their translations
equivalents on the tree. For example let's say we have a page (Test_page)
that was created in a default language "en" in a category TestCat, and has
translations listed: Test_page/es, Test_page/de, Test_page/ar etc.

Doing `<categorytree notranslations="on">TestCat</categorytree> will render
only the Test_page page with it's link to the page on the tree and nothing
more.

Note: If page "Foo/hu" exist but "Foo" doesn't, it should include "Foo/hu"
      in the category tree. In most case though, a base page will exist.
      Also, the feature is only available if Extension:Translate is made
      available on that wiki.

TODO: If "notranslations" is used along side with "showcount", consider
      subtracting the number of pages suppressed from the total page count
      in the category tree for consistency.

Bug: T229265
Change-Id: Ib4e7ab6ad98c05857cda1cd98bbc19e0504677bb
2019-11-03 14:03:27 +01:00
Umherirrender 88893ed005 build: Updating mediawiki/mediawiki-phan-config to 0.8.0
Bug: T235049
Change-Id: I40fd8ddf278a716171a05a30215fdef6fcf123be
2019-11-01 21:38:00 +01:00
Umherirrender 414c62f19b phan: Remove PhanParamReqAfterOpt suppression
Change-Id: I326165c7cdb98dabc2aa9a3fd73d637f2e5bceec
2019-10-12 22:14:41 +02:00
Kunal Mehta 1c779bee3a Use LinkRenderer instead of manually building links
Use LinkRenderer instead of manually re-implementing parts of it and
manually building the <a> tags to create links.

Aside from technical debt cleanup, this will cause "stub" and "mw-
redirect" classes to get added to the <categorytree> output.

Bug: T25771
Change-Id: I1c644ef364818c4202dc0e30602d557dbec46010
2019-09-07 11:49:53 +02:00
Derick Alangi 5b342c51ab Avoid usage of deprecated $wgContLang global (dep in 1.32)
Change-Id: Ic70ac2bc7eeba6af9a69bb1eb839a87cd06c01f8
2019-09-01 19:01:45 +00:00
Sharptrick d78fc9add9 Altered renderNodeInfo() to use LinkRenderer.php.
Using LinkRenderer.php instead of compiling links manually gives the
HtmlPageLinkRendererBegin hook a chance to be called. This enables
compatibility with the DisplayTitle extension.

Change-Id: I67633d1add6d1409eac6962a7bd854c3cc93d5ff
2019-07-31 05:52:00 +00:00
Derick Alangi f9f6ac6348 Avoid use of deprecated ->disableCache() in Parser
This method was deprecated in mediawiki 1.27.

Change-Id: Icdeeb41bbc66bcf6df25e42769bdb4e8140c058a
2019-04-30 12:06:25 +00:00
Matěj Suchánek 89c61833c2 Migrate to new phan
Bug: T216908
Change-Id: I28faf3638dfbc20b84ba78d476b02f7bbc8cbd6a
2019-03-17 21:25:03 +01:00
jenkins-bot c4d39389a8 Merge "Change 'title' attributes to links to use full page name" 2019-02-14 00:53:10 +00:00
Peter Boehm 1dfe6ca618 Change 'title' attributes to links to use full page name
This changes the title attribute on the link generated in the
CategoryTree. The only effect is additional information about the
link target that may be truncated by 'hideprefix' or CSS overflow,
will now still be accessible in another way.

Change-Id: I4f07fa88f0a528634e9bf3c504e84fb4bf55e3bf
2019-02-14 00:46:35 +00:00
Fomafix 0a3f30b8d7 Simplify code by using Xml::element()
Change-Id: I8b0d1c35d8d7cc310769d586a1716ef5ffbd46b3
2019-02-12 02:47:13 +00:00
Fomafix c993bb8353 Fix findings by phpcs
* Add @inheritDoc to functions that are inheritance.
* Move comments to a single line.

Remove the phpcs rule exceptions:
* MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected
* MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic
* MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment

Change-Id: I742ee19f0a3d2d62e08b6f2e35cd9a6b3940cd22
2019-02-06 18:03:50 +00:00
Fomafix b3ac7f5404 Add typehints to function parameters
* Add "= null" when null is supported and used.
* Also fix Doxygen tags.

Change-Id: I209b23eee54b5e8e0f4091f3d4cd7c5e44dbaff0
2019-02-05 15:30:31 +01:00
Fomafix 3cdb4e95f2 Move styles that only used in JavaScript to JavaScript module
Also rename the style module from 'ext.categoryTree.css' to
'ext.categoryTree.styles'.
Keep the previous module name 'ext.categoryTree.css' for compability to
cached versions.
Also move the files of the module 'ext.categoryTree' into a
subdirectory ext.categoryTree.

Change-Id: Ie5ea28acfb43e33a94ec5824baf4f26d63d8e9e6
2019-01-10 13:38:58 +01:00
jenkins-bot be6dd1b089 Merge "Remove trailing \r\t\t" 2018-08-04 18:41:16 +00:00
Brian Wolff f36af62317 Fix some raw html messages
Try also to ensure that the bullet messages are treated the
same in both JS and PHP. It should be noted that the mk and scn
translations are currently broken on the JS side.

Bug: T195010
Change-Id: Id87d26db8d90e293701ae11f6434026a8ae88822
2018-08-02 01:25:31 -07:00
Sophivorus 96fe66c4c5 Remove trailing \r\t\t
Doesn't seem to serve any useful purpose
and adds an unwanted trailing <p></p> after the category tree

Change-Id: Ic76ff3b1156a5627930c1078e488f5c81ec5521d
2018-06-12 16:59:45 +00:00
Fomafix 6684f62bba Simplify by using Xml::element
Xml::element already makes the HTML encoding.

Change-Id: Idee5e6871c5a7b5e6763ebe85275598b9b217224
2018-04-18 09:36:40 +02:00
Kunal Mehta 50c10d1fcb Use standard GPL file header
Change-Id: Ic49d45d0a0cb640d40486735c95f13cc6e29063f
2018-04-16 22:38:06 +00:00
libraryupgrader 5a7ebcfead build: Updating mediawiki/mediawiki-codesniffer to 18.0.0
The following sniffs now pass and were enabled:
* MediaWiki.Commenting.LicenseComment.InvalidLicenseTag

Change-Id: I13c4825186d8ba101feb2a2d28ee8dc9bc7306dd
2018-04-13 22:19:35 +00:00
Kunal Mehta 72db0e9107 Avoid unnecessary is_bool
Strict equality already ensures that the global is a boolean.

Change-Id: I09011f4d6ac5fabe1154ef19d8ba34f289f764f7
2018-04-10 20:48:37 -07:00
Kunal Mehta 1c60788059 Set visibility on all functions
Change-Id: I1ced553ac5c18eafa83e32516ddc463feece96ef
2018-04-10 20:48:37 -07:00