示例#1
0
 protected function xmlFormat($moduleId)
 {
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $bo = new PwDesignModuleBo($moduleId);
     $module = $bo->getModule();
     if ($module['module_type'] != PwDesignModule::TYPE_SCRIPT) {
         exit('fail');
     }
     $data = $bo->getData(true);
     $dom = new DOMDocument('1.0', 'utf-8');
     $root = $dom->createElement('root');
     $dom->appendChild($root);
     foreach ($data as $v) {
         $child = $dom->createElement('data');
         foreach ((array) $v as $_k => $_v) {
             $_k = $dom->createElement($_k);
             $_k->appendChild($dom->createTextNode($_v));
             $child->appendChild($_k);
             $root->appendChild($child);
         }
     }
     header('Content-type: application/xml');
     echo $dom->saveXML();
     exit;
 }
示例#2
0
 public function moduleAction()
 {
     $moduleId = (int) $this->getInput('moduleid', 'post');
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $bo = new PwDesignModuleBo($moduleId);
     $module = $bo->getModule();
     if ($module['isused']) {
         $this->setTemplate('');
     }
     $bo->setStdId();
     $key = Wekit::load('design.srv.display.PwDesignDisplay')->bindDataKey($moduleId);
     $data[$key] = $bo->getData(true, false);
     $this->setOutput($data, '__design_data');
     list($theme, ) = $this->getForward()->getWindView()->getTheme();
     if (is_array($theme)) {
         list($theme, $pack) = $theme;
     }
     if (!$theme) {
         $theme = 'default';
     }
     WindFolder::rm(Wind::getRealDir('DATA:compile.template.' . $theme . '.design.segment.'), true);
     $this->setTemplate('TPL:design.segment.module');
 }
示例#3
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");
 }
示例#4
0
 public function compileList($moduleId)
 {
     $moduleId = (int) $moduleId;
     if (!$moduleId) {
         return '';
     }
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $bo = new PwDesignModuleBo($moduleId);
     $html = $bo->getTemplate();
     $caption = $bo->getTitleHtml();
     $standard = $bo->getStandardSign();
     $module = $bo->getModule();
     $view = $bo->getView();
     if (preg_match('/\\<title>/isU', $html, $m)) {
         $html = str_replace($m[0], $caption, $html);
     } else {
         $html = $caption . $html;
     }
     //$this->appendSegment($module);
     $this->appendModuleId($moduleId);
     if ($this->isDesign && $module['module_type'] != PwDesignModule::TYPE_SCRIPT) {
         //模块进行片段化处理
         if ($html) {
             $tpl = '<div class="J_mod_box" id="J_mod_' . $moduleId . '" data-id="' . $moduleId . '">';
             $tpl .= $html;
             $tpl .= '</div>';
         }
     } else {
         $tpl = $html;
     }
     return $this->_compileSign($tpl, $bo->moduleid, $standard['sTitle'], $standard['sUrl'], $view['isblank']);
 }
 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");
 }
 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;
 }