/** * 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 * "random" for pages and news articles * @param string $sortdirection "asc" for ascending otherwise descending (default) * @return array */ function getZenpageStatistic($number = 10, $option = "all", $mode = "popular", $sortdirection = 'desc') { global $_zp_zenpage, $_zp_current_zenpage_news, $_zp_current_zenpage_pages; $sortdir = strtolower($sortdirection) != 'asc'; $statsarticles = array(); $statscats = array(); $statspages = array(); if ($option == "all" || $option == "news") { $articles = $_zp_zenpage->getArticles($number, NULL, true, $mode, $sortdir, false); $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->getTotal_votes(), "rating" => $obj->getRating(), "content" => $obj->getContent(), "date" => $obj->getDateTime(), "type" => "News"); } $stats = $statsarticles; } if (($option == "all" || $option == "categories") && $mode != "mostrated" && $mode != "toprated") { $categories = $_zp_zenpage->getAllCategories(true, $mode, $sortdir); $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" || $option == "pages") { $pages = $_zp_zenpage->getPages(NULL, false, $number, $mode, $sortdir); $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); if ($mode == 'random') { shuffle($stats); } else { switch ($sortdir) { case 'asc': $desc = false; break; case 'desc': $desc = true; break; } $stats = sortMultiArray($stats, $mode, $desc); } } return $stats; }
/** * 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. * @param string $direction "desc" or "asc" * @return array * @deprecated since version 1.4.6 */ protected function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = NULL, $sticky = true, $sortdirection = 'desc') { global $_zp_combiNews_cache, $_zp_gallery; if (is_null($published)) { if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) { $published = "all"; } else { $published = "published"; } } if (empty($mode)) { $mode = getOption('zenpage_combinews_mode'); } if (isset($_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection])) { return $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection]; } if ($published == "published") { $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'"; $imagesshow = " AND images.show = 1 "; } else { $show = ""; $imagesshow = ""; } getAllAccessibleAlbums($_zp_gallery, $albumlist, false); if (empty($albumlist)) { $albumWhere = 'albums.`id` is NULL'; } else { $albumWhere = 'albums.`id` in (' . implode(',', $albumlist) . ')'; } if ($articles_per_page) { $offset = self::getOffset($articles_per_page); } else { $offset = 0; } if (empty($sortorder)) { $combinews_sortorder = getOption("zenpage_combinews_sortorder"); } else { $combinews_sortorder = $sortorder; } $stickyorder = ''; if ($sticky) { $stickyorder = 'sticky DESC,'; } switch (strtolower($sortdirection)) { case 'desc': default: $sortdir = 'DESC'; break; case 'asc': $sortdir = 'ASC'; break; } $type3 = query("SET @type3:='0'"); switch ($mode) { case "latestimages-thumbnail": case "latestimages-thumbnail-customcrop": case "latestimages-sizedimage": case "latestimages-sizedimage-maxspace": case "latestimages-fullimage": $albumWhere = ' AND ' . $albumWhere; $sortorder = $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 'publishdate': $imagequery = "(SELECT albums.folder, images.filename, IFNULL(images.publishdate,images.date), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")"; 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 = $this->siftResults("(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 " . $sortdir, $offset, $articles_per_page); break; case "latestalbums-thumbnail": case "latestalbums-thumbnail-customcrop": case "latestalbums-sizedimage": case "latestalbums-sizedimage-maxspace": case "latestalbums-fullimage": default: if (empty($show)) { $albumWhere = ' WHERE ' . $albumWhere; } else { $albumWhere = ' AND ' . $albumWhere; } $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 'publishdate': $albumquery = "(SELECT albums.folder, albums.title, IFNULL(albums.publishdate,albums.date), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $show . $albumWhere . ")"; break; case 'mtime': default: $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 = $this->siftResults("(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 " . $sortdir, $offset, $articles_per_page); break; case "latestimagesbyalbum-thumbnail": case "latestimagesbyalbum-thumbnail-customcrop": case "latestimagesbyalbum-sizedimage": case "latestimagesbyalbum-sizedimage-maxspace": case "latestimagesbyalbum-fullimage": $albumWhere = ' AND ' . $albumWhere; $type1 = query("SET @type1:='news'"); $type2 = query("SET @type2:='albums'"); if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime" || $combinews_sortorder != "publishdate") { $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, @type3 as sticky 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, @type3 as sticky 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 . ")"; case "publishdate": $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.publishdate,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")"; break; } $result = $this->siftResults("(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 " . $sortdir, $offset, $articles_per_page); break; case "latestupdatedalbums-thumbnail": case "latestupdatedalbums-thumbnail-customcrop": case "latestupdatedalbums-sizedimage": case "latestupdatedalbums-sizedimage-maxspace": case "latestupdatedalbums-fullimage": $latest = $this->getArticles($articles_per_page, NULL, true, 'date', $sortdirection); $counter = ''; foreach ($latest as $news) { $article = new ZenpageNews($news['titlelink']); if ($article->checkAccess()) { $counter++; $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news"); } } $albums = getAlbumStatistic($articles_per_page, "latestupdated", '', $sortdirection); $latestalbums = array(); $counter = ""; foreach ($albums as $album) { $counter++; $tempalbum = $album; $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->getFileName(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums'); } //$latestalbums = array_merge($latestalbums, $item); $latest = array_merge($latestnews, $latestalbums); $result = sortMultiArray($latest, "date", $sortdirection != 'asc'); if (count($result) > $articles_per_page) { $result = array_slice($result, 0, $articles_per_page); } break; } $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection] = $result; return $result; }
} else { echo gettext('No unpublished categories'); } ?> </fieldset> <br class="clearall" /> <?php $visible = $report == 'news'; $items = $_zp_zenpage->getArticles(0, false); $output = ''; $c = 0; foreach ($items as $key => $item) { $itemobj = new ZenpageNews($item['titlelink']); if (!$itemobj->getShow()) { $c++; $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="artcheck" />' . $itemobj->getTitle() . '</label><a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '"> (' . gettext('View') . ')</a></li>'; } } ?> <fieldset class="smallbox"> <legend><?php reveal('newsbox', $visible); echo gettext('News articles not published'); ?> </legend> <?php if ($output) { echo sprintf(ngettext('%u unpublished article', '%u unpublished articles', $c), $c); ?> <div id="newsbox"<?php if (!$visible) {
/** * Gets the feed item data in a Zenpage news feed * * @param array $item Titlelink a Zenpage article or filename of an image if a combined feed * @return array */ protected function getItemNews($item) { $categories = ''; $feeditem['enclosure'] = ''; $obj = new ZenpageNews($item['titlelink']); $title = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale); $link = $obj->getLink(); $count2 = 0; $plaincategories = $obj->getCategories(); $categories = ''; foreach ($plaincategories as $cat) { $catobj = new ZenpageCategory($cat['titlelink']); $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', '; } $categories = rtrim($categories, ', '); $desc = $obj->getContent($this->locale); $desc = str_replace('//<![CDATA[', '', $desc); $desc = str_replace('//]]>', '', $desc); $feeditem['desc'] = shortenContent($desc, getOption('externalFeed_truncate_length'), '...'); if (!empty($categories)) { $feeditem['category'] = html_encode($categories); $feeditem['title'] = $title . ' (' . $categories . ')'; } $feeditem['link'] = $link; $feeditem['media_content'] = ''; $feeditem['media_thumbnail'] = ''; $feeditem['pubdate'] = date("r", strtotime($obj->getDateTime())); return $feeditem; }
/** * 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; }
/** * Prints all available articles in Zenpage * * @return string */ function printNewsArticlesList($number) { global $_zp_zenpage, $_zp_current_zenpage_news, $host; if (isset($_GET['zenpage']) && $_GET['zenpage'] == "articles") { echo "<h3>Zenpage: <em>" . gettext('Articles') . "</em> <small>" . gettext("(Click on article title to include a link)") . "</small></h3>"; if (isset($_GET['category'])) { $cat = sanitize($_GET['category']); $catobj = new ZenpageCategory($cat); $items = $catobj->getArticles("", "all"); $newscount = count($catobj->getArticles(0, 'all')); } else { $items = $_zp_zenpage->getArticles("", "all"); $newscount = count($_zp_zenpage->getArticles(0, 'all')); } $news_per_page = $number; if (isset($_GET['page'])) { $currentpage = sanitize_numeric($_GET['page']); } else { $currentpage = 1; } $pagestotal = ceil($newscount / $news_per_page); for ($nr = 1; $nr <= $pagestotal; $nr++) { $startnews[$nr] = $nr * $news_per_page - $news_per_page; // get start image number $endnews[$nr] = $nr * $news_per_page - 1; // get end image number } $count = ''; $number = $startnews[$currentpage]; //category selector here later printTinyZenpageCategorySelector($currentpage); if ($newscount != 0) { printTinyPageNav($pagestotal, $currentpage, 'news'); echo "<ul class='zenpagearticles'>"; for ($nr = $number; $nr <= $news_per_page * $currentpage; $nr++) { if ($nr == $newscount) { break; } $newsobj = new ZenpageNews($items[$nr]['titlelink']); $count++; echo "<li>"; if ($_GET['zenpage'] == "articles") { echo "<a href=\"javascript:ZenpageDialog.insert('','news/" . $newsobj->getTitlelink() . "','','','" . $newsobj->getTitlelink() . "','" . addslashes($newsobj->getTitle()) . "','','','articles','','','','');\" title='" . html_encode(truncate_string(getBare($newsobj->getContent()), 300)) . "'>" . addslashes($newsobj->getTitle()) . unpublishedZenpageItemCheck($newsobj) . "</a> <small><em>" . $newsobj->getDatetime() . "</em></small>"; echo " <a href='zoom.php?news=" . urlencode($newsobj->getTitlelink()) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a><br />"; echo '<small><em>' . gettext('Categories:'); $cats = $newsobj->getCategories(); $count = ''; foreach ($cats as $cat) { $count++; $catobj = new ZenpageCategory($cat['titlelink']); if ($count == 1) { echo ' '; } else { echo ', '; } echo $catobj->getTitle(); } echo '</em></small>'; } echo "</li>"; if ($nr === $endnews[$currentpage]) { break; } } // for end echo "</ul>"; } } }
/** * 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; }
function listArticles($cat) { global $counter; global $_zp_current_category; $_zp_current_category = $cat; $articles = $cat->getArticles(); if (!empty($articles)) { ?> <ol class="trouble"> <?php foreach ($articles as $titlelink) { $titlelink = $titlelink['titlelink']; $article = new ZenpageNews($titlelink); $counter++; ?> <li> <h5><a name="<?php echo $titlelink; ?> "><a href="javascript:toggle('article_<?php echo $counter; ?> ');"><?php echo $article->getTitle(); ?> </a></h5> <div id="article_<?php echo $counter; ?> " style="display:none;" class="body"> <?php echo $article->getContent(); ?> </div> <?php ?> </li> <?php } ?> </ol> <?php } }
function printLatestNewsCustom($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true) { global $_zp_gallery, $_zp_current_zenpage_news; $latest = getLatestNews($number, $category); echo "\n<div class=\"latestnews-spotlight\">\n"; $count = ""; foreach ($latest as $item) { $count++; $category = ""; $categories = ""; $obj = new ZenpageNews($item['titlelink']); $title = htmlspecialchars($obj->getTitle()); $link = 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(); } $content = strip_tags($obj->getContent()); $date = zpFormattedDate(getOption('date_format'), strtotime($item['date'])); $type = 'news'; echo "<div>"; echo "<h3><a href=\"" . $link . "\" title=\"" . strip_tags(htmlspecialchars($title, ENT_QUOTES)) . "\">" . htmlspecialchars($title) . "</a></h3>\n"; echo "<div class=\"newsarticlecredit\">\n"; echo "<span class=\"latestnews-date\">" . $date . "</span>\n"; echo "<span class=\"latestnews-cats\">| Posted in " . $categories . "</span>\n"; echo "</div>\n"; echo "<p class=\"latestnews-desc\">" . html_encode(getContentShorten($content, $contentlength, '(...)', null, null)) . "</p>\n"; echo "</div>\n"; if ($count == $number) { break; } } echo "</div>\n"; }