Esempio n. 1
0
 /**
  * Gets the supported formats for the archiver
  *
  * @return array array of formats mapped to extensions
  */
 public static function SupportedFormats()
 {
     $formats = array();
     $strategy = new GitPHP_Archive_Tar();
     if ($strategy->Valid()) {
         $formats[GITPHP_COMPRESS_TAR] = $strategy->Extension();
     }
     $strategy = new GitPHP_Archive_Zip();
     if ($strategy->Valid()) {
         $formats[GITPHP_COMPRESS_ZIP] = $strategy->Extension();
     }
     $strategy = new GitPHP_Archive_Bzip2();
     if ($strategy->Valid()) {
         $formats[GITPHP_COMPRESS_BZ2] = $strategy->Extension();
     }
     $strategy = new GitPHP_Archive_Gzip();
     if ($strategy->Valid()) {
         $formats[GITPHP_COMPRESS_GZ] = $strategy->Extension();
     }
     return $formats;
 }
 /**
  * Initialize archive for reading
  */
 private function InitializeArchive()
 {
     $strategy = null;
     if ($this->params['format'] == GITPHP_COMPRESS_TAR) {
         $strategy = new GitPHP_Archive_Tar();
     } else {
         if ($this->params['format'] == GITPHP_COMPRESS_BZ2) {
             $strategy = new GitPHP_Archive_Bzip2($this->config->GetValue('compresslevel'));
             if (!$strategy->Valid()) {
                 $strategy = new GitPHP_Archive_Tar();
             }
         } else {
             if ($this->params['format'] == GITPHP_COMPRESS_GZ) {
                 $strategy = new GitPHP_Archive_Gzip($this->config->GetValue('compresslevel'));
                 if (!$strategy->Valid()) {
                     $strategy = new GitPHP_Archive_Tar();
                 }
             } else {
                 if ($this->params['format'] == GITPHP_COMPRESS_ZIP) {
                     $strategy = new GitPHP_Archive_Zip($this->config->GetValue('compresslevel'));
                     if (!$strategy->Valid()) {
                         $strategy = new GitPHP_Archive_Tar();
                     }
                 }
             }
         }
     }
     $strategy->SetExe($this->exe);
     $this->archive = new GitPHP_Archive($this->GetProject(), null, $strategy, isset($this->params['file']) ? $this->params['file'] : '', isset($this->params['prefix']) ? $this->params['prefix'] : '');
     $commit = null;
     if (!isset($this->params['hash'])) {
         $commit = $this->GetProject()->GetHeadCommit();
     } else {
         $commit = $this->GetProject()->GetCommit($this->params['hash']);
     }
     $this->archive->SetObject($commit);
 }