MediaWiki REL1_33
updateCSS.php
Go to the documentation of this file.
1<?php
26
27$IP = getenv( 'MW_INSTALL_PATH' ) ?: __DIR__ . '/../../..';
28
29require_once "$IP/maintenance/Maintenance.php";
30
31class UpdateCSS extends Maintenance {
32
33 public function __construct() {
34 parent::__construct();
35
36 $this->requireExtension( 'SyntaxHighlight' );
37 $this->addDescription( 'Generate CSS code for SyntaxHighlight_GeSHi' );
38 }
39
40 public function execute() {
41 $target = __DIR__ . '/../modules/pygments.generated.css';
42 $css = "/* Stylesheet generated by updateCSS.php */\n";
43
44 $result = Shell::command(
46 '-f', 'html',
47 '-S', 'default',
48 '-a', '.' . SyntaxHighlight::HIGHLIGHT_CSS_CLASS
49 )
50 ->restrict( Shell::RESTRICT_DEFAULT | Shell::NO_NETWORK )
51 ->execute();
52
53 if ( $result->getExitCode() != 0 ) {
54 throw new \RuntimeException( $result->getStderr() );
55 }
56
57 $css .= $result->getStdout();
58
59 if ( file_put_contents( $target, $css ) === false ) {
60 $this->output( "Failed to write to {$target}\n" );
61 } else {
62 $this->output( 'CSS written to ' . realpath( $target ) . "\n" );
63 }
64 }
65}
66
67$maintClass = UpdateCSS::class;
68require_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
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
__construct()
Default constructor.
Definition updateCSS.php:33
execute()
Do the actual work.
Definition updateCSS.php:40
require_once RUN_MAINTENANCE_IF_MAIN
$IP
Definition updateCSS.php:27
$maintClass
Definition updateCSS.php:67