/** * 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>'; } } }
/** * Gets all tags used by either all Zenpage news articles or pages. * @param string $mode "news" for Zenpage news article tags, "pages" for Zenpage pages tags * */ function getAllTagsFromZenpage($mode = 'news') { global $_zp_gallery, $_zp_zenpage; if (!getOption('zp_plugin_zenpage')) { return FALSE; } $passwordcheck = ''; $ids = array(); $where = ''; $tagWhere = ""; switch ($mode) { case 'news': if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) { $published = 'all'; } else { $published = 'published'; } $type = 'news'; $items = $_zp_zenpage->getNewsArticles('', $published); foreach ($items as $item) { $obj = new ZenpageNews($item['titlelink']); if ($obj->checkAccess($hint, $show)) { $ids[] = $obj->getID(); } } break; case 'pages': if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) { $published = 'all'; } else { $published = 'published'; } $type = 'pages'; $items = $_zp_zenpage->getPages('', '', $published); foreach ($items as $item) { $obj = new ZenpagePage($item['titlelink']); if ($obj->checkAccess($hint, $show)) { $ids[] = $obj->getID(); } } break; } $count = ''; if (count($ids) == 0) { return FALSE; } else { $tagWhere = " WHERE "; foreach ($ids as $id) { $count++; $tagWhere .= '(o.objectid =' . $id . " AND o.tagid = t.id AND o.type = '" . $type . "')"; if ($count != count($ids)) { $tagWhere .= " OR "; } } } if (empty($tagWhere)) { return FALSE; } else { $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = '" . $type . "') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name"); } return $tags; }