~ubuntu-branches/ubuntu/saucy/mediawiki-extensions/saucy

« back to all changes in this revision

Viewing changes to dist/mediawiki-extensions-base/usr/share/mediawiki-extensions/base/PageCSS/PageCSS.php

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis
  • Date: 2010-05-04 15:13:35 UTC
  • mfrom: (0.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100504151335-54qeucg3ec108q28
Tags: 2.2
* Added Replaces:/Conflicts: to allow a proper upgrade.
Closes: #580066
* Fixed package descriptions.
Closes: #579667
* Patched mediawiki-extensions-fckeditor to make it work with
  php 5.3. The fix may not be perfect but at least it work.
  Not closing the bug (#579822) for now..

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
if (!defined('MEDIAWIKI')) die();
 
3
/**
 
4
 * A parser hook to add per-page CSS to pages with the <css> tag
 
5
 *
 
6
 * @addtogroup Extensions
 
7
 *
 
8
 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
 
9
 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
 
10
 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 
11
 */
 
12
 
 
13
$wgExtensionFunctions[] = array( 'CssHook', 'setup' );
 
14
$wgExtensionCredits['parserhook'][] = array(
 
15
        'name' => 'Page CSS',
 
16
        'description' => 'Parser hook to add per-page CSS using the <tt>&lt;css&gt;</tt> tag',
 
17
        'author' => 'Ævar Arnfjörð Bjarmason'
 
18
);
 
19
 
 
20
class CssHook {
 
21
 
 
22
        public static function setup() {
 
23
                global $wgParser;
 
24
                $wgParser->setHook( 'css', array( 'CssHook', 'parse' ) );
 
25
        }
 
26
        
 
27
        public static function parse( $content, array $args, Parser $parser ) {
 
28
                $css = htmlspecialchars( trim( Sanitizer::checkCss( $content ) ) );
 
29
                $parser->mOutput->addHeadItem( <<<EOT
 
30
<style type="text/css">
 
31
/*<![CDATA[*/
 
32
{$css}
 
33
/*]]>*/
 
34
</style>
 
35
EOT
 
36
                );
 
37
        }
 
38
 
 
39
}
 
 
b'\\ No newline at end of file'