예제 #1
0
파일: ViewsCoder.php 프로젝트: joadr/cms
 public function deleteView($view)
 {
     try {
         $view_path = public_path() . '/site/' . $view->name;
         \FilesHelper::deleteFile($view_path);
     } catch (\Exception $e) {
     }
 }
예제 #2
0
 public function destroy($index)
 {
     $path = public_path() . '/uploads/files/';
     $files = \FilesHelper::filesInFolder($path);
     $file = $files[$index];
     $file_path = $path . $file['name'];
     \FilesHelper::deleteFile($file_path);
     return \Redirect::route('dev.files.index');
 }
function generateArchive($themeName, $userThemeName = '', $includeThemler = true)
{
    register_shutdown_function('fatalErrorShutdownHandler');
    $archiveFile = getThemeArchive($themeName, $userThemeName, $includeThemler);
    $archiveContent = array();
    if (is_readable($archiveFile)) {
        $archiveContent = array('ext' => 'zip', 'content' => base64_encode(FilesHelper::readFile($archiveFile)));
        FilesHelper::deleteFile($archiveFile);
    }
    return $archiveContent;
}
 public static function emptyDirRecursive($dir, $recursive = true)
 {
     foreach (FilesHelper::enumerateFiles($dir, $recursive) as $file) {
         FilesHelper::deleteFile($file['path']);
     }
 }
function uploadTheme($themeName, $filename, $tmp_path)
{
    $uniqid = uniqid();
    $sandbox = FilesHelper::normalizePath(_PS_CACHE_DIR_ . 'sandbox' . DIRECTORY_SEPARATOR . $uniqid) . '/';
    $uploadDir = $sandbox . ThemeInstallHelper::UPLOADED_THEME_DIR_NAME;
    // used in AdminThemesController
    $base_path = $uploadDir . '.zip';
    FilesHelper::createDir($sandbox);
    FilesHelper::renameFile($tmp_path, $base_path);
    $archive = new PclZip($base_path);
    deleteFromArchive($archive, 'modules', true);
    // We upload new theme, not modules to save module functionality
    $helper = new ThemeInstallHelper();
    if ($helper->install($base_path, $sandbox)) {
        $result = array('status' => 'done', 'path' => $base_path);
    } else {
        $themesDir = $uploadDir . '/themes';
        $files = FilesHelper::enumerate($themesDir, false);
        // not enumerateFiles method with directory checking
        if (count($files) === 1 && is_dir($files[0]['path'])) {
            $themeName = str_replace("{$themesDir}/", '', $files[0]['path']);
        }
        if ($themeName && ($theme = Theme::getByDirectory($themeName)) && is_file($uploadDir . '/Config.xml')) {
            $themeDir = $themesDir . '/' . $themeName;
            $previewThemeDir = $themeDir . '/' . $themeName . _PREVIEW_SUFFIX_;
            $newThemeName = checkThemeName($themeName);
            $newThemeDir = $themesDir . '/' . $newThemeName;
            $newThemePreviewDir = $themeDir . '/' . $newThemeName . _PREVIEW_SUFFIX_;
            // 1. rename inner preview folder
            processRename($themeDir, $previewThemeDir, $newThemeDir, $newThemePreviewDir, $newThemeName);
            $newThemePreviewDir = $newThemeDir . '/' . $newThemeName . _PREVIEW_SUFFIX_;
            // 2. now preview folder is correct
            FilesHelper::deleteFile($uploadDir . '/Config.xml');
            FilesHelper::copyFile($newThemePreviewDir . '/designer/Export/Config.xml', $uploadDir . '/Config.xml');
            unset($archive);
            FilesHelper::deleteFile($base_path);
            $archive = new PclZip($base_path);
            addToArchive($archive, $uploadDir, $uploadDir);
            $helper = new ThemeInstallHelper();
            // new object with no errors
            if ($helper->install($base_path, $sandbox)) {
                $result = array('status' => 'done', 'path' => $base_path);
            } else {
                $result = array('status' => 'error', 'errors' => Tools::jsonEncode($helper->getErrors()));
            }
        } else {
            $result = array('status' => 'error', 'errors' => 'Please make sure, that you have selected a valid PrestaShop theme.');
        }
    }
    return $result;
}
 /**
  * Build theme layout files header.tpl, footer.tpl
  */
 private function _buildThemeLayoutFilesFromHtml(&$changed_files, $replaceInfo, $hasReplace)
 {
     $dir = $this->_previewThemeDir . '/templates';
     foreach (FilesHelper::enumerateFiles($dir) as $file) {
         $path = $file['path'];
         $info = pathinfo($path);
         $name = $info['filename'];
         $fileExt = isset($info['extension']) && $info['extension'] ? $info['extension'] : '';
         if (!in_array($fileExt, array('html'))) {
             continue;
         }
         $content = $this->_replaceImageIdToUrl($file['content'], $replaceInfo, $hasReplace);
         $changes = $this->_templateBuilder->build($info, $content);
         $changed_files = array_merge($changed_files, $changes);
         FilesHelper::deleteFile($path);
         $changed_files[] = $path;
     }
 }
예제 #7
0
파일: FileDriver.php 프로젝트: joadr/cms
 private function deleteFile($path)
 {
     \FilesHelper::deleteFile($path);
 }