/** * Prints the x related articles based on a tag search * * @param int $number Number of items to get * @param string $type 'albums', 'images','news','pages', "all" for all combined. * @param string $specific If $type = 'albums' or 'images' name of album * @param bool $excerpt If a text excerpt (gallery items: description; Zenpage items: content) should be shown. NULL for none or number of length * @param bool $thumb For $type = 'albums' or 'images' if a thumb should be shown (default size as set on the options) */ function printRelatedItems($number = 5, $type = 'news', $specific = NULL, $excerpt = NULL, $thumb = false, $date = false) { global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_zenpage_page, $_zp_current_zenpage_news; $label = array('albums' => gettext('Albums'), 'images' => gettext('Images'), 'news' => gettext('News'), 'pages' => gettext('Pages')); $result = getRelatedItems($type, $specific); $resultcount = count($result); if ($resultcount != 0) { ?> <h3 class="relateditems"> <?php printf(gettext('Related %s'), $type); ?> </h3> <ul id="relateditems"> <?php $count = 0; foreach ($result as $item) { $count++; ?> <li class="<?php echo $item['type']; ?> "> <?php $category = ''; switch ($item['type']) { case 'albums': $obj = newAlbum($item['name']); $url = $obj->getLink(); $text = $obj->getDesc(); $category = gettext('Album'); break; case 'images': $alb = newAlbum($item['album']); $obj = newImage($alb, $item['name']); $url = $obj->getLink(); $text = $obj->getDesc(); $category = gettext('Image'); break; case 'news': $obj = new ZenpageNews($item['name']); $url = $obj->getLink(); $text = $obj->getContent(); $category = gettext('News'); break; case 'pages': $obj = new ZenpagePage($item['name']); $url = $obj->getLink(); $text = $obj->getContent(); $category = gettext('Page'); break; } ?> <?php if ($thumb) { $thumburl = false; switch ($item['type']) { case 'albums': $thumburl = $obj->getThumb(); break; case 'images': $thumburl = $obj->getThumb(); break; } if ($thumburl) { ?> <a href="<?php echo html_encode(pathurlencode($url)); ?> " title="<?php echo html_encode($obj->getTitle()); ?> " class="relateditems_thumb"> <img src="<?php echo html_encode(pathurlencode($thumburl)); ?> " alt="<?php echo html_encode($obj->getTitle()); ?> " /> </a> <?php } } ?> <h4><a href="<?php echo html_encode(pathurlencode($url)); ?> " title="<?php echo html_encode($obj->getTitle()); ?> "><?php echo html_encode($obj->getTitle()); ?> </a> <?php if ($date) { switch ($item['type']) { case 'albums': case 'images': $d = $obj->getDateTime(); break; case 'news': case 'pages': $d = $obj->getDateTime(); break; } ?> <span class="relateditems_date"> <?php echo zpFormattedDate(DATE_FORMAT, strtotime($d)); ?> </span> <?php } ?> <?php if ($type == 'all') { ?> (<small><?php echo $category; ?> </small>)<?php } ?> </h4> <?php if ($excerpt) { echo shortenContent($text, $excerpt, '...', true); } ?> </li> <?php if ($count == $number) { break; } } // foreach if ($count) { ?> </ul> <?php } } }