public function writeAble($patch) { foreach ($patch['rule'] as $rule) { if (!PwSystemHelper::checkWriteAble(ROOT_PATH . $rule['filename'])) { return false; } } return true; }
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; }
/** * 注册静态资源 * * @param PwInstallApplication $install * @return PwError true */ public function registeResource($install) { $manifest = $install->getManifest()->getManifest(); if (!isset($manifest['res']) || !$manifest['res']) { return true; } $name = $install->getManifest()->getApplication('alias'); $source = $install->getTmpPackage() . '/' . str_replace('.', '/', $manifest['res']); $targetPath = Wind::getRealDir('THEMES:extres', true); if (!is_dir($source)) { return true; } $writable = PwSystemHelper::checkWriteAble($targetPath . '/'); if (!$writable) { return new PwError('APPCENTER:install.mv.fail', array('{{error}}' => 'THEMES:extres.' . $name)); } PwApplicationHelper::copyRecursive($source, $targetPath . '/' . $name); $install->addInstallLog('packs', $targetPath . '/' . $name); file_put_contents(DATA_PATH . 'tmp/log', 'res!', FILE_APPEND); }
/** * (non-PHPdoc) * * @see PwInstall::afterInstall() * @param PwInstallApplication $install */ public function afterInstall($install) { list(, $pack) = $this->getStyleType($install); $alias = $install->getManifest()->getApplication('alias'); $targetDir = THEMES_PATH . $pack; if (!PwSystemHelper::checkWriteAble($targetDir . '/')) { return new PwError('APPCENTER:install.mv.fail', array('{{error}}' => 'THEMES:' . str_replace('/', '.', $pack))); } $target = $targetDir . '/' . $alias; PwApplicationHelper::mvSourcePack($install->getTmpPackage(), $target); $install->addInstallLog('packs', $target); file_put_contents(DATA_PATH . 'tmp/log', 'afterinstall!', FILE_APPEND); return true; }
public function generate() { $this->baseDir = Wind::getRealDir('EXT:' . $this->alias); if (is_dir($this->baseDir)) { return new PwError('APPCENTER:alias.exist'); } WindFolder::mkRecur($this->baseDir); Wind::import('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, array('service')); $manifest = WindFile::read($this->baseDir . '/Manifest.xml'); $this->manifest = $this->_strtr($manifest); $this->_generateAdmin(); WindFile::write($this->baseDir . '/Manifest.xml', $this->manifest); $this->_resolveTemplate(); $this->_generateService(); return true; }