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");
 }
Beispiel #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");
 }
 protected function decompileTpl($section)
 {
     Wind::import("SRV:design.bo.PwDesignModuleBo");
     if (preg_match_all('/\\<design\\s*id=\\"*D_mod_(\\d+)\\"*\\s*role=\\"*module\\"*\\s*[>|\\/>]<\\/design>/isU', $section, $matches)) {
         foreach ($matches[1] as $k => $v) {
             $bo = new PwDesignModuleBo($v);
             $module = $bo->getModule();
             $property = $bo->getView();
             $_html = '<pw-list id="' . $k . '">';
             $_html .= $bo->getTemplate();
             $_html .= '</pw-list>';
             $section = str_replace($matches[0][$k], $_html, $section);
             $this->_moduleConf[$k] = array('itemid' => $k, 'name' => $module['module_name'], 'model' => $bo->getModel(), 'id' => $v, 'titlenum' => strval($property['titlenum']), 'desnum' => strval($property['desnum']), 'timefmt' => $property['timefmt'], 'limit' => strval($property['limit']));
         }
     }
     return $section;
 }