예제 #1
0
 protected function restoreModule($pageid, $issnap = 0)
 {
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $bakDs = $this->_getBakDs();
     $conpDs = $this->_getComponentDs();
     $module = $bakDs->getBak(PwDesignBak::MODULE, $pageid, $issnap);
     if (!is_array($module['bak_info'])) {
         return false;
     }
     $ds = $this->_getModuleDs();
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $bo = new PwDesignPageBo($pageid);
     Wind::import('SRV:design.srv.PwPortalCompile');
     $srv = new PwPortalCompile($bo);
     foreach ($module['bak_info'] as $k => $v) {
         $dm = new PwDesignModuleDm($k);
         $dm->setFlag($v['model_flag'])->setName($v['module_name'])->setCompid($v['module_compid'])->setProperty(unserialize($v['module_property']))->setCache(unserialize($v['module_cache']))->setTitle(unserialize($v['module_title']))->setModuleTpl($v['module_tpl'])->setIsused($v['isused']);
         $style = unserialize($v['module_style']);
         $dm->setStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass']);
         $ds->updateModule($dm);
     }
     $pageInfo = $bo->getPage();
     if ($pageInfo['page_type'] == PwDesignPage::PORTAL) {
         $srv->restoreList($module['bak_info'], 'index');
     }
     return true;
 }
예제 #2
0
 public function doeditAction()
 {
     $other = array('html', 'searchbar', 'image');
     $model = $this->getInput('model', 'post');
     $moduleid = $this->getInput('moduleid', 'post');
     if (!$moduleid) {
         $this->showError('operate.fail');
     }
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $moduleBo = new PwDesignModuleBo($moduleid);
     $_model = $moduleBo->getModel();
     if ($model != $_model) {
         $this->_getDataDs()->deleteByModuleId($moduleid);
         $this->_getPushDs()->deleteByModuleId($moduleid);
     }
     !$model && ($model = $_model);
     $module = $moduleBo->getModule();
     if (!$module || $module['page_id'] < 1) {
         $this->showError('operate.fail');
     }
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $pageBo = new PwDesignPageBo($module['page_id']);
     if ($pageBo->getLock()) {
         $this->showError('DESIGN:page.edit.other.user');
     }
     Wekit::load('design.PwDesignPermissions');
     $permissions = $this->_getPermissionsService()->getPermissionsForModule($this->loginUser->uid, $moduleid, $module['page_id']);
     if ($permissions < PwDesignPermissions::IS_ADMIN && !in_array($module['model_flag'], $other)) {
         $this->showError("DESIGN:permissions.fail");
     }
     if ($permissions < PwDesignPermissions::IS_PUSH) {
         $this->showError("DESIGN:permissions.fail");
     }
     $name = trim($this->getInput('module_name', 'post'));
     if (empty($name)) {
         $this->showError('DESIGN:module.name.empty');
     }
     $cache = $this->getInput('cache', 'post');
     $property = $this->getInput('property', 'post');
     if ($property['limit'] > 200) {
         $this->showError('DESIGN:maxlimit.error');
     }
     $cls = sprintf('PwDesign%sDataService', ucwords($model));
     Wind::import('SRV:design.srv.model.' . $model . '.' . $cls);
     $service = new $cls();
     if (method_exists($service, 'decorateSaveProperty')) {
         $property = $service->decorateSaveProperty($property);
         if ($property instanceof PwError) {
             $this->showError($property->getError());
         }
     }
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $dm = new PwDesignModuleDm($moduleid);
     $dm->setFlag($model)->setName($name)->setProperty($property)->setCache($cache);
     if (isset($property['html_tpl'])) {
         $dm->setModuleTpl($property['html_tpl']);
     }
     $resource = $this->_getModuleDs()->updateModule($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     Wind::import('SRV:design.srv.data.PwAutoData');
     $srv = new PwAutoData($moduleid);
     $srv->addAutoData();
     $this->showMessage("operate.success");
 }
예제 #3
0
 public function doeditAction()
 {
     $model = $this->getInput('model', 'post');
     $moduleid = $this->getInput('moduleid', 'post');
     if (!$moduleid) {
         $this->showError('operate.fail');
     }
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $moduleBo = new PwDesignModuleBo($moduleid);
     $_model = $moduleBo->getModel();
     if ($model != $_model) {
         $this->_getDataDs()->deleteByModuleId($moduleid);
         $this->_getPushDs()->deleteByModuleId($moduleid);
     }
     !$model && ($model = $_model);
     $module = $moduleBo->getModule();
     if (!$module) {
         $this->showError('operate.fail');
     }
     $name = trim($this->getInput('module_name', 'post'));
     if (empty($name)) {
         $this->showError('DESIGN:module.name.empty');
     }
     $cache = $this->getInput('cache', 'post');
     $property = $this->getInput('property', 'post');
     if ($property['limit'] > 200) {
         $this->showError('DESIGN:maxlimit.error');
     }
     $cls = sprintf('PwDesign%sDataService', ucwords($model));
     Wind::import('SRV:design.srv.model.' . $model . '.' . $cls);
     $service = new $cls();
     if (method_exists($service, 'decorateSaveProperty')) {
         $property = $service->decorateSaveProperty($property);
         if ($property instanceof PwError) {
             $this->showError($property->getError());
         }
     }
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $dm = new PwDesignModuleDm($moduleid);
     $dm->setFlag($model)->setName($name)->setProperty($property)->setCache($cache);
     if ($property['html_tpl']) {
         $dm->setModuleTpl($property['html_tpl']);
     }
     $resource = $this->_getModuleDs()->updateModule($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     Wekit::load('design.srv.PwSegmentService')->updateSegmentByPageId($module['page_id']);
     $this->_getDesignService()->clearCompile();
     Wind::import('SRV:design.srv.data.PwAutoData');
     $srv = new PwAutoData($moduleid);
     $srv->addAutoData();
     $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;
    }