/** * Prints excerpts of the direct subpages (1 level) of a page for a kind of overview. The setup is: * <div class='pageexcerpt'> * <h4>page title</h3> * <p>page content excerpt</p> * <p>read more</p> * </div> * * @param int $excerptlength The length of the page content, if nothing specifically set, the plugin option value for 'news article text length' is used * @param string $readmore The text for the link to the full page. If empty the read more setting from the options is used. * @param string $shortenindicator The optional placeholder that indicates that the content is shortened, if this is not set the plugin option "news article text shorten indicator" is used. * @return string */ function printSubPagesExcerpts($excerptlength = NULL, $readmore = NULL, $shortenindicator = NULL) { global $_zp_current_zenpage_page; if (is_null($readmore)) { $readmore = get_language_string(ZP_READ_MORE); } $pages = $_zp_current_zenpage_page->getPages(); $subcount = 0; if (is_null($excerptlength)) { $excerptlength = ZP_SHORTEN_LENGTH; } foreach ($pages as $page) { $pageobj = new ZenpagePage($page['titlelink']); if ($pageobj->getParentID() == $_zp_current_zenpage_page->getID()) { $subcount++; $pagetitle = html_encode($pageobj->getTitle()); $pagecontent = $pageobj->getContent(); if ($pageobj->checkAccess()) { $pagecontent = getContentShorten($pagecontent, $excerptlength, $shortenindicator, $readmore, $pageobj->getLink()); } else { $pagecontent = '<p><em>' . gettext('This page is password protected') . '</em></p>'; } echo '<div class="pageexcerpt">'; echo '<h4><a href="' . html_encode($pageobj->getLink()) . '" title="' . getBare($pagetitle) . '">' . $pagetitle . '</a></h4>'; echo $pagecontent; echo '</div>'; } } }
$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); $categories = ''; } echo '<h3>' . $obj->getTitle() . '</h3>'; echo '<p><small>' . $obj->getDatetime() . '</small></p>'; echo $obj->getContent(); echo $categories; echo '</div>'; } ?> </div><!-- main div --> </body> </html>
/** * Prints all available pages or categories in Zenpage * * @return string */ function printAllNestedList() { global $_zp_zenpage, $host; if (isset($_GET['zenpage']) && ($_GET['zenpage'] == "pages" || $_GET['zenpage'] == "categories")) { $mode = sanitize($_GET['zenpage']); switch ($mode) { case 'pages': $items = $_zp_zenpage->getPages(false); $listtitle = gettext('Pages'); break; case 'categories': $items = $_zp_zenpage->getAllCategories(false); $listtitle = gettext('Categories'); break; } echo "<h3>Zenpage: <em>" . html_encode($listtitle) . "</em> <small> " . gettext("(Click on article title to include a link)") . "</small></h3>"; echo "<ul class='tinynesteditems'>"; $indent = 1; $open = array(1 => 0); $rslt = false; foreach ($items as $key => $item) { switch ($mode) { case 'pages': $obj = new ZenpagePage($item['titlelink']); $itemcontent = truncate_string(getBare($obj->getContent()), 300); $zenpagepage = _PAGES_ . '/' . $item['titlelink']; $unpublished = unpublishedZenpageItemCheck($obj); $counter = ''; break; case 'categories': $obj = new ZenpageCategory($item['titlelink']); $itemcontent = $obj->getTitle(); $zenpagepage = "news/category/" . $item['titlelink']; $unpublished = unpublishedZenpageItemCheck($obj); $counter = ' (' . count($obj->getArticles()) . ') '; break; } $itemsortorder = $obj->getSortOrder(); $itemtitlelink = $obj->getTitlelink(); $itemtitle = $obj->getTitle(); $itemid = $obj->getID(); $order = explode('-', $itemsortorder); $level = max(1, count($order)); if ($toodeep = $level > 1 && $order[$level - 1] === '') { $rslt = true; } if ($level > $indent) { echo "\n" . str_pad("\t", $indent, "\t") . "<ul>\n"; $indent++; $open[$indent] = 0; } else { if ($level < $indent) { while ($indent > $level) { $open[$indent]--; $indent--; echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n"; } } else { // indent == level if ($open[$indent]) { echo str_pad("\t", $indent, "\t") . "</li>\n"; $open[$indent]--; } else { echo "\n"; } } } if ($open[$indent]) { echo str_pad("\t", $indent, "\t") . "</li>\n"; $open[$indent]--; } echo "<li id='" . $itemid . "' class='itemborder'>"; echo "<a href=\"javascript:ZenpageDialog.insert('','" . $zenpagepage . "','','','" . $itemtitlelink . "','" . js_encode($itemtitle) . "','','','" . $mode . "','','','','');\" title='" . html_encode($itemcontent) . "'>" . html_encode($itemtitle) . $unpublished . $counter . "</a> <small><em>" . $obj->getDatetime() . "</em></small>"; if ($mode == 'pages') { echo " <a href='zoom.php?pages=" . urlencode($itemtitlelink) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a>"; } $open[$indent]++; } while ($indent > 1) { echo "</li>\n"; $open[$indent]--; $indent--; echo str_pad("\t", $indent, "\t") . "</ul>"; } if ($open[$indent]) { echo "</li>\n"; } else { echo "\n"; } 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 getitemPages($item, $len) { $obj = new ZenpagePage($item['titlelink']); $feeditem['title'] = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale); $feeditem['link'] = $obj->getLink(); $desc = $obj->getContent($this->locale); $desc = str_replace('//<![CDATA[', '', $desc); $desc = str_replace('//]]>', '', $desc); $feeditem['desc'] = shortenContent($desc, $len, '...'); $feeditem['enclosure'] = ''; $feeditem['category'] = ''; $feeditem['media_content'] = ''; $feeditem['media_thumbnail'] = ''; $feeditem['pubdate'] = date("r", strtotime($obj->getDatetime())); return $feeditem; }
/** * 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 } } }