Beispiel #1
0
 /**
  * Деинсталляция модуля.
  */
 public static function uninstall($moduleName)
 {
     $inipath = os::path('lib', 'modules', $moduleName, 'module.ini');
     if (file_exists($inipath)) {
         $ini = ini::read($inipath);
         if ('required' == $ini['priority']) {
             return false;
         }
     }
     os::rmdir(dirname($inipath));
     Logger::log($moduleName . ': uninstalled.');
     return true;
 }
Beispiel #2
0
 public static function unzipToFolder($zipName, $folderPath)
 {
     umask(02);
     if (!self::isAvailable()) {
         throw new ZipException();
     }
     $tmpDir = file_exists($folderPath) ? $folderPath . '.tmp' : $folderPath;
     if ($tmpDir != $folderPath and file_exists($tmpDir)) {
         os::rmdir($tmpDir);
     }
     $z = new ZipArchive();
     if (true !== ($error = $z->open($zipName))) {
         throw new RuntimeException(t('Не удалось открыть ZIP архив %name', array('%name' => basename($zipName))));
     }
     if (!$z->extractTo($tmpDir)) {
         if ($tmpDir != $folderPath) {
             os::rmdir($tmpDir);
         }
         throw new RuntimeException(t('Не удалось распаковать содержимое архива в папку %path.', array('%path' => $tmpDir)));
     }
     if ($tmpDir != $folderPath) {
         if (!rename($folderPath, $old = $folderPath . '.old')) {
             os::rmdir($tmpDir);
             throw new RuntimeException(t('Не удалось переименовать временную папку.'));
         }
         rename($tmpDir, $folderPath);
         os::rmdir($old);
     }
 }