示例#1
0
 public function show($data, $num = 1, $current_page = 1, $file_root = '', $model_r = '')
 {
     $id = $data['id'];
     $previous_page = $data['previous_page'];
     $next_page = $data['next_page'];
     unset($data['previous_page'], $data['next_page']);
     $siteconfigs = $this->siteconfigs;
     $categorys = $this->categorys;
     $category = $this->category;
     $cid = $category['cid'];
     $urlrule = $this->category['showurl'];
     $urlrules = explode('|', $urlrule);
     $urlrule = WWW_PATH . $urlrules[0] . '|' . WWW_PATH . $urlrules[1];
     $year = date('Y', $data['addtime']);
     $variables = array('year' => $year, 'cid' => $cid, 'id' => $data['id']);
     $GLOBALS['catdir'] = $this->category['catdir'];
     $GLOBALS['categorydir'] = $this->category['parentdir'];
     if ($data['modelid']) {
         $this->form_format->modelid = $data['modelid'];
         $this->form_format->fields = get_cache('field_' . $data['modelid'], 'model');
     }
     $format_data = $this->form_format->execute($data);
     foreach ($format_data as $_key => $_value) {
         ${$_key} = $_value['data'];
     }
     $seo_title = $title . '_' . $category['name'] . '_' . $siteconfigs['sitename'];
     $seo_keywords = !empty($keywords) ? implode(',', $keywords) : '';
     $seo_description = $remark;
     $elasticid = elasticid($cid);
     if (isset($template) && $template) {
         $_template = $template;
     } elseif ($category['show_template']) {
         $_template = $category['show_template'];
     } elseif (isset($model_r['template'])) {
         $_template = TPLID . ':' . $model_r['template'];
     } else {
         $_template = TPLID . ':show';
     }
     $styles = explode(':', $_template);
     $project_css = isset($styles[0]) ? $styles[0] : 'default';
     $_template = isset($styles[1]) ? $styles[1] : 'show';
     $addtime = $data['addtime'];
     $page = 1;
     //手动分页
     $CONTENT_POS = strpos($content, '_wuzhicms_page_tag_');
     if (!empty($content) && $CONTENT_POS !== false) {
         $contents = array_filter(explode('_wuzhicms_page_tag_', $content));
         $pagetotal = count($contents);
         foreach ($contents as $cons) {
             $urls = $this->urlclass->showurl(array('id' => $id, 'cid' => $cid, 'addtime' => $addtime, 'page' => $page, 'route' => $data['route']));
             $file_root = $urls['root'];
             $content = $cons;
             $content_pages = pages($pagetotal, $page, 1, $urlrule, $variables, 10);
             $tmp_year = date('Y', $addtime);
             $tmp_month = date('m', $addtime);
             $tmp_day = date('d', $addtime);
             $content_pages = pages($pagetotal, $page, 1, $urlrule, array('categorydir' => $category['parentdir'], 'year' => $tmp_year, 'month' => $tmp_month, 'day' => $tmp_day, 'catdir' => $category['catdir'], 'cid' => $cid, 'id' => $id));
             //写入
             ob_start();
             include T('content', $_template, $project_css);
             $this->write($file_root);
             $page++;
             ob_end_clean();
         }
     } else {
         if ($file_root == '') {
             $urls = $this->urlclass->showurl(array('id' => $id, 'cid' => $cid, 'addtime' => $data['addtime'], 'page' => 1, 'route' => $data['route']));
             $file_root = $urls['root'];
         }
         ob_start();
         include T('content', $_template, $project_css);
         return $this->write($file_root);
     }
 }
示例#2
0
 /**
  * 栏目列表
  */
 public function listing()
 {
     $cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : MSG(L('parameter_error'));
     //站点信息
     $siteconfigs = $this->siteconfigs;
     //栏目信息
     $categorys = get_cache('category', 'content');
     $category = get_cache('category_' . $cid, 'content');
     if (empty($category)) {
         MSG('栏目不存在');
     }
     //分页初始化
     $page = max(intval($GLOBALS['page']), 1);
     //分页规则
     $urlrule = '';
     if ($category['child']) {
         $_template = $category['category_template'];
     } else {
         $_template = $category['list_template'];
     }
     if (empty($_template)) {
         $_template = TPLID . ':list';
     }
     $styles = explode(':', $_template);
     $project_css = isset($styles[0]) ? $styles[0] : 'default';
     $_template = isset($styles[1]) ? $styles[1] : 'show';
     $seo_title = $category['seo_title'] ? $category['seo_title'] : $category['name'] . '_' . $siteconfigs['sitename'];
     $seo_keywords = $category['seo_keywords'];
     $seo_description = $category['seo_description'];
     $elasticid = elasticid($cid);
     $model_r = get_cache('model_content', 'model');
     $master_table = $model_r[$category['modelid']]['master_table'];
     if ($category['type'] == 1) {
         $r = $this->db->get_one($master_table, array('cid' => $cid));
         if ($r) {
             extract($r, EXTR_SKIP);
             if ($attr_table = $model_r[$category['modelid']]['attr_table']) {
                 $r = $this->db->get_one($attr_table, array('id' => $id));
                 extract($r, EXTR_SKIP);
             }
         }
     }
     $sub_categorys = sub_categorys($elasticid);
     include T('content', $_template, $project_css);
 }
示例#3
0
 /**
  * 内容预览
  */
 public function view()
 {
     load_function('content', 'content');
     $siteconfigs = get_cache('siteconfigs');
     $id = isset($GLOBALS['id']) ? intval($GLOBALS['id']) : MSG(L('parameter_error'));
     $cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : MSG(L('parameter_error'));
     $categorys = get_cache('category', 'content');
     //查询数据
     $category = get_cache('category_' . $cid, 'content');
     if (empty($category)) {
         MSG('栏目不存在');
     }
     $models = get_cache('model_content', 'model');
     $model_r = $models[$category['modelid']];
     $siteid = $category['siteid'];
     $master_table = $model_r['master_table'];
     $data = $this->db->get_one($master_table, array('id' => $id));
     if ($model_r['attr_table']) {
         $attr_table = $model_r['attr_table'];
         if ($data['modelid']) {
             $modelid = $data['modelid'];
             $attr_table = $models[$modelid]['attr_table'];
         }
         $attrdata = $this->db->get_one($attr_table, array('id' => $id));
         $data = array_merge($data, $attrdata);
     } else {
         $modelid = $model_r['modelid'];
     }
     $model_r = $models[$modelid];
     require get_cache_path('content_format', 'model');
     $form_format = new form_format($modelid);
     $data = $form_format->execute($data);
     foreach ($data as $_key => $_value) {
         ${$_key} = $_value['data'];
     }
     if ($template) {
         $_template = $template;
     } elseif ($model_r['template']) {
         $template_set = unserialize($model_r['template_set']);
         $_template = $template_set[$siteid];
     } else {
         $_template = TPLID . ':show';
     }
     $styles = explode(':', $_template);
     $project_css = isset($styles[0]) ? $styles[0] : '1';
     $_template = isset($styles[1]) ? $styles[1] : 'show';
     $elasticid = elasticid($cid);
     $seo_title = $title . '_' . $category['name'] . '_' . $siteconfigs['sitename'];
     $seo_keywords = !empty($keywords) ? implode(',', $keywords) : '';
     $seo_description = $remark;
     //上一页
     $previous_page = $this->db->get_one($master_table, "`cid` = '{$cid}' AND `id`<'{$id}' AND `status`=9", '*', 0, 'id DESC');
     //下一页
     $next_page = $this->db->get_one($master_table, "`cid`= '{$cid}' AND `id`>'{$id}' AND `status`=9", '*', 0, 'id ASC');
     include T('content', $_template, $project_css);
     include $this->template('check_foot');
 }