/**
 * Gets the statistic for pages, news articles or categories as an unordered list
 *
 * @param int $number The number of news items to get
 * @param string $option "all" pages, articles  and categories
 * 											 "news" for news articles
 * 											 "categories" for news categories
 * 											 "pages" for pages
 * @param string $mode "popular" most viewed for pages, news articles and categories
 * 										 "mostrated" for news articles and pages
 * 										 "toprated" for news articles and pages
 * @return array
 */
function getZenpageStatistic($number = 10, $option = "all", $mode = "popular")
{
    global $_zp_current_zenpage_news, $_zp_current_zenpage_pages;
    $statsarticles = array();
    $statscats = array();
    $statspages = array();
    switch ($mode) {
        case "popular":
            $sortorder = "hitcounter";
            break;
        case "mostrated":
            $sortorder = "total_votes";
            break;
        case "toprated":
            $sortorder = "rating";
            break;
    }
    if ($option == "all" or $option == "news") {
        $articles = query_full_array("SELECT titlelink FROM " . prefix('news') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statsarticles = array();
        foreach ($articles as $article) {
            $counter++;
            $obj = new ZenpageNews($article['titlelink']);
            $statsarticles[$counter] = array("id" => $obj->getID(), "title" => $obj->getTitle(), "titlelink" => $article['titlelink'], "hitcounter" => $obj->getHitcounter(), "total_votes" => $obj->get('total_votes'), "rating" => $obj->get('rating'), "content" => $obj->getContent(), "date" => $obj->getDateTime(), "type" => "News");
        }
        $stats = $statsarticles;
    }
    if (($option == "all" or $option == "categories") && $mode != "mostrated" && $mode != "toprated") {
        $categories = query_full_array("SELECT id, titlelink as title, title as titlelink, hitcounter FROM " . prefix('news_categories') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statscats = array();
        foreach ($categories as $cat) {
            $counter++;
            $statscats[$counter] = array("id" => $cat['id'], "title" => html_encode(get_language_string($cat['title'])), "titlelink" => getNewsCategoryURL($cat['titlelink']), "hitcounter" => $cat['hitcounter'], "total_votes" => "", "rating" => "", "content" => '', "date" => '', "type" => "Category");
        }
        $stats = $statscats;
    }
    if ($option == "all" or $option == "pages") {
        $pages = query_full_array("SELECT titlelink FROM " . prefix('pages') . " ORDER BY {$sortorder} DESC LIMIT {$number}");
        $counter = "";
        $statspages = array();
        foreach ($pages as $page) {
            $counter++;
            $pageobj = new ZenpagePage($page['titlelink']);
            $statspages[$counter] = array("id" => $pageobj->getID(), "title" => $pageobj->getTitle(), "titlelink" => $page['titlelink'], "hitcounter" => $pageobj->getHitcounter(), "total_votes" => $pageobj->get('total_votes'), "rating" => $pageobj->get('rating'), "content" => $pageobj->getContent(), "date" => $pageobj->getDateTime(), "type" => "Page");
        }
        $stats = $statspages;
    }
    if ($option == "all") {
        $stats = array_merge($statsarticles, $statscats, $statspages);
    }
    $stats = sortMultiArray($stats, $sortorder, true);
    return $stats;
}
Exemple #2
0
        $latest = getLatestNews($items, "none");
        break;
    case "withimages":
        $latest = getLatestNews($items, "with_latest_images_date");
        break;
}
$count = "";
foreach ($latest as $item) {
    $count++;
    $category = "";
    $categories = "";
    //get the type of the news item
    switch ($item['type']) {
        case 'news':
            $obj = new ZenpageNews($item['titlelink']);
            $title = get_language_string($obj->get('title'), $locale);
            $link = getNewsURL($obj->getTitlelink());
            $count2 = 0;
            $category = $obj->getCategories();
            foreach ($category as $cat) {
                $count2++;
                if ($count2 != 1) {
                    $categories = $categories . ", ";
                }
                $categories = $categories . get_language_string($cat['titlelink'], $locale);
            }
            $thumb = "";
            $filename = "";
            if (getOption('zenpage_rss_length') != "") {
                // empty value means full content!
                $content = shortenContent(get_language_string($obj->get('content'), $locale), getOption('zenpage_rss_length'), $elipsis = '...');