/** * 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"; }
/** * 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; }
} } } else { ?> <img src="<?php echo pathurlencode($imageobj->getSizedImage(440)); ?> " /> <?php } } else { echo "<div style='text-align: left; width 450px; font-size:0.8em'>"; if (isset($_GET['news'])) { $item = sanitize($_GET['news']); $obj = new ZenpageNews($item); $cats = $obj->getCategories(); $categories = gettext('Categories: '); $count = ''; if ($cats) { foreach ($cats as $cat) { $count++; $catobj = new ZenpageCategory($cat['titlelink']); if ($count != 1) { $categories .= ', '; } $categories .= $catobj->getTitle(); } } } elseif (isset($_GET['pages'])) { $item = sanitize($_GET['pages']); $obj = new ZenpagePage($item);
/** * 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 $option "none" for only news articles * "with_latest_images" for news articles with the latest images by id * "with_latest_images_date" for news articles with the latest images by date * "with_latest_images_mtime" for news articles with the latest images by mtime (upload date) * "with_latest_albums" for news articles with the latest albums by id * "with_latestupdated_albums" for news articles with the latest updated albums * @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 * @return string */ function printLatestNews($number = 5, $option = 'with_latest_images', $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true, $readmore = NULL) { global $_zp_gallery, $_zp_current_zenpage_news; //trigger_error(gettext('printLatestNews is deprecated. Use printLatestCombiNews().'), E_USER_NOTICE); $latest = getLatestNews($number, $option, $category); echo "\n<ul id=\"latestnews\">\n"; $count = ""; foreach ($latest as $item) { $count++; $category = ""; $categories = ""; switch ($item['type']) { case 'news': $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(); $date = zpFormattedDate(DATE_FORMAT, strtotime($item['date'])); $type = 'news'; break; case 'images': $obj = newImage(new Album($_zp_gallery, $item['albumname']), $item['titlelink']); $categories = $item['albumname']; $title = $obj->getTitle(); $link = html_encode($obj->getImageLink()); $content = $obj->getDesc(); if ($option == "with_latest_image_date") { $date = zpFormattedDate(DATE_FORMAT, $item['date']); } else { $date = zpFormattedDate(DATE_FORMAT, strtotime($item['date'])); } $thumb = "<a href=\"" . $link . "\" title=\"" . html_encode(strip_tags($title)) . "\"><img src=\"" . html_encode($obj->getThumb()) . "\" alt=\"" . html_encode(strip_tags($title)) . "\" /></a>\n"; $type = "image"; break; case 'albums': $obj = new Album($_zp_gallery, $item['albumname']); $title = $obj->getTitle(); $categories = ""; $link = html_encode($obj->getAlbumLink()); $thumb = "<a href=\"" . $link . "\" title=\"" . $title . "\"><img src=\"" . html_encode($obj->getAlbumThumb()) . "\" alt=\"" . strip_tags($title) . "\" /></a>\n"; $content = $obj->getDesc(); $date = zpFormattedDate(DATE_FORMAT, strtotime($item['date'])); $type = "album"; break; } echo "<li>"; if (!empty($thumb)) { echo $thumb; } echo "<h3><a href=\"" . $link . "\" title=\"" . strip_tags(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 and $type != "album" && !empty($categories)) { echo "<span class=\"latestnews-cats\">(" . html_encode($categories) . ")</span>\n"; } echo "</li>\n"; if ($count == $number) { break; } } echo "</ul>\n"; }
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"; }
$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 = '...'); } $content = '<![CDATA[' . $content . ']]>'; $type = "news";