/** * Export Module as a zip file. * @param Vtiger_Module Instance of module * @param Path Output directory path * @param String Zipfilename to use * @param Boolean True for sending the output as download */ function export($languageCode, $todir = '', $zipfilename = '', $directDownload = false) { $this->__initExport($languageCode); // Call language export function $this->export_Language($languageCode); $this->__finishExport(); // Export as Zip if ($zipfilename == '') { $zipfilename = "{$languageCode}-" . date('YmdHis') . ".zip"; } $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}"; $zip = new Vtiger_Zip($zipfilename); // Add manifest file $zip->addFile($this->__getManifestFilePath(), "manifest.xml"); // Copy module directory $zip->copyDirectoryFromDisk("languages/{$languageCode}", "modules"); $zip->save(); if ($todir) { copy($zipfilename, $todir); } if ($directDownload) { $zip->forceDownload($zipfilename); unlink($zipfilename); } $this->__cleanupExport(); }
function packen($filename, $wordtemplatedownloadpath, $temp_dir, $concontent, $stylecontent) { //global $filename, $wordtemplatedownloadpath; //write a new content.xml $handle = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/content.xml', "w"); fwrite($handle, $concontent); fclose($handle); //write a new styles.xml $handle2 = fopen($wordtemplatedownloadpath . '/' . $temp_dir . '/styles.xml', "w"); fwrite($handle2, $stylecontent); fclose($handle2); include_once 'vtlib/Vtiger/Zip.php'; $archive = new Vtiger_Zip($wordtemplatedownloadpath . '/' . $filename); //make a new archive (or .odt file) $archive->copyDirectoryFromDiskNoOffset($wordtemplatedownloadpath . $temp_dir); $archive->save(); }
/** * Export Module as a zip file. * @param Vtiger_Module Instance of module * @param Path Output directory path * @param String Zipfilename to use * @param Boolean True for sending the output as download */ function export($moduleInstance, $todir = '', $zipfilename = '', $directDownload = false) { $module = $moduleInstance->name; $this->__initExport($module, $moduleInstance); // Call module export function $this->export_Module($moduleInstance); $this->__finishExport(); // Export as Zip if ($zipfilename == '') { $zipfilename = "{$module}-" . date('YmdHis') . ".zip"; } $zipfilename = "{$this->_export_tmpdir}/{$zipfilename}"; $zip = new Vtiger_Zip($zipfilename); // Add manifest file $zip->addFile($this->__getManifestFilePath(), "manifest.xml"); // Copy module directory $zip->copyDirectoryFromDisk("modules/{$module}"); // Copy templates directory of the module (if any) if (is_dir("Smarty/templates/modules/{$module}")) { $zip->copyDirectoryFromDisk("Smarty/templates/modules/{$module}", "templates"); } // Copy cron files of the module (if any) if (is_dir("cron/modules/{$module}")) { $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron"); } $zip->save(); if ($directDownload) { $zip->forceDownload($zipfilename); unlink($zipfilename); } $this->__cleanupExport(); }
protected function createZipPackage($dirname, $o_module) { include_once 'vtlib/Vtiger/Zip.php'; $module = $o_module->name; // Export as Zip $zipfilename = DIR_TEMP . $dirname . "/{$module}_" . date('Y-m-d') . "_{$o_module->version}.zip"; $zip = new Vtiger_Zip($zipfilename); // Add manifest file $zip->addFile(DIR_TEMP . "{$dirname}/manifest.xml", "manifest.xml"); $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/modules", "modules"); if (is_dir(DIR_TEMP . "{$dirname}/languages")) { $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/languages", "languages"); } if (is_dir(DIR_TEMP . "{$dirname}/templates")) { $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/templates", "templates"); } if (is_dir(DIR_TEMP . "{$dirname}/settings")) { $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/settings", "settings"); } if (is_dir(DIR_TEMP . "{$dirname}/cron")) { $zip->copyDirectoryFromDisk(DIR_TEMP . "{$dirname}/cron", "cron"); } if (file_exists(DIR_TEMP . "{$dirname}/{$module}.png")) { $zip->addFile(DIR_TEMP . "{$dirname}/{$module}.png", "{$module}.png"); } $zip->save(); //$zip->forceDownload($zipfilename); //unlink($zipfilename); return $zipfilename; }
$w->text($upd['description']); $w->endElement(); } $w->startElement("filename"); $w->text($upd['pathfilename']); $w->endElement(); $w->startElement("classname"); $w->text($upd['classname']); $w->endElement(); $w->startElement("systemupdate"); $w->text($upd['systemupdate'] == '1' ? 'true' : 'false'); $w->endElement(); $w->endElement(); $bname = basename($upd['pathfilename']); $zip->addFile($upd['pathfilename'], $bname); } $w->endElement(); $fd = fopen($xmlcfn, 'w'); $cbxml = $w->outputMemory(true); fwrite($fd, $cbxml); fclose($fd); $zip->addFile($xmlcfn, $xmlfilename); $zip->save(); $zip->forceDownload($zipfilename); unlink($zipfilename); } else { echo getTranslatedString('LBL_RECORD_NOT_FOUND'); } } else { echo getTranslatedString('LBL_RECORD_NOT_FOUND'); }
static function buildLangPackage($languageCode, $languageName, $buildPath) { $fileName = $languageName . '.zip'; if (is_file($buildPath . '/' . $fileName)) { unlink($buildPath . '/' . $fileName); } // first we check for the files if (!is_file("include/language/{$languageCode}.manifest.xml")) { // check for manifest throw new Exception("Manifest missing for language package {$languageName}"); } // Export as Zip $zip = new Vtiger_Zip($buildPath . '/' . $fileName); // Add manifest file $zip->addFile("include/language/{$languageCode}.manifest.xml", 'manifest.xml'); // Add calendar files $zip->copyFileFromDisk('jscalendar/', 'jscalendar/', 'calendar-setup.js'); $zip->copyFileFromDisk('jscalendar/lang/', 'jscalendar/lang/', 'calendar-' . substr($languageCode, 0, 2) . '.js'); //$zip->copyFileFromDisk('modules/Emails/language/','modules/Emails/language/','phpmailer.lang-'.$languageCode.'.php'); // Copy module/include language files foreach (glob("{modules,include}/*/language/{$languageCode}.lang.{php,js}", GLOB_BRACE) as $langfile) { $fname = basename($langfile); $dname = dirname($langfile); $zip->copyFileFromDisk($dname, $dname, $fname); } $zip->copyFileFromDisk('include/language/', 'include/language/', $languageCode . '.lang.php'); $zip->copyFileFromDisk('include/js/', 'include/js/', $languageCode . '.lang.js'); $zip->save(); }
static function languageFromFilesystem($languageCode, $languageName, $directDownload = false) { // first we check for the files $wehavefiles = file_exists("include/language/{$languageCode}.manifest.xml"); // check for manifest if ($wehavefiles) { // Export as Zip if (file_exists('packages/optional/manifest.xml')) { @unlink('packages/optional/manifest.xml'); } @copy("include/language/{$languageCode}.manifest.xml", 'packages/optional/manifest.xml'); $mpkg = 'packages/optional/' . $languageName; $zipfilename = $mpkg . '.zip'; if (file_exists($zipfilename)) { @unlink($zipfilename); } $zip = new Vtiger_Zip($zipfilename); // Add manifest file $zip->copyFileFromDisk('packages/optional/', '', 'manifest.xml'); // Add calendar files $zip->copyFileFromDisk('jscalendar/', 'jscalendar/', 'calendar-setup.js'); $zip->copyFileFromDisk('jscalendar/lang/', 'jscalendar/lang/', 'calendar-' . substr($languageCode, 0, 2) . '.js'); // Copy module/include language files foreach (glob('{modules,include}/*/language/' . $languageCode . '.lang.{php,js}', GLOB_BRACE) as $langfile) { $fname = basename($langfile); $dname = dirname($langfile); $zip->copyFileFromDisk($dname, $dname, $fname); } $zip->copyFileFromDisk('include/language/', 'include/language/', $languageCode . '.lang.php'); $zip->copyFileFromDisk('include/js/', 'include/js/', $languageCode . '.lang.js'); $zip->save(); if ($directDownload) { $zip->forceDownload($mpkg . '.zip'); } @unlink('packages/optional/manifest.xml'); } else { echo "ERROR: One or more files necessary to create package are missing"; } }