Exemplo n.º 1
0
 /**
  * 根据key更新
  *
  * @param PwDomainDm $dm
  * @return boolean|Ambigous <number, boolean, rowCount>
  */
 public function updateByDomainKey(PwDomainDm $dm)
 {
     if (!($key = $dm->getField('domain_key'))) {
         return new PwError('DOMAIN:domain_key_null');
     }
     if (($r = $dm->beforeUpdate()) instanceof PwError) {
         return $r;
     }
     return $this->_domainDao()->updateByDomainKey($key, $dm->getData());
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 private function _updateForumDomain($forum)
 {
     //版块域名
     $fid = $forum->fid;
     list($forumdomain, $forumroot) = $this->getInput(array('forumdomain', 'forumroot'));
     $domainKey = $forum->foruminfo['type'] == 'category' ? "bbs/cate/run?fid={$fid}" : "bbs/thread/run?fid={$fid}";
     $oldDomain = Wekit::load('domain.PwDomain')->getByDomainKey($domainKey);
     /* @var $srv PwDomainService */
     $srv = Wekit::load('domain.srv.PwDomainService');
     if (!$forumdomain) {
         Wekit::load('domain.PwDomain')->deleteByDomainKey($domainKey);
         if ($oldDomain) {
             $srv->flushAll();
         }
     } else {
         if ($forumroot) {
             $r = $srv->isDomainValid($forumdomain, $forumroot, $domainKey);
         } else {
             $r = $srv->isNameValid($forumdomain, $domainKey);
         }
         if ($r instanceof PwError) {
             $this->showError($r->getError());
         }
         Wind::import('SRV:domain.dm.PwDomainDm');
         $dm = new PwDomainDm();
         $dm->setDomain($forumdomain)->setDomainKey($domainKey)->setDomainType('forum')->setRoot($forumroot)->setFirst($forumdomain[0])->setId($fid);
         Wekit::load('domain.PwDomain')->replaceDomain($dm);
         if (!$oldDomain || $oldDomain['domain'] != $forumdomain) {
             $srv->flushAll();
         }
     }
 }
Exemplo n.º 4
0
 /**
  * 保存修改
  */
 public function doModifyAction()
 {
     $root = Wekit::C('site', 'cookie.domain');
     if (empty($root)) {
         $this->showError('REWRITE:cookie.domain.fail');
     }
     $root[0] != '.' && ($root = '.' . $root);
     list($app, $domain, $domain_hold) = $this->getInput(array('app', 'domain', 'domain_hold'));
     // 判断域名是否重复
     $unique = array();
     Wind::import('SRV:domain.dm.PwDomainDm');
     $bo = new PwConfigSet('domain');
     $addons = $this->_service()->getDomainAddOns();
     foreach ($app as $key => $value) {
         $domainKey = $addons[$key][1] ? $addons[$key][1] : "{$key}/index/run";
         if ($value) {
             //域名重复
             in_array($value, $unique) && $this->showError(array('REWRITE:domain.same', array($value)));
             $unique[] = $value;
             //添加应用域名
             $dm = new PwDomainDm();
             $dm->setDomain($value)->setRoot(substr($root, 1))->setDomainKey($domainKey)->setDomainType('app')->setFirst($value[0]);
             $r = $this->_ds()->replaceDomain($dm);
             if ($r instanceof PwError) {
                 $this->showError($r->getError());
             }
         } else {
             $this->_ds()->deleteByDomainKey($domainKey);
         }
     }
     $unique = array();
     $space_root = '';
     $siteBo = new PwConfigSet('site');
     foreach ($domain as $k => $v) {
         $domain_root = '';
         if ($v['isopen']) {
             if (!$app['default']) {
                 $this->showError('REWRITE:default.empty');
             }
             if ($k == 'space' && !$v['root']) {
                 $this->showError('REWRITE:root.empty');
             }
             $space_root = isset($domain['space']['root']) ? $domain['space']['root'] : '';
             if ($k != 'space' && $domain['space']['isopen']) {
                 if ($v['root'] == $space_root) {
                     $this->showError('REWRITE:root.same');
                 }
             }
             $unique[] = $v['root'];
             $domain_root = $v['root'] ? $v['root'] . $root : substr($root, 1);
             $dm = new PwDomainDm();
             $dm->setRoot($domain_root)->setDomainType($k);
             $r = $this->_ds()->updateByDomainType($dm);
             if ($r instanceof PwError) {
                 $this->showError($r->getError());
             }
         } elseif ($k != 'forum') {
             $this->_ds()->deleteByDomainType($k);
         }
         $siteBo->set("domain.{$k}.isopen", $v['isopen']);
         $bo->set("{$k}.isopen", $v['isopen'])->set("{$k}.root", $domain_root);
     }
     $bo->set('domain.hold', $domain_hold);
     $bo->flush();
     $siteBo->set('domain.space.root', $space_root);
     $siteBo->flush();
     $this->_service()->flushAll();
     Wekit::load('SRV:nav.srv.PwNavService')->updateConfig();
     $this->showMessage('success');
 }