/** * Checks if a category is protected and returns TRUE or FALSE * NOTE: This function does only check if a password is set not if it has been entered! Use checkNewsCategoryPassword() for that. * * @param string $catlink The optional categorylink of a category, if empty the current category is checked if available * @return bool * @deprecated */ function isProtectedNewsCategory($catlink = '') { deprecated_function_notify(gettext('Use instead the Zenpage category class method isProtected().'), E_USER_NOTICE); global $_zp_current_category; if (empty($catlink) && !is_null($_zp_current_category)) { $cat = $_zp_current_category; } else { $cat = new ZenpageCategory($catlink); } return $cat->isProtected(); }
/** * 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&category=' . urlencode($catobj->getTitlelink()) . '&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&category=' . urlencode($catobj->getTitlelink()) . '&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&category=' . urlencode($catobj->getTitlelink()) . '&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&category=' . urlencode($catobj->getTitlelink()) . '&page=' . $x, FULLWEBPATH); $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>"); break; } } } } } $data .= sitemap_echonl('</urlset>'); // End off the <urlset> tag } return $data; } }
/** * Prints the checkboxes to select and/or show the category of an news article on the edit or add page * * @param int $id ID of the news article if the categories an existing articles is assigned to shall be shown, empty if this is a new article to be added. * @param string $option "all" to show all categories if creating a new article without categories assigned, empty if editing an existing article that already has categories assigned. */ function printCategorySelection($id = '', $option = '') { $selected = ''; echo "<ul class='zenpagechecklist'>\n"; foreach ($all_cats as $cats) { $catobj = new ZenpageCategory($cats['titlelink']); if ($option != "all") { $cat2news = query_single_row("SELECT cat_id FROM " . prefix('news2cat') . " WHERE news_id = " . $id . " AND cat_id = " . $catobj->getID()); if ($cat2news['cat_id'] != "") { $selected = "checked ='checked'"; } } $catname = $catobj->getTitle(); $catlink = $catobj->getTitlelink(); if ($catobj->isProtected() && GALLERY_SECURITY != 'private') { $protected = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/lock.png" alt="' . gettext('password protected') . '" />'; } else { $protected = ''; } $catid = $catobj->getID(); echo "<li class=\"hasimage\" ><label for='cat" . $catid . "'><input name='cat" . $catid . "' id='cat" . $catid . "' type='checkbox' value='" . $catid . "' " . $selected . " />" . $catname . " " . $protected . "</label></li>\n"; } echo "</ul>\n"; }
/** * Prints a context sensitive menu of all pages as a unordered html list * * @param string $option The mode for the menu: * "list" context sensitive toplevel plus sublevel pages, * "list-top" only top level pages, * "omit-top" only sub level pages * "list-sub" lists only the current pages direct offspring * @param string $mode 'pages' or 'categories' * @param bool $counter Only $mode = 'categories': Count the articles in each category * @param string $css_id CSS id of the top level list * @param string $css_class_topactive class of the active item in the top level list * @param string $css_class CSS class of the sub level list(s) * @param string $$css_class_active CSS class of the sub level list(s) * @param string $indexname insert the name (default "Gallery Index") how you want to call the link to the gallery index, insert "" (default) if you don't use it, it is not printed then. * @param int $showsubs Set to depth of sublevels that should be shown always. 0 by default. To show all, set to a true! Only valid if option=="list". * @param bool $startlist set to true to output the UL tab (false automatically if you use 'omit-top' or 'list-sub') * @param int $limit truncation limit display strings * @return string */ function printNestedMenu($option = 'list', $mode = NULL, $counter = TRUE, $css_id = NULL, $css_class_topactive = NULL, $css_class = NULL, $css_class_active = NULL, $indexname = NULL, $showsubs = 0, $startlist = true, $limit = NULL) { global $_zp_zenpage, $_zp_gallery_page, $_zp_current_zenpage_news, $_zp_current_zenpage_page, $_zp_current_category; if (is_null($limit)) { $limit = MENU_TRUNCATE_STRING; } if (is_null($css_id)) { switch ($mode) { case 'pages': $css_id = 'menu_pages'; break; case 'categories': case 'allcategories': $css_id = 'menu_categories'; break; } } if (is_null($css_class_topactive)) { $css_class_topactive = 'menu_topactive'; } if (is_null($css_class)) { $css_class = 'submenu'; } if (is_null($css_class_active)) { $css_class_active = 'menu-active'; } if ($showsubs === true) { $showsubs = 9999999999; } switch ($mode) { case 'pages': $items = $_zp_zenpage->getPages(); $currentitem_id = getPageID(); if (is_object($_zp_current_zenpage_page)) { $currentitem_parentid = $_zp_current_zenpage_page->getParentID(); } else { $currentitem_parentid = NULL; } $currentitem_sortorder = getPageSortorder(); break; case 'categories': case 'allcategories': $items = $_zp_zenpage->getAllCategories(); if (is_object($_zp_current_category) && $mode == 'categories') { $currentitem_sortorder = $_zp_current_category->getSortOrder(); $currentitem_id = $_zp_current_category->getID(); $currentitem_parentid = $_zp_current_category->getParentID(); } else { $currentitem_sortorder = NULL; $currentitem_id = NULL; $currentitem_parentid = NULL; } break; } // don't highlight current pages or foldout if in search mode as next_page() sets page context if (in_context(ZP_SEARCH) && $mode == 'pages') { // categories are not searched $css_class_topactive = ""; $css_class_active = ""; rem_context(ZP_ZENPAGE_PAGE); } if (0 == count($items) + (int) ($mode == 'allcategories')) { return; } // nothing to do $startlist = $startlist && !($option == 'omit-top' || $option == 'list-sub'); if ($startlist) { echo '<ul id="' . $css_id . '">'; } // if index link and if if with count if (!empty($indexname)) { if ($limit) { $display = shortenContent($indexname, $limit, MENU_TRUNCATE_INDICATOR); } else { $display = $indexname; } switch ($mode) { case 'pages': if ($_zp_gallery_page == "index.php") { echo '<li class="' . $css_class_topactive . '">' . html_encode($display) . '</li>'; } else { echo "<li><a href='" . html_encode(getGalleryIndexURL()) . "' title='" . html_encode($indexname) . "'>" . html_encode($display) . "</a></li>"; } break; case 'categories': case 'allcategories': if ($_zp_gallery_page == "news.php" && !is_NewsCategory() && !is_NewsArchive() && !is_NewsArticle()) { echo '<li class="' . $css_class_topactive . '">' . html_encode($display); } else { echo "<li><a href=\"" . html_encode(getNewsIndexURL()) . "\" title=\"" . html_encode($indexname) . "\">" . html_encode($display) . "</a>"; } if ($counter) { if (in_context(ZP_ZENPAGE_NEWS_CATEGORY) && $mode == 'categories') { $totalcount = count($_zp_current_category->getArticles(0)); } else { save_context(); rem_context(ZP_ZENPAGE_NEWS_DATE); $totalcount = count($_zp_zenpage->getArticles(0)); restore_context(); } echo ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $totalcount), $totalcount) . ')</small></span>'; } echo "</li>\n"; break; } } $baseindent = max(1, count(explode("-", $currentitem_sortorder))); $indent = 1; $open = array($indent => 0); $parents = array(NULL); $order = explode('-', $currentitem_sortorder); $mylevel = count($order); $myparentsort = array_shift($order); for ($c = 0; $c <= $mylevel; $c++) { $parents[$c] = NULL; } foreach ($items as $item) { $password_class = ''; switch ($mode) { case 'pages': $catcount = 1; // so page items all show. $pageobj = new ZenpagePage($item['titlelink']); $itemtitle = $pageobj->getTitle(); $itemsortorder = $pageobj->getSortOrder(); $itemid = $pageobj->getID(); $itemparentid = $pageobj->getParentID(); $itemtitlelink = $pageobj->getTitlelink(); $itemurl = $pageobj->getLink(); $count = ''; if ($pageobj->isProtected()) { $password_class = ' has_password'; } break; case 'categories': case 'allcategories': $catobj = new ZenpageCategory($item['titlelink']); $itemtitle = $catobj->getTitle(); $itemsortorder = $catobj->getSortOrder(); $itemid = $catobj->getID(); $itemparentid = $catobj->getParentID(); $itemtitlelink = $catobj->getTitlelink(); $itemurl = $catobj->getLink(); $catcount = count($catobj->getArticles()); if ($counter) { $count = ' <span style="white-space:nowrap;"><small>(' . sprintf(ngettext('%u article', '%u articles', $catcount), $catcount) . ')</small></span>'; } else { $count = ''; } if ($catobj->isProtected()) { $password_class = ' has_password'; } break; } if ($catcount) { $level = max(1, count(explode('-', $itemsortorder))); $process = $level <= $showsubs && $option == "list" || ($option == 'list' || $option == 'list-top') && $level == 1 || ($option == 'list' || $option == 'omit-top' && $level > 1) && ($itemid == $currentitem_id || $itemparentid == $currentitem_id || $level < $mylevel && $level > 1 && strpos($itemsortorder, $myparentsort) === 0 || $level == $mylevel && $currentitem_parentid == $itemparentid) || $option == 'list-sub' && $itemparentid == $currentitem_id; if ($process) { if ($level > $indent) { echo "\n" . str_pad("\t", $indent, "\t") . '<ul class="' . $css_class . '">' . "\n"; $indent++; $parents[$indent] = NULL; $open[$indent] = 0; } else { if ($level < $indent) { $parents[$indent] = NULL; while ($indent > $level) { if ($open[$indent]) { $open[$indent]--; echo "</li>\n"; } $indent--; echo str_pad("\t", $indent, "\t") . "</ul>\n"; } } else { // level == indent, have not changed if ($open[$indent]) { // level = indent echo str_pad("\t", $indent, "\t") . "</li>\n"; $open[$indent]--; } else { echo "\n"; } } } if ($open[$indent]) { // close an open LI if it exists echo "</li>\n"; $open[$indent]--; } echo str_pad("\t", $indent - 1, "\t"); $open[$indent]++; $parents[$indent] = $itemid; if ($level == 1) { // top level $class = $css_class_topactive . $password_class; } else { $class = $css_class_active . $password_class; } if (!is_null($_zp_current_zenpage_page)) { $gettitle = $_zp_current_zenpage_page->getTitle(); $getname = $_zp_current_zenpage_page->getTitlelink(); } else { if (!is_null($_zp_current_category)) { $gettitle = $_zp_current_category->getTitle(); $getname = $_zp_current_category->getTitlelink(); } else { $gettitle = ''; $getname = ''; } } $current = ""; if ($itemtitlelink == $getname && !in_context(ZP_SEARCH)) { switch ($mode) { case 'pages': if ($_zp_gallery_page == 'pages.php') { $current = $class; } break; case 'categories': case 'allcategories': if ($_zp_gallery_page == 'news.php') { $current = $class; } break; } } if (empty($current)) { $current = trim($password_class); } if ($limit) { $itemtitle = shortenContent($itemtitle, $limit, MENU_TRUNCATE_INDICATOR); } echo '<li><a class="' . $current . '" href="' . html_encode($itemurl) . '" title="' . html_encode(getBare($itemtitle)) . '">' . html_encode($itemtitle) . '</a>' . $count; } } } // cleanup any hanging list elements while ($indent > 1) { if ($open[$indent]) { echo "</li>\n"; $open[$indent]--; } $indent--; echo str_pad("\t", $indent, "\t") . "</ul>"; } if ($open[$indent]) { echo "</li>\n"; $open[$indent]--; } else { echo "\n"; } if ($startlist) { echo "</ul>\n"; } }
?> <h1><?php echo gettext('Edit Page:'); ?> <em><?php checkForEmptyTitle($result->getTitle(), 'page', false); ?> </em></h1> <?php if ($result->getDatetime() >= date('Y-m-d H:i:s')) { echo ' <small><strong id="scheduldedpublishing">' . gettext('(Page scheduled for publishing)') . '</strong></small>'; if ($result->getShow() != 1) { echo '<p class="scheduledate"><small>' . gettext('Note: Scheduled publishing is not active unless the page is also set to <em>published</em>') . '</small></p>'; } } if ($result->isProtected() && GALLERY_SECURITY != 'private') { echo '<p class="notebox">' . gettext('<strong>Note:</strong> This page is either password protected or has a passport protected parent.') . '</p>'; } } } if ($result->transient) { ?> <form method="post" name="addnews" action="admin-edit.php?<?php echo $admintype; ?> &save"> <?php XSRFToken('save'); ?> <?php } else {
/** * Gets the title, url and name of a menu item * * @return array */ function getItemTitleAndURL($item) { global $_zp_gallery; $themename = $_zp_gallery->getCurrentTheme(); $array = array("title" => '', "url" => '', "name" => '', 'protected' => false, 'theme' => $themename); $valid = true; $title = get_language_string($item['title']); switch ($item['type']) { case "galleryindex": $array = array("title" => get_language_string($item['title']), "url" => WEBPATH, "name" => WEBPATH, 'protected' => false, 'theme' => $themename); break; case "album": $folderFS = internalToFilesystem($item['link']); $localpath = ALBUM_FOLDER_SERVERPATH . $folderFS; $dynamic = hasDynamicAlbumSuffix($folderFS) && !is_dir($folderFS); $valid = file_exists($localpath) && ($dynamic || is_dir($localpath)); if (!$valid || strpos($localpath, '..') !== false) { $valid = false; $url = ''; $protected = 0; } else { $obj = newAlbum($item['link']); $url = $obj->getLink(0); $protected = $obj->isProtected(); $title = $obj->getTitle(); } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); break; case "zenpagepage": if (class_exists('zenpage')) { $sql = 'SELECT * FROM ' . prefix('pages') . ' WHERE `titlelink`="' . $item['link'] . '"'; $result = query_single_row($sql); if (is_array($result)) { $obj = new ZenpagePage($item['link']); $url = $obj->getLink(0); $protected = $obj->isProtected(); $title = $obj->getTitle(); } else { $valid = false; $url = ''; $protected = 0; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); } break; case "zenpagenewsindex": if (class_exists('zenpage')) { $url = getNewsIndexURL(); $array = array("title" => get_language_string($item['title']), "url" => $url, "name" => $url, 'protected' => false); } break; case "zenpagecategory": if (class_exists('zenpage')) { $sql = "SELECT title FROM " . prefix('news_categories') . " WHERE titlelink = '" . $item['link'] . "'"; $obj = query_single_row($sql, false); if ($obj) { $obj = new ZenpageCategory($item['link']); $title = $obj->getTitle(); $protected = $obj->isProtected(); $url = $obj->getLink(0); } else { $valid = false; $url = ''; $protected = 0; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => $protected, 'theme' => $themename); } break; case "custompage": $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $themename . '/'; if (file_exists($root . $item['link'] . '.php')) { $url = zp_apply_filter('getLink', rewrite_path(_PAGE_ . '/' . $item['link'], "/index.php?p=" . $item['link']), $item['link'] . '.php', NULL); } else { $valid = false; $url = ''; } $array = array("title" => $title, "url" => $url, "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; case "customlink": $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; case 'menulabel': $array = array("title" => get_language_string($item['title']), "url" => NULL, 'name' => $item['title'], 'protected' => false, 'theme' => $themename); break; default: $array = array("title" => get_language_string($item['title']), "url" => $item['link'], "name" => $item['link'], 'protected' => false, 'theme' => $themename); break; } $limit = MENU_TRUNCATE_STRING; $array['valid'] = $valid; if ($limit) { $array['title'] = shortenContent($array['title'], $limit, MENU_TRUNCATE_INDICATOR); } return $array; }