MediaWiki REL1_31
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.
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
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
require_once RUN_MAINTENANCE_IF_MAIN
$IP
Definition updateCSS.php:27
$maintClass
Definition updateCSS.php:67