Esempio n. 1
0
 private function _convertZipEncoding(\GO\Base\Fs\Folder $folder, $charset = 'CP850')
 {
     $items = $folder->ls();
     foreach ($items as $item) {
         if (!\GO\Base\Util\String::isUtf8($item->name())) {
             $item->rename(\GO\Base\Util\String::clean_utf8($item->name(), $charset));
         }
         if ($item->isFolder()) {
             $this->_convertZipEncoding($item, $charset);
         }
     }
 }
Esempio n. 2
0
 /**
  * Run from the browser's address bar. Collects all language files, and puts
  * them in a zip file in the file storage path, respecting the folder
  * structure. I.e., you can later unpack the file contents to the
  * Group-Office path.
  * @param type $params 
  */
 protected function actionZipLanguage($params)
 {
     if (!empty($params['lang'])) {
         $langCode = $params['lang'];
     } else {
         die('<font color="red"><i>The GET parameter lang is required for the zipLanguage action!</i></font>');
     }
     $fileNames = array();
     //gather file list in array
     $commonLangFolder = new \GO\Base\Fs\Folder(\GO::config()->root_path . 'language/');
     if ($commonLangFolder->exists()) {
         $commonLangFolderContentArr = $commonLangFolder->ls();
         $moduleModelArr = \GO::modules()->getAllModules();
         foreach ($commonLangFolderContentArr as $commonLangFolder) {
             if (get_class($commonLangFolder) == 'GO\\Base\\Fs\\Folder') {
                 $commonLangFileArr = $commonLangFolder->ls();
                 foreach ($commonLangFileArr as $commonLangFile) {
                     if (get_class($commonLangFile) == 'GO\\Base\\Fs\\File' && $commonLangFile->name() == $langCode . '.php') {
                         $fileNames[] = str_replace(\GO::config()->root_path, '', $commonLangFile->path());
                     }
                 }
             }
         }
     }
     foreach ($moduleModelArr as $moduleModel) {
         $modLangFolder = new \GO\Base\Fs\Folder($moduleModel->path . 'language/');
         if ($modLangFolder->exists()) {
             $modLangFiles = $modLangFolder->ls();
             foreach ($modLangFiles as $modLangFile) {
                 if ($modLangFile->name() == $langCode . '.php') {
                     $fileNames[] = str_replace(\GO::config()->root_path, '', $modLangFile->path());
                 }
             }
         }
     }
     $tmpFile = \GO\Base\Fs\File::tempFile($langCode . '-' . str_replace('.', '-', \GO::config()->version), 'zip');
     //exec zip
     $cmdString = \GO::config()->cmd_zip . ' ' . $tmpFile->path() . ' ' . implode(" ", $fileNames);
     exec($cmdString, $outputArr, $retVal);
     if ($retVal > 0) {
         trigger_error("Creating ZIP file failed! " . implode("<br />", $outputArr), E_USER_ERROR);
     }
     \GO\Base\Util\Http::outputDownloadHeaders($tmpFile);
     $tmpFile->output();
     $tmpFile->delete();
 }
Esempio n. 3
0
 /**
  * Return the default found exportclasses that are available in the export 
  * folder and where the showInView parameter is true
  * 
  * @return array 
  */
 private function _getExportTypes($path)
 {
     $defaultTypes = array();
     $folder = new Folder($path);
     $contents = $folder->ls();
     $classParts = explode('/', $folder->stripRootPath());
     $classPath = 'GO\\';
     foreach ($classParts as $part) {
         if ($part != 'go' && $part != 'modules') {
             $classPath .= ucfirst($part) . '\\';
         }
     }
     foreach ($contents as $exporter) {
         if (is_file($exporter->path())) {
             $classname = $classPath . $exporter->nameWithoutExtension();
             if ($classname != 'GO\\Base\\Export\\ExportInterface' && $classname != 'GO\\Base\\Export\\Settings') {
                 //$export = new $classname('temp');
                 //this is only compatible with php 5.3:
                 //$classname::$showInView
                 //so we use ReflectionClass
                 $class = new \ReflectionClass($classname);
                 $showInView = $class->getStaticPropertyValue('showInView');
                 $name = $class->getStaticPropertyValue('name');
                 $useOrientation = $class->getStaticPropertyValue('useOrientation');
                 if ($showInView) {
                     $defaultTypes[$classname] = array('name' => $name, 'useOrientation' => $useOrientation);
                 }
             }
         }
     }
     return $defaultTypes;
 }