/** * 修改 * * @param int $styleid * @param array $data * @return boolean */ public function updateStyle(PwStyleDm $dm) { if (($r = $dm->beforeUpdate()) instanceof PwError) { return $r; } return $this->_styleDao()->updateStyle($dm->getField('app_id'), $dm->getData()); }
/** * 使用这个风格 */ 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(); }
/** * 注册应用信息 * * @param PwInstallApplication $install * @return PwError true */ public function registeApplication($install) { $manifest = $install->getManifest(); $application = new PwStyleDm(); $application->setAppId($install->getAppId()); $application->setName($manifest->getApplication('name')); $application->setAlias($manifest->getApplication('alias')); $application->setVersion($manifest->getApplication('version')); $application->setPwVersion($manifest->getApplication('pw-version')); $application->setDescription($manifest->getApplication('description')); $application->setLogo($manifest->getApplication('logo')); $application->setWebsite($manifest->getApplication('website')); $application->setAuthorName($manifest->getApplication('author-name')); $application->setAuthorEmail($manifest->getApplication('author-email')); $application->setAuthorIcon($manifest->getApplication('author-icon')); $application->setCreatedTime(time()); $application->setModifiedTime(time()); list($type) = $this->getStyleType($install); $application->setType($type); if (!$application->beforeAdd()) { return new PwError('APPCENTER:install.mainfest.fail'); } $this->_load()->addStyle($application); $install->setInstallLog('appId', $install->getAppId()); file_put_contents(DATA_PATH . 'tmp/log', 'app!', FILE_APPEND); return true; }