protected function importStructure($structs) { Wind::import('SRV:design.dm.PwDesignStructureDm'); foreach ($structs as $k => $v) { //TODO structname 唯一性检查 $name = 'I_' . WindUtility::generateRandStr(6); $dm = new PwDesignStructureDm(); $style = unserialize($v['struct_style']); $dm->setStructTitle(unserialize($v['struct_title']))->setStructname($name)->setStructStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass']); $resource = $this->_getStructureDs()->replaceStruct($dm); if ($resource instanceof PwError) { return $resource; } $this->_structures[] = $name; $this->_oldstruct[] = $v['struct_name']; } return true; }
public function doeditAction() { $pageid = (int) $this->getInput('pageid', 'post'); $title = $this->getInput('title', 'post'); $struct = $this->bo->getStructure(); if (!$struct) { $this->showMessage("operate.fail"); } Wind::import('SRV:design.dm.PwDesignStructureDm'); $dm = new PwDesignStructureDm(); $dm->setStructTitle($title)->setStructname($this->bo->name); $resource = $this->_getStructureDs()->replaceStruct($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($pageid); $pageInfo = $pageBo->getPage(); Wind::import('SRV:design.srv.PwPortalCompile'); $compile = new PwPortalCompile($pageBo); if ($pageInfo['page_type'] == PwDesignPage::PORTAL) { $compile->replaceTitle($this->bo->name, $title); } elseif ($pageInfo['page_type'] == PwDesignPage::SYSTEM) { !$struct['segment'] && ($struct['segment'] = ''); $compile->replaceTitle($this->bo->name, $title, $struct['segment']); } $this->setOutput($title, 'data'); $this->showMessage("operate.success"); }
protected function compileTitle($section, $segment = '') { Wind::import('SRV:design.dm.PwDesignStructureDm'); $ds = Wekit::load('design.PwDesignStructure'); if (preg_match_all('/\\<pw-title[>|\\/>](.+)<\\/pw-title>/isU', $section, $matches)) { foreach ($matches[1] as $k => $v) { $v = trim($v); $name = 'T_' . $this->getRand(6); $dm = new PwDesignStructureDm(); $dm->setStructTitle($v)->setStructName($name)->setSegment($segment); $resource = $ds->replaceStruct($dm); if ($resource instanceof PwError) { continue; } $_html = '<pw-title id="' . $name . '">\\1</pw-title>'; //$section = str_replace($matches[0][$k], $_html, $section); $section = preg_replace('/\\<pw-title[>|\\/>](.+)<\\/pw-title>/isU', $_html, $section, 1); } $this->isCompile = true; } return $section; }