private function sortFile($file) { $directory = $this->_getDefaultDirectory(); $sort = array('HTML', 'ATTACH', 'TPL', 'THEMES', 'ACLOUD', 'WINDID', 'REP', 'SRV', 'LIB', 'HOOK', 'EXT', 'APPS', 'CONF', 'DATA', 'SRC', 'PUBLIC'); $strtr = array(); $localDirectory = @(include Wind::getRealPath('CONF:directory.php', true)); foreach ($sort as $v) { if ($directory[$v] == $localDirectory[$v]) { continue; } $search = PwSystemHelper::relative(WEKIT_PATH . $directory[$v]); $strtr[$search] = Wind::getRootPath($v); } $_file = ROOT_PATH . $file; foreach ($strtr as $search => $replace) { if (0 === strpos($_file, $search)) { $file = str_replace(ROOT_PATH, '', $replace . substr($_file, strlen($search))); break; } } return $file; }
/** * 结束 */ public function endAction() { list($upgrade, $back) = $this->_backSuccess(); Wekit::load('hook.srv.PwHookRefresh')->refresh(); Wekit::load('SRV:cache.srv.PwCacheUpdateService')->updateAll(); Wekit::load('domain.srv.PwDomainService')->refreshTplCache(); PwSystemHelper::log('upgrade success, current version: ' . 'phpwind ' . NEXT_VERSION . ' release ' . NEXT_RELEASE, $this->version); $this->_clear(); Pw::setCookie('checkupgrade', '', -1); $this->setOutput(array('systeminfo' => 'phpwind ' . NEXT_VERSION . ' release ' . NEXT_RELEASE, 'back' => str_replace(ROOT_PATH, '', $back), 'upgrade' => str_replace(ROOT_PATH, '', $upgrade))); }
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; }
/** * (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; }
private function _log($msg) { PwSystemHelper::log($msg, $this->target); }
/** * 注册静态资源 * * @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); }
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; }