Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4041280
SortTexutil.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SortTexutil.php
View Options
<?php
require_once
__DIR__
.
'/../../../maintenance/Maintenance.php'
;
class
SortTexutil
extends
Maintenance
{
public
function
execute
()
{
$jsonFilePath
=
'./src/WikiTexVC/texutil.json'
;
$jsonContent
=
json_decode
(
file_get_contents
(
$jsonFilePath
),
true
);
if
(
$jsonContent
===
null
)
{
die
(
"Failed to decode texutil.json. Please check the file format.
\n
"
);
}
foreach
(
$jsonContent
as
$key
=>
$value
)
{
// Sort the entry alphabetically
ksort
(
$jsonContent
[
"$key"
]
);
}
// Sort the entire file
ksort
(
$jsonContent
);
$jsonString
=
json_encode
(
$jsonContent
,
JSON_PRETTY_PRINT
|
JSON_UNESCAPED_UNICODE
);
$jsonStringWithTabs
=
preg_replace_callback
(
'/^( +)/m'
,
static
function
(
$matches
)
{
// Convert spaces to tabs (assuming 4 spaces per tab level)
return
str_repeat
(
"
\t
"
,
strlen
(
$matches
[
1
]
)
/
4
);
},
$jsonString
)
.
"
\n
"
;
// prevent eslint error Unnecessary escape character: \/ no-useless-escape
$jsonStringWithTabs
=
str_replace
(
'
\/
'
,
'/'
,
$jsonStringWithTabs
);
file_put_contents
(
$jsonFilePath
,
$jsonStringWithTabs
);
echo
"texutil.json successfully sorted.
\n
"
;
}
}
$maintClass
=
SortTexutil
::
class
;
require_once
RUN_MAINTENANCE_IF_MAIN
;
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 15 2026, 06:21 (12 w, 5 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c0/9d/c31561d3845ffda233f04640f310
Default Alt Text
SortTexutil.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment