/**
  * 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();
 }
Beispiel #2
0
                $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');
}
Beispiel #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();
 }
 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";
     }
 }