function printNewsHTML($num)
 {
     if (!$_REQUEST['words']) {
         return;
     }
     global $_zp_current_zenpage_news, $_zp_current_search;
     if (!defined('CROP_NEWS')) {
         define('CROP_NEWS', TRUE);
     }
     save_context();
     add_context(ZP_ZENPAGE_NEWS_ARTICLE);
     $u = 0;
     processExpired('zenpage_news');
     $articles = $_zp_current_search->getSearchNews();
     if (count($articles) == 0) {
         return;
     }
     $articles = $this->sortArticles($articles, 'id');
     echo "<div id='snr'>";
     echo "<div>Also found " . count($articles) . " news";
     if (count($articles) > 3) {
         echo " - showing the last 3</div>";
     } else {
         echo "</div>";
     }
     echo "</div>";
     $len = count($articles);
     for ($u = $len - 1; $u >= 0 && $u > $len - 4; $u--) {
         $news = $articles[$u];
         $_zp_current_zenpage_news = new ZenpageNews($news['titlelink']);
         Utils::render("tiles/news/template.php");
     }
     restore_context();
 }
/**
 * Gets news articles and images of a gallery to show them together on the news section
 *
 * NOTE: This function does not exclude articles that are password protected via a category
 *
 * @param int $articles_per_page The number of articles to get
 * @param string $mode 	"latestimages-thumbnail"
 *											"latestimages-thumbnail-customcrop"
 *											"latestimages-sizedimage"
 *											"latestalbums-thumbnail"
 *		 									"latestalbums-thumbnail-customcrop"
 *		 									"latestalbums-sizedimage"
 *		 									"latestimagesbyalbum-thumbnail"
 *		 									"latestimagesbyalbum-thumbnail-customcrop"
 *		 									"latestimagesbyalbum-sizedimage"
 *		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
 *	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
 *
 * @param string $published "published" for published articles,
 * 													"unpublished" for un-published articles,
 * 													"all" for all articles
 * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
 * @param bool $sticky set to true to place "sticky" articles at the front of the list.
 * @return array
 */
function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = '', $sticky = true)
{
    deprecated_function_notify(gettext('Use the Zenpage class method instead.'));
    global $_zp_gallery, $_zp_flash_player;
    processExpired('news');
    if (is_null($published)) {
        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
            $published = "all";
        } else {
            $published = "published";
        }
    }
    if (empty($mode)) {
        $mode = getOption("zenpage_combinews_mode");
    }
    if ($published == "published") {
        $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
        $imagesshow = " AND images.show = 1 ";
    } else {
        $show = "";
        $imagesshow = "";
    }
    $passwordcheck = "";
    if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
        $albumWhere = "";
        $passwordcheck = "";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND albums.id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "AND albums.show=1" . $passwordcheck;
    }
    $limit = getLimitAndOffset($articles_per_page);
    if (empty($sortorder)) {
        $combinews_sortorder = getOption("zenpage_combinews_sortorder");
    } else {
        $combinews_sortorder = $sortorder;
    }
    $stickyorder = '';
    if ($sticky) {
        $stickyorder = 'sticky DESC,';
    }
    $type3 = query("SET @type3:='0'");
    switch ($mode) {
        case "latestimages-thumbnail":
        case "latestimages-thumbnail-customcrop":
        case "latestimages-sizedimage":
            $sortorder = "images." . $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='images'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case 'mtime':
                    $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestalbums-thumbnail":
        case "latestalbums-thumbnail-customcrop":
        case "latestalbums-sizedimage":
            $sortorder = $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
                case 'mtime':
                    $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestimagesbyalbum-thumbnail":
        case "latestimagesbyalbum-thumbnail-customcrop":
        case "latestimagesbyalbum-sizedimage":
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime") {
                $combinews_sortorder = "date";
            }
            $combinews_sortorder = "date";
            $sortorder = "images." . $combinews_sortorder;
            switch ($combinews_sortorder) {
                case "date":
                    $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`date`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case "mtime":
                    $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`mtime`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            //echo "<pre>"; print_r($result); echo "</pre>";
            //$result = "";
            break;
        case "latestupdatedalbums-thumbnail":
        case "latestupdatedalbums-thumbnail-customcrop":
        case "latestupdatedalbums-sizedimage":
            $latest = getNewsArticles($articles_per_page, '', NULL, true);
            $counter = '';
            foreach ($latest as $news) {
                $article = new ZenpageNews($news['titlelink']);
                if ($article->checkAccess($hint, $show)) {
                    $counter++;
                    $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                }
            }
            $albums = getAlbumStatistic($articles_per_page, "latestupdated");
            $latestalbums = array();
            $counter = "";
            foreach ($albums as $album) {
                $counter++;
                $tempalbum = new Album($_zp_gallery, $album['folder']);
                $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                $timestamp = $tempalbum->get('mtime');
                if ($timestamp == 0) {
                    $albumdate = $tempalbum->getDateTime();
                } else {
                    $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                }
                $latestalbums[$counter] = array("albumname" => $tempalbum->getFolder(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
            }
            //$latestalbums = array_merge($latestalbums, $item);
            $latest = array_merge($latestnews, $latestalbums);
            $result = sortMultiArray($latest, "date", true);
            if (count($result) > $articles_per_page) {
                $result = array_slice($result, 0, 10);
            }
            break;
    }
    //$result = "";
    return $result;
}