/**
  * Gets the sub pages recursivly by titlelink
  * @param $all set true for all sub page levels (default) or false for only the direct sub level
  * @return array
  */
 function getSubPages()
 {
     global $_zp_zenpage;
     $subpages = array();
     $sortorder = $this->getSortOrder();
     $pages = $_zp_zenpage->getPages();
     foreach ($pages as $page) {
         $pageobj = new ZenpagePage($page['titlelink']);
         if ($pageobj->getParentID() == $this->getID() && $pageobj->getSortOrder() != $sortorder) {
             // exclude the page itself!
             array_push($subpages, $pageobj->getTitlelink());
         }
     }
     if (count($subpages) != 0) {
         return $subpages;
     } else {
         return FALSE;
     }
 }
/**
 * 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>';
        }
    }
}
Esempio n. 3
0
 /**
  * Gets the parent pages recursivly to the page whose parentid is passed or the current object
  *
  * @param int $parentid The parentid of the page to get the parents of
  * @param bool $initparents
  * @return array
  */
 function getParents(&$parentid = '', $initparents = true)
 {
     global $parentpages, $_zp_zenpage;
     $allitems = $_zp_zenpage->getPages();
     if ($initparents) {
         $parentpages = array();
     }
     if (empty($parentid)) {
         $currentparentid = $this->getParentID();
     } else {
         $currentparentid = $parentid;
     }
     foreach ($allitems as $item) {
         $obj = new ZenpagePage($item['titlelink']);
         $itemtitlelink = $obj->getTitlelink();
         $itemid = $obj->getID();
         $itemparentid = $obj->getParentID();
         if ($itemid == $currentparentid) {
             array_unshift($parentpages, $itemtitlelink);
             $obj->getParents($itemparentid, false);
         }
     }
     return $parentpages;
 }