コード例 #1
0
    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;
    }
コード例 #2
0
 public function getPageId($router, $pageName = '', $uniqueId = 0)
 {
     $isUniqueid = (int) $uniqueId;
     $pageId = 0;
     $ds = $this->_getPageDs();
     $pageList = $ds->getPageByRouter($router);
     foreach ($pageList as $v) {
         if ($v['is_unique'] && $v['is_unique'] == $isUniqueid) {
             $pageId = $v['page_id'];
             break;
         }
         if (!$v['is_unique']) {
             $pageId = $v['page_id'];
         }
     }
     if ($pageId < 1) {
         Wind::import('SRV:design.dm.PwDesignPageDm');
         $dm = new PwDesignPageDm();
         $dm->setName($pageName)->setRouter($router)->setUnique($uniqueId)->setType(PwDesignPage::NORMAL);
         $pageName && $dm->setType(PwDesignPage::SYSTEM);
         if ($router == 'special/index/run') {
             $portal = Wekit::load('design.PwDesignPortal')->getPortal($uniqueId);
             $dm->setName($portal['title'])->setType(PwDesignPage::PORTAL)->setIsUnique($isUniqueid);
         }
         $pageId = $ds->addPage($dm);
         if ($pageId instanceof PwError) {
             return false;
         }
         //自定义页面复制默认模版
         if ($router == 'special/index/run') {
             $tplPath = 'special_' . $uniqueId;
             $srv = Wekit::load('design.srv.PwDesignService');
             $result = $srv->defaultTemplate($pageId, $tplPath);
             if ($result) {
                 Wind::import('SRV:design.dm.PwDesignPortalDm');
                 $dm = new PwDesignPortalDm($portal['id']);
                 $dm->setTemplate($tplPath);
                 Wekit::load('design.PwDesignPortal')->updatePortal($dm);
             }
         }
     }
     return $pageId;
 }