[2643] | 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 | { |
---|
[2664] | 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 .= '/'; |
---|
[2643] | 48 | if ($GLOBALS['phpgw_info']['server']['csspacker'] == "True") |
---|
| 49 | foreach($this->files as $cssFile) |
---|
| 50 | { |
---|
| 51 | if (!file_exists(PHPGW_SERVER_ROOT.SEP.$cssFile."pack.css")) |
---|
| 52 | $this->create_pack($cssFile); |
---|
[2664] | 53 | $out .= "\n\t\t<link href='".$path.$cssFile."pack.css' type='text/css' rel='StyleSheet'>"; |
---|
[2643] | 54 | |
---|
| 55 | } |
---|
| 56 | else |
---|
| 57 | foreach($this->files as $cssFile) |
---|
[2664] | 58 | { |
---|
| 59 | $_SESSION['debug'][] = "/".$cssFile; |
---|
| 60 | $out .= "\n\t\t<link href='".$path.$cssFile."' type='text/css' rel='StyleSheet'>"; |
---|
| 61 | } |
---|
[2643] | 62 | return $out; |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | function validate_file($file, $stack = false ) |
---|
| 66 | { |
---|
[2648] | 67 | if (file_exists(PHPGW_SERVER_ROOT . SEP . $file)) |
---|
[2643] | 68 | $this->files[] = $file; |
---|
| 69 | } |
---|
| 70 | } |
---|
| 71 | ?> |
---|