JCSSManagerCompressBaseCommand Class Reference
Public Member Functions |
|
__construct ($in_files, $out_file) | |
COnstructor. |
|
execute () | |
Executes commands. |
|
Protected Member Functions |
|
clean_in_files ($in_files) | |
Combine in files to groups. |
|
compress ($in_files, $out_file, &$versioned_file_path) | |
COmpress given files. |
|
get_db_type () | |
Returns type of compressed file. |
|
gzip ($file, &$gzip_file) | |
Create a gzipped file. |
|
Protected Attributes |
|
$in_files | |
$out_file |
Detailed Description
Definition at line 2 of file compress.base.cmd.php.
Constructor & Destructor Documentation
JCSSManagerCompressBaseCommand::__construct | ( | $ | in_files, | |
$ | out_file | |||
) |
COnstructor.
- Parameters:
-
$in_files array $out_file string A template string for output naming
- Returns:
- void
Definition at line 13 of file compress.base.cmd.php.
00013 { 00014 $this->in_files = $this->clean_in_files(Arr::force($in_files, false)); 00015 $this->out_file = $out_file; 00016 parent::__construct(null, false); 00017 }
Member Function Documentation
JCSSManagerCompressBaseCommand::clean_in_files | ( | $ | in_files | ) | [protected] |
Combine in files to groups.
Definition at line 22 of file compress.base.cmd.php.
00022 { 00023 $ret = array(); 00024 foreach($in_files as $key => $value) { 00025 if (is_numeric($key)) { 00026 $ret['default'][] = $value; 00027 } 00028 else { 00029 $ret[$key] = $value; 00030 } 00031 } 00032 return $ret; 00033 }
JCSSManagerCompressBaseCommand::compress | ( | $ | in_files, | |
$ | out_file, | |||
&$ | versioned_file_path | |||
) | [protected] |
COmpress given files.
- Returns:
- Status
Reimplemented in JCSSManagerCompressJSClosureCommand, JCSSManagerCompressCSSCsstidyCommand, and JCSSManagerCompressBaseYuiCommand.
Definition at line 87 of file compress.base.cmd.php.
00087 { 00088 $ret = new Status('JCSSManagerCompressBase::compress not implemented'); 00089 return $ret; 00090 }
JCSSManagerCompressBaseCommand::execute | ( | ) |
Executes commands.
- Returns:
- Status
Reimplemented from CommandDelegate.
Definition at line 40 of file compress.base.cmd.php.
00040 { 00041 Load::models('jcsscompressedfiles'); 00042 $ret = new Status(); 00043 00044 $files_to_unlink = array(); 00045 foreach($this->in_files as $groupname => $in_files) { 00046 $versioned_file_name = false; 00047 $out_file = $this->out_file; 00048 if ($groupname != 'default') { 00049 $arr = explode('.', $out_file); 00050 $ext = array_pop($arr); 00051 $arr[] = $groupname; 00052 $arr[] = $ext; 00053 $out_file = implode('.', $arr); 00054 } 00055 if (count($in_files)) { 00056 $ret->merge($this->compress($in_files, $out_file, $files_to_unlink)); 00057 } 00058 else { 00059 file_put_contents($out_file, ''); 00060 } 00061 if ($ret->is_ok()) { 00062 $dao = JCSSCompressedFiles::update_db($this->get_db_type(), $out_file, $in_files, $ret); 00063 if ($ret->is_ok()) { 00064 $versioned_file_name = JCSSManager::make_absolute($dao->get_versioned_filename()); 00065 rename($out_file, $versioned_file_name); 00066 } 00067 } 00068 00069 $gzip_file = false; 00070 if ($versioned_file_name && $ret->is_ok()) { 00071 $ret->merge($this->gzip($versioned_file_name, $gzip_file)); 00072 } 00073 } 00074 00075 foreach($files_to_unlink as $src) { 00076 @unlink($src); 00077 } 00078 00079 return $ret; 00080 }
JCSSManagerCompressBaseCommand::get_db_type | ( | ) | [protected] |
Returns type of compressed file.
- Returns:
- string One of TYPE_X constants
Reimplemented in JCSSManagerCompressJSClosureCommand, JCSSManagerCompressCSSCsstidyCommand, JCSSManagerCompressCSSYuiCommand, and JCSSManagerCompressJSYuiCommand.
Definition at line 119 of file compress.base.cmd.php.
JCSSManagerCompressBaseCommand::gzip | ( | $ | file, | |
&$ | gzip_file | |||
) | [protected] |
Create a gzipped file.
- Returns:
- Status
Definition at line 97 of file compress.base.cmd.php.
00097 { 00098 $ret = new Status(); 00099 00100 if (Config::has_feature(ConfigJCSSManager::ALSO_GZIP)) { 00101 $gzipped_file = $file . '.gz'; 00102 $fp = gzopen($gzipped_file, 'w9'); 00103 if ($fp) { 00104 gzwrite($fp, file_get_contents($file)); 00105 gzclose($fp); 00106 } 00107 else { 00108 $ret->append('JCSSManager: Could not create gzip-file'); 00109 } 00110 } 00111 return $ret; 00112 }
Member Data Documentation
JCSSManagerCompressBaseCommand::$in_files
[protected] |
Definition at line 3 of file compress.base.cmd.php.
JCSSManagerCompressBaseCommand::$out_file
[protected] |
Definition at line 4 of file compress.base.cmd.php.
The documentation for this class was generated from the following file:
- contributions/jcssmanager/behaviour/commands/jcssmanager/base/compress.base.cmd.php