public function init() { $catid = intval($_GET['catid']); $id = intval($_GET['id']); if (!$catid || !$id) { showmessage(L('information_does_not_exist'), 'blank'); } $_userid = $this->_userid; $_username = $this->_username; $_groupid = $this->_groupid; $page = intval($_GET['page']); $page = max($page, 1); $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { showmessage(L('information_does_not_exist'), 'blank'); } $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $siteid = $GLOBALS['siteid'] = $CAT['siteid']; $MODEL = getcache('model', 'commons'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename']; $r = $this->db->get_one(array('id' => $id)); if (!$r || $r['status'] != 99) { showmessage(L('info_does_not_exists'), 'blank'); } $this->db->table_name = $tablename . '_data'; $r2 = $this->db->get_one(array('id' => $id)); $rs = $r2 ? array_merge($r, $r2) : $r; //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); //最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid; $template = 'demo'; //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($siteid, $catid, $title, $description, $seo_keywords); include template('content', $template); }
/** * 帐号管理 */ public function account_manage() { $userid = (int) AppframeAction::$Cache['uid']; $Member = M("Member"); $data = $Member->where(array("userid" => $userid))->find(); if (!$data) { service("Passport")->logoutLocal(); $this->error("请先登陆!", U("Index/login")); } require_once RUNTIME_PATH . 'content_output.class.php'; $modelid = AppframeAction::$Cache['User']['modelid']; $Model_Member = F("Model_Member"); $tablename = $Model_Member[$modelid]['tablename']; //相应会员模型数据 $modeldata = M(ucwords($tablename))->where(array("userid" => $userid))->find(); $content_output = new content_output($modelid); $output_data = $content_output->get($modeldata); $Model_field = F("Model_field_" . $modelid); $this->assign("output_data", $output_data); $this->assign("Model_field", $Model_field); $this->assign($data); $this->display(); }
/** * 内容页 */ public function show() { $catid = intval($_GET['catid']); $id = intval($_GET['id']); if (!$catid || !$id) { showmessage(L('information_does_not_exist'), 'blank'); } $_userid = $this->_userid; $_username = $this->_username; $_groupid = $this->_groupid; $page = isset($_GET['page']) ? max(intval($_GET['page']), 1) : 1; $CATEGORYS = S('common/category_content'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { showmessage(L('information_does_not_exist'), 'blank'); } $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $MODEL = S('common/model'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->get_prefix() . $MODEL[$modelid]['tablename']; $r = $this->db->getby_id($id); if (!$r || $r['status'] != 99) { showmessage(L('info_does_not_exists'), 'blank'); } $this->db->table_name = $tablename . '_data'; $r2 = $this->db->getby_id($id); $rs = $r2 ? array_merge($r, $r2) : $r; // 再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); // 检查文章会员组权限 if ($groupids_view && is_array($groupids_view)) { $_groupid = cookie('_groupid'); $_groupid = intval($_groupid); if (!$_groupid) { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward))); } if (!in_array($_groupid, $groupids_view)) { showmessage(L('no_priv')); } } else { // 根据栏目访问权限判断权限 $_priv_data = $this->_category_priv($catid); if ($_priv_data == '-1') { $forward = urlencode(Base_Request::get_url()); showmessage(L('login_website'), U('member/passport/login', array('forward' => $forward))); } elseif ($_priv_data == '-2') { showmessage(L('no_priv')); } } if (app_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } // 阅读收费 类型 $paytype = $rs['paytype']; $readpoint = $rs['readpoint']; $allow_visitor = 1; if ($readpoint || $this->category_setting['defaultchargepoint']) { if (!$readpoint) { $readpoint = $this->category_setting['defaultchargepoint']; $paytype = $this->category_setting['paytype']; } // 检查是否支付过 $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype); if (!$allow_visitor) { $http_referer = urlencode(Base_Request::get_url()); $allow_visitor = String::authcode($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer; } else { $allow_visitor = 1; } } // 最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = isset($arrparentid[1]) ? $arrparentid[1] : $catid; $template = $template ? $template : $CAT['setting']['show_template']; if (!$template) { $template = 'show'; } // SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); define('STYLE', $CAT['setting']['template_list']); if (isset($rs['paginationtype'])) { $paginationtype = $rs['paginationtype']; $maxcharperpage = $rs['maxcharperpage']; } $pages = $titles = ''; if ($rs['paginationtype'] == 1) { // 自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = Loader::lib('content:contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($rs['paginationtype'] != 0) { // 手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = Loader::lib('content:url'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } // 当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls); // 判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } } } $this->db->table_name = $tablename; // 上一页 $previous_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('lt', $id)))->order('id DESC')->find(); // 下一页 $next_page = $this->db->where(array('status' => 99, 'catid' => $catid, 'id' => array('gt', $id)))->find(); if (empty($previous_page)) { $previous_page = array('title' => L('first_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page') . '\');'); } include template('content', $template); }
/** * 生成内容页 * @param $file 文件地址 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 * @param $upgrade 是否是升级数据 */ public function show($file, $data = '', $array_merge = 1, $action = 'add', $upgrade = 0) { if ($upgrade) { $file = '/' . ltrim($file, WEB_PATH); } $allow_visitor = 1; $id = $data['id']; if ($array_merge) { $data = new_stripslashes($data); $data = array_merge($data['system'], $data['model']); } //通过rs获取原始值 $rs = $data; if (isset($data['paginationtype'])) { $paginationtype = $data['paginationtype']; $maxcharperpage = $data['maxcharperpage']; } else { $paginationtype = 0; } $catid = $data['catid']; $CATEGORYS = $this->categorys; $CAT = $CATEGORYS[$catid]; $CAT['setting'] = string2array($CAT['setting']); define('STYLE', $CAT['setting']['template_list']); //最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid; //$file = '/'.$file; //添加到发布点队列 //当站点为非系统站点 if ($this->siteid != 1) { $site_dir = $this->sitelist[$this->siteid]['dirname']; $file = $this->html_root . '/' . $site_dir . $file; } $this->queue->add_queue($action, $file, $this->siteid); $modelid = $CAT['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $output_data = $content_output->get($data); extract($output_data); if (module_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } $this->db = pc_base::load_model('content_model'); $this->db->set_model($modelid); //上一页 $previous_page = $this->db->get_one("`catid` = '{$catid}' AND `id`<'{$id}' AND `status`=99", '*', 'id DESC'); //下一页 $next_page = $this->db->get_one("`catid`= '{$catid}' AND `id`>'{$id}' AND `status`=99"); if (empty($previous_page)) { $previous_page = array('title' => L('first_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page', '', 'content') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page', '', 'content') . '\');'); } $title = strip_tags($title); //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $siteid = $this->siteid; $SEO = seo($siteid, $catid, $title, $description, $seo_keywords); $ishtml = 1; $template = $template ? $template : $CAT['setting']['show_template']; //分页处理 $pages = $titles = ''; if ($paginationtype == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = pc_base::load_app_class('contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($paginationtype != 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = pc_base::load_app_class('url', 'content'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $upgrade = $upgrade ? '/' . ltrim($file, WEB_PATH) : ''; $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], '', '', 'edit', $upgrade); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //生成分页 foreach ($pageurls as $page => $urls) { $pages = content_pages($pagenumber, $page, $pageurls); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } $pagefile = $urls[1]; if ($this->siteid != 1) { $pagefile = $this->html_root . '/' . $site_dir . $pagefile; } $this->queue->add_queue($action, $pagefile, $this->siteid); $pagefile = PHPCMS_PATH . $pagefile; ob_start(); include template('content', $template); $this->createhtml($pagefile); } return true; } } //分页处理结束 $file = PHPCMS_PATH . $file; ob_start(); include template('content', $template); return $this->createhtml($file); }
public function show() { $WAP = $this->wap; $WAP_SETTING = string2array($WAP['setting']); $TYPE = $this->types; $GLOBALS['siteid'] = $siteid = max($this->siteid, 1); $typeid = $type_tmp = intval($_GET['typeid']); $catid = $_GET['catid']; $id = intval($_GET['id']); if (!$catid || !$id) { exit(L('parameter_error')); } $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $page = intval($_GET['page']); $page = max($page, 1); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { exit(L('information_does_not_exist', '', 'content')); } $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $siteid = $GLOBALS['siteid'] = $CAT['siteid']; $MODEL = getcache('model', 'commons'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename']; $r = $this->db->get_one(array('id' => $id)); if (!$r || $r['status'] != 99) { showmessage(L('info_does_not_exists'), 'blank'); } $this->db->table_name = $tablename . '_data'; $r2 = $this->db->get_one(array('id' => $id)); $rs = $r2 ? array_merge($r, $r2) : $r; //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); $typeid = $type_tmp; if (strpos($content, '[/page]') !== false) { $content = preg_replace("|\\[page\\](.*)\\[/page\\]|U", '', $content); } elseif (strpos($content, '[page]') !== false) { $content = str_replace('[page]', '', $content); } //根据设置字节数对文章加入分页标记 if ($maxcharperpage < 10) { $maxcharperpage = $WAP_SETTING['c_num']; } $contentpage = pc_base::load_app_class('contentpage', 'content'); $content = $contentpage->get_data($content, $maxcharperpage); $isshow = 1; if ($pictureurls) { $pictureurl = pic_pages($pictureurls); $isshow = 0; //进行图片分页处理 $PIC_POS = strpos($pictureurl, '[page]'); if ($PIC_POS !== false) { $this->url = pc_base::load_app_class('wap_url', 'wap'); $pictureurls = array_filter(explode('[page]', $pictureurl)); $pagenumber = count($pictureurls); if (strpos($pictureurl, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $typeid); } $END_POS = strpos($pictureurl, '[/page]'); if ($END_POS !== false) { if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $pictureurl, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls, 0); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $pictureurl = $pictureurls[$page]; } else { if ($page == 1 && !empty($titles)) { $pictureurl = $title . '[/page]' . $pictureurls[$page - 1]; } else { $pictureurl = $pictureurls[$page - 1]; } } } } //进行自动分页处理 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = pc_base::load_app_class('wap_url', 'wap'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $typeid); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($_GET['remains'] == 'true') { $content = $pages = ''; for ($i = $page; $i <= $pagenumber; $i++) { $content .= $contents[$i - 1]; } } } $content = content_strip(wml_strip($content)); $template = $WAP_SETTING['show_template'] ? $WAP_SETTING['show_template'] : 'show'; include template('wap', $template); }
/** * 生成内容页 * @param $data 数据 * @param $array_merge 是否合并 */ public function show($data = '', $array_merge = 1) { if (empty($data)) { if (!empty($this->data)) { $data = $this->data; // 重置数据 $this->data = array(); } else { $this->error = '没有数据'; return false; } } //初始化一些模板分配变量 $this->assignInitialize(); //取得信息ID $id = $data['id']; //栏目ID $catid = $data['catid']; //获取当前栏目数据 $category = getCategory($catid); //扩展配置 $setting = $category['setting']; //是否生成静态 if (empty($setting['content_ishtml'])) { return false; } //模型ID $this->modelid = $category['modelid']; //检查数据是否合并 if (!$array_merge) { ContentModel::getInstance($this->modelid)->dataMerger($data); } //原始数据 $this->assign('_original', $data); //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //tag tag('html_shwo_buildhtml', $data); $content_output = new \content_output($this->modelid); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); //SEO $seo_keywords = ''; if (!empty($output_data['keywords'])) { $seo_keywords = implode(',', $output_data['keywords']); } $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords); //内容页模板 $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template']; //去除模板文件后缀 $newstempid = explode('.', $template); $template = "Show/{$newstempid[0]}"; //获取模板文件地址 $templatePath = parseTemplateFile($template); //分页处理 $pages = $titles = ''; //分配解析后的文章数据到模板 $this->assign($output_data); //seo分配到模板 $this->assign('SEO', $seo); //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] > 0) { //分页表情出现次数 $content_page_pos = strpos($output_data['content'], '[page]'); if ($content_page_pos !== false) { $contents = array_filter(explode('[page]', $output_data['content'])); $pagenumber = count($contents); for ($i = 1; $i <= $pagenumber; $i++) { //URL地址处理 $urlrules = $this->generateShowUrl($data, $i); //用于分页导航 if (!isset($pageurl['index'])) { $pageurl['index'] = $urlrules['page']['index']; $pageurl['list'] = $urlrules['page']['list']; } $pageurls[$i] = $urlrules; } $pages = ''; //生成分页 foreach ($pageurls as $page => $urls) { //$pagenumber 分页总数 $_GET[C('VAR_PAGE')] = $page; $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => $pageurl))->show(); $content = $contents[$page - 1]; //分页 $this->assign('pages', $pages); $this->assign('content', $content); $this->buildHtml($urls['path'], SITE_PATH, $templatePath); } return true; } } //对pages进行赋值null,解决由于上一篇有分页下一篇无分页的时候,会把上一篇的分页带到下一篇! $this->assign("pages", null); $this->assign("content", $output_data['content']); //当没有启用内容页分页时候(如果内容字段有启用分页,不会执行到此步骤),判断其他支持分页的标签进行分页处理 unset($GLOBALS["Total_Pages"]); $page = 1; $j = 1; //开始生成列表 do { $this->assign(C("VAR_PAGE"), $page); //生成路径 $category_url = $this->generateShowUrl($data, $page); $GLOBALS['URLRULE'] = $category_url['page']; //生成 $this->buildHtml($category_url["path"], SITE_PATH, $templatePath); $page++; $j++; $total_number = isset($_GET['total_number']) ? (int) $_GET['total_number'] : (int) $GLOBALS["Total_Pages"]; } while ($j <= $total_number); return true; }
function info_top() { $exist_posids = array(); $memberinfo = $this->memberinfo; $_username = $this->memberinfo['username']; $id = intval($_GET['id']); $catid = $_GET['catid']; $pos_data = pc_base::load_model('position_data_model'); if (!$id || !$catid) { showmessage(L('illegal_parameters'), HTTP_REFERER); } if (isset($catid) && $catid) { $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); $category = $CATEGORYS[$catid]; if ($category['type'] == 0) { $modelid = $category['modelid']; $this->model = getcache('model', 'commons'); $this->content_db = pc_base::load_model('content_model'); $this->content_db->set_model($modelid); $this->content_db->table_name = $this->content_db->db_tablepre . $this->model[$modelid]['tablename']; $r = $this->content_db->get_one(array('id' => $id, 'username' => $_username, 'sysadd' => 0)); if (!$r) { showmessage(L('illegal_operation')); } //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($r); extract($data); } } //置顶推荐位数组 $infos = getcache('info_setting', 'commons'); $toptype_posid = array('1' => $infos['top_city_posid'], '2' => $infos['top_zone_posid'], '3' => $infos['top_district_posid']); foreach ($toptype_posid as $_k => $_v) { if ($pos_data->get_one(array('id' => $id, 'catid' => $catid, 'posid' => $_v))) { $exist_posids[$_k] = 1; } } include template('member', 'info_top'); }
public function public_preview() { $catid = intval($_GET['catid']); $id = intval($_GET['id']); if (!$catid || !$id) { showmessage(L('missing_part_parameters'), 'blank'); } $page = intval($_GET['page']); $page = max($page, 1); $CATEGORYS = getcache('category_content_' . $this->get_siteid(), 'commons'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { showmessage(L('missing_part_parameters'), 'blank'); } define('HTML', true); $CAT = $CATEGORYS[$catid]; $siteid = $CAT['siteid']; $MODEL = getcache('model', 'commons'); $modelid = $CAT['modelid']; $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename']; $r = $this->db->get_one(array('id' => $id)); if (!$r) { showmessage(L('information_does_not_exist')); } $this->db->table_name = $this->db->table_name . '_data'; $r2 = $this->db->get_one(array('id' => $id)); $rs = $r2 ? array_merge($r, $r2) : $r; //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); $CAT['setting'] = string2array($CAT['setting']); $template = $template ? $template : $CAT['setting']['show_template']; $allow_visitor = 1; //SEO $SEO = seo($siteid, $catid, $title, $description); define('STYLE', $CAT['setting']['template_list']); if (isset($rs['paginationtype'])) { $paginationtype = $rs['paginationtype']; $maxcharperpage = $rs['maxcharperpage']; } $pages = $titles = ''; if ($rs['paginationtype'] == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = pc_base::load_app_class('contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($rs['paginationtype'] != 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = pc_base::load_app_class('url', 'content'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } else { //当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls); } //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { $content = $contents[$page - 1]; } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } } } include template('content', $template); $pc_hash = $_SESSION['pc_hash']; $steps = intval($_GET['steps']); echo "\n\t\t<link href=\"" . CSS_PATH . "dialog_simp.css\" rel=\"stylesheet\" type=\"text/css\" />\n\t\t<script language=\"javascript\" type=\"text/javascript\" src=\"" . JS_PATH . "dialog.js\"></script>\n\t\t<script type=\"text/javascript\">art.dialog({lock:false,title:'" . L('operations_manage') . "',mouse:true, id:'content_m', content:'<span id=cloading ><a href=\\'javascript:ajax_manage(1)\\'>" . L('passed_checked') . "</a> | <a href=\\'javascript:ajax_manage(2)\\'>" . L('reject') . "</a> | <a href=\\'javascript:ajax_manage(3)\\'>" . L('delete') . "</a></span>',left:'100%',top:'100%',width:200,height:50,drag:true, fixed:true});\n\t\tfunction ajax_manage(type) {\n\t\t\tif(type==1) {\n\t\t\t\t\$.get('?m=content&c=content&a=pass&ajax_preview=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t} else if(type==2) {\n\t\t\t\t\$.get('?m=content&c=content&a=pass&ajax_preview=1&reject=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t} else if(type==3) {\n\t\t\t\t\$.get('?m=content&c=content&a=delete&ajax_preview=1&dosubmit=1&catid=" . $catid . "&steps=" . $steps . "&id=" . $id . "&pc_hash=" . $pc_hash . "');\n\t\t\t}\n\t\t\t\$('#cloading').html('<font color=red>" . L('operation_success') . "<span id=\"secondid\">2</span>" . L('after_a_few_seconds_left') . "</font>');\n\t\t\tsetInterval('set_time()', 1000);\n\t\t\tsetInterval('window.close()', 2000);\n\t\t}\n\t\tfunction set_time() {\n\t\t\t\$('#secondid').html(1);\n\t\t}\n\t\t</script>"; }
public function shows() { $catid = I('get.catid', 0, 'intval'); $id = I('get.id', 0, 'intval'); $page = intval($_GET[C("VAR_PAGE")]); $page = max($page, 1); //获取当前栏目数据 $category = getCategory($catid); if (empty($category)) { send_http_status(404); exit; } //反序列化栏目配置 $category['setting'] = $category['setting']; //检查是否禁止访问动态页 if ($category['setting']['showoffmoving']) { send_http_status(404); exit; } //模型ID $this->modelid = $category['modelid']; $this->db = ContentModel::getInstance($this->modelid); $data = $this->db->relation(true)->where(array("id" => $id, 'status' => 99))->find(); if (empty($data)) { send_http_status(404); exit; } $this->db->dataMerger($data); //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //载入字段数据处理类 if (false == require_cache(RUNTIME_PATH . 'content_output.class.php')) { D("Category")->category_cache(); D("Content_cache")->model_content_cache(); require RUNTIME_PATH . 'content_output.class.php'; } $content_output = new content_output($this->modelid); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; $output_data['title'] = strip_tags($output_data['title']); //SEO $seo_keywords = ''; if (!empty($output_data['keywords'])) { $seo_keywords = implode(',', $output_data['keywords']); } $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords); //内容页模板 $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; unset($newstempid); //分页处理 $pages = $titles = ''; //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } //按字数分割成几页处理开始 import('Contentpage', APP_PATH . C("APP_GROUP_PATH") . '/Contents/ORG'); $contentpage = new Contentpage(); $contentfy = $contentpage->get_data($output_data['content'], $maxcharperpage); //自动分页有时会造成返回空,如果返回空,就不分页了 if (!empty($contentfy)) { $output_data['content'] = $contentfy; } } //分配解析后的文章数据到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $seo); //栏目ID $this->assign("catid", $catid); //分页生成处理 //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] > 0) { $urlrules = $this->url->show($data, $page); //手动分页 $CONTENT_POS = strpos($output_data['content'], '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $output_data['content'])); $pagenumber = count($contents); $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => $urlrules['page']))->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { $content = $contents[$page - 1]; } //分页 $this->assign("pages", $pages); $this->assign("content", $content); } } else { $this->assign("content", $output_data['content']); } $this->display("Show:" . $template); }
/** * 信息查看 */ public function public_view() { $formid = (int) $this->_get("formid"); $dataid = (int) $this->_get("dataid"); if (!$formid || !$dataid) { $this->error("该信息不存在!<script>setTimeout(function(){window.top.art.dialog.list['check'].close();},1500);</script>"); } $tablename = M('Model')->where(array("modelid" => $formid))->getField("tablename"); if (!$tablename) { $this->error("该表单不存在!<script>setTimeout(function(){window.top.art.dialog.list['check'].close();},1500);</script>"); } $tablename = ucwords($tablename); $data = M($tablename)->where(array("dataid" => $dataid))->find(); if (!$data) { $this->error("该信息不存在!<script>setTimeout(function(){window.top.art.dialog.list['check'].close();},1500);</script>"); } //引入输入表单处理类 require RUNTIME_PATH . 'content_output.class.php'; $content_form = new content_output($formid); $data['modelid'] = $formid; //字段内容 $forminfos = $content_form->get($data); $fields = $content_form->fields; $this->assign("show_header", true); $this->assign("forminfos", $forminfos); $this->assign("data", $data); $this->assign("fields", $fields); $this->display("view"); }
/** * 生成内容页 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 */ public function show($data = '', $array_merge = 1, $action = 'add') { if (!$data['inputtime'] || !$data['id'] || !$data['catid']) { return false; } //初始化一些模板分配变量 $this->assignInitialize(); //取得信息ID $id = $data['id']; //栏目ID $catid = $data['catid']; //获取当前栏目数据 $category = getCategory($catid); //模型ID $this->modelid = $category['modelid']; //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //载入字段数据处理类 if (false == require_cache(RUNTIME_PATH . 'content_output.class.php')) { D("Category")->category_cache(); D("Content_cache")->model_content_cache(); require RUNTIME_PATH . 'content_output.class.php'; } $content_output = new content_output($this->modelid); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; $output_data['title'] = strip_tags($output_data['title']); //SEO $seo_keywords = ''; if (!empty($output_data['keywords'])) { $seo_keywords = implode(',', $output_data['keywords']); } $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords); //内容页模板 $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; unset($newstempid); //检测模板是否存在、不存在使用默认! $tempstatus = parseTemplateFile("Show:" . $template); if ($tempstatus == false && $template != "show") { //模板不存在,重新使用默认模板 $template = "show"; $tempstatus = parseTemplateFile("Show:" . $template); if ($tempstatus == false) { return false; } } else { if ($tempstatus == false) { return false; } } //分页处理 $pages = $titles = ''; //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } //按字数分割成几页处理开始 import('Contentpage', APP_PATH . C("APP_GROUP_PATH") . '/Contents/ORG'); $contentpage = new Contentpage(); $contentfy = $contentpage->get_data($output_data['content'], $maxcharperpage); //自动分页有时会造成返回空,如果返回空,就不分页了 if (!empty($contentfy)) { $output_data['content'] = $contentfy; } } //分配解析后的文章数据到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $seo); //栏目ID $this->assign("catid", $catid); //分页生成处理 //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] > 0) { //手动分页 $CONTENT_POS = strpos($output_data['content'], '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $output_data['content'])); $pagenumber = count($contents); for ($i = 1; $i <= $pagenumber; $i++) { //URL地址处理 $urlrules = $this->url->show($data, $i); //用于分页导航 if (!isset($pageurl['index'])) { $pageurl['index'] = $urlrules['page']['index']; $pageurl['list'] = $urlrules['page']['list']; } $pageurls[$i] = $urlrules; } $pages = ""; //生成分页 foreach ($pageurls as $page => $urls) { //$pagenumber 分页总数 $_GET[C("VAR_PAGE")] = $page; $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => $pageurl))->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { $content = $contents[$page - 1]; } //分页 $this->assign("pages", $pages); $this->assign("content", $content); $this->buildHtml($urls['path'], SITE_PATH . "/", $tempstatus); } return true; } } //对pages进行赋值null,解决由于上一篇有分页下一篇无分页的时候,会把上一篇的分页带到下一篇! $this->assign("pages", null); $this->assign("content", $output_data['content']); //当没有启用内容页分页时候(如果内容字段有启用分页,不会执行到此步骤),判断其他支持分页的标签进行分页处理 unset($GLOBALS["Total_Pages"]); $page = 1; $j = 1; //开始生成列表 do { $this->assign(C("VAR_PAGE"), $page); //生成路径 $category_url = $this->url->show($data, $page); $GLOBALS['URLRULE'] = implode("~", $category_url['page']); //生成 $this->buildHtml($category_url["path"], SITE_PATH . "/", $tempstatus); $page++; $j++; $total_number = isset($_GET['total_number']) ? (int) $_GET['total_number'] : (int) $GLOBALS["Total_Pages"]; } while ($j <= $total_number); return true; }
function get_pic_content($pics) { if (!$pics) { return ''; } $info = explode('|', $pics); $catid = intval($info[1]); $id = intval($info[0]); unset($info); $db = pc_base::load_model('content_model'); if (!$catid || !$id) { return false; } $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { return false; } $category = $CAT = $CATEGORYS[$catid]; $category_setting = string2array($category['setting']); $siteid = $CAT['siteid']; $MODEL = getcache('model', 'commons'); $modelid = $CAT['modelid']; $tablename = $db->table_name = $db->db_tablepre . $MODEL[$modelid]['tablename']; $r = $db->get_one(array('id' => $id)); if (!$r || $r['status'] != 99) { return false; } $db->table_name = $tablename . '_data'; $r2 = $db->get_one(array('id' => $id)); $rs = array_merge($r, $r2); //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); extract($data); if (empty($previous_page)) { $previous_page = array('title' => L('first_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page', '', 'content') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page', '', 'content'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page', '', 'content') . '\');'); } ob_start(); include template('special', 'api_picture'); $data = ob_get_contents(); ob_clean(); return $data; }
/** * 会员资料查看 */ public function memberinfo() { $this->assign("show_header", true); $userid = (int) $this->_get("userid"); $Member = M("Member"); //主表 $data = $Member->where(array("userid" => $userid))->find(); if (!$data) { $this->error("该会员不存在!"); } $modelid = $data['modelid']; $Model_Member = F("Model_Member"); $tablename = $Model_Member[$modelid]['tablename']; //相应会员模型数据 $modeldata = M(ucwords($tablename))->where(array("userid" => $userid))->find(); //去除敏感信息 unset($data['password']); unset($data['encrypt']); require_cache(RUNTIME_PATH . 'content_output.class.php'); $content_output = new content_output($modelid); $output_data = $content_output->get($modeldata); $Model_field = F("Model_field_" . $modelid); $this->assign("output_data", $output_data); $this->assign("Model_field", $Model_field); $this->assign($data); $this->display(); }
/** * 生成内容页 * @param $file 文件地址 * @param $data 数据 * @param $array_merge 是否合并 * @param $action 方法 */ public function show($file, $data = '', $array_merge = 1, $action = 'add') { //取得信息ID $id = $data['id']; //判断数据是否已经合并成一个数组,而不是分主表和附表 if ($array_merge) { $data = new_stripslashes($data); $data = array_merge($data['system'], $data['model']); $data['id'] = $id; } //通过rs获取原始值 $rs = $data; //栏目ID $catid = $data['catid']; //获取栏目缓存 $Category = $this->categorys; //获取当前栏目数据 $CAT = $Category[$catid]; //反序列化栏目配置 $CAT['setting'] = unserialize($CAT['setting']); //模型ID $this->modelid = $modelid = $CAT['modelid']; //获取主表名 $this->table_name = $this->Model[$this->modelid]['tablename']; //处理由于通过关联模型获取数据,会把副表字段内容归入下标为 表名_data ,重新组合 if (isset($data[ucwords($this->table_name) . "_data"])) { $data = array_merge($data, $data[ucwords($this->table_name) . "_data"]); unset($data[ucwords($this->table_name) . "_data"]); } //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //载入字段数据处理类 if (!file_exists(RUNTIME_PATH . 'content_output.class.php')) { $this->error("请更新缓存后再操作!"); } require_cache(RUNTIME_PATH . 'content_output.class.php'); $content_output = new content_output($modelid, $catid, $Category); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; extract($output_data); $this->table_name = $this->Model[$this->modelid]['tablename']; $this->db = M(ucwords($this->table_name)); //上一篇 $where = array(); $where['catid'] = $catid; $where['status'] = array("EQ", "99"); $where['id'] = array("LT", $id); $previous_page = $this->db->where($where)->order(array("id" => "DESC"))->find(); //下一篇 $where['id'] = array("GT", $id); $next_page = $this->db->where($where)->find(); if (empty($previous_page)) { $previous_page = array('title' => "第一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'第一页\');'); } if (empty($next_page)) { $next_page = array('title' => "最后一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'最后一页\');'); } $output_data['title'] = $title = strip_tags($title); //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); //模板处理开始 $template = $template ? $template : $CAT['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; unset($newstempid); //检测模板是否存在、不存在使用默认! $tempstatus = parseTemplateFile("Show:" . $template); if ($tempstatus == false) { //模板不存在,重新使用默认模板 $template = "show"; $tempstatus = parseTemplateFile("Show:" . $template); } //分页处理 $pages = $titles = ''; if ($paginationtype == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } //按字数分割成几页处理开始 import('Contentpage', APP_PATH . C("APP_GROUP_PATH") . '/Contents/ORG'); $contentpage = new Contentpage(); $contentfy = $contentpage->get_data($content, $maxcharperpage); //自动分页有时会造成返回空,如果返回空,就不分页了 if (!empty($contentfy)) { $content = $contentfy; } } //分配变量到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $SEO); //上一篇 下一篇 $this->assign("previous_page", $previous_page); $this->assign("next_page", $next_page); //栏目ID $this->assign("catid", $catid); //模板地址 $template = $tempstatus; //分页生成处理 if ($paginationtype > 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $data['inputtime'], $data['prefix'], '', 'edit'); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } $urlrules = $this->url->show($id, $page, $catid, $data['inputtime'], $data['prefix'], "", "", "URLRULE"); $urlrules = implode("~", $urlrules); define('URLRULE', $urlrules); $pages = ""; //生成分页 foreach ($pageurls as $page => $urls) { //$pagenumber 分页总数 $_GET[C("VAR_PAGE")] = $page; $pages = page($pagenumber, 1, $page, 6, C("VAR_PAGE"), '', true)->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } //分页 $this->assign("pages", $pages); $this->assign("content", $content); $pagefile = $urls[1]; //生成路径 $this->buildHtml($pagefile, SITE_PATH . "/", $template); } $this->assign("pages", ""); return true; } } $this->assign("content", $content); //分页处理结束 $filename = $file; //生成路径 $this->buildHtml($filename, SITE_PATH . "/", $template); return true; }
/** * 内容页 */ public function shows() { $catid = $this->_get("catid"); $id = $this->_get("id"); $page = intval($_GET[C("VAR_PAGE")]); $page = max($page, 1); if (!$id || !$catid) { $this->error("缺少参数!"); } $model = F("Model"); $this->categorys = F("Category"); //主表名称 $tableName = ucwords($model[$this->categorys[$catid]['modelid']]['tablename']); if (empty($tableName)) { $this->error("模型不存在!"); } $this->db = new ContentModel($tableName); $data = $this->db->relation(true)->where(array("id" => $id, 'status' => 99))->find(); if (empty($data)) { $this->error("该信息不存在!"); } $data = array_merge($data, $data[$tableName . "_data"]); unset($data[$tableName . "_data"]); if (isset($data['paginationtype'])) { $paginationtype = $data['paginationtype']; $maxcharperpage = $data['maxcharperpage']; } else { $paginationtype = 0; } $catid = $data['catid']; $CATEGORYS = $this->categorys; $CAT = $CATEGORYS[$catid]; //取得栏目配置 $CAT['setting'] = unserialize($CAT['setting']); //模型ID $this->modelid = $modelid = $CAT['modelid']; //载入字段数据处理类 require_cache(RUNTIME_PATH . 'content_output.class.php'); $content_output = new content_output($modelid, $catid, $CATEGORYS); $output_data = $content_output->get($data); $output_data['id'] = $id; extract($output_data); //上一页 $where = array(); $where['catid'] = $catid; $where['status'] = array("EQ", "99"); $where['id'] = array("LT", $id); $previous_page = $this->db->where($where)->order(array("id" => "DESC"))->find(); //下一页 $where['id'] = array("GT", $id); $next_page = $this->db->where($where)->find(); if (empty($previous_page)) { $previous_page = array('title' => "第一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'第一页\');'); } if (empty($next_page)) { $next_page = array('title' => "最后一页", 'thumb' => CONFIG_SITEURL . 'statics/images/nopic_small.gif', 'url' => 'javascript:alert(\'最后一页\');'); } $output_data['title'] = $title = strip_tags($title); //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $SEO = seo($catid, $title, $description, $seo_keywords); //模板处理开始 $template = $template ? $template : $CAT['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; //检测模板是否存在、不存在使用默认! $tempstatus = parseTemplateFile("Show:" . $template); if ($tempstatus == false) { $template = "show"; unset($tempstatus); } //分页处理 $pages = $titles = ''; if ($paginationtype == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } import('@.ORG.Contentpage'); $contentpage = new Contentpage(); $contentfy = $contentpage->get_data($content, $maxcharperpage); //自动分页有时会造成返回空,如果返回空,就不分页了 if (!empty($contentfy)) { $content = $contentfy; } } //分配变量到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $SEO); //上一篇 下一篇 $this->assign("previous_page", $previous_page); $this->assign("next_page", $next_page); //栏目ID $this->assign("catid", $catid); //模板地址 $template = $tempstatus; //文章支持分页 if ($paginationtype > 0) { $urlrules = $this->url->show($id, $page, $catid, $inputtime, $prefix, "", "", "URLRULE"); $urlrules = implode("~", $urlrules); //print_r($urlrules);exit; define('URLRULE', $urlrules); //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //当不存在 [/page]时,则使用下面分页 $pages = page($pagenumber, 1, $page, 6, C("VAR_PAGE"), '', true)->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } } } $this->assign("pages", $pages); $this->assign("content", $content); $this->display($template); }
public function show() { $catid = intval($_GET['catid']); $id = intval($_GET['id']); if (!$catid || !$id) { showmessage(L('information_does_not_exist'), 'blank'); } $page = intval($_GET['page']); $page = max($page, 1); $siteids = getcache('category_content', 'commons'); $siteid = $siteids[$catid]; $CATEGORYS = getcache('category_content_' . $siteid, 'commons'); if (!isset($CATEGORYS[$catid]) || $CATEGORYS[$catid]['type'] != 0) { showmessage(L('information_does_not_exist'), 'blank'); } $this->category = $CAT = $CATEGORYS[$catid]; $this->category_setting = $CAT['setting'] = string2array($this->category['setting']); $siteid = $GLOBALS['siteid'] = $CAT['siteid']; $MODEL = getcache('model', 'commons'); $modelid = $CAT['modelid']; $tablename = $this->db->table_name = $this->db->db_tablepre . $MODEL[$modelid]['tablename']; $r = $this->db->get_one(array('id' => $id)); if (!$r || $r['status'] != 99) { showmessage(L('info_does_not_exists'), 'blank'); } $this->db->table_name = $tablename . '_data'; $r2 = $this->db->get_one(array('id' => $id)); $rs = $r2 ? array_merge($r, $r2) : $r; //再次重新赋值,以数据库为准 $catid = $CATEGORYS[$r['catid']]['catid']; $modelid = $CATEGORYS[$catid]['modelid']; require_once CACHE_MODEL_PATH . 'content_output.class.php'; $content_output = new content_output($modelid, $catid, $CATEGORYS); $data = $content_output->get($rs); //print_r($data); extract($data); //检查文章会员组权限 if ($groupids_view && is_array($groupids_view)) { $_groupid = param::get_cookie('_groupid'); $_groupid = intval($_groupid); if (!$_groupid) { $forward = urlencode(get_url()); showmessage(L('login_website'), APP_PATH . 'index.php?m=member&c=index&a=login&forward=' . $forward); } if (!in_array($_groupid, $groupids_view)) { showmessage(L('no_priv')); } } else { //根据栏目访问权限判断权限 $_priv_data = $this->_category_priv($catid); if ($_priv_data == '-1') { $forward = urlencode(get_url()); showmessage(L('login_website'), APP_PATH . 'index.php?m=member&c=index&a=login&forward=' . $forward); } elseif ($_priv_data == '-2') { showmessage(L('no_priv')); } } if (module_exists('comment')) { $allow_comment = isset($allow_comment) ? $allow_comment : 1; } else { $allow_comment = 0; } //阅读收费 类型 $paytype = $rs['paytype']; $readpoint = $rs['readpoint']; $allow_visitor = 1; if ($readpoint || $this->category_setting['defaultchargepoint']) { if (!$readpoint) { $readpoint = $this->category_setting['defaultchargepoint']; $paytype = $this->category_setting['paytype']; } //检查是否支付过 $allow_visitor = self::_check_payment($catid . '_' . $id, $paytype); if (!$allow_visitor) { $http_referer = urlencode(get_url()); $allow_visitor = sys_auth($catid . '_' . $id . '|' . $readpoint . '|' . $paytype) . '&http_referer=' . $http_referer; } else { $allow_visitor = 1; } } //最顶级栏目ID $arrparentid = explode(',', $CAT['arrparentid']); $top_parentid = $arrparentid[1] ? $arrparentid[1] : $catid; $brother_cats = subcat($top_parentid); //顶级栏目子栏目集合,03月10日 $template = $template ? $template : $CAT['setting']['show_template']; if (!$template) { $template = 'show'; } //SEO $seo_keywords = ''; if (!empty($keywords)) { $seo_keywords = implode(',', $keywords); } $_cateinfo = M("category")->get_one("catid=" . $catid); $sys_title = M("safe_system")->get_one("id=1"); $SEO = array('site_title' => $sys_title['attr_value'], 'keyword' => empty($seo_keywords) ? $sys_title['attr_value'] : $seo_keywords, "description" => $sys_title['attr_value'], 'title' => $title . " - " . $_cateinfo['catname'] . " - "); define('STYLE', $CAT['setting']['template_list']); if (isset($rs['paginationtype'])) { $paginationtype = $rs['paginationtype']; $maxcharperpage = $rs['maxcharperpage']; } $pages = $titles = ''; if ($rs['paginationtype'] == 1) { //自动分页 if ($maxcharperpage < 10) { $maxcharperpage = 500; } $contentpage = pc_base::load_app_class('contentpage'); $content = $contentpage->get_data($content, $maxcharperpage); } if ($rs['paginationtype'] != 0) { //手动分页 $CONTENT_POS = strpos($content, '[page]'); if ($CONTENT_POS !== false) { $this->url = pc_base::load_app_class('url', 'content'); $contents = array_filter(explode('[page]', $content)); $pagenumber = count($contents); if (strpos($content, '[/page]') !== false && $CONTENT_POS < 7) { $pagenumber--; } for ($i = 1; $i <= $pagenumber; $i++) { $pageurls[$i] = $this->url->show($id, $i, $catid, $rs['inputtime']); } $END_POS = strpos($content, '[/page]'); if ($END_POS !== false) { if ($CONTENT_POS > 7) { $content = '[page]' . $title . '[/page]' . $content; } if (preg_match_all("|\\[page\\](.*)\\[/page\\]|U", $content, $m, PREG_PATTERN_ORDER)) { foreach ($m[1] as $k => $v) { $p = $k + 1; $titles[$p]['title'] = strip_tags($v); $titles[$p]['url'] = $pageurls[$p][0]; } } } //当不存在 [/page]时,则使用下面分页 $pages = content_pages($pagenumber, $page, $pageurls); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { if ($page == 1 && !empty($titles)) { $content = $title . '[/page]' . $contents[$page - 1]; } else { $content = $contents[$page - 1]; } } if ($titles) { list($title, $content) = explode('[/page]', $content); $content = trim($content); if (strpos($content, '</p>') === 0) { $content = '<p>' . $content; } if (stripos($content, '<p>') === 0) { $content = $content . '</p>'; } } } } $this->db->table_name = $tablename; //上一页 $previous_page = $this->db->get_one("`catid` = '{$catid}' AND `id`<'{$id}' AND `status`=99", '*', 'id DESC'); //下一页 $next_page = $this->db->get_one("`catid`= '{$catid}' AND `id`>'{$id}' AND `status`=99"); if (empty($previous_page)) { $previous_page = array('title' => L('first_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('first_page') . '\');'); } if (empty($next_page)) { $next_page = array('title' => L('last_page'), 'thumb' => IMG_PATH . 'nopic_small.gif', 'url' => 'javascript:alert(\'' . L('last_page') . '\');'); } include template('content', $template); }
public function shows() { $catid = I('get.catid', 0, 'intval'); $id = I('get.id', 0, 'intval'); $page = intval($_GET[C("VAR_PAGE")]); $page = max($page, 1); //获取当前栏目数据 $category = getCategory($catid); if (empty($category)) { send_http_status(404); exit; } //反序列化栏目配置 $category['setting'] = $category['setting']; //检查是否禁止访问动态页 if ($category['setting']['showoffmoving']) { send_http_status(404); exit; } //模型ID $modelid = $category['modelid']; $data = ContentModel::getInstance($modelid)->relation(true)->where(array("id" => $id, 'status' => 99))->find(); if (empty($data)) { send_http_status(404); exit; } ContentModel::getInstance($modelid)->dataMerger($data); //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } //tag tag('html_shwo_buildhtml', $data); $content_output = new \content_output($modelid); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; $output_data['title'] = strip_tags($output_data['title']); //SEO $seo_keywords = ''; if (!empty($output_data['keywords'])) { $seo_keywords = implode(',', $output_data['keywords']); } $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords); //内容页模板 $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; unset($newstempid); //分页处理 $pages = $titles = ''; //分配解析后的文章数据到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $seo); //栏目ID $this->assign("catid", $catid); //分页生成处理 //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] > 0) { $urlrules = $this->Url->show($data, $page); //手动分页 $CONTENT_POS = strpos($output_data['content'], '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $output_data['content'])); $pagenumber = count($contents); $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => $urlrules['page']))->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { $content = $contents[$page - 1]; } //分页 $this->assign("pages", $pages); $this->assign("content", $content); } } else { $this->assign("content", $output_data['content']); } $this->display("Show/{$template}"); }
public function public_preview() { $id = I('get.id', 0, 'intval'); $catid = I('get.catid', 0, 'intval'); $page = intval($_GET[C("VAR_PAGE")]); $page = max($page, 1); //获取当前栏目数据 $category = getCategory($catid); if (empty($category)) { $this->error('该栏目不存在!'); } //反序列化栏目配置 $category['setting'] = $category['setting']; //模型ID $modelid = $category['modelid']; $data = ContentModel::getInstance($modelid)->relation(true)->where(array("id" => $id))->find(); if (empty($data)) { $this->error('该信息不存在!'); } ContentModel::getInstance($modelid)->dataMerger($data); //分页方式 if (isset($data['paginationtype'])) { //分页方式 $paginationtype = $data['paginationtype']; //自动分页字符数 $maxcharperpage = (int) $data['maxcharperpage']; } else { //默认不分页 $paginationtype = 0; } $content_output = new \content_output($modelid); //获取字段类型处理以后的数据 $output_data = $content_output->get($data); $output_data['id'] = $id; $output_data['title'] = strip_tags($output_data['title']); //SEO $seo_keywords = ''; if (!empty($output_data['keywords'])) { $seo_keywords = implode(',', $output_data['keywords']); } $seo = seo($catid, $output_data['title'], $output_data['description'], $seo_keywords); //内容页模板 $template = $output_data['template'] ? $output_data['template'] : $category['setting']['show_template']; //去除模板文件后缀 $newstempid = explode(".", $template); $template = $newstempid[0]; //分页处理 $pages = $titles = ''; //分配解析后的文章数据到模板 $this->assign($output_data); //seo分配到模板 $this->assign("SEO", $seo); //栏目ID $this->assign("catid", $catid); //分页生成处理 //分页方式 0不分页 1自动分页 2手动分页 if ($data['paginationtype'] > 0) { //手动分页 $CONTENT_POS = strpos($output_data['content'], '[page]'); if ($CONTENT_POS !== false) { $contents = array_filter(explode('[page]', $output_data['content'])); $pagenumber = count($contents); $pages = page($pagenumber, 1, $page, array('isrule' => true, 'rule' => array('index' => 'index.php?m=Content&a=public_preview&catid=' . $catid . '&id=' . $id, 'list' => 'index.php?m=Content&a=public_preview&catid=' . $catid . '&id=' . $id . '&page={$page}')))->show("default"); //判断[page]出现的位置是否在第一位 if ($CONTENT_POS < 7) { $content = $contents[$page]; } else { $content = $contents[$page - 1]; } //分页 $this->assign("pages", $pages); $this->assign("content", $content); } } else { $this->assign("content", $output_data['content']); } $this->display(parseTemplateFile("Show/{$template}")); }