/**
 * 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)
{
    $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 && $itemarray['valid']) {
            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 'category':
                        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) {
                            $published = "all";
                        } else {
                            $published = "published";
                        }
                        $catobj = newCategory($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="' . html_encode(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";
    }
}
Exemple #2
0
            $published = 'published';
            break;
        case 'sticky':
            $published = 'sticky';
    }
} else {
    $published = 'all';
}
$sortorder = 'publishdate';
$direction = true;
if (isset($_GET['sortorder'])) {
    list($sortorder, $sortdirection) = explode('-', $_GET['sortorder']);
    $direction = $sortdirection && $sortdirection == 'desc';
}
if (isset($_GET['category'])) {
    $catobj = newCategory(sanitize($_GET['category']));
} else {
    $catobj = NULL;
}
$resultU = $_zp_CMS->getArticles(0, 'unpublished', false, $sortorder, $direction, false, $catobj);
$result = $_zp_CMS->getArticles(0, $published, false, $sortorder, $direction, false, $catobj);
foreach ($result as $key => $article) {
    $article = newArticle($article['titlelink']);
    if (!$article->isMyItem(ZENPAGE_NEWS_RIGHTS) || $cur_author && $cur_author != $article->getAuthor()) {
        unset($result[$key]);
    }
}
foreach ($resultU as $key => $article) {
    $article = newArticle($article['titlelink']);
    if (!$article->isMyItem(ZENPAGE_NEWS_RIGHTS) || $cur_author && $cur_author != $article->getAuthor()) {
        unset($resultU[$key]);
					<?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('CMS')) {
    $visible = $report == 'categories';
    $items = $_zp_CMS->getAllCategories(false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = newCategory($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="catcheck" />' . $itemobj->getTitle() . '</label>';
            if ($desc = shortenContent($itemobj->getDesc(), 50, '...')) {
                $output .= ' "' . strip_tags($desc) . '"';
            }
            $output .= ' <a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '">(' . gettext('View') . ')</a> <a href="' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-edit.php?newscategory&titlelink=' . html_encode($itemobj->getTitlelink()) . '">(' . gettext('Edit') . ')</a></li>';
        }
    }
    ?>
					<br class="clearall" />
					<fieldset class="smallbox">
						<legend><?php 
    if ($c > 0) {
        reveal('catbox', $visible);
Exemple #4
0
        // an image type object
    } else {
        // a simple link
        $args['album'] = $args['image'] = $imagef = $imageb = $image = $alt1 = $title1 = NULL;
        if (isset($args['news'])) {
            $obj = newArticle($args['news']);
            $title = gettext('<em>news article</em>: %s');
            $token = gettext('title with link to news article');
        }
        if (isset($args['pages'])) {
            $obj = newPage($args['pages']);
            $title = gettext('<em>page</em>: %s');
            $token = gettext('title with link to page');
        }
        if (isset($args['news_categories'])) {
            $obj = newCategory($args['news_categories']);
            $title = gettext('<em>category</em>: %s');
            $token = gettext('title with link to category');
        }
    }
    $link = $obj->getLink();
    $title1 = getBare($obj->getTitle());
    if ($image && $obj->table == 'images') {
        $link2 = $obj->album->getLink();
    } else {
        $link2 = $alt2 = $title2 = false;
    }
    ?>
			<script type="text/javascript">
				// <!-- <![CDATA[
				var link = '<?php 
/**
 * Gets links to Zenpage news categories incl. pagination
 *
 * @return string
 */
function getSitemapNewsCategories()
{
    global $_zp_CMS, $sitemap_number;
    //TODO not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_newscats');
        $newscats = $_zp_CMS->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 = newCategory($newscat['titlelink']);
                if (!$catobj->isProtected()) {
                    $base = $catobj->getLink();
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = str_replace(WEBPATH, seo_locale::localePath(true, $locale), $base);
                                $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 = dynamic_locale::fullHostPath($locale) . $base;
                                $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 = FULLHOSTPATH . $base;
                            $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
                    $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++) {
                            $base = $catobj->getLink($x);
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = str_replace(WEBPATH, seo_locale::localePath(true, $locale), $base);
                                        $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 = dynamic_locale::fullHostPath($locale) . $base;
                                        $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 = FULLHOSTPATH . $base;
                                    $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;
    }
}
 /**
  * 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 = newArticle($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 = newCategory($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->getPublishDate()));
     return $feeditem;
 }
    }
}
if (isset($_GET['delete'])) {
    XSRFdefender('delete_category');
    $reports[] = deleteZenpageObj(newCategory(sanitize($_GET['delete'])));
}
if (isset($_GET['hitcounter'])) {
    XSRFdefender('hitcounter');
    $x = $_zp_CMS->getCategory(sanitize_numeric($_GET['id']));
    $obj = newCategory($x['titlelink']);
    $obj->set('hitcounter', 0);
    $obj->save();
}
if (isset($_GET['publish'])) {
    XSRFdefender('update');
    $obj = newCategory(sanitize($_GET['titlelink']));
    $obj->setShow(sanitize_numeric($_GET['publish']));
    $obj->save();
}
if (isset($_GET['save'])) {
    XSRFdefender('save_categories');
    updateCategory($reports, true);
}
/*
 * Here we should restart if any action processing has occurred to be sure that everything is
 * in its proper state. But that would require significant rewrite of the handling and
 * reporting code so is impractical. Instead we will presume that all that needs to be restarted
 * is the CMS object.
 */
$_zp_CMS = new CMS();
printAdminHeader('news', 'categories');
Exemple #8
0
    {
        $locallist = $obj->getAlbums();
        foreach ($locallist as $folder) {
            $album = newAlbum($folder);
            if (!$album->isDynamic() && $album->checkAccess()) {
                $albumlist[] = $album->getID();
                self::getAllAccessibleAlbums($album, $albumlist);
            }
        }
    }
}
global $plugin_is_filter;
enableExtension('galleryArticles', $plugin_is_filter);
$obj = new Combi();
$combi = $obj->getOldCombiNews();
$cat = newCategory('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(array('folder' => $article['albumname'], 'filename' => $article['titlelink']), false);
            break;
        case 'albums':
            $obj = newAlbum($article['albumname'], false);
            break;
        default:
            $obj = NULL;
            break;
    }
Exemple #9
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 = newArticle($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 = newCategory($cat['titlelink']);
         $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', ';
     }
     $categories = rtrim($categories, ', ');
     $feeditem['desc'] = shortenContent($obj->getContent($this->locale), getOption('RSS_truncate_length'), '...');
     if (!empty($categories)) {
         $feeditem['category'] = html_encode($categories);
         $feeditem['title'] = $title . ' (' . $categories . ')';
     }
     $feeditem['link'] = PROTOCOL . '://' . $this->host . $link;
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     $feeditem['pubdate'] = date("r", strtotime($item['date']));
     return $feeditem;
 }
/**
 * 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 = newCategory(rtrim($query['category'], '/'), false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['category']);
                } else {
                    if (isset($query['date'])) {
                        $redirectURL = _NEWS_ARCHIVE_ . '/' . rtrim($query['date'], '/') . '/';
                        unset($query['date']);
                    }
                }
                if (isset($query['title'])) {
                    $obj = newArticle(rtrim($query['title'], '/'), false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'pages':
                if (isset($query['title'])) {
                    $obj = newPage(rtrim($query['title'], '/'), false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'search':
                $redirectURL = _SEARCH_;
                if (isset($query['date'])) {
                    $redirectURL = _ARCHIVE_ . '/' . rtrim($query['date'], '/') . '/';
                    unset($query['date']);
                } else {
                    if (isset($query['searchfields']) && $query['searchfields'] == 'tags') {
                        $redirectURL = _TAGS_;
                        unset($query['searchfields']);
                    }
                }
                if (isset($query['words'])) {
                    if (!preg_match('/^[0-9A-F]+\\.[0-9A-F]+$/i', $query['words'])) {
                        $query['words'] = SearchEngine::encode($query['words']);
                    }
                    $redirectURL .= '/' . $query['words'] . '/';
                    unset($query['words']);
                }
                break;
            default:
                $redirectURL = getCustomPageURL(rtrim($query['p'], '/'));
                break;
        }
        unset($query['p']);
        if (isset($query['page'])) {
            $redirectURL = rtrim($redirectURL, '/') . '/' . rtrim($query['page'], '/');
            unset($query['page']);
        }
    } else {
        if (isset($query['album'])) {
            if (isset($query['image'])) {
                $obj = newImage(array('folder' => $query['album'], 'filename' => $query['image']), NULL, true);
                unset($query['image']);
            } else {
                $obj = newAlbum($query['album'], NULL, true);
            }
            if (is_object($obj) && !$obj->exists) {
                return '';
            }
            unset($query['album']);
            $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $obj->getLink(@$query['page']));
            unset($query['page']);
        } else {
            if (isset($query['page'])) {
                //index page
                $redirectURL = _PAGE_ . '/' . rtrim($query['page'], '/');
                unset($query['page']);
            }
        }
    }
    if ($redirectURL && !empty($query)) {
        $redirectURL .= '?' . http_build_query($query);
    }
    return $redirectURL;
}
Exemple #11
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 = newCategory($cat['titlelink']);
             $parentid = $catobj->getParentID();
             $parentcats = $catobj->getParents();
             foreach ($parentcats as $parentcat) {
                 if ($catlink == $parentcat) {
                     $count = 1;
                     break;
                 }
             }
         }
         return $count == 1;
     } else {
         return false;
     }
 }
/**
* Prints all available articles or categories in Zenpage
*
* @param string $current

 set to category selected (if any)
*
* @return string
*/
function printNewsCategorySelector($current)
{
    global $_zp_gallery, $_zp_CMS;
    ?>
	<select id="categoryselector" name="categoryselect">
		<?php 
    $cats = $_zp_CMS->getAllCategories(false);
    foreach ($cats as $cat) {
        if ($cat['titlelink'] == $current) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        $catobj = newCategory($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 
}
/**
 * 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_CMS;
    switch ($option) {
        case "news":
            $items = $_zp_CMS->getArticles();
            $type = gettext("Articles");
            break;
        case "pages":
            $items = $_zp_CMS->getPages(false);
            $type = gettext("Pages");
            break;
        case "categories":
            $type = gettext("Categories");
            $items = $_zp_CMS->getAllCategories(false);
            break;
    }
    $total = count($items);
    $pub = 0;
    foreach ($items as $item) {
        switch ($option) {
            case "news":
                $itemobj = newArticle($item['titlelink']);
                break;
            case "pages":
                $itemobj = newPage($item['titlelink']);
                break;
            case "categories":
                $itemobj = newCategory($item['titlelink']);
                break;
        }
        if ($itemobj->getShow() == 1) {
            $pub++;
        }
    }
    $unpub = $total - $pub;
    return array($total, $type, $unpub);
}
/**
 * Worker function for creating layout selectors. Returns the HTML
 *
 * @param object $obj
 * @param string $type
 * @param string $text
 * @param string$secondary
 */
function getLayoutSelector($obj, $type, $text, $prefix = '', $secondary = false)
{
    global $_zp_gallery;
    $selectdefault = '';
    $selected = '';
    $files = array();
    $list = array();
    $getlayout = '';
    $table = $obj->table;
    $path = SERVERPATH . '/' . THEMEFOLDER . '/' . $_zp_gallery->getCurrentTheme() . '/';
    $defaultlayout = '';
    $defaulttext = gettext('default');
    switch ($table) {
        case 'albums':
            if ($secondary) {
                //	the selector for the image default of the album
                $filesmask = 'image';
            } else {
                $filesmask = 'album';
            }
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            break;
        case 'images':
            $filesmask = 'image';
            $album = $obj->album;
            $child = $album->getID();
            $defaulttext = gettext('album default');
            break;
        case 'pages':
            $filesmask = 'pages';
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            break;
        case 'news':
            $child = false;
            $categories = $obj->getCategories();
            if ($categories) {
                foreach ($categories as $cat) {
                    $cat = newCategory($cat['titlelink']);
                    $getlayout = getSelectedLayout($cat, 'multiple_layouts_news_categories');
                    if ($getlayout && $getlayout['data']) {
                        //	in at least one news category with an alternate page
                        $defaulttext = gettext('inherited');
                        $defaultlayout = gettext('from category');
                        break;
                    }
                }
            }
            $filesmask = 'news';
            break;
        case 'news_categories':
            $child = $obj->getParentID();
            $defaulttext = gettext('inherited');
            $filesmask = 'news';
            break;
    }
    $curdir = getcwd();
    chdir($path);
    $files = safe_glob($filesmask . '*.php');
    chdir($curdir);
    if ($child) {
        $defaultlayout = checkParentLayouts($obj, $type);
        $defaultlayout = $defaultlayout['data'];
    }
    if ($defaultlayout) {
        $defaultlayout = stripSuffix($defaultlayout);
    } else {
        $defaultlayout = $filesmask;
    }
    if ($obj->transient) {
        $getlayout = false;
    } else {
        $getlayout = query_single_row("SELECT * FROM " . prefix('plugin_storage') . ' WHERE `aux` = ' . $obj->getID() . ' AND `type` = "' . $type . '"');
    }
    if (!$child && ($key = array_search($filesmask . '.php', $files)) !== false) {
        unset($files[$key]);
    }
    foreach ($files as $file) {
        $file = filesystemToInternal($file);
        $list[stripSuffix($file)] = $file;
    }
    ksort($list);
    $html = $text;
    if (count($files) != 0) {
        $html .= '<select id="' . $type . $prefix . '" name="' . $prefix . $type . '">' . "\n";
        if (is_array($getlayout)) {
            $selectedlayout = $getlayout['data'];
        } else {
            $selectedlayout = '';
        }
        $html .= '<option value=""' . ($selectedlayout == '' ? ' selected="selected"' : '') . ' style="background-color:LightGray" >*' . $defaulttext . '* (' . $defaultlayout . ')</option>' . "\n";
        foreach ($list as $display => $file) {
            $html .= '<option value="' . html_encode($file) . '"' . ($selectedlayout == $file ? ' selected="selected"' : '') . '>' . $display . '</option>' . "\n";
        }
        $html .= '</select>' . "\n";
    } else {
        $html = '<p class="no_extra">' . sprintf(gettext('No extra <em>%s</em> theme pages available'), $filesmask) . '</p>' . "\n";
    }
    return $html;
}
 /**
  * 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 = newCategory($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;
         }
     }
 }
     $category_obj->setVar('cat_url', @$_POST['cat_url']);
     $cat_isNew = $category_obj->isNew();
     if (!$category_handler->insert($category_obj)) {
         $message = _AM_NEWBB_DATABASEERROR;
     }
     if ($cat_id = $category_obj->getVar("cat_id") && $cat_isNew) {
         $category_handler->applyPermissionTemplate($category_obj);
     }
     redirect_header("admin_cat_manager.php", 2, $message);
     exit;
 default:
     if (!($categories = $category_handler->getByPermission("all"))) {
         loadModuleAdminMenu(1, _AM_NEWBB_CREATENEWCATEGORY);
         echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_CREATENEWCATEGORY . "</legend>";
         echo "<br />";
         newCategory();
         echo "</fieldset>";
         break;
     }
     loadModuleAdminMenu(1, _AM_NEWBB_CATADMIN);
     echo "<fieldset><legend style='font-weight: bold; color: #900;'>" . _AM_NEWBB_CATADMIN . "</legend>";
     echo "<br />";
     echo "<a style='border: 1px solid #5E5D63; color: #000000; font-family: verdana, tahoma, arial, helvetica, sans-serif; font-size: 1em; padding: 4px 8px; text-align:center;' href='admin_cat_manager.php?op=mod'>" . _AM_NEWBB_CREATENEWCATEGORY . "</a><br /><br />";
     echo "<table border='0' cellpadding='4' cellspacing='1' width='100%' class='outer'>";
     echo "<tr align='center'>";
     echo "<td class='bg3'>" . _AM_NEWBB_CATEGORY1 . "</td>";
     echo "<td class='bg3' width='10%'>" . _AM_NEWBB_EDIT . "</td>";
     echo "<td class='bg3' width='10%'>" . _AM_NEWBB_DELETE . "</td>";
     echo "</tr>";
     foreach ($categories as $key => $onecat) {
         $cat_edit_link = "<a href=\"admin_cat_manager.php?op=mod&cat_id=" . $onecat->getVar('cat_id') . "\">" . newbb_displayImage('admin_edit', _EDIT) . "</a>";
/**
 * 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_page, $_zp_current_category, $_zp_current_search;
    if (in_context(ZP_SEARCH_LINKED)) {
        $page = $_zp_current_search->page;
        $searchwords = $_zp_current_search->getSearchWords();
        $searchdate = $_zp_current_search->getSearchDate();
        $searchfields = $_zp_current_search->getSearchFields(true);
        if (is_NewsCategory()) {
            $search_obj_list = array('news' => $_zp_current_search->getCategoryList());
        } else {
            $search_obj_list = NULL;
        }
        $searchpagepath = getSearchURL($searchwords, $searchdate, $searchfields, $page, $search_obj_list);
        if (empty($searchdate)) {
            $title = gettext("Return to search");
            $text = gettext("Search");
        } else {
            $title = gettext("Return to archive");
            $text = gettext("Archive");
        }
        if ($before) {
            echo '<span class="beforetext">' . html_encode($before) . '</span>';
        }
        echo "<a href='" . $searchpagepath . "' title='" . html_encode($title) . "'>" . html_encode($text) . "</a>";
        if ($after) {
            echo '<span class="aftertext">' . html_encode($after) . '</span>';
        }
    } else {
        if (is_Pages()) {
            //$parentid = $_zp_current_page->getParentID();
            $parentitems = $_zp_current_page->getParents();
        } else {
            if (is_NewsCategory()) {
                //$parentid = $_zp_current_category->getParentID();
                $parentitems = $_zp_current_category->getParents();
            } else {
                $parentitems = array();
            }
        }
        foreach ($parentitems as $item) {
            if (is_Pages()) {
                $pageobj = newPage($item);
                $parentitemurl = $pageobj->getLink();
                $parentitemtitle = $pageobj->getTitle();
            }
            if (is_NewsCategory()) {
                $catobj = newCategory($item);
                $parentitemurl = $catobj->getLink();
                $parentitemtitle = $catobj->getTitle();
            }
            if ($before) {
                echo '<span class="beforetext">' . html_encode($before) . '</span>';
            }
            echo "<a href='" . html_encode($parentitemurl) . "'>" . html_encode($parentitemtitle) . "</a>";
            if ($after) {
                echo '<span class="aftertext">' . html_encode($after) . '</span>';
            }
        }
    }
}
        $snippet = substr($snippet, 0, -2);
    }
}
$properties = $modx->db->escape($_POST['properties']);
$moduleguid = $modx->db->escape($_POST['moduleguid']);
$sysevents = $_POST['sysevents'];
//Kyle Jaebker - added category support
if (empty($_POST['newcategory']) && $_POST['categoryid'] > 0) {
    $categoryid = intval($_POST['categoryid']);
} elseif (empty($_POST['newcategory']) && $_POST['categoryid'] <= 0) {
    $categoryid = 0;
} else {
    include_once MODX_MANAGER_PATH . 'includes/categories.inc.php';
    $categoryid = checkCategory($_POST['newcategory']);
    if (!$categoryid) {
        $categoryid = newCategory($_POST['newcategory']);
    }
}
if ($name == "") {
    $name = "Untitled snippet";
}
switch ($_POST['mode']) {
    case '23':
        // Save new snippet
        // invoke OnBeforeSnipFormSave event
        $modx->invokeEvent("OnBeforeSnipFormSave", array("mode" => "new", "id" => $id));
        // disallow duplicate names for new snippets
        $rs = $modx->db->select('COUNT(id)', $modx->getFullTableName('site_snippets'), "name='{$name}'");
        $count = $modx->db->getValue($rs);
        if ($count > 0) {
            $modx->manager->saveFormValues(23);
Exemple #19
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;
     }
     $all = zp_loggedin(MANAGE_ALL_NEWS_RIGHTS);
     if (array_key_exists($key = $sortorder . (int) $sortdirection . (bool) $visible . (bool) $all, $this->categoryCache)) {
         return $this->categoryCache[$key];
     } else {
         if ($visible) {
             foreach ($structure as $key => $cat) {
                 $catobj = newCategory($cat['titlelink']);
                 if ($all || $catobj->getShow() || $catobj->subRights()) {
                     $structure[$key]['show'] = 1;
                 } else {
                     unset($structure[$key]);
                 }
             }
         }
         if (!is_null($sorttype) || !is_null($sortdirection)) {
             if ($sorttype == 'random') {
                 shuffle($structure);
             } else {
                 $structure = sortMultiArray($structure, $sortorder, !$sortdirection, true, false, false);
             }
         }
         $this->categoryCache[$key] = $structure;
         return $structure;
     }
 }