Ejemplo n.º 1
0
 /**
  * Installs a zip file from the passed directory.
  *
  * @todo This is theme-specific - it really ought to be moved to the page_theme_archive class, at least most it.
  *
  * @param string $zipfile
  * @param bool $inplace Set to false if $file should be moved to the temporary directory before working on it, set to true if it's already in the temp directory.
  *
  * @return string Returns the base directory into which the zipfile was unzipped
  */
 protected function install($file, $inplace = false)
 {
     if (!$inplace) {
         $directory = $this->uploadZipToTemp($file);
     } else {
         $directory = $file;
     }
     $dir = $this->unzip($directory);
     $dirFull = $this->getArchiveDirectory($dir);
     $dirBase = substr(strrchr($dirFull, '/'), 1);
     if (file_exists($this->targetDirectory . '/' . $dirBase)) {
         throw new Exception(t('The directory %s already exists. Perhaps this item has already been installed.', $this->targetDirectory . '/' . $dirBase));
     } else {
         $this->f->copyAll($dirFull, $this->targetDirectory . '/' . $dirBase);
         if (!is_dir($this->targetDirectory . '/' . $dirBase)) {
             throw new Exception(t('Unable to copy directory %s to %s. Perhaps permissions are set incorrectly or the target directory does not exist.', $dirBase, $this->targetDirectory));
         }
     }
     return $dirBase;
 }