MediaWiki REL1_33
updateLexerList.php
Go to the documentation of this file.
1<?php
27
28$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
29
30require_once "$IP/maintenance/Maintenance.php";
31
33 public function __construct() {
34 parent::__construct();
35
36 $this->requireExtension( 'SyntaxHighlight' );
37 $this->addDescription( 'Update list of lexers supported by SyntaxHighlight_GeSHi' );
38 }
39
40 public function execute() {
41 $header = 'Generated by ' . basename( __FILE__ );
42
43 $lexers = [];
44
45 $result = Shell::command(
47 '-L', 'lexer'
48 )
49 ->restrict( Shell::RESTRICT_DEFAULT | Shell::NO_NETWORK )
50 ->execute();
51
52 if ( $result->getExitCode() != 0 ) {
53 throw new \RuntimeException( $result->getStderr() );
54 }
55
56 $output = $result->getStdout();
57 foreach ( explode( "\n", $output ) as $line ) {
58 if ( substr( $line, 0, 1 ) === '*' ) {
59 $newLexers = explode( ', ', trim( $line, "* :\n" ) );
60 $lexers = array_merge( $lexers, $newLexers );
61 }
62 }
63 $lexers = array_unique( $lexers );
64 sort( $lexers );
65 $data = [];
66 foreach ( $lexers as $lexer ) {
67 $data[$lexer] = true;
68 }
69
70 $writer = new StaticArrayWriter();
71 $code = $writer->create( $data, $header );
72
73 file_put_contents( __DIR__ . '/../SyntaxHighlight.lexers.php', $code );
74 $this->output( "Updated language list written to SyntaxHighlight.lexers.php\n" );
75 }
76}
77
78$maintClass = UpdateLexerList::class;
79require_once RUN_MAINTENANCE_IF_MAIN;
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$line
Definition cdb.php:59
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
requireExtension( $name)
Indicate that the specified extension must be loaded before the script can run.
output( $out, $channel=null)
Throw some output to the user.
addDescription( $text)
Set the description text.
Executes shell commands.
Definition Shell.php:44
execute()
Do the actual work.
__construct()
Default constructor.
Format a static PHP array to be written to a file.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Definition hooks.txt:856
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2272
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
require_once RUN_MAINTENANCE_IF_MAIN
$header
$maintClass