Beispiel #1
0
 /**
  * Save
  *
  * @param string $code Code
  *
  * @return void
  */
 protected function saveCode($code)
 {
     if ("\r\n" != PHP_EOL) {
         $code = str_replace("\r\n", PHP_EOL, $code);
     }
     $code = str_replace(chr(194) . chr(160), ' ', $code);
     $file = $this->getFileName();
     \Includes\Utils\FileManager::write($file, $code);
     if (\Includes\Utils\FileManager::isFileWriteable($file)) {
         \XLite\Core\TopMessage::addInfo('Your custom file is successfully saved');
         \Includes\Utils\FileManager::deleteFile(str_replace('custom', 'custom.min', $file));
         \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('name' => $this->getBackupName(), 'value' => $code, 'category' => 'XC\\ThemeTweaker'));
         \XLite\Core\Config::updateInstance();
         $config = \XLite\Core\Config::getInstance()->Performance;
         if ($config->aggregate_css || $config->aggregate_js) {
             \Includes\Utils\FileManager::unlinkRecursive(LC_DIR_CACHE_RESOURCES);
             \XLite\Core\TopMessage::addInfo('Aggregation cache has been cleaned');
         }
     } else {
         \XLite\Core\TopMessage::addError('The file {{file}} does not exist or is not writable.', array('file' => $file));
     }
 }
Beispiel #2
0
 /**
  * isFileWritable
  *
  * @return boolean
  */
 public function isFileWritable()
 {
     return $this->isDirExists() && (!$this->isFileExists() || \Includes\Utils\FileManager::isFileWriteable($this->sqldumpFile));
 }