Esempio n. 1
0
 function getCategoryStructure()
 {
     if (is_null($this->categoryStructure)) {
         $allcategories = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER by sort_order");
         $structure = array();
         foreach ($allcategories as $cat) {
             $catobj = new ZenpageCategory($cat['titlelink']);
             if ($catobj->isMyItem(VIEW_NEWS_RIGHTS)) {
                 $cat['show'] = 1;
             } else {
                 if ($cat['show'] && $cat['parentid']) {
                     $cat['show'] = $structure[$cat['parentid']]['show'];
                 }
             }
             $structure[$cat['id']] = $cat;
         }
         $structure = sortMultiArray($structure, 'sort_order', false, false, false, true);
         $this->categoryStructure = $structure;
     }
     return $this->categoryStructure;
 }
Esempio n. 2
0
function printLatestNewsCustom($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true)
{
    global $_zp_gallery, $_zp_current_zenpage_news;
    $latest = getLatestNews($number, $category);
    echo "\n<div class=\"latestnews-spotlight\">\n";
    $count = "";
    foreach ($latest as $item) {
        $count++;
        $category = "";
        $categories = "";
        $obj = new ZenpageNews($item['titlelink']);
        $title = htmlspecialchars($obj->getTitle());
        $link = getNewsURL($item['titlelink']);
        $count2 = 0;
        $category = $obj->getCategories();
        foreach ($category as $cat) {
            $catobj = new ZenpageCategory($cat['titlelink']);
            $count2++;
            if ($count2 != 1) {
                $categories = $categories . "; ";
            }
            $categories = $categories . $catobj->getTitle();
        }
        $content = strip_tags($obj->getContent());
        $date = zpFormattedDate(getOption('date_format'), strtotime($item['date']));
        $type = 'news';
        echo "<div>";
        echo "<h3><a href=\"" . $link . "\" title=\"" . strip_tags(htmlspecialchars($title, ENT_QUOTES)) . "\">" . htmlspecialchars($title) . "</a></h3>\n";
        echo "<div class=\"newsarticlecredit\">\n";
        echo "<span class=\"latestnews-date\">" . $date . "</span>\n";
        echo "<span class=\"latestnews-cats\">| Posted in " . $categories . "</span>\n";
        echo "</div>\n";
        echo "<p class=\"latestnews-desc\">" . html_encode(getContentShorten($content, $contentlength, '(...)', null, null)) . "</p>\n";
        echo "</div>\n";
        if ($count == $number) {
            break;
        }
    }
    echo "</div>\n";
}
/**
 * Prints the parent items breadcrumb navigation for pages or categories
 *
 * @param string $before Text to place before the breadcrumb item
 * @param string $after Text to place after the breadcrumb item
 */
function printZenpageItemsBreadcrumb($before = NULL, $after = NULL)
{
    global $_zp_current_zenpage_page, $_zp_current_category;
    $parentitems = array();
    if (is_Pages()) {
        //$parentid = $_zp_current_zenpage_page->getParentID();
        $parentitems = $_zp_current_zenpage_page->getParents();
    }
    if (is_NewsCategory()) {
        //$parentid = $_zp_current_category->getParentID();
        $parentitems = $_zp_current_category->getParents();
    }
    foreach ($parentitems as $item) {
        if (is_Pages()) {
            $pageobj = new ZenpagePage($item);
            $parentitemurl = html_encode($pageobj->getLink());
            $parentitemtitle = $pageobj->getTitle();
        }
        if (is_NewsCategory()) {
            $catobj = new ZenpageCategory($item);
            $parentitemurl = $catobj->getLink();
            $parentitemtitle = $catobj->getTitle();
        }
        if ($before) {
            echo '<span class="beforetext">' . html_encode($before) . '</span>';
        }
        echo "<a href='" . $parentitemurl . "'>" . html_encode($parentitemtitle) . "</a>";
        if ($after) {
            echo '<span class="aftertext">' . html_encode($after) . '</span>';
        }
    }
}
Esempio n. 4
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 getItemNews($item)
 {
     $categories = '';
     $feeditem['enclosure'] = '';
     $obj = new ZenpageNews($item['titlelink']);
     $title = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale);
     $link = $obj->getLink();
     $count2 = 0;
     $plaincategories = $obj->getCategories();
     $categories = '';
     foreach ($plaincategories as $cat) {
         $catobj = new ZenpageCategory($cat['titlelink']);
         $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', ';
     }
     $categories = rtrim($categories, ', ');
     $desc = $obj->getContent($this->locale);
     $desc = str_replace('//<![CDATA[', '', $desc);
     $desc = str_replace('//]]>', '', $desc);
     $feeditem['desc'] = shortenContent($desc, getOption('externalFeed_truncate_length'), '...');
     if (!empty($categories)) {
         $feeditem['category'] = html_encode($categories);
         $feeditem['title'] = $title . ' (' . $categories . ')';
     }
     $feeditem['link'] = $link;
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     $feeditem['pubdate'] = date("r", strtotime($obj->getDateTime()));
     return $feeditem;
 }
Esempio n. 5
0
<?php

class Combi extends Zenpage
{
    function getOldCombiNews()
    {
        return $this->getCombiNews(NULL, NULL, 'published');
    }
}
global $plugin_is_filter;
enableExtension('galleryArticles', $plugin_is_filter);
$obj = new Combi();
$combi = $obj->getOldCombiNews();
$cat = new ZenpageCategory('combiNews', true);
$cat->setTitle(gettext('combiNews'));
$cat->setDesc(gettext('Auto category for ported combi-news articles.'));
$cat->save();
foreach ($combi as $article) {
    switch ($article['type']) {
        case 'images':
            $obj = newImage(NULL, array('folder' => $article['albumname'], 'filename' => $article['titlelink']), false);
            if ($obj->exists) {
                $obj->setPublishDate($article['date']);
                self::publishArticle($obj, 'combiNews');
            }
            break;
        case 'albums':
            $obj = newAlbum($article['albumname'], false);
            if ($obj->exists) {
                $obj->setPublishDate($article['date']);
                self::publishArticle($obj, 'combiNews');
    updateItemSortorder('categories', $reports);
}
if (isset($_GET['delete'])) {
    XSRFdefender('delete_category');
    $reports[] = deleteCategory($_GET['delete']);
}
if (isset($_GET['hitcounter'])) {
    XSRFdefender('hitcounter');
    $x = $_zp_zenpage->getCategory(sanitize_numeric($_GET['id']));
    $obj = new ZenpageCategory($x['titlelink']);
    $obj->set('hitcounter', 0);
    $obj->save();
}
if (isset($_GET['publish'])) {
    XSRFdefender('update');
    $obj = new ZenpageCategory(sanitize($_GET['titlelink']));
    $obj->setShow(sanitize_numeric($_GET['publish']));
    $obj->save();
}
if (isset($_GET['save'])) {
    XSRFdefender('save_categories');
    addCategory($reports);
}
if (isset($_GET['id'])) {
    $x = $_zp_zenpage->getCategory(sanitize_numeric($_GET['id']));
    $result = new ZenpageCategory($x['titlelink']);
} else {
    if (isset($_GET['update'])) {
        XSRFdefender('update_categories');
        $result = updateCategory($reports);
    } else {
/**
 * Counts news articles, either all or by category or archive date, published or un-published
 *
 * @param string $category The categorylink of the category to count
 * @param string $published "published" for an published articles,
 * 													"unpublished" for an unpublised articles,
 * 													"all" for all articles
 * @return array
 */
function countArticles($category = '', $published = 'published', $count_subcat_articles = true)
{
    deprecated_function_notify(gettext('Count the articles instead.'));
    global $_zp_post_date;
    if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
        $published = "all";
    } else {
        $published = "published";
    }
    $show = "";
    if (empty($category)) {
        switch ($published) {
            case "published":
                $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
                break;
            case "unpublished":
                $show = " WHERE `show` = 0 AND date <= '" . date('Y-m-d H:i:s') . "'";
                break;
            case "all":
                $show = "";
                break;
        }
        // date archive query addition
        if (in_context(ZP_ZENPAGE_NEWS_DATE)) {
            $postdate = $_zp_post_date;
            if (empty($show)) {
                $and = " WHERE ";
            } else {
                $and = " AND ";
            }
            $datesearch = $and . "date LIKE '{$postdate}%'";
        } else {
            $datesearch = "";
        }
        $result = query("SELECT COUNT(*) FROM " . prefix('news') . $show . $datesearch);
        $row = db_fetch_row($result);
        $count = $row[0];
        return $count;
    } else {
        $catobj = new ZenpageCategory($category);
        switch ($published) {
            case "published":
                $show = " AND news.show = 1 AND news.date <= '" . date('Y-m-d H:i:s') . "'";
                break;
            case "unpublished":
                $show = " AND news.show = 0 AND news.date <= '" . date('Y-m-d H:i:s') . "'";
                break;
            case "all":
                $show = "";
                break;
        }
        if ($count_subcat_articles) {
            $subcats = $catobj->getSubCategories();
        }
        if ($subcats && $count_subcat_articles) {
            $cat = " (cat.cat_id = '" . $catobj->getID() . "'";
            foreach ($subcats as $subcat) {
                $subcatobj = new ZenpageCategory($subcat);
                $cat .= "OR cat.cat_id = '" . $subcatobj->getID() . "' ";
            }
            $cat .= ") AND cat.news_id = news.id ";
        } else {
            $cat = " cat.cat_id = '" . $catobj->getID() . "' AND cat.news_id = news.id ";
        }
        $result = query_full_array("SELECT DISTINCT news.titlelink FROM " . prefix('news2cat') . " as cat, " . prefix('news') . " as news WHERE " . $cat . $show);
        $count = count($result);
        return $count;
    }
}
/**
 * returns an array of how many pages, articles, categories and news or pages comments we got.
 *
 * @param string $option What the statistic should be shown of: "news", "pages", "categories"
 */
function getNewsPagesStatistic($option)
{
    global $_zp_zenpage;
    switch ($option) {
        case "news":
            $items = $_zp_zenpage->getNewsArticles();
            $type = gettext("Articles");
            break;
        case "pages":
            $items = $_zp_zenpage->getPages(false);
            $type = gettext("Pages");
            break;
        case "categories":
            $type = gettext("Categories");
            $cats = $_zp_zenpage->getAllCategories(false);
            $total = count($cats);
            $unpub = 0;
            break;
    }
    if ($option == "news" or $option == "pages") {
        $total = count($items);
        $pub = 0;
        foreach ($items as $item) {
            switch ($option) {
                case "news":
                    $itemobj = new ZenpageNews($item['titlelink']);
                    break;
                case "pages":
                    $itemobj = new ZenpagePage($item['titlelink']);
                    break;
                case "categories":
                    $itemobj = new ZenpageCategory($item['titlelink']);
                    break;
            }
            $show = $itemobj->getShow();
            if ($show == 1) {
                $pub++;
            }
        }
        //echo " (un-published: ";
        $unpub = $total - $pub;
    }
    return array($total, $type, $unpub);
}
/**
 * Prints the parent items breadcrumb navigation for pages or categories
 *
 * @param string $mode 'pages or 'categories'
 * @param string $before Text to place before the breadcrumb item
 * @param string $after Text to place after the breadcrumb item
 */
function printZenpageItemsBreadcrumb($before = NULL, $after = NULL)
{
    global $_zp_current_zenpage_page, $_zp_current_category;
    $parentitems = array();
    if (is_Pages()) {
        //$parentid = $_zp_current_zenpage_page->getParentID();
        $parentitems = $_zp_current_zenpage_page->getParents();
    }
    if (is_NewsCategory()) {
        //$parentid = $_zp_current_category->getParentID();
        $parentitems = $_zp_current_category->getParents();
    }
    foreach ($parentitems as $item) {
        if (is_Pages()) {
            $pageobj = new ZenpagePage($item);
            $parentitemurl = html_encode(getPageLinkURL($item));
            $parentitemtitle = $pageobj->getTitle();
        }
        if (is_NewsCategory()) {
            $catobj = new ZenpageCategory($item);
            $parentitemurl = getNewsCategoryURL($item);
            $parentitemtitle = $catobj->getTitle();
        }
        echo $before . "<a href='" . $parentitemurl . "'>" . $parentitemtitle . "</a>" . $after;
    }
}
Esempio n. 10
0
 /**
  * Checks if an article is in a sub category of $catlink
  *
  * @param string $catlink The titlelink of a category
  * @return bool
  */
 function inSubNewsCategoryOf($catlink)
 {
     if (!empty($catlink)) {
         $categories = $this->getCategories();
         $count = 0;
         foreach ($categories as $cat) {
             $catobj = new ZenpageCategory($cat['titlelink']);
             $parentid = $catobj->getParentID();
             $parentcats = $catobj->getParents();
             foreach ($parentcats as $parentcat) {
                 if ($catlink == $parentcat) {
                     $count = 1;
                     break;
                 }
             }
         }
         return $count == 1;
     } else {
         return false;
     }
 }
if (isset($_GET['published'])) {
    switch ($_GET['published']) {
        case 'no':
            $published = 'unpublished';
            break;
        case 'yes':
            $published = 'published';
            break;
        case 'sticky':
            $published = 'sticky';
    }
} else {
    $published = 'all';
}
if (isset($_GET['category'])) {
    $catobj = new ZenpageCategory(sanitize($_GET['category']));
    $resultU = $catobj->getArticles(0, 'unpublished', false);
    $result = $catobj->getArticles(0, $published, false);
} else {
    $catobj = NULL;
    $resultU = $_zp_zenpage->getNewsArticles(0, 'unpublished', false);
    $result = $_zp_zenpage->getNewsArticles(0, $published, false);
}
foreach ($result as $key => $article) {
    $article = new ZenpageNews($article['titlelink']);
    if (!$article->isMyItem(ZENPAGE_NEWS_RIGHTS)) {
        unset($result[$key]);
    }
}
foreach ($resultU as $key => $article) {
    $article = new ZenpageNews($article['titlelink']);
Esempio n. 12
0
        echo $catobj->getTitlelink();
        ?>
"><?php 
        echo $h4;
        ?>
</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;
/**
 * 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 style='margin-bottom:10px;'>Zenpage: <em>" . html_encode($listtitle) . "</em> <small> " . gettext("(Click on article title to include a link)") . "</small></h3>";
        echo "<ul style='list-style: none; margin: 5px 0px 0px -10px;'>";
        $indent = 1;
        $open = array(1 => 0);
        $rslt = false;
        foreach ($items as $key => $item) {
            $itemcss = "padding: 5px 0px 5px 0px;";
            switch ($mode) {
                case 'pages':
                    $obj = new ZenpagePage($item['titlelink']);
                    $itemcontent = truncate_string(strip_tags($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 style='margin:6px 0px 0px -10px;'>\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 . "' style='list-style: none; padding: 4px 0px 4px 0px;border-top: 1px dotted gray'>";
            echo "<a href=\"javascript:ZenpageDialog.insert('" . $zenpagepage . "','" . $itemtitlelink . "','" . html_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";
    }
}
Esempio n. 14
0
/**
 * @deprecated
 * @since 1.4.6
 */
function getNewsCategoryPath($category, $page)
{
    deprecated_functions::notify(gettext('Create an object and use the object getLink'));
    $obj = new ZenpageCategory($category);
    return $obj->getLink($page);
}
Esempio n. 15
0
}
if (is_AdminEditPage('newscategory')) {
    $tab = 'news';
    $_GET['tab'] = 'categories';
    if (isset($_GET['save'])) {
        XSRFdefender('save');
        updateCategory($reports, true);
    }
    if (isset($_GET['titlelink'])) {
        $result = new ZenpageCategory(urldecode(sanitize($_GET['titlelink'])));
    } else {
        if (isset($_GET['update'])) {
            XSRFdefender('update');
            $result = updateCategory($reports);
        } else {
            $result = new ZenpageCategory('');
            $result->setShow(1);
        }
    }
}
printAdminHeader($tab, $result->transient ? gettext('add') : gettext('edit'));
zp_apply_filter('texteditor_config', 'zenpage');
zenpageJSCSS();
datepickerJS();
codeblocktabsJS();
?>
<script type="text/javascript">
	//<!-- <![CDATA[
	var deleteArticle = "<?php 
echo gettext("Are you sure you want to delete this article? THIS CANNOT BE UNDONE!");
?>
 /**
  * Checks if user is allowed to access news category
  * @param $hint
  * @param $show
  */
 function checkforGuest(&$hint = NULL, &$show = NULL)
 {
     if (!parent::checkForGuest()) {
         return false;
     }
     $obj = $this;
     $hash = $this->getPassword();
     while (empty($hash) && !is_null($obj)) {
         $parentID = $obj->getParentID();
         if (empty($parentID)) {
             $obj = NULL;
         } else {
             $sql = 'SELECT `titlelink` FROM ' . prefix('news_categories') . ' WHERE `id`=' . $parentID;
             $result = query_single_row($sql);
             $obj = new ZenpageCategory($result['titlelink']);
             $hash = $obj->getPassword();
         }
     }
     if (empty($hash)) {
         // no password required
         return 'zp_public_access';
     } else {
         $authType = "zp_category_auth_" . $this->getID();
         $saved_auth = zp_getCookie($authType);
         if ($saved_auth == $hash) {
             return $authType;
         } else {
             $user = $this->getUser();
             if (!empty($user)) {
                 $show = true;
             }
             $hint = $this->getPasswordHint();
             return false;
         }
     }
 }
Esempio n. 17
0
/**
 * Prints the categories of current article as a unordered html list WITHOUT links
 *
 * @param string $separator A separator to be shown between the category names if you choose to style the list inline
 */
function jqm_printNewsCategories($separator = '', $class = '')
{
    $categories = getNewsCategories();
    $catcount = count($categories);
    if ($catcount != 0) {
        echo "<ul class=\"{$class}\">\n";
        $count = 0;
        foreach ($categories as $cat) {
            $count++;
            $catobj = new ZenpageCategory($cat['titlelink']);
            if ($count >= $catcount) {
                $separator = "";
            }
            echo "<li>" . $catobj->getTitle() . "</li>\n";
        }
        echo "</ul>\n";
    }
}
Esempio n. 18
0
/**
 * Prints a context sensitive menu of all pages as a unordered html list
 *
 * @param string $menuset the menu tree to output
 * @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 $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 $counter TRUE (FALSE default) if you want the count of articles for Zenpage news categories or images/subalbums for albums.
 * @return string
 */
function printCustomMenu($menuset = 'default', $option = 'list', $css_id = '', $css_class_topactive = '', $css_class = '', $css_class_active = '', $showsubs = 0, $counter = false)
{
    global $_zp_zenpage, $_zp_gallery_page, $_zp_current_zenpage_page, $_zp_current_category;
    $itemcounter = '';
    if ($css_id != "") {
        $css_id = " id='" . $css_id . "'";
    }
    if ($showsubs === true) {
        $showsubs = 9999999999;
    }
    $sortorder = getCurrentMenuItem($menuset);
    $items = getMenuItems($menuset, getMenuVisibility());
    if (count($items) == 0) {
        return;
    }
    // nothing to do
    $currentitem_parentid = @$items[$sortorder]['parentid'];
    if ($startlist = !($option == 'omit-top' || $option == 'list-sub')) {
        echo "<ul{$css_id}>";
    }
    $pageid = @$items[$sortorder]['id'];
    $baseindent = max(1, count(explode("-", $sortorder)));
    $indent = 1;
    $open = array($indent => 0);
    $parents = array(NULL);
    $order = explode('-', $sortorder);
    $mylevel = count($order);
    $myparentsort = array_shift($order);
    for ($c = 0; $c <= $mylevel; $c++) {
        $parents[$c] = NULL;
    }
    foreach ($items as $item) {
        $itemarray = getItemTitleAndURL($item);
        $itemURL = $itemarray['url'];
        $itemtitle = $itemarray['title'];
        $level = max(1, count(explode('-', $item['sort_order'])));
        $process = $level <= $showsubs && $option == "list" || ($option == 'list' || $option == 'list-top') && $level == 1 || (($option == 'list' || $option == 'omit-top' && $level > 1) && ($item['id'] == $pageid || $item['parentid'] == $pageid || $level < $mylevel && $level > 1 && strpos($item['sort_order'], $myparentsort) === 0) || $level == $mylevel && $currentitem_parentid == $item['parentid']) || $option == 'list-sub' && $item['parentid'] == $pageid;
        if ($process) {
            if ($level > $indent) {
                echo "\n" . str_pad("\t", $indent, "\t") . "<ul class=\"{$css_class} menu_{$item['type']}\">\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] += $item['include_li'];
            $parents[$indent] = $item['id'];
            if ($counter) {
                switch ($item['type']) {
                    case 'album':
                        $albumobj = newAlbum($item['link']);
                        $numimages = $albumobj->getNumImages();
                        $numsubalbums = $albumobj->getNumAlbums();
                        $itemcounter = ' <span style="white-space:nowrap;"><small>(';
                        if ($numsubalbums != 0) {
                            $itemcounter .= sprintf(ngettext('%u album', '%u albums', $numsubalbums), $numsubalbums);
                        }
                        if ($numimages != 0) {
                            if ($numsubalbums != 0) {
                                $itemcounter .= ' ';
                            }
                            $itemcounter .= sprintf(ngettext('%u image', '%u images', $numimages), $numimages);
                        }
                        $itemcounter .= ')</small></span>';
                        break;
                    case 'zenpagecategory':
                        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) {
                            $published = "all";
                        } else {
                            $published = "published";
                        }
                        $catobj = new ZenpageCategory($item['link']);
                        $catcount = count($catobj->getArticles(0, $published));
                        $itemcounter = "<small> (" . $catcount . ")</small>";
                        break;
                }
            }
            if ($item['id'] == $pageid && !is_null($pageid)) {
                if ($level == 1) {
                    // top level
                    $class = $css_class_topactive;
                } else {
                    $class = $css_class_active;
                }
                echo '<li class="menu_' . trim($item['type'] . ' ' . $class) . '">' . $itemtitle . $itemcounter;
            } else {
                if (strpos($sortorder, $item['sort_order']) === 0) {
                    // we are in the heritage chain
                    $class = ' ' . $css_class_active . '-' . ($mylevel - $level);
                } else {
                    $class = '';
                }
                if ($item['include_li']) {
                    echo '<li class="menu_' . $item['type'] . $class . '">';
                }
                if ($item['span_id'] || $item['span_class']) {
                    echo '<span';
                    if ($item['span_id']) {
                        echo ' id="' . $item['span_id'] . '"';
                    }
                    if ($item['span_class']) {
                        echo ' class="' . $item['span_class'] . '"';
                    }
                    echo '>';
                }
                switch ($item['type']) {
                    case 'html':
                        echo $item['link'];
                        break;
                    case 'menufunction':
                        $i = strpos($itemURL, '(');
                        if ($i) {
                            if (function_exists(trim(substr($itemURL, 0, $i)))) {
                                eval($itemURL);
                            }
                        }
                        break;
                    case 'menulabel':
                        echo $itemtitle;
                        break;
                    default:
                        if (empty($itemURL)) {
                            $itemURL = FULLWEBPATH;
                        }
                        echo '<a href="' . $itemURL . '" title="' . getBare($itemtitle) . '">' . $itemtitle . '</a>' . $itemcounter;
                        break;
                }
                if ($item['span_id'] || $item['span_class']) {
                    echo '</span>';
                }
            }
        }
    }
    // 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";
    }
}
Esempio n. 19
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;
    }
}
/**
 * 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. 21
0
 /**
  *
  * Returns an array of News article IDs belonging to the search categories
  */
 function subsetNewsCategories()
 {
     global $_zp_zenpage;
     if (!is_array($this->category_list)) {
         return false;
     }
     $cat = '';
     $list = $_zp_zenpage->getAllCategories();
     foreach ($list as $category) {
         if (in_array($category['title'], $this->category_list)) {
             $catobj = new ZenpageCategory($category['titlelink']);
             $cat .= ' `cat_id`=' . $catobj->get('id') . ' OR';
             $subcats = $catobj->getSubCategories();
             if ($subcats) {
                 foreach ($subcats as $subcat) {
                     $catobj = new ZenpageCategory($subcat);
                     $cat .= ' `cat_id`=' . $catobj->get('id') . ' OR';
                 }
             }
         }
     }
     $sql = 'SELECT DISTINCT `news_id` FROM ' . prefix('news2cat') . ' WHERE ' . substr($cat, 0, -3);
     $result = query_full_array($sql);
     $list = array();
     foreach ($result as $row) {
         $list[] = $row['news_id'];
     }
     return $list;
 }
Esempio n. 22
0
/**
 * Prints the dropdown menu for the category selector for the news articles list
 *
 */
function printTinyZenpageCategorySelector($currentpage = '')
{
    global $_zp_zenpage;
    $result = $_zp_zenpage->getAllCategories(false);
    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='tinyzenpage.php?zenpage=articles&amp;page=" . $currentpage . "'>" . 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='tinyzenpage.php?zenpage=articles&amp;page=" . $currentpage . "&amp;category=" . $catobj->getTitlelink() . "'>" . $levelmark . $title . $count . "</option>\n";
        }
    }
    ?>
		</select>
		<script type="text/javascript" >
			// <!-- <![CDATA[
			function gotoLink(form) {
				var OptionIndex = form.ListBoxURL.selectedIndex;
				this.location = form.ListBoxURL.options[OptionIndex].value;
			}
			// ]]> -->
		</script>
	</form>
	<br />
	<?php 
}
Esempio n. 23
0
					<?php 
if (count($publish_images_list) > 0) {
    echo sprintf(ngettext('%u album with unpublished images', '%u albums with unpublished images', $c), $c);
} else {
    echo gettext('No images meet the criteria.');
}
?>
				</fieldset>
				<?php 
if (class_exists('Zenpage')) {
    $visible = $report == 'categories';
    $items = $_zp_zenpage->getAllCategories(false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = new ZenpageCategory($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="catcheck" />' . $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('catbox', $visible);
    echo gettext('Categories not published');
    ?>
</legend>
						<?php 
    if ($output) {
Esempio n. 24
0
 function __construct($options)
 {
     $this->options = $options;
     if (isset($this->options['lang'])) {
         $this->locale = $this->options['lang'];
     } else {
         $this->locale = getOption('locale');
     }
     $this->locale_xml = strtr($this->locale, '_', '-');
     if (isset($this->options['sortdir'])) {
         $this->sortdirection = strtolower($this->options['sortdir']) != 'asc';
     } else {
         $this->sortdirection = true;
     }
     if (isset($this->options['sortorder'])) {
         $this->sortorder = $this->options['sortorder'];
     } else {
         $this->sortorder = NULL;
     }
     switch ($this->feedtype) {
         case 'comments':
             if (isset($this->options['type'])) {
                 $this->commentfeedtype = $this->options['type'];
             } else {
                 $this->commentfeedtype = 'all';
             }
             if (isset($this->options['id'])) {
                 $this->id = (int) $this->options['id'];
             }
             break;
         case 'gallery':
             if (isset($this->options['albumsmode'])) {
                 $this->mode = 'albums';
             }
             if (isset($this->options['folder'])) {
                 $this->albumfolder = $this->options['folder'];
                 $this->collection = true;
             } else {
                 if (isset($this->options['albumname'])) {
                     $this->albumfolder = $this->options['albumname'];
                     $this->collection = false;
                 } else {
                     $this->collection = false;
                 }
             }
             if (is_null($this->sortorder)) {
                 if ($this->mode == "albums") {
                     $this->sortorder = getOption($this->feed . "_sortorder_albums");
                 } else {
                     $this->sortorder = getOption($this->feed . "_sortorder");
                 }
             }
             break;
         case 'news':
             if ($this->sortorder == 'latest') {
                 $this->sortorder = NULL;
             }
             if (isset($this->options['category'])) {
                 $this->catlink = $this->options['category'];
                 $catobj = new ZenpageCategory($this->catlink);
                 $this->cattitle = $catobj->getTitle();
                 $this->newsoption = 'category';
             } else {
                 $this->catlink = '';
                 $this->cattitle = '';
                 $this->newsoption = 'news';
             }
             break;
         case 'pages':
             break;
         case 'null':
             //we just want the class instantiated
             return;
     }
     if (isset($this->options['itemnumber'])) {
         $this->itemnumber = (int) $this->options['itemnumber'];
     } else {
         $this->itemnumber = getOption($this->feed . '_items');
     }
 }
Esempio n. 25
0
/**
 * Returns the News category title or catlink (name) or the mode (all news or category only) for the Zenpage news feed.
 *
 * @param string $arrayfield "catlink", "catttitle" or "option"
 * @return string
 */
function getRSSNewsCatOptions($arrayfield)
{
    $arrayfield = sanitize($arrayfield);
    if (!empty($arrayfield)) {
        if (isset($_GET['category'])) {
            $catlink = sanitize($_GET['category']);
            $catobj = new ZenpageCategory($catlink);
            $cattitle = html_encode($catobj->getTitle());
            $option = "category";
        } else {
            $catlink = "";
            $cattitle = "";
            $option = "news";
        }
        $array = array("catlink" => $catlink, "cattitle" => $cattitle, "option" => $option);
        return $array[$arrayfield];
    }
}
/**
* 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 
}
Esempio n. 27
0
/**
 * Checks if there is a layout inherited from a parent items (album, page or category) and returns it. Returns false otherwise.
 *
 * @param object $obj the object being selected
 * @param string $type For Zenphoto gallery items "multiple_layouts_albums"
 * 										 For Zenpage CMS items , "multiple_layouts_pages", , "multiple_layouts_news" , "multiple_layouts_news_categories"
 * @return result
 */
function checkParentLayouts($obj, $type)
{
    $parents = array();
    switch ($type) {
        case 'multiple_layouts_images':
            $type = 'multiple_layouts_albums_images';
            $obj = $obj->getAlbum();
            array_unshift($parents, $obj);
        case 'multiple_layouts_albums':
        case 'multiple_layouts_albums_images':
            while (!is_null($obj = $obj->getParent())) {
                array_unshift($parents, $obj);
            }
            if (count($parents) > 0) {
                $parents = array_reverse($parents);
                //reverse so we can check the direct parent first.
                foreach ($parents as $parentobj) {
                    $parentlayouts = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux`=' . $parentobj->getID() . ' AND `type` = "' . $type . '"');
                    if ($parentlayouts && $parentlayouts['data']) {
                        return $parentlayouts;
                    }
                }
            }
            break;
        case 'multiple_layouts_pages':
        case 'multiple_layouts_news_categories':
            $parents = $obj->getParents();
            if (count($parents) > 0) {
                $parents = array_reverse($parents);
                //reverse so we can check the direct parent first.
                foreach ($parents as $parent) {
                    if ($type === 'multiple_layouts_pages') {
                        $parentobj = new ZenpagePage($parent);
                    } else {
                        $parentobj = new ZenpageCategory($parent);
                    }
                    $parentlayouts = query_single_row('SELECT * FROM ' . prefix('plugin_storage') . ' WHERE `aux`=' . $parentobj->getID() . ' AND `type` = "' . $type . '"');
                    if ($parentlayouts && $parentlayouts['data']) {
                        return $parentlayouts;
                    }
                }
            }
            break;
    }
    return false;
}
Esempio n. 28
0
        ?>
" />
	<?php 
    }
} else {
    echo "<div style='text-align: left; width 450px; font-size:0.8em'>";
    if (isset($_GET['news'])) {
        $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;
Esempio n. 29
0
 /**
  * Gets all categories
  * @param bool $visible TRUE for published and unprotected
  * @param string $sorttype NULL for the standard order as sorted on the backend, "title", "id", "popular", "random"
  * @param bool $sortdirection TRUE for ascending or FALSE for descending order
  * @return array
  */
 function getAllCategories($visible = true, $sorttype = NULL, $sortdirection = NULL)
 {
     $structure = $this->getCategoryStructure();
     if (is_null($sortdirection)) {
         $sortdirection = $this->sortdirection;
     }
     switch ($sorttype) {
         case "id":
             $sortorder = "id";
             break;
         case "title":
             $sortorder = "title";
             break;
         case "popular":
             $sortorder = 'hitcounter';
             break;
         case "random":
             $sortorder = 'random';
             break;
         default:
             $sortorder = "sort_order";
             break;
     }
     if ($visible) {
         foreach ($structure as $key => $cat) {
             $catobj = new ZenpageCategory($cat['titlelink']);
             if ($catobj->getShow() || $catobj->isMyItem(LIST_RIGHTS)) {
                 $structure[$key]['show'] = 1;
             } else {
                 unset($structure[$key]);
             }
         }
     }
     if (!is_null($sorttype) || !is_null($sortdirection)) {
         if ($sorttype == 'random') {
             shuffle($structure);
         } else {
             //sortMultiArray descending = true
             if ($sortdirection) {
                 $sortdir = false;
             } else {
                 $sortdir = true;
             }
             $structure = sortMultiArray($structure, $sortorder, $sortdir, true, false, false);
         }
     }
     return $structure;
 }
 /**
  * Gets news articles titlelinks this category is attached to
  *
  * NOTE: Since this function only returns titlelinks for use with the object model it does not exclude articles that are password protected via a category
  *
  *
  * @param int $articles_per_page The number of articles to get
  * @param string $published "published" for published articles
  *													"published-unpublished" for published articles only from an unpublished category,
  * 													"unpublished" for unpublished articles,
  * 													"sticky" for sticky articles (published or not!) for Admin page use only,
  * 													"all" for all articles
  * @param boolean $ignorepagination Since also used for the news loop this function automatically paginates the results if the "page" GET variable is set. To avoid this behaviour if using it directly to get articles set this TRUE (default FALSE)
  * @param string $sortorder "date" for sorting by date (default)
  * 													"title" for sorting by title
  * 													This parameter is not used for date archives
  * @param string $sortdirection "desc" (default) for descending sort order
  * 													    "asc" for ascending sort order
  * 											        This parameter is not used for date archives
  * @param bool $sticky set to true to place "sticky" articles at the front of the list.
  * @return array
  */
 function getArticles($articles_per_page = '', $published = NULL, $ignorepagination = false, $sortorder = "date", $sortdirection = "desc", $sticky = true)
 {
     global $_zp_current_category, $_zp_post_date, $_zp_zenpage;
     $_zp_zenpage->processExpired('news');
     if (empty($published)) {
         $published = "published";
         if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | VIEW_NEWS_RIGHTS)) {
             $published = "all";
         }
     }
     $show = "";
     // new code to get nested cats
     $catid = $this->getID();
     $subcats = $this->getSubCategories();
     if ($subcats) {
         $cat = " (cat.cat_id = '" . $catid . "'";
         foreach ($subcats as $subcat) {
             $subcatobj = new ZenpageCategory($subcat);
             $cat .= "OR cat.cat_id = '" . $subcatobj->getID() . "' ";
         }
         $cat .= ") AND cat.news_id = news.id ";
     } else {
         $cat = " cat.cat_id = '" . $catid . "' AND cat.news_id = news.id ";
     }
     if (in_context(ZP_ZENPAGE_NEWS_DATE)) {
         $postdate = $_zp_post_date;
     } else {
         $postdate = NULL;
     }
     if ($sticky) {
         $sticky = 'sticky DESC,';
     }
     // sortorder and sortdirection
     switch ($sortorder) {
         case "date":
         default:
             $sort1 = "date";
             break;
         case "title":
             $sort1 = "title";
             break;
     }
     switch ($sortdirection) {
         case "desc":
         default:
             $dir = "DESC";
             break;
         case "asc":
             $dir = "ASC";
             $sticky = false;
             //makes no sense
             break;
     }
     /*** get articles by category ***/
     switch ($published) {
         case "published":
             $show = " AND `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = false;
             break;
         case "published-unpublished":
             $show = " AND `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = true;
             break;
         case "unpublished":
             $show = " AND `show` = 0 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = true;
             break;
         case 'sticky':
             $show = ' AND `sticky` <> 0';
             $getUnpublished = true;
             break;
         case "all":
             $getUnpublished = true;
             $show = "";
             break;
     }
     $order = " ORDER BY " . $sticky . "news.{$sort1} {$dir}";
     $sql = "SELECT DISTINCT news.titlelink FROM " . prefix('news') . " as news, " . prefix('news2cat') . " as cat WHERE" . $cat . $show . $order;
     $resource = $result = query($sql);
     if ($resource) {
         if ($ignorepagination) {
             $offset = 0;
         } else {
             $offset = $_zp_zenpage->getOffset($articles_per_page);
         }
         if (is_object($_zp_current_category)) {
             $currentcategory = $_zp_current_category->getTitlelink();
         } else {
             $currentcategory = false;
         }
         $result = array();
         while ($item = db_fetch_assoc($resource)) {
             $article = new ZenpageNews($item['titlelink']);
             if ($getUnpublished || $currentcategory && $article->inNewsCategory($currentcategory) || $article->categoryIsVisible()) {
                 $offset--;
                 if ($offset < 0) {
                     $result[] = $item;
                     if ($articles_per_page && count($result) >= $articles_per_page) {
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }