public function updatePortal(PwDesignPortalDm $dm)
 {
     $resource = $dm->beforeUpdate();
     if ($resource instanceof PwError) {
         return $resource;
     }
     return $this->_getDao()->update($dm->id, $dm->getData());
 }
 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;
 }
Exemple #3
0
 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");
 }
 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);
 }