/**
 * 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. 2
0
 /**
  * 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;
 }
Esempio n. 3
0
							<?php 
    } else {
        echo gettext('No unpublished articles');
    }
    ?>
					</fieldset>
					<?php 
    $visible = $report == 'pages';
    $items = $_zp_zenpage->getPages(false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = new ZenpagePage($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="pagecheck" />' . $itemobj->getTitle() . '</label><a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '"> (' . gettext('View') . ')</a></li>';
        }
    }
    ?>
					<br class="clearall" />
					<fieldset class="smallbox">
						<legend><?php 
    reveal('pagebox', $visible);
    echo gettext('Pages not published');
    ?>
</legend>
						<?php 
    if ($report == 'pages') {
        ?>
							<div class="messagebox fade-message">
								<h2><?php 
/**
 * Creates a "REWRITE" url given the query parameters that represent the link
 *
 * @param type $query
 * @return string
 */
function zpRewriteURL($query)
{
    $redirectURL = '';
    if (isset($query['p'])) {
        sanitize($query);
        switch ($query['p']) {
            case 'news':
                $redirectURL = _NEWS_;
                if (isset($query['category'])) {
                    $obj = new ZenpageCategory($query['category'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['category']);
                } else {
                    if (isset($query['date'])) {
                        $redirectURL = _NEWS_ARCHIVE_ . '/' . $query['date'];
                        unset($query['date']);
                    }
                }
                if (isset($query['title'])) {
                    $obj = new ZenpageNews($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'pages':
                $redirectURL = _PAGES_;
                if (isset($query['title'])) {
                    $obj = new ZenpagePage($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'search':
                $redirectURL = _SEARCH_;
                if (isset($query['date'])) {
                    $redirectURL = _ARCHIVE_ . '/' . $query['date'];
                    unset($query['date']);
                } else {
                    if (isset($query['searchfields']) && $query['searchfields'] == 'tags') {
                        $redirectURL = _TAGS_;
                        unset($query['searchfields']);
                    }
                }
                if (isset($query['words'])) {
                    $redirectURL .= '/' . $query['words'];
                    unset($query['words']);
                }
                break;
            default:
                $redirectURL = getCustomPageURL($query['p']);
                break;
        }
        unset($query['p']);
        $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $redirectURL);
        if (isset($query['page'])) {
            $redirectURL .= '/' . $query['page'];
            unset($query['page']);
        }
        $q = http_build_query($query);
        if ($q) {
            $redirectURL .= '?' . $q;
        }
    } else {
        if (isset($query['album'])) {
            if (isset($query['image'])) {
                $obj = newImage(NULL, array('folder' => $query['album'], 'filename' => $query['image']), true);
                unset($query['image']);
            } else {
                $obj = newAlbum($query['album'], NULL, true);
            }
            unset($query['album']);
            if (!$obj->exists) {
                return '';
            }
            $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $obj->getLink());
            $q = http_build_query($query);
            if ($q) {
                $redirectURL .= '?' . $q;
            }
        }
    }
    return $redirectURL;
}
Esempio n. 5
0
/**
 * Gets the title, url and name of a menu item
 *
 * @return array
 */
function getItemTitleAndURL($item)
{
    global $_zp_gallery;
    $themename = $_zp_gallery->getCurrentTheme();
    $array = array("title" => '', "url" => '', "name" => '', 'protected' => false, 'theme' => $themename);
    $valid = true;
    $title = get_language_string($item['title']);
    switch ($item['type']) {
        case "galleryindex":
            $array = array("title" => get_language_string($item['title']), "url" => WEBPATH, "name" => WEBPATH, 'protected' => false, 'theme' => $themename);
            break;
        case "album":
            $folderFS = internalToFilesystem($item['link']);
            $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS;
            $dynamic = hasDynamicAlbumSuffix($folderFS) && !is_dir($folderFS);
            $valid = file_exists($localpath) && ($dynamic || is_dir($localpath));
            if (!$valid || strpos($localpath, '..') !== false) {
                $valid = false;
                $url = '';
                $protected = 0;
            } else {
                $obj = newAlbum($item['link']);
                $url = $obj->getLink(0);
                $protected = $obj->isProtected();
                $title = $obj->getTitle();
            }
            $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename);
            break;
        case "zenpagepage":
            if (class_exists('zenpage')) {
                $sql = 'SELECT * FROM ' . prefix('pages') . ' WHERE `titlelink`="' . $item['link'] . '"';
                $result = query_single_row($sql);
                if (is_array($result)) {
                    $obj = new ZenpagePage($item['link']);
                    $url = $obj->getLink(0);
                    $protected = $obj->isProtected();
                    $title = $obj->getTitle();
                } else {
                    $valid = false;
                    $url = '';
                    $protected = 0;
                }
                $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename);
            }
            break;
        case "zenpagenewsindex":
            if (class_exists('zenpage')) {
                $url = getNewsIndexURL();
                $array = array("title" => get_language_string($item['title']), "url" => $url, "name" => $url, 'protected' => false);
            }
            break;
        case "zenpagecategory":
            if (class_exists('zenpage')) {
                $sql = "SELECT title FROM " . prefix('news_categories') . " WHERE titlelink = '" . $item['link'] . "'";
                $obj = query_single_row($sql, false);
                if ($obj) {
                    $obj = new ZenpageCategory($item['link']);
                    $title = $obj->getTitle();
                    $protected = $obj->isProtected();
                    $url = $obj->getLink(0);
                } else {
                    $valid = false;
                    $url = '';
                    $protected = 0;
                }
                $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename);
            }
            break;
        case "custompage":
            $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/';
            if (file_exists($root . $item['link'] . '.php')) {
                $url = zp_apply_filter('getLink', rewrite_path(_PAGE_ . '/' . $item['link'], "/index.php?p=" . $item['link']), $item['link'] . '.php', NULL);
            } else {
                $valid = false;
                $url = '';
            }
            $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => false, 'theme' => $themename);
            break;
        case "customlink":
            $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename);
            break;
        case 'menulabel':
            $array = array("title" => get_language_string($item['title']), "url" => NULL, 'name' => $item['title'], 'protected' => false, 'theme' => $themename);
            break;
        default:
            $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename);
            break;
    }
    $limit = MENU_TRUNCATE_STRING;
    $array['valid'] = $valid;
    if ($limit) {
        $array['title'] = shortenContent($array['title'], $limit, MENU_TRUNCATE_INDICATOR);
    }
    return $array;
}
Esempio n. 6
0
/**
 * 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 
        }
    }
}
Esempio n. 7
0
        ?>
</strong></h2>

							<?php 
        printPageContent();
        printCodeblock(1);
        $subpages = $_zp_current_zenpage_page->getPages();
        if ($subpages) {
            ?>
								<ul data-role="listview" data-inset="true" data-theme="a" class="ui-listview ui-group-theme-a">
									<?php 
            foreach ($subpages as $subpage) {
                $obj = new ZenpagePage($subpage['titlelink']);
                ?>
										<li><a href="<?php 
                echo html_encode($obj->getLink());
                ?>
" title="<?php 
                echo html_encode($obj->getTitle());
                ?>
"><?php 
                echo html_encode($obj->getTitle());
                ?>
</a></li>
										<?php 
            }
            ?>
								</ul>
								<?php 
        }
        printTags('links', gettext('<strong>Tags:</strong>') . ' ', 'taglist', ', ');
Esempio n. 8
0
/**
 * @deprecated
 * @since 1.4.6
 */
function getPageLinkPath($titlelink)
{
    deprecated_functions::notify(gettext('Create an object and use the object getLink'));
    $obj = new ZenpagePage($titlelink);
    return $obj->getLink();
}