示例#1
0
 /**
  * combine an array of files into one file
  *
  * @param array array An array of absolute file locations, which we want to combine into a single file
  *
  * @return object
  */
 public function concat($array)
 {
     //make sure we have work to do
     if (empty($array) or !is_array($array)) {
         return false;
     }
     //check our file is within the cache duration and none of the files have been updated
     if (self::cacheValid($this->file, $this->duration) and !self::filesUpdated($this->file, $array)) {
         //if our files havent been updated and our cache time is valid, swap the file path to a uri
         $this->file = self::pathToUri($this->file);
         //return self to skip the following steps
         return $this;
     }
     //create the new handle with our css file
     $handle = fopen($this->file, 'w');
     //loop the array of css files, adding them to the cache file
     foreach ($array as $concat_file) {
         //check if we have been passed in URLs which we cant use, so swap
         $concat_file = self::uriToPath($concat_file);
         if (!file_exists($concat_file)) {
             continue;
         }
         $content = " \n\n /* ====== " . self::pathToUri($concat_file) . " ====== " . Timer::mtime() . " */ \n\n " . file_get_contents($concat_file);
         fwrite($handle, $content);
     }
     //close the conntection
     fclose($handle);
     //return the location of the file we've been working on
     $this->file = self::pathToUri($this->file);
     return $this;
 }
示例#2
0
 /**
  * add our data to log
  *
  * @return string
  */
 function add($array)
 {
     $array['timestamp'] = date('H:i:s d/m');
     $array['memory'] = $this->memory();
     $array['interval'] = Timer::convert(round(Timer::mtime() - $this->microtime, $this->time_precision));
     $this->time = Timer::mtime();
     $this->log[] = $array;
 }