source: trunk/phpgwapi/inc/class.css.inc.php @ 2644

Revision 2644, 2.2 KB checked in by rodsouza, 14 years ago (diff)

Ticket #1044 - Corrigindo problema com caminho.

  • Property svn:executable set to *
Line 
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                        if ($GLOBALS['phpgw_info']['server']['csspacker'] == "True")
50                                  foreach($this->files as $cssFile)
51                                  {
52                                          if (!file_exists(PHPGW_SERVER_ROOT.SEP.$cssFile."pack.css"))
53                                                $this->create_pack($cssFile);
54                                          $out .= "\n\t\t<link href='".$path.$cssFile."pack.css' type='text/css' rel='StyleSheet'>";
55                                         
56                                  }
57                          else
58                                  foreach($this->files as $cssFile)
59                                          $out .= "\n\t\t<link href='".$path.$cssFile."' type='text/css' rel='StyleSheet'>";
60                          return $out;
61                }
62
63                function validate_file($file, $stack = false )
64                {
65                        if (file_exists(PHPGW_SERVER_ROOT . '/' . $file))
66                                $this->files[] = $file;
67                }
68        }
69?>
Note: See TracBrowser for help on using the repository browser.