Exemplo n.º 1
0
 static function buildModulePackage($moduleName, $buildPath)
 {
     $fileName = $moduleName . '.zip';
     if (is_file($buildPath . '/' . $fileName)) {
         unlink($buildPath . '/' . $fileName);
     }
     // first we check for the files
     if (!is_dir("modules/{$moduleName}")) {
         // check for module directory
         throw new Exception("Module directory missing for {$moduleName}");
     }
     if (!file_exists("modules/{$moduleName}/manifest.xml")) {
         // check for manifest
         throw new Exception("Module manifest missing for module {$moduleName}");
     }
     if (!is_dir("modules/{$moduleName}/language")) {
         // check for language directory
         throw new Exception("Module language directory missing for module {$moduleName}");
     }
     // Export as Zip
     $zip = new Vtiger_Zip($buildPath . '/' . $fileName);
     // Add manifest file
     $zip->addFile("modules/{$moduleName}/manifest.xml", 'manifest.xml');
     // Copy module directory
     $zip->copyDirectoryFromDisk("modules/{$moduleName}");
     // Copy templates directory of the module (if any)
     if (is_dir("Smarty/templates/modules/{$moduleName}")) {
         $zip->copyDirectoryFromDisk("Smarty/templates/modules/{$moduleName}", "templates");
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$moduleName}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$moduleName}", "cron");
     }
     $zip->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($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();
 }
Exemplo n.º 3
0
 /**
  * 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();
 }
Exemplo n.º 4
0
 /**
  * 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 = $moduleInstance->name . "_" . date('Y-m-d-Hi') . "_" . $moduleInstance->version . ".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 Settings/module directory
     if (is_dir("modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("modules/Settings/{$module}", 'settings/');
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron");
     }
     //Copy module templates files
     if (is_dir("layouts/vlayout/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/{$module}", "templates");
     }
     //Copy Settings module templates files, if any
     if (is_dir("layouts/vlayout/modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/Settings/{$module}", "settings/templates");
     }
     //Copy language files
     $this->__copyLanguageFiles($zip, $module);
     //Copy image file
     if (file_exists("layouts/vlayout/skins/images/{$module}.png")) {
         $zip->copyFileFromDisk("layouts/vlayout/skins/images", "", "{$module}.png");
     }
     $zip->save();
     if ($todir) {
         copy($zipfilename, $todir);
     }
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 5
0
 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;
 }
 /**
  * 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 Settings/module directory
     if (is_dir("modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("modules/Settings/{$module}", 'settings/');
     }
     // Copy cron files of the module (if any)
     if (is_dir("cron/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("cron/modules/{$module}", "cron");
     }
     //Copy module templates files
     if (is_dir("layouts/vlayout/modules/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/{$module}", "templates");
     }
     //Copy Settings module templates files, if any
     if (is_dir("layouts/vlayout/modules/Settings/{$module}")) {
         $zip->copyDirectoryFromDisk("layouts/vlayout/modules/Settings/{$module}", "settings/templates");
     }
     //Support to multiple layouts of module
     $layoutDirectories = glob('layouts' . '/*', GLOB_ONLYDIR);
     foreach ($layoutDirectories as $key => $layoutName) {
         $moduleLayout = $layoutName . "/modules/{$module}";
         if (is_dir($moduleLayout)) {
             $zip->copyDirectoryFromDisk($moduleLayout, $moduleLayout);
         }
         $settingsLayout = $layoutName . "/modules/Settings/{$module}";
         if (is_dir($settingsLayout)) {
             $zip->copyDirectoryFromDisk($settingsLayout, $settingsLayout);
         }
     }
     //Copy language files
     $this->__copyLanguageFiles($zip, $module);
     $zip->save();
     if ($todir) {
         copy($zipfilename, $todir);
     }
     if ($directDownload) {
         $zip->forceDownload($zipfilename);
         unlink($zipfilename);
     }
     $this->__cleanupExport();
 }
Exemplo n.º 7
0
 static function packageFromFilesystem($moduleName, $mandatory = false, $directDownload = false)
 {
     // first we check for the files
     $wehavefiles = is_dir("modules/{$moduleName}");
     // check for module directory
     $wehavefiles = $wehavefiles and file_exists("modules/{$moduleName}/manifest.xml");
     // check for manifest
     $wehavefiles = $wehavefiles and is_dir("modules/{$moduleName}/language");
     // check for language directory
     if ($wehavefiles) {
         // Export as Zip
         $mpkg = 'packages/' . ($mandatory ? 'mandatory/' : 'optional/') . $moduleName;
         $zipfilename = $mpkg . '.zip';
         if (file_exists($zipfilename)) {
             @unlink($zipfilename);
         }
         $zip = new Vtiger_Zip($zipfilename);
         // Add manifest file
         $zip->addFile("modules/{$moduleName}/manifest.xml", 'manifest.xml');
         // Copy module directory
         $zip->copyDirectoryFromDisk("modules/{$moduleName}");
         // Copy templates directory of the module (if any)
         if (is_dir("Smarty/templates/modules/{$moduleName}")) {
             $zip->copyDirectoryFromDisk("Smarty/templates/modules/{$moduleName}", "templates");
         }
         // Copy cron files of the module (if any)
         if (is_dir("cron/modules/{$moduleName}")) {
             $zip->copyDirectoryFromDisk("cron/modules/{$moduleName}", "cron");
         }
         $zip->save();
         if ($directDownload) {
             $zip->forceDownload($mpkg . '.zip');
         }
     } else {
         echo "ERROR: One or more files necessary to create package are missing";
     }
 }