Changeset 26 for trunk/lib/CSS.inc.php
- Timestamp:
- Dec 3, 2005 11:23:27 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/CSS.inc.php
r25 r26 7 7 * 8 8 * @author Quinn Comendant <quinn@strangecode.com> 9 * @version 1.1 10 * TODO: set different css files attached to an app with /css.php?app=name 11 * TODO: 9 * @version 1.2 12 10 */ 13 11 class CSS { 14 12 15 13 // Include these style sheets. 16 var $_css_files = array( );14 var $_css_files = array('_default' => array()); 17 15 18 16 // Cache style sheets? … … 64 62 * @return bool True on success, false on failure. 65 63 */ 66 function setFile($file )64 function setFile($file, $app='_default') 67 65 { 68 if (file_exists($file)) { 69 $this->_css_files[] = $file; 66 if ($fp = fopen($file, 'r', true)) { 67 $this->_css_files[$app][] = $file; 68 fclose($fp); 70 69 return true; 71 70 } else { … … 82 81 * @return bool False if no files have been set. 83 82 */ 84 function headers( )83 function headers($app='_default') 85 84 { 86 if (empty($this->_css_files )) {85 if (empty($this->_css_files[$app])) { 87 86 App::logMsg(sprintf('CSS::headers called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__); 88 87 return false; 89 88 } 90 89 91 90 // Get time of latest modified file, including this class file. 92 $files_mtime = array_map('filemtime', array_merge($this->_css_files, array(__FILE__))); 91 $files_mtime = array(); 92 foreach (array_merge($this->_css_files[$app], array(__FILE__)) as $file) { 93 $files_mtime[] = statIncludePath($file, 'mtime'); 94 } 93 95 sort($files_mtime, SORT_NUMERIC); 94 $ mtime = array_pop($files_mtime);96 $latest_mtime = array_pop($files_mtime); 95 97 96 98 if ($this->_params['cache_css']) { 97 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $ mtime) . ' GMT');99 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $latest_mtime) . ' GMT'); 98 100 header('Cache-Control: public, max-age=86400'); 99 101 } else { … … 112 114 * @return bool False if no files have been set. 113 115 */ 114 function output( )116 function output($app='_default') 115 117 { 116 if (empty($this->_css_files )) {118 if (empty($this->_css_files[$app])) { 117 119 App::logMsg(sprintf('CSS::output called without specifying any files.', null), LOG_WARNING, __FILE__, __LINE__); 118 120 return false; 119 121 } 120 121 foreach ($this->_css_files as $file) {122 include $file;123 }124 122 } 123 125 124 } 126 125 ?>
Note: See TracChangeset
for help on using the changeset viewer.