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; }
private function _generateAdmin() { if ($this->need_admin) { $classname = $this->_ucwords($this->alias) . '_ConfigDo'; $hook = array('s_admin_menu' => array('app_' . $this->alias => array('class' => 'EXT:' . $this->alias . '.service.srv.' . $classname, 'loadway' => 'load', 'method' => 'getAdminMenu', 'description' => $this->name . 'admin menu'))); Wind::import('WIND:parser.WindXmlParser'); $parser = new WindXmlParser(); $hook = preg_replace('/<\\?xml[^\\?]+\\?>/i', '', $parser->parseToXml($hook, Wind::getApp()->getResponse()->getCharset())); $hook = str_replace('><', ">\n\t<", $hook); $this->manifest = strtr($this->manifest, array('{{inject_services}}' => $hook)); $class = WindFile::read(dirname($this->defaultDir) . '/hook.admin'); $class = strtr($class, array('{{alias}}' => $this->alias, '{{name}}' => $this->name, '{{classname}}' => $classname, '{{author}}' => $this->author, '{{email}}' => $this->email, '{{website}}' => $this->website)); WindFolder::mkRecur($this->baseDir . '/service/srv/'); WindFile::write($this->baseDir . '/service/srv/' . $classname . '.php', $class); } else { $this->manifest = strtr($this->manifest, array('{{inject_services}}' => '')); WindFolder::clearRecur($this->baseDir . '/admin', true); WindFolder::clearRecur($this->baseDir . '/template/admin', true); } }