private function generate_cache_file()
 {
     try {
         $cache_file = new File($this->cache_file_path);
         $cache_file->open(File::WRITE);
         $cache_file->lock();
         $cache_file->write($this->get_parsed_content());
         $cache_file->unlock();
         $cache_file->close();
         $cache_file->change_chmod(0666);
     } catch (IOException $ex) {
         throw new TemplateLoadingException('The template file cache couldn\'t been written due to this problem: ' . $ex->getMessage());
     }
 }
 private function generate_cache_file()
 {
     $real_file_content = @file_get_contents($this->real_filepath);
     if ($real_file_content === false) {
         throw new FileTemplateLoadingException($this->filepath, $this->real_filepath);
     }
     $parser = new TemplateSyntaxParser();
     $result = $parser->parse($real_file_content);
     try {
         $cache_file = new File($this->cache_filepath);
         $cache_file->open(File::WRITE);
         $cache_file->lock();
         $cache_file->write($result);
         $cache_file->unlock();
         $cache_file->close();
         $cache_file->change_chmod(0666);
     } catch (IOException $ex) {
         throw new TemplateLoadingException('The template file cache couldn\'t been written due to this problem :' . $ex->getMessage());
     }
 }
Example #3
0
 function write($module_name, &$cache_string)
 {
     $file_path = PATH_TO_ROOT . '/cache/' . $module_name . '.php';
     import('io/filesystem/file');
     $cache_file = new File($file_path, WRITE);
     $cache_file->delete();
     $cache_file->open();
     $cache_file->lock();
     $cache_file->write("<?php\n" . $cache_string . "\n?>");
     $cache_file->unlock();
     $cache_file->close();
     $cache_file->change_chmod(0666);
     if (!file_exists($file_path) && filesize($file_path) == 0) {
         $Errorh->handler('Cache -> La génération du fichier de cache <strong>' . $file . '</strong> a échoué!', E_USER_ERROR, __LINE__, __FILE__);
     }
 }
 /**
  * Exports optimized content to a file.
  */
 public function export_to_file($location)
 {
     if (!empty($this->files) || !empty($this->scripts)) {
         $file = new File($location);
         $file->delete();
         $file->open(File::WRITE);
         $file->lock();
         $file->write($this->content);
         $file->unlock();
         $file->close();
         $file->change_chmod(0666);
     }
 }
Example #5
0
 function _save($file_cache_path)
 {
     import('io/filesystem/file');
     $file = new File($file_cache_path);
     $file->open(WRITE);
     $file->lock();
     $file->write($this->template);
     $file->unlock();
     $file->close();
     $file->change_chmod(0666);
 }