MediaWiki REL1_32
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";
68require_once RUN_MAINTENANCE_IF_MAIN;
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