protected function saveUploadedFile() { $file = new Gpf_Db_File(); $file->set('filename', $this->name); $file->set('filesize', $this->size); $file->set('filetype', $this->type); $file->save(); $dir = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'); if ($dir->isExists()) { $dir->delete(); } $dir->mkdir(); $tmpZip = new Gpf_Io_File($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $dir->copy(new Gpf_Io_File($this->tmpName),$tmpZip); $archive = new PclZip($this->getZipFolderUrl().$file->getFileId().'/'.$file->getFileId().".zip"); $err = $archive->extract($this->getZipFolderUrl().$file->getFileId().'/'); if ($err <= 0) { throw new Gpf_Exception("code: ".$err); } $tmpZip->delete(); return $file; }
protected function copy(Gpf_Io_File $source, Gpf_Io_File $target) { if ($this->isCustomPageTemplate($source)) { return; } if ($this->isInstallThemeConfigFile($source, $target)) { Gpf_Io_File::copy($source, $target); return; } if ($this->isThemeConfigFile($source)) { $accountsThemeConfigFile = $this->getAccuontsThemeConfig($target); $isThemeEnabled = $this->getEnabled($accountsThemeConfigFile); Gpf_Io_File::copy($source, $target); $accountsThemeConfigFile = $this->getAccuontsThemeConfig($target); $accountsThemeConfigFile->setSetting(Gpf_Desktop_Theme::ENABLED, $isThemeEnabled ? 'Y' : 'N'); return; } $this->installedTemplate = new Gpf_Db_InstalledTemplate(); $this->installedTemplate->setName(substr($source->getFileName(), $this->sourceOffset)); try { $this->installedTemplate->load(); } catch (Exception $e) { } parent::copy($source, $target); $this->installedTemplate->setContentHash(md5($source->getContents())); $this->installedTemplate->setVersion(md5($source->getContents())); $this->installedTemplate->setOverwriteExisting($this->resourceOverwritten); $this->installedTemplate->save(); }
protected function copy(Gpf_Io_File $source, Gpf_Io_File $target) { $this->resourceOverwritten = false; if ($target->isExists() && $this->isFileChanged($source, $target)) { try { Gpf_Io_File::copy($target, new Gpf_Io_File($target->getFileName() . '.v' . str_replace('.', '_', Gpf_Application::getInstance()->getVersion())), $this->mode); $this->resourceOverwritten = true; } catch (Gpf_Exception $e) { $message = $this->_('Could not backup changed theme resource file %s (%s)', $target->getFileName(), $e->getMessage()); Gpf_Log::error($message); throw new Gpf_Exception($message); } } try { Gpf_Io_File::copy($source, $target, $this->mode); } catch (Gpf_Exception $e) { $message = $this->_('Could not install new theme resource (%s) file. Make sure that file is writable by webserver.', $target->getFileName()); Gpf_Log::error($message); throw new Gpf_Exception($message); } }
private function copyToBannerUploads($fileName) { $source = new Gpf_Io_File(Gpf_Paths::getInstance()->getResourcePath($fileName, Gpf_Paths::IMAGE_DIR)); $targetRelativePath = Gpf_Paths::getInstance()->getAccountDirectoryRelativePath() . Pap_Merchants_Banner_BannerUpload::BANNERS_DIR . $fileName; $target = new Gpf_Io_File('../' . $targetRelativePath); try { Gpf_Io_File::copy($source, $target, 0777); } catch (Exception $e) { throw new Gpf_Exception($this->_('Error during copy of sample banner image %s.', $source->getFileName())); } return Gpf_Paths::getInstance()->getFullBaseServerUrl() . $targetRelativePath; }
protected function copy(Gpf_Io_File $source, Gpf_Io_File $target) { Gpf_Io_File::copy($source, $target, $this->mode); }
/** * If exists language with this code in account directory already, backup translation file * * @param $language */ private function backupOriginalTranslation(Gpf_Lang_CsvLanguage $language) { $origFileName = Gpf_Lang_CsvLanguage::getAccountCsvFileName($language->getCode()); $file = new Gpf_Io_File($origFileName); if ($file->isExists()) { Gpf_Io_File::copy($file, new Gpf_Io_File($origFileName . '.v' . str_replace('.', '', Gpf_Application::getInstance()->getVersion()) . '_' . date("YmdHis"))); } }