1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * Expresso API - CSS * |
---|
4 | * ------------------------------------------------------------------------ * |
---|
5 | * This program is Free Software; you can redistribute it and/or modify it * |
---|
6 | * under the terms of the GNU General Public License as published by the * |
---|
7 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
8 | * option) any later version. * |
---|
9 | \**************************************************************************/ |
---|
10 | |
---|
11 | /** |
---|
12 | * Expresso CSS support class |
---|
13 | * |
---|
14 | * Only instanstiate this class using: |
---|
15 | * <code> |
---|
16 | * if(!@is_object($GLOBALS['phpgw']->css)) |
---|
17 | * { |
---|
18 | * $GLOBALS['phpgw']->css = CreateObject('phpgwapi.css'); |
---|
19 | * } |
---|
20 | * </code> |
---|
21 | */ |
---|
22 | class css |
---|
23 | { |
---|
24 | private $files = array( ); |
---|
25 | |
---|
26 | function css() |
---|
27 | { |
---|
28 | |
---|
29 | } |
---|
30 | |
---|
31 | function create_pack($cssFile){ |
---|
32 | require_once('csstidy/class.csstidy.php'); |
---|
33 | $csstidy = new csstidy(); |
---|
34 | $csstidy->load_template('highest_compression'); |
---|
35 | $cssFilePath=PHPGW_SERVER_ROOT.SEP.$cssFile.'pack.css'; |
---|
36 | $fp = fopen($cssFilePath, 'w'); |
---|
37 | if ($csstidy->parse(file_get_contents(PHPGW_SERVER_ROOT.SEP.$cssFile))) |
---|
38 | fwrite($fp, $csstidy->print->plain()); |
---|
39 | } |
---|
40 | |
---|
41 | function get_css() |
---|
42 | { |
---|
43 | $path = ( ! empty( $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] ) ) ? |
---|
44 | $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'webserver_url' ] : '/'; |
---|
45 | |
---|
46 | if ( strpos( $path, '/' ) != ( strlen( $path ) - 1 ) ) |
---|
47 | $path .= '/'; |
---|
48 | |
---|
49 | foreach ( $this -> files as $cssFile ) |
---|
50 | { |
---|
51 | if ( $GLOBALS[ 'phpgw_info' ][ 'server' ][ 'csspacker' ] == "True" ) |
---|
52 | { |
---|
53 | if ( ! file_exists( PHPGW_SERVER_ROOT . SEP . $cssFile . 'pack.css' ) ) |
---|
54 | $this -> create_pack( $cssFile ); |
---|
55 | |
---|
56 | $cssFile .= 'pack.css'; |
---|
57 | } |
---|
58 | |
---|
59 | $out .= '<link type="text/css" rel="StyleSheet" href="' . $path . $cssFile . '" />'; |
---|
60 | } |
---|
61 | |
---|
62 | return $out; |
---|
63 | } |
---|
64 | |
---|
65 | function validate_file($file, $stack = false ) |
---|
66 | { |
---|
67 | if (file_exists(PHPGW_SERVER_ROOT . SEP . $file)) |
---|
68 | $this->files[] = $file; |
---|
69 | } |
---|
70 | } |
---|
71 | ?> |
---|