public function getPageId($router, $pageName = '', $uniqueId = 0) { $isUniqueid = (int) $uniqueId; $pageId = 0; $ds = $this->_getPageDs(); $pageList = $ds->getPageByRouter($router); foreach ($pageList as $v) { if ($v['is_unique'] && $v['is_unique'] == $isUniqueid) { $pageId = $v['page_id']; break; } if (!$v['is_unique']) { $pageId = $v['page_id']; } } if ($pageId < 1) { Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm(); $dm->setName($pageName)->setRouter($router)->setUnique($uniqueId)->setType(PwDesignPage::NORMAL); $pageName && $dm->setType(PwDesignPage::SYSTEM); if ($router == 'special/index/run') { $portal = Wekit::load('design.PwDesignPortal')->getPortal($uniqueId); $dm->setName($portal['title'])->setType(PwDesignPage::PORTAL)->setIsUnique($isUniqueid); } $pageId = $ds->addPage($dm); if ($pageId instanceof PwError) { return false; } //自定义页面复制默认模版 if ($router == 'special/index/run') { $tplPath = 'special_' . $uniqueId; $srv = Wekit::load('design.srv.PwDesignService'); $result = $srv->defaultTemplate($pageId, $tplPath); if ($result) { Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($portal['id']); $dm->setTemplate($tplPath); Wekit::load('design.PwDesignPortal')->updatePortal($dm); } } } return $pageId; }
public function editstyleAction() { $styleid = $this->getInput('styleid', 'get'); $portalid = (int) $this->getInput('portalid', 'get'); $ds = $this->_getPortalDs(); $portal = $ds->getPortal($portalid); if (!$portal) { $this->showError("operate.fail"); } $styleDs = Wekit::load('APPS:appcenter.service.PwStyle'); $style = $styleDs->getStyle($styleid); if (!$style || $style['style_type'] != 'portal') { $this->showError("operate.fail"); } $pageInfo = $this->_getPageDs()->getPageByTypeAndUnique(PwDesignPage::PORTAL, $portalid); if (!$pageInfo) { $this->showError("operate.fail"); } //导入文件 Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($pageInfo['page_id']); $this->clearPage($pageInfo); Wind::import('SRV:design.srv.PwDesignImportZip'); $srv = new PwDesignImportZip($pageBo); if (!$srv->appcenterToLocal($style['alias'])) { $this->showError("operate.fail"); } Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($portalid); $dm->setTemplate($pageBo->getTplPath()); $ds->updatePortal($dm); $this->_getDesignService()->clearCompile(); //更新数据 Wind::import('SRV:design.srv.data.PwAutoData'); foreach ($srv->newIds as $id) { if (!$id) { continue; } $autoSrv = new PwAutoData($id); $autoSrv->addAutoData(); } $this->showMessage("operate.success"); }
/** * 自定义页面升级 start * * @return boolean */ protected function _designUpgrade() { Wind::import('SRV:design.srv.vo.PwDesignPortalSo'); $vo = new PwDesignPortalSo(); $vo->setIsopen(1); $list = $this->_getPortalDs()->searchPortal($vo, 0, 100); $dirList = array(); foreach ($list as $k => $v) { if (empty($v['template'])) { $dirList[$k] = $v['id']; } } $dir = Wind::getRealDir('THEMES:portal.local.'); $_dir = array(); if (!is_dir($dir)) { return array(); } if (!($handle = @opendir($dir))) { return array(); } while (false !== ($file = @readdir($handle))) { if ('.' === $file || '..' === $file) { continue; } $fileName = $dir . $file; if (is_file($fileName)) { continue; } elseif (is_dir($fileName) && is_numeric($file)) { $key = array_search($file, $dirList); unset($dirList[$k]); if ((int) $file != $file) { continue; } $tplPath = 'special_' . $file; Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($file); $dm->setTemplate($tplPath); Wekit::load('design.PwDesignPortal')->updatePortal($dm); $this->copyRecur($fileName, $dir . $tplPath . '/'); } } $srv = Wekit::load('design.srv.PwDesignService'); foreach ($dirList as $k => $v) { $tplPath = 'special_' . $v; $result = $srv->defaultTemplate($k, $tplPath); if ($result) { WindFile::write($dir . $tplPath . '/template/index.htm', $this->_tpl()); Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($v); $dm->setTemplate($tplPath); Wekit::load('design.PwDesignPortal')->updatePortal($dm); } } @closedir($handle); return true; }
/** * 清空当前页设计数据 * Enter description here ... * @see ImportController->dorunAction */ public function doclearAction() { $pageid = (int) $this->getInput('pageid', 'post'); Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($pageid); $pageInfo = $pageBo->getPage(); if (!$pageInfo) { $this->showError("operate.fail"); } $permissions = $this->_getPermissionsService()->getPermissionsForPage($this->loginUser->uid, $pageid); if ($permissions < PwDesignPermissions::IS_DESIGN) { $this->showError("DESIGN:permissions.fail"); } Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($pageid); if ($pageBo->getLock()) { $this->showError('DESIGN:page.edit.other.user'); } $ids = explode(',', $pageInfo['module_ids']); $names = explode(',', $pageInfo['module_names']); $moduleDs = $this->_getModuleDs(); $bakDs = $this->_getBakDs(); $dataDs = $this->_getDataDs(); $pushDs = $this->_getPushDs(); $imageSrv = Wekit::load('design.srv.PwDesignImage'); // module $moduleDs->deleteByPageId($pageid); // data && push foreach ($ids as $id) { $dataDs->deleteByModuleId($id); $pushDs->deleteByModuleId($id); $imageSrv->clearFolder($id); } //structure $ds = $this->_getStructureDs(); foreach ($names as $name) { $ds->deleteStruct($name); } //segment $this->_getSegmentDs()->deleteSegmentByPageid($pageid); //bak $bakDs->deleteByPageId($pageid); $tplPath = $pageBo->getTplPath(); $this->_getDesignService()->clearTemplate($pageid, $tplPath); if ($pageInfo['page_type'] == PwDesignPage::PORTAL) { Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($pageInfo['page_unique']); $dm->setTemplate($tplPath); $this->_getPortalDs()->updatePortal($dm); $srv = Wekit::load('design.srv.PwDesignService'); $result = $srv->defaultTemplate($pageid, $tplPath); } else { $this->_getPageDs()->deletePage($pageid); } $this->_getDesignService()->clearCompile(); $this->showMessage("operate.success"); }