Пример #1
0
 public function generate()
 {
     $addons = Wekit::load('APPS:appcenter.service.srv.PwInstallApplication')->getConfig('style-type');
     $base = str_replace('/', '.', $addons[$this->style_type][1]);
     $this->defaultDir = Wind::getRealDir('THEMES:' . $base . '.default');
     if (!is_dir($this->defaultDir)) {
         return new PwError('APPCENTER:generate.style.unsupport');
     }
     $this->baseDir = Wind::getRealDir('THEMES:' . $base . '.' . $this->alias);
     if (is_dir($this->baseDir)) {
         return new PwError('APPCENTER:alias.exist');
     }
     WindFolder::mkRecur($this->baseDir);
     Wind::import('APPS:appcenter.service.srv.helper.PwSystemHelper');
     $writable = PwSystemHelper::checkWriteAble($this->baseDir . '/');
     if (!$writable) {
         return new PwError('APPCENTER:generate.copy.fail');
     }
     PwApplicationHelper::copyRecursive($this->defaultDir, $this->baseDir);
     $file = $this->baseDir . '/Manifest.xml';
     Wind::import('WIND:parser.WindXmlParser');
     $parser = new WindXmlParser();
     $manifest = $parser->parse($file);
     $manifest['application']['name'] = $this->name;
     $manifest['application']['alias'] = $this->alias;
     $manifest['application']['description'] = $this->description;
     $manifest['application']['version'] = $this->version;
     $manifest['application']['pw-version'] = $this->pwversion;
     $manifest['application']['website'] = $this->website;
     $manifest['application']['author-name'] = $this->author;
     $manifest['application']['author-email'] = $this->email;
     $parser = new WindXmlParser();
     $manifest = str_replace('><', ">\n\t<", $parser->parseToXml(array('manifest' => $manifest), Wind::getApp()->getResponse()->getCharset()));
     WindFile::write($this->baseDir . '/Manifest.xml', $manifest);
     return 'THEMES:' . $base . '.' . $this->alias;
 }
 public function generateBaseInfo()
 {
     $this->baseDir = Wind::getRealDir('EXT:' . $this->alias);
     $file = $this->baseDir . '/Manifest.xml';
     Wind::import('WIND:parser.WindXmlParser');
     $parser = new WindXmlParser();
     $manifest = $parser->parse($file);
     $manifest['application']['name'] = $this->name;
     $manifest['application']['description'] = $this->description;
     $manifest['application']['version'] = $this->version;
     $manifest['application']['pw-version'] = $this->pwversion;
     $manifest['application']['author-name'] = $this->author;
     $manifest['application']['author-email'] = $this->email;
     $manifest['application']['website'] = $this->website;
     $parser = new WindXmlParser();
     $manifest = str_replace('><', ">\n\t<", $parser->parseToXml(array('manifest' => $manifest), Wind::getApp()->getResponse()->getCharset()));
     if (!WindFile::write($file, $manifest)) {
         return new PwError('APPCENTER:generate.copy.fail');
     }
 }