public function doeditAction() { $tpl = $this->getInput('tpl', 'post'); $compid = (int) $this->getInput('compid', 'post'); $tpl = $this->_getDesignService()->filterTemplate($tpl); if (!$this->_getDesignService()->checkTemplate($tpl)) { $this->showError("DESIGN:template.error"); } $property = $this->bo->getProperty(); $limit = $this->compileFor($tpl); $property['limit'] = $limit ? $limit : $property['limit']; Wind::import('SRV:design.dm.PwDesignModuleDm'); $dm = new PwDesignModuleDm($this->bo->moduleid); $dm->setModuleTpl($tpl)->setCompid($compid)->setProperty($property); $resource = $this->_getModuleDs()->updateModule($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } $module = $this->bo->getModule(); Wekit::load('design.srv.PwSegmentService')->updateSegmentByPageId($module['page_id']); Wind::import('SRV:design.srv.data.PwAutoData'); $srv = new PwAutoData($this->bo->moduleid); $srv->addAutoData(); $this->_getDesignService()->clearCompile(); if ($module['module_type'] == PwDesignModule::TYPE_SCRIPT) { $this->showMessage("operate.success", "design/module/run?type=api", true); } else { $this->showMessage("operate.success"); } }
protected function restoreModule($pageid, $issnap = 0) { Wind::import('SRV:design.dm.PwDesignModuleDm'); $bakDs = $this->_getBakDs(); $conpDs = $this->_getComponentDs(); $module = $bakDs->getBak(PwDesignBak::MODULE, $pageid, $issnap); if (!is_array($module['bak_info'])) { return false; } $ds = $this->_getModuleDs(); Wind::import('SRV:design.bo.PwDesignPageBo'); $bo = new PwDesignPageBo($pageid); Wind::import('SRV:design.srv.PwPortalCompile'); $srv = new PwPortalCompile($bo); foreach ($module['bak_info'] as $k => $v) { $dm = new PwDesignModuleDm($k); $dm->setFlag($v['model_flag'])->setName($v['module_name'])->setCompid($v['module_compid'])->setProperty(unserialize($v['module_property']))->setCache(unserialize($v['module_cache']))->setTitle(unserialize($v['module_title']))->setModuleTpl($v['module_tpl'])->setIsused($v['isused']); $style = unserialize($v['module_style']); $dm->setStyle($style['font'], $style['link'], $style['border'], $style['margin'], $style['padding'], $style['background'], $style['styleclass']); $ds->updateModule($dm); } $pageInfo = $bo->getPage(); if ($pageInfo['page_type'] == PwDesignPage::PORTAL) { $srv->restoreList($module['bak_info'], 'index'); } return true; }
public function updateModule(PwDesignModuleDm $dm) { $resource = $dm->beforeUpdate(); if ($resource instanceof PwError) { return $resource; } return $this->_getDao()->updateModule($dm->moduleid, $dm->getData()); }
public function doeditAction() { $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.PwDesignModuleDm'); $dm = new PwDesignModuleDm($this->bo->moduleid); $dm->setStyle($font, $link, $border, $margin, $padding, $background, $styleclass); $resource = $this->_getModuleDs()->updateModule($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } $display = Wekit::load('design.srv.display.PwDesignDisplay'); $styleSrv = $this->_getStyleService(); $styleSrv->setDom($display->bindDataKey($this->bo->moduleid)); $style = $dm->getStyle(); //$style = array('font'=>$font, 'link'=>$link, 'border'=>$border, 'margin'=>$margin, 'padding'=>$padding, 'background'=>$background, 'styleclass'=>$styleclass); $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 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; }
public function doeditAction() { $tpl = $this->getInput('tpl', 'post'); $compid = (int) $this->getInput('compid', 'post'); $tpl = $this->_getDesignService()->filterTemplate($tpl); if (!$this->_getDesignService()->checkTemplate($tpl)) { $this->showError("DESIGN:template.error"); } $property = $this->bo->getProperty(); $limit = $this->compileFor($tpl); $property['limit'] = $limit ? $limit : $property['limit']; Wind::import('SRV:design.dm.PwDesignModuleDm'); $dm = new PwDesignModuleDm($this->bo->moduleid); $dm->setModuleTpl($tpl)->setCompid($compid)->setProperty($property); $resource = $this->_getModuleDs()->updateModule($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } //更新模版 $module = $this->bo->getModule(); if ($module['module_type'] == PwDesignModule::TYPE_IMPORT) { Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($this->pageid); $pageInfo = $pageBo->getPage(); Wind::import('SRV:design.srv.PwPortalCompile'); $compile = new PwPortalCompile($pageBo); if ($pageInfo['page_type'] == PwDesignPage::PORTAL) { $compile->replaceList($this->bo->moduleid, $tpl); } elseif ($pageInfo['page_type'] == PwDesignPage::SYSTEM) { !$module['segment'] && ($module['segment'] = ''); $compile->replaceList($this->bo->moduleid, $tpl, $module['segment']); } } //更机数据 Wind::import('SRV:design.srv.data.PwAutoData'); $srv = new PwAutoData($this->bo->moduleid); $srv->addAutoData(); $this->showMessage("operate.success"); }
/** * 对模块进行删除 * PS:不是真正的删除,记录为isused = 0状态 */ public function deleteAction() { $moduleid = (int) $this->getInput('moduleid', 'post'); $module = $this->_getModuleDs()->getModule($moduleid); if (!$module || $module['page_id'] < 1) { $this->showError('operate.fail'); } Wekit::load('design.PwDesignPermissions'); $permissions = $this->_getPermissionsService()->getPermissionsForModule($this->loginUser->uid, $moduleid); if ($permissions < PwDesignPermissions::IS_DESIGN) { $this->showError("DESIGN:permissions.fail"); } Wind::import('SRV:design.bo.PwDesignPageBo'); $pageBo = new PwDesignPageBo($module['page_id']); if ($pageBo->getLock()) { $this->showError('DESIGN:page.edit.other.user'); } Wind::import('SRV:design.dm.PwDesignModuleDm'); $dm = new PwDesignModuleDm($moduleid); $dm->setIsused(0); $resource = $this->_getModuleDs()->updateModule($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } //if (!$this->_getModuleDs()->deleteModule($moduleid)) $this->showMessage("operate.fail"); $this->_getDataDs()->deleteByModuleId($moduleid); Wekit::load('design.PwDesignPush')->deleteByModuleId($moduleid); //删除导入数据的模版内容 $dir = Wind::getRealDir('THEMES:portal.local.'); $path = $dir . $pageBo->getTplPath() . '/template/'; $files = WindFolder::read($path, WindFolder::READ_FILE); foreach ($files as $file) { $filePath = $path . $file; $content = WindFile::read($filePath); if (!$content) { continue; } $tmp = preg_replace('/\\<pw-list\\s*id=\\"' . $moduleid . '\\"\\s*>(.+)<\\/pw-list>/isU', '', $content); if ($tmp != $content) { WindFile::write($filePath, $tmp); } } $this->showMessage("operate.success"); }
public function doeditAction() { $array = array(); $html = ''; $title = $this->getInput('title', 'post'); $link = $this->getInput('link', 'post'); $image = $this->getInput('image', 'post'); $float = $this->getInput('float', 'post'); $margin = $this->getInput('margin', 'post'); //$position = $this->getInput('position','post'); //$pixels = $this->getInput('pixels','post'); $fontsize = $this->getInput('fontsize', 'post'); $fontcolor = $this->getInput('fontcolor', 'post'); $fontbold = $this->getInput('fontbold', 'post'); $fontunderline = $this->getInput('fontunderline', 'post'); $fontitalic = $this->getInput('fontitalic', 'post'); $bgimage = $this->getInput('bgimage', 'post'); $bgcolor = $this->getInput('bgcolor', 'post'); $bgposition = $this->getInput('bgposition', 'post'); $styleSrv = $this->_getStyleService(); $background = array(); $bgimage && ($background['image'] = $bgimage); $bgcolor && ($background['color'] = $bgcolor); $bgposition && ($background['position'] = $bgposition); //foreach ($pixels AS &$v) $v = (int)$v ? (int)$v: ''; foreach ($fontsize as &$v) { $v = (int) $v ? (int) $v : ''; } foreach ($title as $k => $value) { $_tmp = array('title' => $title[$k], 'link' => $link[$k], 'image' => $image[$k], 'float' => $float[$k], 'margin' => $margin[$k], 'fontsize' => $fontsize[$k], 'fontcolor' => $fontcolor[$k], 'fontbold' => $fontbold[$k], 'fontunderline' => $fontunderline[$k], 'fontitalic' => $fontitalic[$k]); $style = $this->_buildTitleStyle($_tmp); $styleSrv->setStyle($style); list($dom, $jstyle) = $styleSrv->getCss($style); $jtitle = $image[$k] ? '<img src="' . $_tmp['image'] . '" title="' . WindSecurity::escapeHTML($_tmp['title']) . '">' : WindSecurity::escapeHTML($_tmp['title']); if ($jtitle) { $html .= '<span '; $html .= $jstyle ? 'style="' . $jstyle . '"' : ''; $html .= '>'; $html .= $_tmp['link'] ? '<a href="' . $_tmp['link'] . '">' : ''; $html .= $jtitle; $html .= $_tmp['link'] ? '</a>' : ''; $html .= '</span>'; $array['titles'][] = $_tmp; } } if ($background) { $array['background'] = $background; $bg = array('background' => $background); $styleSrv->setStyle($bg); list($dom, $data['background']) = $styleSrv->getCss(); } $bgStyle = $data['background'] ? ' style="' . $data['background'] . '"' : ''; if ($html) { $html = '<h2 class="cc design_tmode_h2"' . $bgStyle . '>' . $html . '</h2>'; } Wind::import('SRV:design.dm.PwDesignModuleDm'); $dm = new PwDesignModuleDm($this->bo->moduleid); $dm->setTitle($array); $resource = $this->_getModuleDs()->updateModule($dm); if ($resource instanceof PwError) { $this->showError($resource->getError()); } $this->setOutput($html, 'html'); $this->showMessage("operate.success"); }
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"); }
public function tagModule() { $ds = $this->_getPageDs(); Wind::import('SRV:design.dm.PwDesignPageDm'); $dm = new PwDesignPageDm(); $dm->setType(PwDesignPage::SYSTEM)->setName('话题')->setRouter('tag/index/run')->setSegments(array('huatidemo')); $pageid = $ds->addPage($dm); if ($pageid instanceof PwError) { return false; } Wind::import('SRV:design.srv.vo.PwDesignComponentSo'); $vo = new PwDesignComponentSo(); $vo->setCompname('话题封面 [ 间隔 ]'); $comp = Wekit::load('design.PwDesignComponent')->searchComponent($vo); if (!$comp) { return false; } $comp = array_shift($comp); $tpl = $comp['comp_tpl']; $property = array("islogo" => 1, "order" => 5, "limit" => 18, "timefmt" => "m-d"); $cache = array('expired' => 15, 'start_hour' => 0, 'start_minute' => 0, 'end_hour' => 0, 'end_minute' => 0); Wind::import('SRV:design.dm.PwDesignModuleDm'); $moduleDm = new PwDesignModuleDm(); $moduleDm->setFlag('tag')->setPageId($pageid)->setName('演示:热门话题')->setModuleTpl($tpl)->setProperty($property)->setCache($cache)->setCompid($comp['comp_id'])->setIsused(1); $moduleid = Wekit::load('design.PwDesignModule')->addModule($moduleDm); if ($moduleid instanceof PwError) { return false; } $dm = new PwDesignPageDm($pageid); $dm->setModuleIds(array($moduleid)); $ds->updatePage($dm); $rand = WindUtility::generateRandStr(8); $tpl = <<<TPL <div id="{$rand}" class="design_layout_style J_mod_layout box_no" role="structure_{$rand}" data-lcm="100">\t\t\t <h2 class="design_layout_hd cc J_layout_hd" role="titlebar"></h2>\t\t\t <div id="J_mod_{$moduleid}" class="design_layout_ct mod_box J_mod_box" data-id="{$moduleid}"> <design id="D_mod_{$moduleid}" role="module"> </design> </div> </div> TPL; Wekit::load('design.PwDesignSegment')->replaceSegment('huatidemo', $pageid, $tpl); Wind::import('SRV:design.srv.data.PwAutoData'); $srv = new PwAutoData($moduleid); $srv->addAutoData(); return true; }
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; }