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; }
/** * Enter description here ... * @param int $pageid * @param int $uniqueid */ public function getNewPageId($pageid, $uniqueid = 0, $isunique = false) { Wind::import('SRV:design.dm.PwDesignPageDm'); $ds = $this->_getPageDs(); $pageInfo = $ds->getPage($pageid); if (!$pageInfo) { return new PwError('operate.fail'); } $dm = new PwDesignPageDm($pageid); if ($isunique) { list($pagename, $id) = $this->getUniquePage($pageInfo['page_router'], $uniqueid); $dm->setIsUnique($id)->setName($pagename); } elseif ($pageInfo['page_type'] != PwDesignPage::PORTAL) { $dm->setIsUnique(0); if ($pageInfo['is_unique']) { $ds->deleteNoUnique($pageInfo['page_router'], 0); } } //设计模式解锁 $dm->setDesignLock(0, 0); $ds->updatePage($dm); return $pageid; }
public function afterDesign() { $ds = Wekit::load('design.PwDesignPage'); Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm($this->pageid); $dm->setModuleIds(array_unique($this->moduleIds))->setStrucNames($this->structNames)->setSegments($this->segments); $resource = $ds->updatePage($dm); Wekit::load('design.PwDesignModule')->batchUpdateIsUsed($this->moduleIds); if ($this->isDesign) { $loginUser = Wekit::getLoginUser(); $dm = new PwDesignPageDm($this->pageid); $dm->setDesignLock($loginUser->uid, Pw::getTime()); $ds->updatePage($dm); Wekit::load('design.srv.PwPageBakService')->doSnap($this->pageid); } }
/** * 设计模计轮循加锁 * Enter description here ... */ public function lockdesignAction() { $pageid = (int) $this->getInput('pageid', 'post'); $pageInfo = $this->_getPageDs()->getPage($pageid); if (!$pageInfo) { $this->showError("operate.fail"); } Wekit::load('design.PwDesignPermissions'); $permissions = $this->_getPermissionsService()->getPermissionsForPage($this->loginUser->uid, $pageid); if ($permissions <= PwDesignPermissions::NEED_CHECK) { $this->showError("DESIGN:permissions.fail"); } list($uid, $time) = explode('|', $pageInfo['design_lock']); if ($uid != $this->loginUser->uid) { $this->showError("operate.fail"); } Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm($pageid); $dm->setDesignLock($this->loginUser->uid, Pw::getTime()); $this->_getPageDs()->updatePage($dm); $this->showMessage("operate.success"); }
public function tagModule() { $ds = $this->_getPageDs(); Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm(); $dm->setType(PwDesignPage::SYSTEM)->setName('话题')->setRouter('tag/index/run')->setSegments(array('huatidemo')); $pageid = $ds->addPage($dm); if ($pageid instanceof PwError) { return false; } Wind::import('SRV:design.srv.vo.PwDesignComponentSo'); $vo = new PwDesignComponentSo(); $vo->setCompname('话题封面 [ 间隔 ]'); $comp = Wekit::load('design.PwDesignComponent')->searchComponent($vo); if (!$comp) { return false; } $comp = array_shift($comp); $tpl = $comp['comp_tpl']; $property = array("islogo" => 1, "order" => 5, "limit" => 18, "timefmt" => "m-d"); $cache = array('expired' => 15, 'start_hour' => 0, 'start_minute' => 0, 'end_hour' => 0, 'end_minute' => 0); Wind::import('SRV:design.dm.PwDesignModuleDm'); $moduleDm = new PwDesignModuleDm(); $moduleDm->setFlag('tag')->setPageId($pageid)->setName('演示:热门话题')->setModuleTpl($tpl)->setProperty($property)->setCache($cache)->setCompid($comp['comp_id'])->setIsused(1); $moduleid = Wekit::load('design.PwDesignModule')->addModule($moduleDm); if ($moduleid instanceof PwError) { return false; } $dm = new PwDesignPageDm($pageid); $dm->setModuleIds(array($moduleid)); $ds->updatePage($dm); $rand = WindUtility::generateRandStr(8); $tpl = <<<TPL <div id="{$rand}" class="design_layout_style J_mod_layout box_no" role="structure_{$rand}" data-lcm="100">\t\t\t <h2 class="design_layout_hd cc J_layout_hd" role="titlebar"></h2>\t\t\t <div id="J_mod_{$moduleid}" class="design_layout_ct mod_box J_mod_box" data-id="{$moduleid}"> <design id="D_mod_{$moduleid}" role="module"> </design> </div> </div> TPL; Wekit::load('design.PwDesignSegment')->replaceSegment('huatidemo', $pageid, $tpl); Wind::import('SRV:design.srv.data.PwAutoData'); $srv = new PwAutoData($moduleid); $srv->addAutoData(); return true; }
public function updatePage(PwDesignPageDm $dm) { $resource = $dm->beforeUpdate(); if ($resource instanceof PwError) { return $resource; } return $this->_getDao()->updatePage($dm->pageid, $dm->getData()); }
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); }
protected function updatePage() { Wind::import('SRV:design.dm.PwDesignPageDm'); $moduleIds = implode(',', $this->newIds); $moduleIds = $moduleIds ? $moduleIds . ',' . $this->_pageInfo['module_ids'] : $this->_pageInfo['module_ids']; $moduleIds = array_filter(explode(',', $moduleIds)); $dm = new PwDesignPageDm($this->_pageInfo['page_id']); $dm->setModuleIds($moduleIds)->setStrucNames($this->_structures); $resource = Wekit::load('design.PwDesignPage')->updatePage($dm); return $resource; }
protected function clearPage($pageInfo) { $pageid = $pageInfo['page_id']; //doclear start //@see DesignController->doclearAction $ids = explode(',', $pageInfo['module_ids']); $names = explode(',', $pageInfo['struct_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); $bakDs->deleteByPageId($pageid); Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm($pageid); $dm->setModuleIds(array())->setStrucNames(array()); $this->_getPageDs()->updatePage($dm); //doclear end }