public function replaceStruct(PwDesignStructureDm $dm)
 {
     $resource = $dm->beforeAdd();
     if ($resource instanceof PwError) {
         return $resource;
     }
     return $this->_getDao()->replace($dm->getData());
 }
 protected function restoreStructure($pageid, $issnap = 0)
 {
     $data = $this->_getBakDs()->getBak(PwDesignBak::STRUCTURE, $pageid, $issnap);
     if (!is_array($data['bak_info'])) {
         return false;
     }
     Wind::import('SRV:design.dm.PwDesignStructureDm');
     $ds = $this->_getStructureDs();
     foreach ($data['bak_info'] as $k => $v) {
         $style = unserialize($v['struct_style']);
         $dm = new PwDesignStructureDm($k);
         $dm->setStructName($k)->setStructTitle(unserialize($v['struct_title']))->setStructStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass']);
         $ds->replaceStruct($dm);
     }
     return true;
 }
 public function doeditstyleAction()
 {
     $styleclass = $this->getInput('styleclass', 'post');
     $font = $this->getInput('font', 'post');
     $link = $this->getInput('link', 'post');
     $border = $this->getInput('border', 'post');
     $margin = $this->getInput('margin', 'post');
     $padding = $this->getInput('padding', 'post');
     $background = $this->getInput('background', 'post');
     if ($border['isdiffer']) {
         unset($border['linewidth']);
         unset($border['style']);
         unset($border['color']);
     } else {
         unset($border['top']);
         unset($border['left']);
         unset($border['right']);
         unset($border['bottom']);
     }
     if ($margin['isdiffer']) {
         unset($margin['both']);
     } else {
         unset($margin['top']);
         unset($margin['right']);
         unset($margin['left']);
         unset($margin['bottom']);
     }
     if ($padding['isdiffer']) {
         unset($padding['both']);
     } else {
         unset($padding['top']);
         unset($padding['right']);
         unset($padding['left']);
         unset($padding['bottom']);
     }
     Wind::import('SRV:design.dm.PwDesignStructureDm');
     $dm = new PwDesignStructureDm();
     $dm->setStructStyle($font, $link, $border, $margin, $padding, $background, $styleclass)->setStructName($this->bo->name)->setStructTitle($this->bo->getTitle());
     $resource = $this->_getStructureDs()->replaceStruct($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     $style = $dm->getStyle();
     //$style = array('font'=>$font, 'link'=>$link, 'border'=>$border, 'margin'=>$margin, 'padding'=>$padding, 'background'=>$background, 'styleclass'=>$styleclass);
     $styleSrv = $this->_getStyleService();
     $styleSrv->setDom($this->bo->name);
     $styleSrv->setStyle($style);
     //$this->differStyle($style)
     $_style['styleDomId'] = $styleSrv->getCss($style);
     $_style['styleDomIdLink'] = $styleSrv->getLink($style);
     $_style['styleDomClass'] = $styleclass;
     $this->setOutput($_style, 'data');
     $this->showMessage("operate.success");
 }
 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;
 }
Exemple #5
0
 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;
 }