/**
 * Prints the latest news either only news articles or with the latest images or albums as a unordered html list
 *
 * NOTE: Latest images and albums require the image_album_statistic plugin
 *
 * @param int $number The number of news items to get
 * @param string $category Optional news articles by category (only "none" option"
 * @param bool $showdate If the date should be shown
 * @param bool $showcontent If the content should be shown
 * @param int $contentlength The lengths of the content
 * @param bool $showcat If the categories should be shown
 * @param string $readmore Text for the read more link, if empty the option value for "zenpage_readmore" is used
 * @param bool $sticky place sticky articles at the front of the list
 * @return string
 */
function printLatestNews($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true, $readmore = NULL, $sticky = true)
{
    global $_zp_gallery, $_zp_current_zenpage_news;
    //check if things are deprecated
    $args = func_get_args();
    $deprecated = array("none", "with_latest_images", "with_latest_images_date", "with_latest_images_mtime", "with_latest_images_publishdate", "with_latest_albums", "with_latest_albums_date", "with_latest_albums_mtime", "with_latest_albums_publishdate", "with_latestupdated_albums");
    if (in_array($category, $deprecated)) {
        // there must be the old options parameter!
        Zenpage_internal_deprecations::printLatestNews();
        list($number, $option, $category, $showdate, $showcontent, $contentlength, $showcat, $readmore, $sticky) = array_merge($args, array(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL));
    }
    $latest = getLatestNews($number, $category, $sticky);
    echo "\n<ul id=\"latestnews\">\n";
    $count = "";
    foreach ($latest as $item) {
        $count++;
        $category = "";
        $categories = "";
        $obj = new ZenpageNews($item['titlelink']);
        $title = html_encode($obj->getTitle());
        $link = html_encode(getNewsURL($item['titlelink']));
        $count2 = 0;
        $category = $obj->getCategories();
        foreach ($category as $cat) {
            $catobj = new ZenpageCategory($cat['titlelink']);
            $count2++;
            if ($count2 != 1) {
                $categories = $categories . ", ";
            }
            $categories = $categories . $catobj->getTitle();
        }
        $thumb = "";
        $content = $obj->getContent();
        if ($obj->getTruncation()) {
            $shorten = true;
        }
        $date = zpFormattedDate(DATE_FORMAT, strtotime($item['date']));
        echo "<li>";
        echo "<h3><a href=\"" . $link . "\" title=\"" . getBare(html_encode($title)) . "\">" . $title . "</a></h3>\n";
        if ($showdate) {
            echo "<span class=\"latestnews-date\">" . $date . "</span>\n";
        }
        if ($showcontent) {
            echo "<span class=\"latestnews-desc\">" . getContentShorten($content, $contentlength, '', $readmore, $link) . "</span>\n";
        }
        if ($showcat && !empty($categories)) {
            echo "<span class=\"latestnews-cats\">(" . html_encode($categories) . ")</span>\n";
        }
        echo "</li>\n";
        if ($count == $number) {
            break;
        }
    }
    echo "</ul>\n";
}