Beispiel #1
0
function static_news($news, $symbol = 'fck_pageindex', $en = false)
{
    if (!$news) {
        return false;
    }
    global $static_dir;
    global $static_url;
    $url = "{$static_url}/news/news.php?id={$news->id}&page_type=static";
    if ($en) {
        $url .= "&lang=en";
    }
    $content = file_get_contents($url);
    $date = date('Ym', strtotime($news->created_at));
    $dir = "{$static_dir}/review/{$date}";
    if (!is_dir($dir)) {
        mkdir($dir);
    }
    $news_id = str_pad($news->id, 7, '0', STR_PAD_LEFT);
    if ($en) {
        $news_id .= "_en";
    }
    $file = $dir . "/{$news_id}.shtml";
    if (!write_to_file($file, $content, 'w')) {
        return false;
    }
    $page_count = get_fck_page_count($news->content);
    if ($page_count > 1) {
        for ($i = 2; $i <= $page_count; $i++) {
            $url = "{$static_url}/news/news.php?id={$news->id}&{$symbol}={$i}&page_type=static";
            if ($en) {
                $url .= "&lang=en";
            }
            $content = file_get_contents($url);
            $file = "{$dir}/{$news_id}_{$i}.shtml";
            if (!write_to_file($file, $content, 'w')) {
                return false;
            }
        }
    }
    //handle the english article
    if (!$en) {
        $db = get_db();
        $db->query("select * from fb_news_relationship where chinese_news_id = {$news->id}");
        if ($db->move_first()) {
            $news->find($news->id);
            return static_news($news, $symbol, true);
        }
    }
    return true;
}
Beispiel #2
0
function print_news_static_page($content, $symbol = 'fck_pageindex')
{
    $page_count = get_fck_page_count($content);
    if ($page_count <= 1) {
        return;
    }
    $page_index = intval($_REQUEST[$symbol]);
    $page_index = $page_index >= 1 ? $page_index : 1;
    $page_prev = $page_index - 1;
    $page_next = $page_index + 1;
    if ($_GET['page_type'] != 'static') {
        function static_url($index)
        {
            $url = $_SERVER['PHP_SELF'];
            $pattern = '/(.+)\\/page\\/(\\d+)/';
            if (preg_match($pattern, $url)) {
                $url = preg_replace($pattern, '$1', $url);
            }
            return $url . "/page/{$index}";
        }
    } else {
        function static_url($index)
        {
            global $news;
            return get_news_url($news, 'static', $index);
        }
    }
    $page_str = "";
    if ($page_prev <= 0) {
        $page_str .= "<span class='paginate_botton'>上页</span>";
    } else {
        $url = static_url($page_prev);
        $page_str .= "<span class='paginate_botton'><a href='{$url}'>上页</a></span>";
    }
    for ($i = 1; $i <= $page_count; $i++) {
        $url = static_url($i);
        $page_str .= "<span class='page_span";
        if ($i == $page_index) {
            $page_str .= "2";
        }
        $page_str .= "'><a href='{$url}'>{$i}</a></span>";
    }
    if ($page_next > $page_count) {
        $page_str .= "<span class='paginate_botton'>下页</span>";
    } else {
        $url = static_url($page_next);
        $page_str .= "<span class='paginate_botton'><a href='{$url}'>下页</a></span>";
    }
    echo $page_str;
}
Beispiel #3
0
function paginate_news($news)
{
    if (is_numeric($news)) {
        $table = new table_class('eb_news');
        $news = $table->find($news);
    }
    global $page_page_count;
    global $page_type;
    $_REQUEST['page_type'] && ($page_type = $_REQUEST['page_type']);
    $page_page_count = get_fck_page_count($news->content);
    if ($page_type == 'static') {
        return paginate(get_news_url($news, 'static'), null, 'page', false, 'static', 2);
    } else {
        return paginate(null, null, 'page', false, 'normal', 2);
    }
}