Esempio n. 1
0
/**
 * Gets links to Zenpage news categories incl. pagination
 *
 * @return string
 */
function getSitemapZenpageNewsCategories()
{
    global $_zp_zenpage, $sitemap_number;
    //TODO not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_newscats');
        $newscats = $_zp_zenpage->getAllCategories();
        if ($newscats) {
            $data .= sitemap_echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap_echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            foreach ($newscats as $newscat) {
                $catobj = new ZenpageCategory($newscat['titlelink']);
                if (!$catobj->isProtected()) {
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1';
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', dynamic_locale::fullHostPath($locale));
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', FULLWEBPATH);
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                    // getting pages for the categories
                    /*
                    					  if(!empty($articlesperpage)) {
                    					  $zenpage_articles_per_page = sanitize_numeric($articlesperpage);
                    					  } else {
                    					  $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                    					  } */
                    $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                    $articlecount = count($catobj->getArticles());
                    $catpages = ceil($articlecount / $zenpage_articles_per_page);
                    if ($catpages > 1) {
                        for ($x = 2; $x <= $catpages; $x++) {
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x;
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x, '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, dynamic_locale::fullHostPath($locale));
                                        $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x, '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, FULLWEBPATH);
                                    $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                        }
                    }
                }
            }
            $data .= sitemap_echonl('</urlset>');
            // End off the <urlset> tag
        }
        return $data;
    }
}
/**
 * Prints a context sensitive menu of all pages as a unordered html list
 *
 * @param string $option The mode for the menu:
 * 												"list" context sensitive toplevel plus sublevel pages,
 * 												"list-top" only top level pages,
 * 												"omit-top" only sub level pages
 * 												"list-sub" lists only the current pages direct offspring
 * @param string $mode 'pages' or 'categories'
 * @param bool $counter Only $mode = 'categories': Count the articles in each category
 * @param string $css_id CSS id of the top level list
 * @param string $css_class_topactive class of the active item in the top level list
 * @param string $css_class CSS class of the sub level list(s)
 * @param string $$css_class_active CSS class of the sub level list(s)
 * @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" (default) if you don't use it, it is not printed then.
 * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list".
 * @param bool $startlist set to true to output the UL tab (false automatically if you use 'omit-top' or 'list-sub')
 * @param int $limit truncation limit display strings
 * @return string
 */
function printNestedMenu($option = 'list', $mode = NULL, $counter = TRUE, $css_id = NULL, $css_class_topactive = NULL, $css_class = NULL, $css_class_active = NULL, $indexname = NULL, $showsubs = 0, $startlist = true, $limit = NULL)
{
    global $_zp_zenpage, $_zp_gallery_page, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category;
    if (is_null($limit)) {
        $limit = MENU_TRUNCATE_STRING;
    }
    if ($css_id != "") {
        $css_id = " id='" . $css_id . "'";
    }
    if ($css_class_topactive != "") {
        $css_class_topactive = " class='" . $css_class_topactive . "'";
    }
    if ($css_class != "") {
        $css_class = " class='" . $css_class . "'";
    }
    if ($css_class_active != "") {
        $css_class_active = " class='" . $css_class_active . "'";
    }
    if ($showsubs === true) {
        $showsubs = 9999999999.0;
    }
    switch ($mode) {
        case 'pages':
            $items = $_zp_zenpage->getPages();
            $currentitem_id = getPageID();
            if (is_object($_zp_current_zenpage_page)) {
                $currentitem_parentid = $_zp_current_zenpage_page->getParentID();
            } else {
                $currentitem_parentid = NULL;
            }
            $currentitem_sortorder = getPageSortorder();
            break;
        case 'categories':
        case 'allcategories':
            $items = $_zp_zenpage->getAllCategories();
            if (is_object($_zp_current_category) && $mode == 'categories') {
                $currentitem_sortorder = $_zp_current_category->getSortOrder();
                $currentitem_id = $_zp_current_category->getID();
                $currentitem_parentid = $_zp_current_category->getParentID();
            } else {
                $currentitem_sortorder = NULL;
                $currentitem_id = NULL;
                $currentitem_parentid = NULL;
            }
            break;
    }
    // don't highlight current pages or foldout if in search mode as next_page() sets page context
    if (in_context(ZP_SEARCH) && $mode == 'pages') {
        // categories are not searched
        $css_class_topactive = "";
        $css_class_active = "";
        rem_context(ZP_ZENPAGE_PAGE);
    }
    if (0 == count($items) + (int) ($mode == 'allcategories')) {
        return;
    }
    // nothing to do
    $startlist = $startlist && !($option == 'omit-top' || $option == 'list-sub');
    if ($startlist) {
        echo "<ul{$css_id}>";
    }
    // if index link and if if with count
    if (!empty($indexname)) {
        if ($limit) {
            $display = shortenContent($indexname, $limit, MENU_TRUNCATE_INDICATOR);
        } else {
            $display = $indexname;
        }
        switch ($mode) {
            case 'pages':
                if ($_zp_gallery_page == "index.php") {
                    echo "<li {$css_class_topactive}>" . html_encode($display) . "</li>";
                } else {
                    echo "<li><a href='" . html_encode(getGalleryIndexURL()) . "' title='" . html_encode($indexname) . "'>" . html_encode($display) . "</a></li>";
                }
                break;
            case 'categories':
            case 'allcategories':
                if ($_zp_gallery_page == "news.php" && !is_NewsCategory() && !is_NewsArchive() && !is_NewsArticle()) {
                    echo "<li {$css_class_topactive}>" . html_encode($display);
                } else {
                    echo "<li><a href=\"" . html_encode(getNewsIndexURL()) . "\" title=\"" . html_encode($indexname) . "\">" . html_encode($display) . "</a>";
                }
                if ($counter) {
                    if (in_context(ZP_ZENPAGE_NEWS_CATEGORY) && $mode == 'categories') {
                        $totalcount = count($_zp_current_category->getArticles(0));
                    } else {
                        save_context();
                        rem_context(ZP_ZENPAGE_NEWS_DATE);
                        $totalcount = count($_zp_zenpage->getArticles(0));
                        restore_context();
                    }
                    echo ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $totalcount), $totalcount) . ')</small></span>';
                }
                echo "</li>\n";
                break;
        }
    }
    $baseindent = max(1, count(explode("-", $currentitem_sortorder)));
    $indent = 1;
    $open = array($indent => 0);
    $parents = array(NULL);
    $order = explode('-', $currentitem_sortorder);
    $mylevel = count($order);
    $myparentsort = array_shift($order);
    for ($c = 0; $c <= $mylevel; $c++) {
        $parents[$c] = NULL;
    }
    foreach ($items as $item) {
        switch ($mode) {
            case 'pages':
                $catcount = 1;
                //	so page items all show.
                $pageobj = new ZenpagePage($item['titlelink']);
                $itemtitle = $pageobj->getTitle();
                $itemsortorder = $pageobj->getSortOrder();
                $itemid = $pageobj->getID();
                $itemparentid = $pageobj->getParentID();
                $itemtitlelink = $pageobj->getTitlelink();
                $itemurl = $pageobj->getLink();
                $count = '';
                break;
            case 'categories':
            case 'allcategories':
                $catobj = new ZenpageCategory($item['titlelink']);
                $itemtitle = $catobj->getTitle();
                $itemsortorder = $catobj->getSortOrder();
                $itemid = $catobj->getID();
                $itemparentid = $catobj->getParentID();
                $itemtitlelink = $catobj->getTitlelink();
                $itemurl = $catobj->getLink();
                $catcount = count($catobj->getArticles());
                if ($counter) {
                    $count = ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $catcount), $catcount) . ')</small></span>';
                } else {
                    $count = '';
                }
                break;
        }
        if ($catcount) {
            $level = max(1, count(explode('-', $itemsortorder)));
            $process = $level <= $showsubs && $option == "list" || ($option == 'list' || $option == 'list-top') && $level == 1 || ($option == 'list' || $option == 'omit-top' && $level > 1) && ($itemid == $currentitem_id || $itemparentid == $currentitem_id || $level < $mylevel && $level > 1 && strpos($itemsortorder, $myparentsort) === 0 || $level == $mylevel && $currentitem_parentid == $itemparentid) || $option == 'list-sub' && $itemparentid == $currentitem_id;
            if ($process) {
                if ($level > $indent) {
                    echo "\n" . str_pad("\t", $indent, "\t") . "<ul{$css_class}>\n";
                    $indent++;
                    $parents[$indent] = NULL;
                    $open[$indent] = 0;
                } else {
                    if ($level < $indent) {
                        $parents[$indent] = NULL;
                        while ($indent > $level) {
                            if ($open[$indent]) {
                                $open[$indent]--;
                                echo "</li>\n";
                            }
                            $indent--;
                            echo str_pad("\t", $indent, "\t") . "</ul>\n";
                        }
                    } else {
                        // level == indent, have not changed
                        if ($open[$indent]) {
                            // level = indent
                            echo str_pad("\t", $indent, "\t") . "</li>\n";
                            $open[$indent]--;
                        } else {
                            echo "\n";
                        }
                    }
                }
                if ($open[$indent]) {
                    // close an open LI if it exists
                    echo "</li>\n";
                    $open[$indent]--;
                }
                echo str_pad("\t", $indent - 1, "\t");
                $open[$indent]++;
                $parents[$indent] = $itemid;
                if ($level == 1) {
                    // top level
                    $class = $css_class_topactive;
                } else {
                    $class = $css_class_active;
                }
                if (!is_null($_zp_current_zenpage_page)) {
                    $gettitle = $_zp_current_zenpage_page->getTitle();
                    $getname = $_zp_current_zenpage_page->getTitlelink();
                } else {
                    if (!is_null($_zp_current_category)) {
                        $gettitle = $_zp_current_category->getTitle();
                        $getname = $_zp_current_category->getTitlelink();
                    } else {
                        $gettitle = '';
                        $getname = '';
                    }
                }
                $current = "";
                if ($itemtitlelink == $getname && !in_context(ZP_SEARCH)) {
                    switch ($mode) {
                        case 'pages':
                            if ($_zp_gallery_page == 'pages.php') {
                                $current = $class;
                            }
                            break;
                        case 'categories':
                        case 'allcategories':
                            if ($_zp_gallery_page == 'news.php') {
                                $current = $class;
                            }
                            break;
                    }
                }
                if ($limit) {
                    $itemtitle = shortenContent($itemtitle, $limit, MENU_TRUNCATE_INDICATOR);
                }
                echo "<li><a {$current} href=\"" . html_encode($itemurl) . "\" title=\"" . html_encode(getBare($itemtitle)) . "\">" . html_encode($itemtitle) . "</a>" . $count;
            }
        }
    }
    // cleanup any hanging list elements
    while ($indent > 1) {
        if ($open[$indent]) {
            echo "</li>\n";
            $open[$indent]--;
        }
        $indent--;
        echo str_pad("\t", $indent, "\t") . "</ul>";
    }
    if ($open[$indent]) {
        echo "</li>\n";
        $open[$indent]--;
    } else {
        echo "\n";
    }
    if ($startlist) {
        echo "</ul>\n";
    }
}
/**
 * Prints the dropdown menu for the category selector for the news articles list
 *
 */
function printCategoryDropdown()
{
    global $_zp_zenpage;
    $currentpage = $_zp_zenpage->getCurrentAdminNewsPage();
    $result = $_zp_zenpage->getAllCategories(false);
    if (isset($_GET['date'])) {
        $datelink = "&amp;date=" . $_GET['date'];
        $datelinkall = "?date=" . $_GET['date'];
    } else {
        $datelink = "";
        $datelinkall = "";
    }
    if (isset($_GET['category'])) {
        $selected = '';
        $category = sanitize($_GET['category']);
    } else {
        $selected = "selected='selected'";
        $category = "";
    }
    ?>
	<form name ="AutoListBox2" id="categorydropdown" style="float:left" action="#" >
	<select name="ListBoxURL" size="1" onchange="gotoLink(this.form)">
		<?php 
    echo "<option {$selected} value='admin-news-articles.php?pagenr=" . $currentpage . getNewsAdminOptionPath(false, true, true) . "'>" . gettext("All categories") . "</option>\n";
    foreach ($result as $cat) {
        $catobj = new ZenpageCategory($cat['titlelink']);
        // check if there are articles in this category. If not don't list the category.
        $count = count($catobj->getArticles(0, 'all'));
        $count = " (" . $count . ")";
        if ($category == $cat['titlelink']) {
            $selected = "selected='selected'";
        } else {
            $selected = "";
        }
        //This is much easier than hacking the nested list function to work with this
        $getparents = $catobj->getParents();
        $levelmark = '';
        foreach ($getparents as $parent) {
            $levelmark .= '&raquo; ';
        }
        $title = $catobj->getTitle();
        if (empty($title)) {
            $title = '*' . $catobj->getTitlelink() . '*';
        }
        if ($count != " (0)") {
            echo "<option {$selected} value='admin-news-articles.php?pagenr=" . $currentpage . "&amp;category=" . $catobj->getTitlelink() . getNewsAdminOptionPath(false, true, true) . "'>" . $levelmark . $title . $count . "</option>\n";
        }
    }
    ?>
	</select>
	<script language="JavaScript" type="text/javascript" >
		// <!-- <![CDATA[
		function gotoLink(form) {
		var OptionIndex=form.ListBoxURL.selectedIndex;
		parent.location = form.ListBoxURL.options[OptionIndex].value;}
		// ]]> -->
</script>
</form>
<?php 
}
Esempio n. 4
0
        echo $admintype;
        ?>
&amp;update<?php 
        echo $page;
        ?>
">
									<?php 
        XSRFToken('update');
    }
    ?>
								<input type="hidden" name="id" value="<?php 
    echo $result->getID();
    ?>
" />
								<input type="hidden" name="titlelink-old" id="titlelink-old" value="<?php 
    echo html_encode($result->getTitlelink());
    ?>
" />
								<input type="hidden" name="lastchange" id="lastchange" value="<?php 
    echo date('Y-m-d H:i:s');
    ?>
" />
								<input type="hidden" name="lastchangeauthor" id="lastchangeauthor" value="<?php 
    echo $_zp_current_admin_obj->getUser();
    ?>
" />
								<input type="hidden" name="hitcounter" id="hitcounter" value="<?php 
    echo $result->getHitcounter();
    ?>
" />
/**
* Prints all available articles or categories in Zenpage
*
* @param string $current

 set to category selected (if any)
*
* @return string
*/
function printZenpageNewsCategorySelector($current)
{
    global $_zp_gallery, $_zp_zenpage;
    ?>
	<select id="categoryselector" name="categoryselect">
		<?php 
    $cats = $_zp_zenpage->getAllCategories(false);
    foreach ($cats as $cat) {
        if ($cat['titlelink'] == $current) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        $catobj = new ZenpageCategory($cat['titlelink']);
        //This is much easier than hacking the nested list function to work with this
        $getparents = $catobj->getParents();
        $levelmark = '';
        foreach ($getparents as $parent) {
            $levelmark .= '» ';
        }
        echo "<option value = '" . html_encode($catobj->getTitlelink()) . "'" . $selected . '>';
        echo $levelmark . $catobj->getTitle() . "</option>";
    }
    ?>
	</select>
	<?php 
}
 /**
  * Gets the parent categories recursivly to the category whose parentid is passed or the current object
  *
  * @param int $parentid The parentid of the category to get the parents of
  * @param bool $initparents
  * @return array
  */
 function getParents(&$parentid = '', $initparents = true)
 {
     global $parentcats, $_zp_zenpage;
     $allitems = $_zp_zenpage->getAllCategories(false);
     if ($initparents) {
         $parentcats = array();
     }
     if (empty($parentid)) {
         $currentparentid = $this->getParentID();
     } else {
         $currentparentid = $parentid;
     }
     foreach ($allitems as $item) {
         $obj = new ZenpageCategory($item['titlelink']);
         $itemtitlelink = $obj->getTitlelink();
         $itemid = $obj->getID();
         $itemparentid = $obj->getParentID();
         if ($itemid == $currentparentid) {
             array_unshift($parentcats, $itemtitlelink);
             $obj->getParents($itemparentid, false);
         }
     }
     return $parentcats;
 }
Esempio n. 7
0
        ?>
</a></li>
		<?php 
    } else {
        unset($cats[$key]);
    }
}
?>
</ol>
<?php 
foreach ($cats as $cat) {
    $catobj = new ZenpageCategory($cat);
    $h4 = $catobj->getTitle();
    ?>
	<h4><a name="<?php 
    echo $catobj->getTitlelink();
    ?>
"></a><?php 
    echo $h4;
    ?>
</h4>
	<?php 
    listArticles($catobj);
}
function listArticles($cat)
{
    global $counter;
    global $_zp_current_category;
    $_zp_current_category = $cat;
    $articles = $cat->getArticles();
    if (!empty($articles)) {