Esempio n. 1
0
 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);
 }
Esempio n. 2
0
/**
 * 多图分页处理
 */
function pic_pages($array)
{
    if (!is_array($array) || empty($array)) {
        return false;
    }
    foreach ($array as $k => $p) {
        $photo_arr[$k] = '<img src="' . $p['url'] . '"><br>' . $p['alt'];
    }
    $photo_page = @implode('[page]', $photo_arr);
    $photo_page = content_strip(wml_strip($photo_page), 0);
    return $photo_page;
}