public function zip($charset = 'utf-8')
 {
     Wind::import('LIB:utility.PwZip');
     $zip = new PwZip();
     $files = $this->read($this->dir);
     $fromCharset = Wekit::app()->charset;
     foreach ($files as &$v) {
         $v['filename'] = str_replace($this->dir, '', $v['filename']);
         $ext = strrchr($v['filename'], ".");
         if ($ext != $this->_tplExt) {
             continue;
         }
         //$v['data'] = $this->decompilePw($v['data']);
         $v['data'] = $this->decompileTitle($v['data']);
         //$v['data'] = $this->decompileList($v['data']);
         $v['data'] = $this->decompileTpl($v['data']);
         $v['data'] = $this->decompileStyle($v['data']);
     }
     foreach ($files as $file) {
         if ($file['filename'] == 'module/data.txt') {
             continue;
         }
         if (strtolower($file['filename']) == 'manifest.xml') {
             Wind::import("WIND:parser.WindXmlParser");
             $xml = new WindXmlParser('1.0', $fromCharset);
             $config = $xml->parseXmlStream($file['data'], 0);
             unset($config['module']);
             $file['data'] = $this->xmlFormat($config, $charset);
         } else {
             $ext = strtolower(substr(strrchr($file['filename'], '.'), 1));
             if (in_array($ext, array('css', 'js', 'htm'))) {
                 $file['data'] = WindConvert::convert($file['data'], $charset, $fromCharset);
             }
         }
         $file['filename'] = $this->folder . '/' . $file['filename'];
         if (!$zip->addFile($file['data'], $file['filename'])) {
             return new PwError("DESIGN:zlib.error");
         }
     }
     $txt = $this->doTxt($charset);
     $txtfile = $this->folder . '/module/data.txt';
     $zip->addFile($txt['content'], $txtfile);
     return $zip->getCompressedFile();
 }
示例#2
0
 public function zip()
 {
     Wind::import('LIB:utility.PwZip');
     $zip = new PwZip();
     $files = $this->read($this->dir);
     foreach ($files as &$v) {
         $v['filename'] = str_replace($this->dir, '', $v['filename']);
         $ext = strrchr($v['filename'], ".");
         if ($ext != $this->_tplExt) {
             continue;
         }
         //$v['data'] = $this->decompilePw($v['data']);
         $v['data'] = $this->decompileTitle($v['data']);
         //$v['data'] = $this->decompileList($v['data']);
         $v['data'] = $this->decompileTpl($v['data']);
         $v['data'] = $this->decompileStyle($v['data']);
     }
     foreach ($files as $file) {
         if ($file['filename'] == 'module/data.txt') {
             continue;
         }
         if (strtolower($file['filename']) == 'manifest.xml') {
             Wind::import("WIND:parser.WindXmlParser");
             $xml = new WindXmlParser();
             $config = $xml->parseXmlStream($file['data'], 0);
             unset($config['module']);
             $file['data'] = $this->xmlFormat($config);
         }
         $file['filename'] = $this->folder . '/' . $file['filename'];
         if (!$zip->addFile($file['data'], $file['filename'])) {
             return new PwError("DESIGN:zlib.error");
         }
     }
     $txt = $this->doTxt();
     $txtfile = $this->folder . '/module/data.txt';
     $zip->addFile($txt['content'], $txtfile);
     return $zip->getCompressedFile();
 }
示例#3
0
 public static function zip($dir, $target)
 {
     $files = self::readRecursive($dir);
     Wind::import('LIB:utility.PwZip');
     $zip = new PwZip();
     $dir_len = strlen(dirname($dir)) + 1;
     foreach ($files as $v) {
         $zip->addFile(WindFile::read($v), substr($v, $dir_len));
     }
     return WindFile::write($target, $zip->getCompressedFile());
 }