Пример #1
0
 public function deleteAction()
 {
     $portalid = (int) $this->getInput('id', 'get');
     $portal = $this->_getPortalDs()->getPortal($portalid);
     $pageInfo = $this->_getPageDs()->getPageByTypeAndUnique(PwDesignPage::PORTAL, $portalid);
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $pageBo = new PwDesignPageBo($pageInfo['page_id']);
     if ($pageInfo) {
         $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');
         $moduleDs->deleteByPageId($pageInfo['page_id']);
         // module&& data && push
         $list = Wekit::load('design.PwDesignModule')->getByPageid($this->pageid);
         foreach ($list as $id => $v) {
             $dataDs->deleteByModuleId($id);
             $pushDs->deleteByModuleId($id);
             $imageSrv->clearFolder($id);
         }
         //structure
         $ds = $this->_getStructureDs();
         foreach ($names as $name) {
             $ds->deleteStruct($name);
         }
         //segment
         $this->_getSegmentDs()->deleteSegmentByPageid($pageInfo['page_id']);
         $this->_getPageDs()->deletePage($pageInfo['page_id']);
         $this->_getPermissionsDs()->deleteByTypeAndDesignId(PwDesignPermissions::TYPE_PAGE, $pageInfo['page_id']);
     }
     $this->_getDesignService()->clearTemplate($pageBo->pageid, $pageBo->getTplPath());
     if ($this->_getPortalDs()->deletePortal($portalid)) {
         if ($portal['cover']) {
             $ext = strrchr($portal['cover'], ".");
             $filename = 'portal/' . $portalid . $ext;
             Pw::deleteAttach($filename);
         }
         $this->showMessage("operate.success");
     }
     $this->showMessage("operate.fail");
 }
Пример #2
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");
 }
Пример #3
0
 /**
  * 对模块进行删除
  * PS:不是真正的删除,记录为isused = 0状态
  */
 public function deleteAction()
 {
     $moduleid = (int) $this->getInput('moduleid', 'post');
     $module = $this->_getModuleDs()->getModule($moduleid);
     if (!$module || $module['page_id'] < 1) {
         $this->showError('operate.fail');
     }
     Wekit::load('design.PwDesignPermissions');
     $permissions = $this->_getPermissionsService()->getPermissionsForModule($this->loginUser->uid, $moduleid);
     if ($permissions < PwDesignPermissions::IS_DESIGN) {
         $this->showError("DESIGN:permissions.fail");
     }
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $pageBo = new PwDesignPageBo($module['page_id']);
     if ($pageBo->getLock()) {
         $this->showError('DESIGN:page.edit.other.user');
     }
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $dm = new PwDesignModuleDm($moduleid);
     $dm->setIsused(0);
     $resource = $this->_getModuleDs()->updateModule($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     //if (!$this->_getModuleDs()->deleteModule($moduleid)) $this->showMessage("operate.fail");
     $this->_getDataDs()->deleteByModuleId($moduleid);
     Wekit::load('design.PwDesignPush')->deleteByModuleId($moduleid);
     //删除导入数据的模版内容
     $dir = Wind::getRealDir('THEMES:portal.local.');
     $path = $dir . $pageBo->getTplPath() . '/template/';
     $files = WindFolder::read($path, WindFolder::READ_FILE);
     foreach ($files as $file) {
         $filePath = $path . $file;
         $content = WindFile::read($filePath);
         if (!$content) {
             continue;
         }
         $tmp = preg_replace('/\\<pw-list\\s*id=\\"' . $moduleid . '\\"\\s*>(.+)<\\/pw-list>/isU', '', $content);
         if ($tmp != $content) {
             WindFile::write($filePath, $tmp);
         }
     }
     $this->showMessage("operate.success");
 }
Пример #4
0
 /**
  * 清空当前页设计数据
  * 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");
 }