Beispiel #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;
 }
 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');
 }
 public function setModuleBo(PwDesignModuleBo $moduleBo)
 {
     $this->_moduleBo = $moduleBo;
     $this->_viewSet = $moduleBo->getView();
 }
Beispiel #4
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");
 }
 /**
  * 为模版缓存id
  * 
  */
 public function setStdId()
 {
     self::$stdId = $this->moduleid;
 }
Beispiel #6
0
 /**
  * 用于segment中模块的转换
  * Enter description here ...
  * @param unknown_type $content <design id="D_mod_60" role="module"></design>
  */
 public function replaceModule($content = '')
 {
     if (preg_match_all('/\\<design\\s*id=\\"*D_mod_(\\d+)\\"*\\s*role=\\"*module\\"*\\s*[>|\\/>]<\\/design>/isU', $content, $matches)) {
         Wind::import('SRV:design.bo.PwDesignModuleBo');
         foreach ($matches[1] as $k => $v) {
             $this->appendModuleId($v);
             $bo = new PwDesignModuleBo($v);
             $html = $bo->getTemplate();
             $caption = $bo->getTitleHtml();
             $standard = $bo->getStandardSign();
             $view = $bo->getView();
             if (preg_match('/\\<title>/isU', $html, $m)) {
                 $html = str_replace($m[0], $caption, $html);
             } else {
                 $html = $caption . $html;
             }
             $html = $this->_compileSign($html, $bo->moduleid, $standard['sTitle'], $standard['sUrl'], $view['isblank']);
             $content = str_replace($matches[0][$k], $html, $content);
         }
     }
     return $content;
 }
 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");
 }
 private function _getModuleCss()
 {
     $css = array();
     Wind::import('SRV:design.bo.PwDesignModuleBo');
     $srv = Wekit::load("design.srv.PwDesignStyle");
     $moduleIds = explode(',', $this->_pageInfo['module_ids']);
     foreach ($moduleIds as $v) {
         if (!$v) {
             continue;
         }
         $bo = new PwDesignModuleBo($v);
         $dom = $this->_module_pre . $v;
         $srv->setDom($dom);
         $srv->setStyle($bo->getStyle());
         list($domId, $_css) = $srv->getCss();
         $css[$domId] = $_css;
         list($domId, $_css) = $srv->getLink($bo->getStyle());
         $css[$domId] = $_css;
     }
     return $css;
 }
 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;
 }