/** * 使用这个风格 */ public function useStyle($styleid) { if (!($style = $this->_styleDs()->getStyle($styleid))) { return new PwError('STYLE:style.not.exist'); } $oldStyle = $this->_styleDs()->getCurrentStyleByType($style['style_type']); if ($oldStyle) { $oldDm = new PwStyleDm(); $oldDm->setAppid($oldStyle['app_id'])->setIsCurrent(0); $this->_styleDs()->updateStyle($oldDm); } $dm = new PwStyleDm(); $dm->setAppid($styleid)->setIsCurrent(1); $this->_styleDs()->updateStyle($dm); //Wekit::load('domain.srv.PwDomainService')->refreshTplCache(); return $this->_setConfigBo($style); }
/** * 安装过程中风格的初始化 * */ public function init() { $install = Wekit::load('APPS:appcenter.service.srv.PwInstallApplication'); $configBo = new PwConfigSet('site'); $config = $install->getConfig('style-type'); foreach ($config as $k => $v) { $configBo->set("theme.{$k}.pack", $v[1]); $pack = Wind::getRealDir('THEMES:' . str_replace('/', '.', $v[1]) . '.default'); $id = $this->install($pack); if (!$id) { continue; } $dm = new PwStyleDm(); $dm->setAppid($id)->setIsCurrent(1); $this->_styleDs()->updateStyle($dm); $configBo->set("theme.{$k}.default", 'default'); } $configBo->flush(); }