/** * 获得指定分类下的文章总数 * * @param integer $cat_id * * @return integer */ function get_article_count($cat_id, $requirement = '') { global $db, $ecs; if ($requirement != '') { $count = $db->getOne('SELECT COUNT(*) FROM ' . $ecs->table('ecsmart_article') . ' WHERE ' . get_article_children($cat_id) . ' AND title like \'%' . $requirement . '%\' AND is_open = 1'); } else { $count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('ecsmart_article') . " WHERE " . get_article_children($cat_id) . " AND is_open = 1"); } return $count; }
function get_articleslist() { $result = get_filter(); if ($result === false) { $filter = array(); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['cat_id'] = empty($_REQUEST['cat_id']) ? 0 : intval($_REQUEST['cat_id']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.article_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ''; if (!empty($filter['keyword'])) { $where = " AND a.title LIKE '%" . mysql_like_quote($filter['keyword']) . "%'"; } if ($filter['cat_id']) { $where .= " AND a." . get_article_children($filter['cat_id']); } /* 文章总数 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('article') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac ON ac.cat_id = a.cat_id ' . 'WHERE 1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size($filter); /* 获取文章数据 */ $sql = 'SELECT a.* , ac.cat_name ' . 'FROM ' . $GLOBALS['ecs']->table('article') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac ON ac.cat_id = a.cat_id ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['date'] = local_date($GLOBALS['_CFG']['time_format'], $rows['add_time']); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
if ($res !== false) { while ($row = $db->fetchRow($res)) { $item_url = 'package.php'; $separator = strpos($item_url, '?') === false ? '?' : '&'; $about = $uri . $item_url; $title = htmlspecialchars($row['act_name']); $link = $uri . $item_url . $separator . 'from=rss'; $desc = htmlspecialchars($row['act_desc']); $subject = $_LANG['remark_package']; $date = local_date('r', $row['start_time']); $rss->addItem($about, $title, $link, $desc, $subject, $date); } $rss->outputRSS($ver); } } elseif (substr($_REQUEST['type'], 0, 11) == 'article_cat') { $sql = 'SELECT article_id, title, author, add_time' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND ' . get_article_children(substr($_REQUEST['type'], 11)) . ' ORDER BY add_time DESC LIMIT ' . $_CFG['article_page_size']; $res = $db->query($sql); if ($res !== false) { while ($row = $db->fetchRow($res)) { $item_url = build_uri('article', array('aid' => $row['article_id']), $row['title']); $separator = strpos($item_url, '?') === false ? '?' : '&'; $about = $uri . $item_url; $title = htmlspecialchars($row['title']); $link = $uri . $item_url . $separator . 'from=rss'; $desc = ''; $subject = htmlspecialchars($row['author']); $date = local_date('r', $row['add_time']); $rss->addItem($about, $title, $link, $desc, $subject, $date); } $rss->outputRSS($ver); }
/** * 获得文章分类下的文章列表 * * @access public * @param integer $cat_id * @param integer $page * @param integer $size * * @return array */ function get_cat_articles($cat_id, $page = 1, $size = 20, $requirement = '') { //取出所有非0的文章 if ($cat_id == '-1') { $cat_str = 'cat_id > 0'; } else { $cat_str = get_article_children($cat_id); } //增加搜索条件,如果有搜索内容就进行搜索 if ($requirement != '') { $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND title like \'%' . $requirement . '%\' ' . ' ORDER BY article_type DESC, article_id DESC'; } else { $sql = 'SELECT article_id, title, author, add_time, file_url, open_type' . ' FROM ' . $GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND ' . $cat_str . ' ORDER BY article_type DESC, article_id DESC'; } $res = $GLOBALS['db']->selectLimit($sql, $size, ($page - 1) * $size); $arr = array(); if ($res) { while ($row = $GLOBALS['db']->fetchRow($res)) { $article_id = $row['article_id']; $arr[$article_id]['id'] = $article_id; $arr[$article_id]['title'] = $row['title']; $arr[$article_id]['short_title'] = $GLOBALS['_CFG']['article_title_length'] > 0 ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$article_id]['author'] = empty($row['author']) || $row['author'] == '_SHOPHELP' ? $GLOBALS['_CFG']['shop_name'] : $row['author']; $arr[$article_id]['url'] = $row['open_type'] != 1 ? build_uri('article', array('aid' => $article_id), $row['title']) : trim($row['file_url']); $arr[$article_id]['add_time'] = date($GLOBALS['_CFG']['date_format'], $row['add_time']); } } return $arr; }
$link = $uri . $item_url . $separator . 'from=rss'; $desc = htmlspecialchars($row['act_desc']); $subject = $_LANG['remark_package']; $date = local_date('r', $row['start_time']); $rss->addItem($about, $title, $link, $desc, $subject, $date); } $rss->outputRSS($ver); } } elseif(substr($_REQUEST['type'], 0, 11) == 'article_cat') { $sql = 'SELECT article_id, title, author, add_time' . ' FROM ' .$GLOBALS['ecs']->table('article') . ' WHERE is_open = 1 AND ' . get_article_children(substr($_REQUEST['type'], 11)) . ' ORDER BY add_time DESC LIMIT ' . $_CFG['article_page_size']; $res = $db->query($sql); if ($res !== false) { while ($row = $db->fetchRow($res)) { $item_url = build_uri('article', array('aid' => $row['article_id']), $row['title']); $separator = (strpos($item_url, '?') === false)? '?' : '&'; $about = $uri . $item_url; $title = htmlspecialchars($row['title']); $link = $uri . $item_url . $separator . 'from=rss'; $desc = ''; $subject = htmlspecialchars($row['author']); $date = local_date('r', $row['add_time']);
/** * 获得指定分类下的文章总数 * * @param integer $cat_id * * @return integer */ function get_article_count($cat_id) { global $db, $ecs; $count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('article') . " WHERE " . get_article_children($cat_id) . " AND is_open = 1"); return $count; }
function get_articles_list($cat_id = 0, $page_size = 20, $is_important = -1, $keyword = '', $sort_by = 'a.article_id', $sort_order = 'DESC') { $filter = array(); $filter['keyword'] = $keyword; $filter['cat_id'] = $cat_id; $filter['sort_by'] = $sort_by; $filter['sort_order'] = $sort_order; $filter['page_size'] = $page_size; $where = ''; if (!empty($filter['keyword'])) { $where = " AND a.title LIKE '%" . mysql_like_quote($filter['keyword']) . "%'"; } if ($filter['cat_id']) { $where .= " AND a." . get_article_children($filter['cat_id']); } if ($is_important > -1) { $where .= " AND a.is_important=" . $is_important . " "; } /* 文章总数 */ $sql = 'SELECT COUNT(*) FROM ' . $GLOBALS['ecs']->table('article') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac ON ac.cat_id = a.cat_id ' . 'WHERE is_open=1 ' . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter = page_and_size_new($filter); /* 获取文章数据 */ $sql = 'SELECT a.* , ac.cat_name ' . 'FROM ' . $GLOBALS['ecs']->table('article') . ' AS a ' . 'LEFT JOIN ' . $GLOBALS['ecs']->table('article_cat') . ' AS ac ON ac.cat_id = a.cat_id ' . 'WHERE is_open=1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order']; $filter['keyword'] = stripslashes($filter['keyword']); $arr = array(); $res = $GLOBALS['db']->selectLimit($sql, $filter['page_size'], $filter['start']); while ($rows = $GLOBALS['db']->fetchRow($res)) { $rows['date'] = local_date('Y-m-d', $rows['add_time']); $rows['add_time'] = local_date('Y-m-d H:i:s', $rows['add_time']); $rows['alt'] = $rows['title']; $rows['short_title'] = sub_str($rows['title'], 13); $rows['middle_title'] = sub_str(${$rows}['title'], 16); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_articleslist($offset) { $result = get_filter(); if ($result === false) { $filter = array(); $filter['keyword'] = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']); if (isset($_REQUEST['is_ajax']) && $_REQUEST['is_ajax'] == 1) { $filter['keyword'] = json_str_iconv($filter['keyword']); } $filter['cat_id'] = empty($_REQUEST['cat_id']) ? 0 : intval($_REQUEST['cat_id']); $filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'a.article_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']); $where = ''; if (!empty($filter['keyword'])) { $where = " AND a.title LIKE '%" . mysql_like_quote($filter['keyword']) . "%'"; } if ($filter['cat_id']) { $where .= " AND a." . get_article_children($filter['cat_id']); } /* 文章总数 */ $sql = 'SELECT COUNT(*)as count FROM ' . $this->pre . 'touch_article AS a ' . 'LEFT JOIN ' . $this->pre . 'touch_article_cat AS ac ON ac.cat_id = a.cat_id ' . 'WHERE 1 ' . $where; $res = $this->row($sql); $filter['record_count'] = $res['count']; $filter = page_and_size($filter); /* 获取文章数据 */ $sql = 'SELECT a.* , ac.cat_name ' . 'FROM ' . $this->pre . 'touch_article AS a ' . 'LEFT JOIN ' . $this->pre . 'touch_article_cat AS ac ON ac.cat_id = a.cat_id ' . 'WHERE 1 ' . $where . ' ORDER by ' . $filter['sort_by'] . ' ' . $filter['sort_order'] . ' LIMIT ' . $offset; $filter['keyword'] = stripslashes($filter['keyword']); set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $arr = array(); $res = $this->query($sql); foreach ($res as $rows) { $rows['date'] = local_date(C('time_format'), $rows['add_time']); $arr[] = $rows; } return array('arr' => $arr, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); }
function get_cat_new_arts($cat_id, $num) { if ($cat_id == "-1") { $cat_str = "cat_id > 0"; } else { $cat_str = get_article_children($cat_id); } $sql = "SELECT a.article_id, a.title, ac.cat_name, a.add_time, a.file_url, a.open_type, ac.cat_id, ac.cat_name FROM " . $GLOBALS['ecs']->table("article") . " AS a, " . $GLOBALS['ecs']->table("article_cat") . " AS ac WHERE a.is_open = 1 and a.article_type = 0 AND a.cat_id = ac.cat_id AND ac.cat_type = 1 AND a." . $cat_str . " ORDER BY a.add_time DESC LIMIT " . $num; $res = $GLOBALS['db']->getAll($sql); $arr = array(); foreach ($res as $idx => $row) { $arr[$idx]['id'] = $row['article_id']; $arr[$idx]['title'] = $row['title']; $arr[$idx]['short_title'] = 0 < $GLOBALS['_CFG']['article_title_length'] ? sub_str($row['title'], $GLOBALS['_CFG']['article_title_length']) : $row['title']; $arr[$idx]['cat_name'] = $row['cat_name']; $arr[$idx]['add_time'] = local_date($GLOBALS['_CFG']['date_format'], $row['add_time']); $arr[$idx]['url'] = $row['open_type'] != 1 ? build_uri("article", array("aid" => $row['article_id']), $row['title']) : trim($row['file_url']); $arr[$idx]['cat_url'] = build_uri("article_cat", array("acid" => $row['cat_id']), $row['cat_name']); } return $arr; }