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 doeditAction() { $id = (int) $this->getInput('portalid', 'post'); $title = $this->getInput('title', 'post'); $coverfrom = (int) $this->getInput('coverfrom', 'post'); $pagename = $this->getInput('pagename', 'post'); $keywords = $this->getInput('keywords', 'post'); $description = $this->getInput('description', 'post'); if (!$title) { $this->showError("DESIGN:title.is.empty"); } if (!$pagename) { $this->showError("DESIGN:pagename.is.empty"); } //二级域名start list($domain, $root) = $this->getInput(array('domain', 'root'), 'post'); if ($root) { if (!$domain) { Wekit::load('domain.PwDomain')->deleteByDomainKey("special/index/run?id={$id}"); } else { $r = Wekit::load('domain.srv.PwDomainService')->isDomainValid($domain, $root, "special/index/run?id={$id}"); if ($r instanceof PwError) { $this->showError($r->getError()); } Wind::import('SRV:domain.dm.PwDomainDm'); $dm = new PwDomainDm(); $dm->setDomain($domain)->setDomainKey("special/index/run?id={$id}")->setDomainType('special')->setRoot($root)->setFirst($domain[0])->setId($id); Wekit::load('domain.PwDomain')->replaceDomain($dm); } Wekit::load('domain.srv.PwDomainService')->flushAll(); } //二级域名end if (!$this->_validator($pagename)) { $this->showError("DESIGN:pagename.validator.fail"); } $ds = $this->_getPortalDs(); $portal = $ds->getPortal($id); if (!$portal) { $this->showError("operate.fail"); } $count = $ds->countPortalByPagename($pagename); if ($portal['pagename'] != $pagename && $count >= 1) { $this->showError("DESIGN:pagename.already.exists"); } if ($coverfrom == 2) { $cover = ''; $upload = $this->_upload($id); if ($upload['filename']) { $cover = Pw::getPath($upload['path'] . $upload['filename']); } } else { $cover = $this->getInput('webcover', 'post'); $cover = preg_match("/^http:\\/\\/(.*)\$/", $cover) ? $cover : ''; } Wind::import('SRV:design.dm.PwDesignPortalDm'); $dm = new PwDesignPortalDm($id); $dm->setPageName($pagename)->setTitle($title)->setCover($cover)->setDomain($domain)->setIsopen((int) $this->getInput('isopen', 'post'))->setHeader((int) $this->getInput('isheader', 'post'))->setNavigate((int) $this->getInput('isnavigate', 'post'))->setFooter((int) $this->getInput('isfooter', 'post'))->setKeywords($keywords)->setDescription($description); $resource = $ds->updatePortal($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } $pageInfo = $this->_getPageDs()->getPageByTypeAndUnique(PwDesignPage::PORTAL, $id); //更新页面名称 Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm($pageInfo['page_id']); $dm->setName($title); $this->_getPageDs()->updatePage($dm); //seo Wind::import('SRV:seo.dm.PwSeoDm'); $dm = new PwSeoDm(); $dm->setMod('area')->setPage('custom')->setParam($id)->setTitle($title)->setKeywords($keywords)->setDescription($description); Wekit::load('seo.srv.PwSeoService')->batchReplaceSeoWithCache($dm); $this->showMessage("operate.success", "special/index/run?id=" . $id, true); }
protected function restorePage($pageid, $issnap = 0) { $page = $this->_getBakDs()->getBak(PwDesignBak::PAGE, $pageid, $issnap); Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm($pageid); $dm->setName($page['bak_info']['page_name'])->setType($page['bak_info']['page_type'])->setRouter($page['bak_info']['page_router'])->setUnique($page['bak_info']['page_unique'])->setModuleIds(explode(',', $page['bak_info']['module_ids']))->setStrucNames(explode(',', $page['bak_info']['struct_names']))->setSegments(explode(',', $page['bak_info']['segments'])); return $this->_getPageDs()->updatePage($dm); }