MediaWiki REL1_30
updateCSS.php
Go to the documentation of this file.
1<?php
25use Symfony\Component\Process\ProcessBuilder;
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 $this->addDescription( 'Generate CSS code for SyntaxHighlight_GeSHi' );
36 }
37
38 public function execute() {
39 $target = __DIR__ . '/../modules/pygments.generated.css';
40 $css = "/* Stylesheet generated by updateCSS.php */\n";
41
42 $builder = new ProcessBuilder();
43 $builder->setPrefix( SyntaxHighlight_GeSHi::getPygmentizePath() );
44
45 $process = $builder
46 ->add( '-f' )->add( 'html' )
47 ->add( '-S' )->add( 'default' )
48 ->add( '-a' )->add( '.' . SyntaxHighlight::HIGHLIGHT_CSS_CLASS )
49 ->getProcess();
50
51 $process->run();
52
53 if ( !$process->isSuccessful() ) {
54 throw new \RuntimeException( $process->getErrorOutput() );
55 }
56
57 $css .= $process->getOutput();
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...
addDescription( $text)
Set the description text.
__construct()
Default constructor.
Definition updateCSS.php:33
execute()
Do the actual work.
Definition updateCSS.php:38
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