📄 正在查看:twcms/block/kp_block_global_show.lib.php
大小:1,983 字节 · 修改:2014-01-27 02:24:16 · 行数:61
1<?php
2defined('KONG_PATH') || exit;
3
4/**
5 * 内容页模块
6 * @param string dateformat 时间格式
7 * @param int show_prev_next 显示上下翻页
8 * @return array
9 */
10function kp_block_global_show($conf) {
11 global $run, $_show;
12
13 // hook kp_block_global_show_before.php
14
15 $dateformat = empty($conf['dateformat']) ? 'Y-m-d H:i:s' : $conf['dateformat'];
16 $show_prev_next = isset($conf['show_prev_next']) && (int)$conf['show_prev_next'] ? true : false;
17
18 // 排除单页模型
19 $mid = &$run->_var['mid'];
20 if($mid == 1) return FALSE;
21
22 // 初始模型表名
23 $run->cms_content_data->table = 'cms_'.$run->_var['table'].'_data';
24
25 // 格式化
26 $run->cms_content->format($_show, $mid, $dateformat);
27
28 // 合并大数据字段
29 $id = &$_show['id'];
30 $_show['comment_url'] = $run->cms_content->comment_url($run->_var['cid'], $id);
31 $_show['views_url'] = $run->_cfg['webdir'].'index.php?u=views--cid-'.$run->_var['cid'].'-id-'.$id;
32 $data = $run->cms_content_data->read($id);
33 if($data) $_show += $data;
34
35 // 提示:文章模型没有图集
36 if(isset($_show['images'])) {
37 $_show['images'] = (array)_json_decode($_show['images']);
38 foreach($_show['images'] as &$v) {
39 $v['big'] = $run->_cfg['webdir'].$v['big'];
40 $v['thumb'] = $run->_cfg['webdir'].$v['thumb'];
41 }
42 }
43
44 // 显示上下翻页 (大数据站点建议关闭)
45 if($show_prev_next) {
46 // 上一页
47 $_show['prev'] = $run->cms_content->find_fetch(array('cid' => $run->_var['cid'], 'id'=>array('<'=> $id)), array('id'=>-1), 0 , 1);
48 $_show['prev'] = current($_show['prev']);
49 $run->cms_content->format($_show['prev'], $mid, $dateformat);
50
51 // 下一页
52 $_show['next'] = $run->cms_content->find_fetch(array('cid' => $run->_var['cid'], 'id'=>array('>'=> $id)), array('id'=>1), 0 , 1);
53 $_show['next'] = current($_show['next']);
54 $run->cms_content->format($_show['next'], $mid, $dateformat);
55 }
56
57 // hook kp_block_global_show_after.php
58
59 return $_show;
60}
61