Commit graph

78 commits

Author SHA1 Message Date
Novem Linguae 82b5c422c2 CategoryTree: improve comment
Contrary to what this comment says, this extension is not all-AJAX.
If you disable JavaScript in the browser, the subcategory counts
still show, so it is about half JS, half PHP. The JS part is the little
triangle you can click to load the list of subpages.

Change-Id: Ib25a13c57656b832e079627301f45b94bbd7e814
2024-11-16 15:38:35 -08:00
Ebrahim Byagowi 845595cb8e Remove an outdated comment
No href will be added on the JS side either.

Change-Id: I4c78fef10c24a942db7e468106588b16012ab653
2024-11-05 14:48:02 +03:30
Ebrahim Byagowi 77b047b12b Remove page href from arrows
As having href causes arrows to be clickable before JavaScript
handler be loaded.

And since that disables visited logic, let's remove it.

Change-Id: Ice4c979d020342890fffd587bb5bee88fcc2a1ae
2024-11-05 13:06:36 +03:30
jenkins-bot 6f4d131768 Merge "Get mode from data-ct-options instead of data-ct-mode" 2024-11-04 15:20:58 +00:00
Fomafix 46defa6251 docs: Replace CategoryTreeFunctions.php by CategoryTree
In 8e51ea4e3a CategoryTreeFunctions.php
was renamed to includes/CategoryTree.php. The class name was already
CategoryTree.

Change-Id: I2734c92810df0f653ae1ea402a149e42e7be08cb
2024-11-04 14:26:13 +00:00
Fomafix a62550b687 Get mode from data-ct-options instead of data-ct-mode
The attribute data-ct-options already contains the mode and attribute
data-ct-mode is just redundant. The attribute data-ct-mode is now not
needed anymore and removed from the rendered HTML.

Change-Id: If261f3cdab6c55243e80dc2ef3caa884538b02bc
2024-11-04 12:08:22 +00:00
Andre Klapper 63688178e9 Use explicit nullable type on parameter arguments (for PHP 8.4)
Implicitly marking parameter $... as nullable is deprecated in PHP
8.4. The explicit nullable type must be used instead.

Bug: T376276
Change-Id: I40bb7a0a02aaa467cbf0ae182adf5601ccbcb58e
2024-10-26 14:43:49 +02:00
jenkins-bot fbc82558e8 Merge "Remove duplicate/unnecessary trim" 2024-10-10 16:45:07 +00:00
jenkins-bot 4d2836760f Merge "Move all Parser handling to Hooks::parserHook" 2024-10-10 16:45:06 +00:00
jenkins-bot ee0a3f1aab Merge "Remove $allowMissing and make the check directly on the hook" 2024-10-10 16:01:18 +00:00
jenkins-bot 7aaf9f42be Merge "Replace use of getDirMark with HTML markup" 2024-10-05 17:32:34 +00:00
Ebrahim Byagowi fcc3334125 Make category links arrow link to actual categories
I believe having arrows linked to the actual pages can
be much more useful than linking to '#' of the same
page. Linking to the correct page makes user to notice
if the page is already visited also using color of
the arrow.

If we didn't like link visited logic to be not used we
could've used a different link rather than color of links
and going makes us able to :visited logic of
If8b2b45b24351ee5c8fc9ee1380563f5d5b88678 also.

Personally however I'm in believe that having a useful
link that can be opened on a different tab using
Ctrl (or long click on phones) is always more useful.

Change-Id: Ib56fad0b711853d67b2d55617b36deff56141c74
2024-10-05 00:48:31 +03:30
Fomafix 092797b0e2 Remove duplicate/unnecessary trim
CategoryTree::makeTitle also makes a trim and an early return.

A trim on the return value of renderChildren() is not needed.

Change-Id: I1fc2705277491797eb6c0d0900152b63913ca875
2024-10-04 19:55:50 +00:00
Fomafix 921e6fe3f9 Move all Parser handling to Hooks::parserHook
Change-Id: I5d35c6d87b610ffb566588a3d0c75067c1d06962
2024-10-04 19:55:24 +00:00
Fomafix a918bdea16 Remove $allowMissing and make the check directly on the hook
This change avoids a super category expand button on not existing
categories.

This change even avoids loading the modules if there are no valid
categories.

Change-Id: I38a2b49aaef7cf46d9f89e1cc9fd65e2382155f5
2024-10-04 19:53:37 +00:00
Ebrahim Byagowi fe71840c56 Replace use of getDirMark with HTML markup
Bug: T375975
Depends-On: I2ee6d8fb9161a5434eacad819c6d7784aee8aac3
Change-Id: Ia1ab65222c486ea89e6b916fd1d5a6860439205e
2024-10-04 22:06:26 +03:30
Fomafix b1e3b5f06d Update namespaces of PHP classes
Change-Id: I8c4e81631b4c3f7321837e12713a8a33762a8fcc
2024-10-03 19:55:44 +00:00
Fomafix 8fe224cd60 Use PHP types
* Add PHP type hints where possible.
* Remove @var, @param and @return if redundant to type declaration
* Remove redundant type conversions which are now enforced by type
  hints.
* Enforce that decodeBoolean returns only a bool.

Change-Id: I8da84ed4dc778dd9d84f8d9eec0a399f5ed26405
2024-08-20 08:16:37 +00:00
Umherirrender 3e2ce8c6f4 Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I51931c3aab6aa1e5bc77b3cc83b8014cf557ff75
2024-06-08 23:29:21 +02:00
Fomafix e6c9eab90f Use namespaced PHP classes
These namespaces are available since MediaWiki 1.42 which is already
required in extension.json.

Change-Id: If72d77a5440516beeac637b4baf06e9b4c672e8a
2024-05-22 20:11:23 +00:00
Umherirrender d8f77953a1 Migrate to IReadableDatabase::newSelectQueryBuilder
RIGHT JOIN is unsupported by SelectQueryBuilder, swapped to LEFT JOIN

Bug: T312395
Change-Id: Idd646422dc6c984d7ceab23743e53e64bccb987c
2024-04-25 20:21:57 +02:00
Nardog 08a23b5c26 Make the toggle reachable by keyboard
Bug: T355636
Change-Id: Ie765cddd664933fa07638c661874bef80782dd45
2024-02-05 06:53:05 +00:00
Fomafix 9206c5368b Inject service DBLoadBalancerFactory
Change-Id: I50195f98c2ea130f9dba73e357977653c2fc1a37
2023-11-14 13:40:30 -05:00
Fomafix c63d5da014 Replace global variables by injected Config
Convert some functions to non-static function to access the Config
object.

Change-Id: Iac3d6a6c00eef169aec91b8c367cbbb7359a9b02
2023-11-14 07:15:35 +00:00
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