00001 <?php
00002 class JCSSCompressedFiles {
00003
00004
00005
00006 public static function find($type) {
00007 $dao = new DAOJcsscompressedfiles();
00008 $dao->type = $type;
00009 $dao->sort('num_sources', DataObjectBase::DESC);
00010 return $dao->find_array();
00011 }
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 public static function update_db($type, $out_filename, $sources, $err) {
00023 $hash = md5_file($out_filename);
00024
00025 $filename = JCSSManager::make_relativ($out_filename);
00026
00027 $dao = new DAOJcsscompressedfiles();
00028 $dao->type = $type;
00029 $dao->filename = $filename;
00030 if ($dao->find(DataObjectBase::AUTOFETCH)) {
00031 if ($dao->hash != $hash) {
00032 $dao->hash = $hash;
00033 $dao->num_sources = count($sources);
00034 $dao->sources = $sources;
00035 $dao->version++;
00036 $err->merge($dao->update());
00037 }
00038 }
00039 else {
00040 $dao = new DAOJcsscompressedfiles();
00041 $dao->type = $type;
00042 $dao->filename = $filename;
00043 $dao->version = 1;
00044 $dao->hash = $hash;
00045 $dao->num_sources = count($sources);
00046 $dao->sources = $sources;
00047 $err->merge($dao->insert());
00048 }
00049
00050 return $dao;
00051 }
00052
00053
00054
00055
00056 public static function remove($type, $out_filename) {
00057 $dao = new DAOJcsscompressedfiles();
00058 $dao->type = $type;
00059 $dao->filename = $out_filename;
00060 return $dao->delete();
00061 }
00062 }