Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7396942
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'
;
use
MediaWiki\Maintenance\Maintenance
;
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
Sat, Nov 21, 14:25 (5 h, 15 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0a/52/ead35b3e984c7dfb1f2add190941
Default Alt Text
SortTexutil.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment