Exemplo n.º 1
0
	public function doaddAction() {
		$struct = $this->getInput('struct','post');
		$pageid = $this->getInput('pageid','post');
		$model = $this->getInput('model','post');
		if (!$model || $pageid <1) $this->showError('operate.fail');
		Wekit::load('design.PwDesignPermissions');
		$permissions = $this->_getPermissionsService()->getPermissionsForPage($this->loginUser->uid, $pageid);
		if ($permissions < PwDesignPermissions::IS_DESIGN ) $this->showError("DESIGN:permissions.fail");
		Wind::import('SRV:design.bo.PwDesignModelBo');
		$bo = new PwDesignModelBo($model);
		if (!$bo->isModel()) $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();
		
		
		$ds = $this->_getModuleDs();
		Wind::import('SRV:design.dm.PwDesignModuleDm');
 		$dm = new PwDesignModuleDm();
 		$dm->setPageId($pageid)
 			->setStruct($struct)
 			->setFlag($model)
			->setName($name)
			->setCache($cache)
			->setModuleType(PwDesignModule::TYPE_DRAG)
			->setIsused(1);
		$resource = $ds->addModule($dm);
		if ($resource instanceof PwError) $this->showError($resource->getError());
		
		$dm = new PwDesignModuleDm($resource);
		if (method_exists($service, 'decorateSaveProperty')) {
			$property = $service->decorateSaveProperty($property, $resource);
			if ($property  instanceof PwError ) $this->showError($property->getError());
		}
		$dm->setProperty($property);
		if ($property['html_tpl']) $dm->setModuleTpl($property['html_tpl']);
		$r = $ds->updateModule($dm);
		if ($r instanceof PwError) $this->showError($r->getError());
		
		Wind::import('SRV:design.srv.data.PwAutoData');
		$srv = new PwAutoData($resource);
		$srv->addAutoData();
		
		$this->setOutput($resource, 'data');
		$this->showMessage("operate.success");
	}
Exemplo n.º 2
0
 protected function importModule($modules)
 {
     $ds = $this->_getModuleDs();
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     foreach ($modules as $k => $v) {
         $dm = new PwDesignModuleDm();
         if (!$v['module_name']) {
             continue;
         }
         $style = unserialize($v['module_style']);
         $dm->setPageId($this->_pageInfo['page_id'])->setFlag($v['model_flag'])->setName($v['module_name'])->setStruct($v['module_struct'])->setProperty(unserialize($v['module_property']))->setCache(unserialize($v['module_cache']))->setTitle(unserialize($v['module_title']))->setStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass'])->setIsused(1)->setModuleType($v['module_type'])->setModuleTpl($v['module_tpl']);
         $resource = $ds->addModule($dm);
         if ($resource instanceof PwError) {
             return $resource;
         }
         $this->newIds[$k] = (int) $resource;
     }
     return true;
 }
Exemplo n.º 3
0
 protected function compileList($section, $segment = '')
 {
     Wind::import('SRV:design.dm.PwDesignModuleDm');
     $ds = Wekit::load('design.PwDesignModule');
     if (preg_match_all('/\\<pw-list[>|\\/>](.+)<\\/pw-list>/isU', $section, $matches)) {
         foreach ($matches[1] as $k => $v) {
             $v = str_replace("\t", '', trim($v));
             $name = 'section_' . $this->getRand(6);
             $dm = new PwDesignModuleDm();
             $dm->setPageId($this->pageid)->setSegment($segment)->setFlag('thread')->setName($name)->setModuleTpl($v)->setModuleType(PwDesignModule::TYPE_IMPORT)->setIsused(1);
             $moduleId = $ds->addModule($dm);
             if ($moduleId instanceof PwError) {
                 continue;
             }
             $_html = '<pw-list id="' . $moduleId . '">\\1</pw-list>';
             $section = preg_replace('/\\<pw-list[>|\\/>](.+)<\\/pw-list>/isU', $_html, $section, 1);
         }
         $this->isCompile = true;
     }
     return $section;
 }