Esempio n. 1
0
 /**
  * 文章feed
  * @param null
  * 显示数量由 feed_num决定
  */
 public function listSingle()
 {
     $PostsList = new PostsLogic();
     $post_list = $PostsList->getList(get_opinion('feed_num'), 'single', 'post_id desc', true);
     $RSS = new RSS(get_opinion('title'), '', get_opinion('description'), '');
     // 站点标题的链接
     foreach ($post_list as $list) {
         $RSS->AddItem($list['post_title'], 'http://' . $_SERVER["SERVER_NAME"] . getSingleURLByID($list['post_id']), $list['post_content'], $list['post_date']);
     }
     $RSS->Display();
 }
Esempio n. 2
0
 /**
  * @param $tag
  * @param $content
  * @usage <recentlist type="文章类型" num="数量"  order="排序" relation="是否关联"  length="字长度" li_attr='li属性' ul_attr="ul属性"></recentlist>
  * @return string
  */
 public function _recentlist($tag, $content)
 {
     $PostsLogic = new PostsLogic();
     $num = isset($tag['num']) ? (int) $tag['num'] : 5;
     $post_type = isset($tag['type']) ? $tag['type'] : 'single';
     $order = isset($tag['order']) ? $tag['order'] : 'post_date desc';
     $relation = isset($tag['relation']) ? $tag['relation'] : false;
     $li_attr = isset($tag['li_attr']) ? $tag['li_attr'] : '';
     $ul_attr = isset($tag['ul_attr']) ? $tag['ul_attr'] : '';
     $length = isset($tag['length']) ? (int) $tag['length'] : 20;
     $info['post_type'] = $post_type;
     $post_list = $PostsLogic->getList($num, $post_type, $order, $relation, $info);
     $parseStr = '<ul ' . $ul_attr . '>';
     foreach ($post_list as $value) {
         $parseStr .= '<li ' . $li_attr . '>
         <a href="' . getSingleURLByID($value['post_id']) . '" title="' . $value['post_title'] . '">
             ' . mb_substr($value['post_title'], 0, $length, "UTF-8") . ' </a></li>';
     }
     $parseStr .= '</ul>';
     if (!empty($parseStr)) {
         return $parseStr;
     }
 }
Esempio n. 3
0
/**
 * @param $post_id
 * @param $post_cat
 * @return null|string
 */
function get_previous_post($post_id, $post_cat)
{
    $where["cat_id"] = $post_cat[0]["cat_id"];
    $where["post_id"] = array('lt', $post_id);
    $next_post_id = D('Post_cat')->field('post_id')->where($where)->find();
    $post = D('Posts', 'Logic')->detail($next_post_id["post_id"], false);
    if (!$post) {
        return null;
    }
    $res = '<a href = "' . getSingleURLByID($post['post_id'], $post['post_type']) . '">' . is_top($post['post_top']) . $post['post_title'] . '</a>';
    return $res;
}
 /**
  * @param $tag
  * @param $content
  * @usage <recentlist type="文章类型" num="数量"  order="排序" relation="是否关联"  length="字长度" li_attr='li属性' ul_attr="ul属性"></recentlist>
  * @return string
  */
 public function _recentlist($tag, $content)
 {
     $num = isset($tag['num']) ? (int) $tag['num'] : 5;
     $post_type = isset($tag['type']) ? $tag['type'] : 'single';
     $order = isset($tag['order']) ? $tag['order'] : 'post_id desc';
     $relation = isset($tag['relation']) ? $tag['relation'] : false;
     $li_attr = isset($tag['li_attr']) ? $tag['li_attr'] : '';
     $ul_attr = isset($tag['ul_attr']) ? $tag['ul_attr'] : '';
     $length = isset($tag['length']) ? (int) $tag['length'] : 20;
     $info['post_type'] = $post_type;
     $post_list = D('Posts', 'Logic')->cache(true)->where($info)->order($order)->limit($num)->relation($relation)->select();
     $parseStr = '<ul ' . $ul_attr . '>';
     foreach ($post_list as $value) {
         $parseStr .= '<li ' . $li_attr . '>
         <a href="' . getSingleURLByID($value['post_id']) . '" title="' . $value['post_title'] . '">
             ' . mb_substr($value['post_title'], 0, $length, "UTF-8") . ' </a></li>';
     }
     $parseStr .= '</ul>';
     if (!empty($parseStr)) {
         return $parseStr;
     }
 }
Esempio n. 5
0
/**
 * 动态获取页面url
 * @param $ID
 * @param string $type
 */
function getPageURLByID($ID, $type = 'page')
{
    getSingleURLByID($ID, $type);
}