function getOptionsSupported() { global $personalities; if (!extensionEnabled('print_album_menu') && (($m = getOption('garland_menu')) == 'garland' || $m == 'zenpage' || $m == 'garland')) { $note = '<p class="notebox">' . sprintf(gettext('<strong>Note:</strong> The <em>%s</em> custom menu makes use of the <em>print_album_menu</em> plugin.'), $m) . '</p>'; } else { $note = ''; } $options = array(gettext('Theme personality') => array('key' => 'garland_personality', 'type' => OPTION_TYPE_SELECTOR, 'selections' => $personalities, 'desc' => gettext('Select the theme personality')), gettext('Allow search') => array('key' => 'Allow_search', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext('Set to enable search form.')), gettext('Allow cloud') => array('key' => 'Allow_cloud', 'type' => OPTION_TYPE_CHECKBOX, 'desc' => gettext('Set to enable tag cloud for album page.')), gettext('Custom menu') => array('key' => 'garland_menu', 'type' => OPTION_TYPE_CUSTOM, 'desc' => gettext('Set this to the <em>menu_manager</em> menu you wish to use.') . $note)); if (extensionEnabled('zenpage')) { global $_zp_CMS; $pages = $_zp_CMS->getPages(false); $list = array(); foreach ($pages as $page) { $pageObj = newPage($page['titlelink']); if (!$pageObj->getShow()) { $list[getBare(get_language_string($page['title']))] = $page['titlelink']; } } $options[gettext('Custom Homepage')] = array('key' => 'garland_customHome', 'type' => OPTION_TYPE_SELECTOR, 'selections' => $list, 'null_selection' => gettext('none'), 'desc' => gettext('Select the <em>pages</em> titlelink for the home page. Only unpublished pages are offered for selection.')); } if (getOption('garland_personality') == 'image_gallery') { $options[gettext('Image gallery transition')] = array('key' => 'garland_transition', 'type' => OPTION_TYPE_SELECTOR, 'selections' => array(gettext('None') => '', gettext('Fade') => 'fade', gettext('Shrink/grow') => 'resize', gettext('Horizontal') => 'slide-hori', gettext('Vertical') => 'slide-vert'), 'order' => 10, 'desc' => gettext('Transition effect for Image gallery')); $options[gettext('Image gallery caption')] = array('key' => 'garland_caption_location', 'type' => OPTION_TYPE_RADIO, 'buttons' => array(gettext('On image') => 'image', gettext('Separate') => 'separate', gettext('Omit') => 'none'), 'order' => 10.5, 'desc' => gettext('Location for Image gallery picture caption')); } return $options; }
function parseXml($filename, $structure) { $projectName = str_replace(".xml", "", $filename); newProject($projectName); if ($structure->page) { foreach ($structure->page as $page) { newPage($page->name, $page->extension, $page->location); } } if ($structure->component) { foreach ($structure->component as $component) { newComponent($component->name, $component->extension, $component->location); } } }
function addpage() { global $CurrentActivePage, $WebPagesList; $slug = $_GET[slug]; $insidebar = true; if (isset($_POST[save])) { $content = $_POST[content]; $insidebar = $_POST[insidebar] == '1' ? true : false; $title = $_POST[title]; if ($title != '' and $content != '') { //die( "<b>$title.$content</b>" ); $pdetails = newPage($title, '', $insidebar); $WebPagesList[] = $pdetails; $slug = $pdetails[pageslug]; if (!file_exists(sitedir($slug)) and put2file(sitedir($slug), stripslashes($_POST[content]))) { savepages(); echo "The page was created successfully<br>"; echo "File Created : " . sitedir($slug) . "<br>"; echo "Content : " . substr(strip_tags($content), 0, 100) . (strlen($content) > 100 ? '...' : '') . "<br>"; return; } else { echo "save failed"; if (file_exists(sitedir($slug))) { echo " - a page with similar title already exists"; } } } else { echo "Either the title or the content is/are empty!!! Please check your input!!<br>"; } } echo "<form action='?action=addpage' method=post>"; echo "<h2>Add a new page</h2>"; echo "Page Title : <input name='title' type='text' value='{$title}' /><br>"; echo "Type of page : \r\n\t\t\t<select name='insidebar'>\r\n\t\t\t\t<option value=1 " . ($insidebar == true ? ' selected ' : '') . ">Sidebar Page</option>\r\n\t\t\t\t<option value=0 " . ($insidebar == false ? ' selected ' : '') . ">Normal Page</option>\r\n\t\t\t</select>\r\n\t\t <br>"; echo "Content : <br>"; echo "<textarea name=content rows=30 cols=70>{$content}</textarea>"; echo "<br><input type=submit value=save name=save>"; echo "</form>"; }
/** * Gets all tags used by either all Zenpage news articles or pages. * @param string $mode "news" for Zenpage news article tags, "pages" for Zenpage pages tags * */ function getAllTagsFromZenpage($mode = 'news') { global $_zp_gallery, $_zp_CMS; if (!extensionEnabled('zenpage')) { return FALSE; } $passwordcheck = ''; $ids = array(); $where = ''; $tagWhere = ""; switch ($mode) { case 'news': if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) { $published = 'all'; } else { $published = 'published'; } $type = 'news'; $items = $_zp_CMS->getArticles(false, $published); foreach ($items as $item) { $obj = newArticle($item['titlelink']); if ($obj->checkAccess()) { $ids[] = $obj->getID(); } } break; case 'pages': $published = !zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS); $type = 'pages'; $items = $_zp_CMS->getPages($published); foreach ($items as $item) { $obj = newPage($item['titlelink']); if ($obj->checkAccess()) { $ids[] = $obj->getID(); } } break; } $count = ''; if (count($ids) == 0) { return FALSE; } else { $tagWhere = " WHERE "; foreach ($ids as $id) { $count++; $tagWhere .= '(o.objectid =' . $id . " AND o.tagid = t.id AND o.type = '" . $type . "')"; if ($count != count($ids)) { $tagWhere .= " OR "; } } } if (empty($tagWhere)) { return FALSE; } else { $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = '" . $type . "') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name"); } return $tags; }
/** * Gets an item object by id * * @param string $table database table to search * @param int $id id of the item to get * @return mixed */ function getItemByID($table, $id) { if ($result = query_single_row('SELECT * FROM ' . prefix($table) . ' WHERE id =' . (int) $id)) { switch ($table) { case 'images': if ($alb = getItemByID('albums', $result['albumid'])) { return newImage($alb, $result['filename'], true); } break; case 'albums': return newAlbum($result['folder'], false, true); case 'news': return newArticle($result['titlelink']); case 'pages': return newPage($result['titlelink']); case 'news_categories': return new Category($result['titlelink']); } } return NULL; }
/** * Gets all pages or published ones. * * NOTE: Since this function only returns titlelinks for use with the object model it does not exclude pages that are password protected * * @param bool $published TRUE for published or FALSE for all pages including un-published * @param bool $toplevel TRUE for only the toplevel pages * @param int $number number of pages to get (NULL by default for all) * @param string $sorttype NULL for the standard order as sorted on the backend, "title", "date", "id", "popular", "mostrated", "toprated", "random" * @param string $sortdirection false for ascenting, true for descending * @return array */ function getPages($published = NULL, $toplevel = false, $number = NULL, $sorttype = NULL, $sortdirection = NULL) { global $_zp_loggedin; if (is_null($sortdirection)) { $sortdirection = $this->getSortDirection('pages'); } if (is_null($sorttype)) { $sorttype = $this->getSortType('pages'); if (empty($sorttype)) { $sorttype = 'date'; } } if (is_null($published)) { $published = !zp_loggedin(); $all = zp_loggedin(MANAGE_ALL_PAGES_RIGHTS | VIEW_UNPUBLISHED_PAGE_RIGHTS); } else { $all = !$published; } $published = $published && !zp_loggedin(ZENPAGE_PAGES_RIGHTS); $now = date('Y-m-d H:i:s'); $gettop = ''; if ($published) { if ($toplevel) { $gettop = " AND parentid IS NULL"; } $show = " WHERE `show` = 1 AND date <= '" . $now . "'" . $gettop; } else { if ($toplevel) { $gettop = " WHERE parentid IS NULL"; } $show = $gettop; } if ($sortdirection) { $sortdir = ' DESC'; } else { $sortdir = ' ASC'; } switch ($sorttype) { default: $sortorder = $sorttype; break; case 'popular': $sortorder = 'hitcounter'; break; case 'mostrated': $sortorder = 'total_votes'; break; case 'toprated': if (empty($sortdir)) { $sortdir = ' DESC'; } $sortorder = '(total_value/total_votes) ' . $sortdir . ', total_value'; break; case 'random': $sortorder = 'RAND()'; $sortdir = ''; break; } $all_pages = array(); // Disabled cache var for now because it does not return un-publishded and published if logged on index.php somehow if logged in. $result = query('SELECT * FROM ' . prefix('pages') . $show . ' ORDER by `' . $sortorder . '`' . $sortdir); if ($result) { while ($row = db_fetch_assoc($result)) { if ($all || $row['show']) { $all_pages[] = $row; } else { if ($_zp_loggedin) { $page = newPage($row['titlelink']); if ($page->subRights()) { $all_pages[] = $row; } else { $parentid = $page->getParentID(); if ($parentid) { $parent = getItemByID('pages', $parentid); if ($parent->subRights() & MANAGED_OBJECT_RIGHTS_VIEW) { $all_pages[] = $row; } } } } } if ($number && count($result) >= $number) { break; } } db_free_result($result); } return $all_pages; }
/** * Gets the title, url and name of a menu item * * @return array */ function getItemTitleAndURL($item) { global $_zp_gallery; $themename = $_zp_gallery->getCurrentTheme(); $array = array(); $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 "page": $sql = 'SELECT * FROM ' . prefix('pages') . ' WHERE `titlelink`="' . $item['link'] . '"'; $result = query_single_row($sql); if (is_array($result) && extensionEnabled('zenpage')) { $obj = newPage($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); break; case "newsindex": if ($valid = extensionEnabled('zenpage')) { $url = getNewsIndexURL(); } else { $url = ''; } $array = array("title" => get_language_string($item['title']), "url" => $url, "name" => $url, 'protected' => false); break; case "category": $valid = extensionEnabled('zenpage'); $sql = "SELECT title FROM " . prefix('news_categories') . " WHERE titlelink = '" . $item['link'] . "'"; $obj = query_single_row($sql, false); if ($obj && $valid) { $obj = newCategory($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); 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; }
</div> <br class="clearall" /> </div> <?php } else { echo gettext('No unpublished articles'); } ?> </fieldset> <?php $visible = $report == 'pages'; $items = $_zp_CMS->getPages(false); $output = ''; $c = 0; foreach ($items as $key => $item) { $itemobj = newPage($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->getContent(), 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()) . '" title="' . html_encode($itemobj->getTitle()) . '">(' . gettext('Edit') . ')</a></li>'; } } ?> <br class="clearall" /> <fieldset class="smallbox"> <legend><?php if ($c > 0) { reveal('pagebox', $visible);
/** * Loads a zenpage pages page * Sets up $_zp_current_page and returns it as the function result. * @param $titlelink the titlelink of a zenpage page to setup a page object directly. Used for custom * page scripts based on a zenpage page. * * @return object */ function load_zenpage_pages($titlelink) { global $_zp_current_page; $_zp_current_page = newPage($titlelink); if ($_zp_current_page->loaded) { add_context(ZP_ZENPAGE_PAGE | ZP_ZENPAGE_SINGLE); } else { $_GET['p'] = 'PAGES:' . $titlelink; return NULL; } return $_zp_current_page; }
/** * @package EDK */ require_once 'common/admin/admin_menu.php'; $page = new Page(); $page->setAdmin(); $page->setTitle('Administration - Navigation - Top Navigation'); if ($_GET['incPrio']) { increasePriority($_GET['incPrio']); } else { if ($_GET['decPrio']) { decreasePriority($_GET['decPrio']); } else { if ($_POST) { if ($_POST['add']) { newPage($_POST['newname'], $_POST['newurl'], '_self'); } else { if ($_POST['rename']) { $id = array_search('rename', $_POST['rename']); renamePage($id, $_POST['name'][$id]); } else { if ($_POST['change']) { $id = array_search('change', $_POST['change']); changeUrl($id, $_POST['url'][$id]); } else { if ($_POST['delete']) { $id = array_search('delete', $_POST['delete']); delPage($id); } else { if ($_POST['hide']) { $id = array_search('hide', $_POST['hide']);
/** * Prints the x related articles based on a tag search * * @param int $number Number of items to get * @param string $type 'albums', 'images','news','pages', "all" for all combined. * @param string $specific If $type = 'albums' or 'images' name of album * @param bool $excerpt If a text excerpt (gallery items: description; Zenpage items: content) should be shown. NULL for none or number of length * @param bool $thumb For $type = 'albums' or 'images' if a thumb should be shown (default size as set on the options) */ function printRelatedItems($number = 5, $type = 'news', $specific = NULL, $excerpt = NULL, $thumb = false, $date = false) { global $_zp_gallery, $_zp_current_album, $_zp_current_image; $label = array('albums' => gettext('Albums'), 'images' => gettext('Images'), 'news' => gettext('News'), 'pages' => gettext('Pages')); $result = getRelatedItems($type, $specific); $resultcount = count($result); if ($resultcount != 0) { ?> <h3 class="relateditems"> <?php printf(gettext('Related %s'), $type); ?> </h3> <ul id="relateditems"> <?php $count = 0; foreach ($result as $item) { $count++; ?> <li class="<?php echo $item['type']; ?> "> <?php $category = ''; switch ($item['type']) { case 'albums': $obj = newAlbum($item['name']); $url = $obj->getLink(); $text = $obj->getDesc(); $category = gettext('Album'); break; case 'images': $alb = newAlbum($item['album']); $obj = newImage($alb, $item['name']); $url = $obj->getLink(); $text = $obj->getDesc(); $category = gettext('Image'); break; case 'news': $obj = newArticle($item['name']); $url = $obj->getLink(); $text = $obj->getContent(); $category = gettext('News'); break; case 'pages': $obj = newPage($item['name']); $url = $obj->getLink(); $text = $obj->getContent(); $category = gettext('Page'); break; } ?> <?php if ($thumb) { $thumburl = false; switch ($item['type']) { case 'albums': $thumburl = $obj->getThumb(); break; case 'images': $thumburl = $obj->getThumb(); break; } if ($thumburl) { ?> <a href="<?php echo html_encode(pathurlencode($url)); ?> " title="<?php echo html_encode($obj->getTitle()); ?> " class="relateditems_thumb"> <img src="<?php echo html_encode(pathurlencode($thumburl)); ?> " alt="<?php echo html_encode($obj->getTitle()); ?> " /> </a> <?php } } ?> <h4><a href="<?php echo html_encode(pathurlencode($url)); ?> " title="<?php echo html_encode($obj->getTitle()); ?> "><?php echo html_encode($obj->getTitle()); ?> </a> <?php if ($date) { ?> <span class="relateditems_date"> <?php echo zpFormattedDate(DATE_FORMAT, strtotime($obj->getDateTime())); ?> </span> <?php } ?> <?php if ($type == 'all') { ?> (<small><?php echo $category; ?> </small>)<?php } ?> </h4> <?php if ($excerpt) { echo html_encodeTagged(shortenContent($text, $excerpt, '...', true)); } ?> </li> <?php if ($count == $number) { break; } } // foreach if ($count) { ?> </ul> <?php } } }
/** * Prints all available pages in Zenpage * * @param string $current set to the page selected (if any) * * @return string */ function printPagesSelector($current) { global $_zp_gallery, $_zp_CMS; ?> <select id="pageselector" name="pageselect"> <?php $pages = $_zp_CMS->getPages(false); foreach ($pages as $key => $page) { if ($page['titlelink'] == $current) { $selected = ' selected= "selected"'; } else { $selected = ''; } $pageobj = newPage($page['titlelink']); $level = substr_count($pageobj->getSortOrder(), "-"); $arrow = ""; for ($count = 1; $count <= $level; $count++) { $arrow .= "» "; } echo "<option value='" . html_encode($pageobj->getTitlelink()) . "'" . $selected . '>'; echo $arrow . $pageobj->getTitle() . unpublishedZenphotoItemCheck($pageobj) . "</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); }
/** * Gets links to all Zenpage pages * * @return string */ function getSitemapPages() { global $_zp_CMS, $sitemap_number; //not splitted into several sitemaps yet if ($sitemap_number == 1) { $data = ''; $limit = sitemap_getDBLimit(2); $sitemap_locales = generateLanguageList(); $changefreq = getOption('sitemap_changefreq_pages'); $pages = $_zp_CMS->getPages(true); if ($pages) { $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 ($pages as $page) { $pageobj = newPage($page['titlelink']); $lastchange = $date = substr($pageobj->getPublishDate(), 0, 10); if (!is_null($pageobj->getLastchange())) { $lastchange = substr($pageobj->getLastchange(), 0, 10); } if ($date > $lastchange) { $date = $lastchange; } if (!$pageobj->isProtected()) { $base = $pageobj->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<lastmod>" . $date . "</lastmod>\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<lastmod>" . $date . "</lastmod>\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<lastmod>" . $date . "</lastmod>\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; } }
/** * Checks if user is allowed to access the page * @param $hint * @param $show */ function checkforGuest(&$hint = NULL, &$show = NULL) { if (!parent::checkForGuest()) { return false; } $pageobj = $this; $hash = $pageobj->getPassword(); while (empty($hash) && !is_null($pageobj)) { $parentID = $pageobj->getParentID(); if (empty($parentID)) { $pageobj = NULL; } else { $sql = 'SELECT `titlelink` FROM ' . prefix('pages') . ' WHERE `id`=' . $parentID; $result = query_single_row($sql); $pageobj = newPage($result['titlelink']); $hash = $pageobj->getPassword(); } } if (empty($hash)) { // no password required return 'zp_public_access'; } else { $authType = "zp_page_auth_" . $pageobj->getID(); $saved_auth = zp_getCookie($authType); if ($saved_auth == $hash) { return $authType; } else { $user = $pageobj->getUser(); $show = !empty($user); $hint = $pageobj->getPasswordHint(); return false; } } }
$user = isset($_SESSION['user']) && $_SESSION['user'] ? $_SESSION['user'] : ''; $pageTitle = 'Administrate Honeymoon'; include '_headerHead.inc'; include '_headerTail.inc'; if ($action != 'login' && $action != 'logout' && !$user) { login(); } else { switch ($action) { case 'login': login(); break; case 'logout': logout(); break; case 'newPage': newPage(); break; case 'editPage': editPage(); break; case 'deletePage': deletePage(); break; default: listPages(); } } include '_footer.inc'; //************************************************************************************* function login() {
public function getitems() { $items = array(); if ($album = @$this->options['album']) { if ($image = @$this->options['image']) { if (!is_array($image)) { $image = array($image); } foreach ($image as $filename) { $obj = newImage(array('folder' => $album, 'filename' => $filename), true, true); if ($obj->exists) { $items[] = $obj; } } } else { if (!is_array($album)) { $album = array($album); } foreach ($album as $folder) { $obj = newAlbum($folder, true); if ($obj->exists) { $items[] = $obj; } } } return $items; } if ($this->feedtype == 'news' && ($news = @$this->options['titlelink'])) { if (!is_array($news)) { $news = array($news); } foreach ($news as $article) { $obj = newArticle($article, false); if ($obj->loaded) { $items[] = array('titlelink' => $article); } } return $items; } if ($this->feedtype == 'pages' && ($pages = @$this->options['titlelink'])) { if (!is_array($pages)) { $pages = array($pages); } foreach ($pages as $page) { $obj = newPage($page, false); if ($obj->loaded) { $items[] = array('titlelink' => $page); } } return $items; } return parent::getitems(); }
function addpage() { global $CurrentActivePage, $WebPagesList; $slug = $_GET[slug]; $insidebar = true; if (isset($_POST[save])) { $content = stripslashes($_POST[content]); $insidebar = $_POST[insidebar] == '1' ? true : false; $title = stripslashes($_POST[title]); if ($title != '' and $content != '') { $pdetails = newPage($title, '', $insidebar); $WebPagesList[] = $pdetails; $slug = $pdetails[pageslug]; $newPageFile = pageDataDir($slug); if (!file_exists($newPageFile)) { put2file($newPageFile, $content); savepages(); echo "The page was created successfully<br />"; echo "File Created : " . $newPageFile . "<br />"; echo "Content : " . substr(strip_tags($content), 0, 100) . (strlen($content) > 100 ? '...' : '') . "<br />"; return; } else { echo "save failed"; if (file_exists($content)) { echo " - a page with similar title already exists"; } } } else { echo "Either the title or the content is/are empty!!! Please check your input!!<br />"; } } echo "<h2>Add a new page</h2>"; EditCreateForm('new', newPage('')); }
$args['image'] = $thumbobj->getFilename(); $args['album'] = $thumbobj->album->getFilename(); $imageb = preg_replace('~&check=(.*)~', '', getIPSizedImage($size, $thumbobj)); } $alt1 = $obj->getFileName(); // 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;
/** * Function to create the page title to be used within the html <head> <title></title> element. * Usefull if you use one header.php for the header of all theme pages instead of individual ones on the theme pages * It returns the title and site name in reversed breadcrumb order: * <title of current page> | <parent item if present> | <gallery title> * It supports standard gallery pages as well a custom and Zenpage news articles, categories and pages. * * @param string $separator How you wish the parts to be separated * @param bool $listparents If the parent objects should be printed in reversed order before the current */ function getHeadTitle($separator = ' | ', $listparents = true) { global $_zp_gallery, $_zp_current_album, $_zp_current_image, $_zp_current_article, $_zp_current_page, $_zp_gallery_page, $_zp_current_category, $_zp_page, $_myFavorites; $mainsitetitle = html_encode(getBare(getMainSiteName())); $separator = html_encode($separator); if ($mainsitetitle) { $mainsitetitle = $separator . $mainsitetitle; } $gallerytitle = html_encode(getBareGalleryTitle()); if ($_zp_page > 1) { $pagenumber = ' (' . $_zp_page . ')'; } else { $pagenumber = ''; } switch ($_zp_gallery_page) { case 'index.php': return $gallerytitle . $mainsitetitle . $pagenumber; break; case 'album.php': case 'favorites.php': case 'image.php': if ($listparents) { $parents = getParentAlbums(); $parentalbums = ''; if (count($parents) != 0) { $parents = array_reverse($parents); foreach ($parents as $parent) { $parentalbums .= html_encode(getBare($parent->getTitle())) . $separator; } } } else { $parentalbums = ''; } $albumtitle = html_encode(getBareAlbumTitle()) . $pagenumber . $separator . $parentalbums . $gallerytitle . $mainsitetitle; switch ($_zp_gallery_page) { case 'album.php': case 'favorites.php': return $albumtitle; break; case 'image.php': return html_encode(getBareImageTitle()) . $separator . $albumtitle; break; } break; case 'news.php': if (function_exists("is_NewsArticle")) { if (is_NewsArticle()) { return html_encode(getBareNewsTitle()) . $pagenumber . $separator . gettext('News') . $separator . $gallerytitle . $mainsitetitle; } else { if (is_NewsCategory()) { return html_encode(getBare($_zp_current_category->getTitle())) . $pagenumber . $separator . gettext('News') . $separator . $gallerytitle . $mainsitetitle; } else { return gettext('News') . $pagenumber . $separator . $gallerytitle . $mainsitetitle; } } } break; case 'pages.php': if ($listparents) { $parents = $_zp_current_page->getParents(); $parentpages = ''; if (count($parents) != 0) { $parents = array_reverse($parents); foreach ($parents as $parent) { $obj = newPage($parent); $parentpages .= html_encode(getBare($obj->getTitle())) . $separator; } } } else { $parentpages = ''; } return html_encode(getBarePageTitle()) . $pagenumber . $separator . $parentpages . $gallerytitle . $mainsitetitle; break; case '404.php': return gettext('Object not found') . $separator . $gallerytitle . $mainsitetitle; break; default: // for all other possible static custom pages $custompage = stripSuffix($_zp_gallery_page); $standard = array('contact' => gettext('Contact'), 'register' => gettext('Register'), 'search' => gettext('Search'), 'archive' => gettext('Archive view'), 'password' => gettext('Password required')); if (is_object($_myFavorites)) { $standard['favorites'] = gettext('My favorites'); } if (array_key_exists($custompage, $standard)) { return $standard[$custompage] . $pagenumber . $separator . $gallerytitle . $mainsitetitle; } else { return $custompage . $pagenumber . $separator . $gallerytitle . $mainsitetitle; } break; } }
/** * 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 gallery items "multiple_layouts_albums" * For zenpage 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 = newPage($parent); } else { $parentobj = newCategory($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; }
/** * Gets latest comments for news articles and pages * * @param int $number how many comments you want. * @param string $type "all" for all latest comments for all news articles and all pages * "news" for the lastest comments of one specific news article * "page" for the lastest comments of one specific page * @param int $itemID the ID of the element to get the comments for if $type != "all" */ function getLatestZenpageComments($number, $type = "all", $itemID = "") { $itemID = sanitize_numeric($itemID); $number = sanitize_numeric($number); $checkauth = zp_loggedin(); if ($type == 'all' || $type == 'news') { $newspasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) { $newsshow = ''; } else { $newsshow = 'news.show=1 AND'; $newscheck = query_full_array("SELECT * FROM " . prefix('news') . " ORDER BY date"); foreach ($newscheck as $articlecheck) { $obj = newArticle($articlecheck['titlelink']); if ($obj->inProtectedCategory()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $newsshow = ''; } else { $excludenews = " AND id != " . $articlecheck['id']; $newspasswordcheck = $newspasswordcheck . $excludenews; } } } } } if ($type == 'all' || $type == 'page') { $pagepasswordcheck = ""; if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS)) { $pagesshow = ''; } else { $pagesshow = 'pages.show=1 AND'; $pagescheck = query_full_array("SELECT * FROM " . prefix('pages') . " ORDER BY date"); foreach ($pagescheck as $pagecheck) { $obj = newPage($pagecheck['titlelink']); if ($obj->isProtected()) { if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) { $pagesshow = ''; } else { $excludepages = " AND pages.id != " . $pagecheck['id']; $pagepasswordcheck = $pagepasswordcheck . $excludepages; } } } } } switch (strtolower($type)) { case "news": $whereNews = " WHERE {$newsshow} news.id = " . $itemID . " AND c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; break; case "page": $wherePages = " WHERE {$pagesshow} pages.id = " . $itemID . " AND c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; case "all": $whereNews = " WHERE {$newsshow} c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck; $wherePages = " WHERE {$pagesshow} c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck; break; } $comments_news = array(); $comments_pages = array(); if ($type == "all" or $type == "news") { $comments_news = query_full_array("SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, news.title, news.titlelink FROM " . prefix('comments') . " AS c, " . prefix('news') . " AS news " . $whereNews . " ORDER BY c.id DESC LIMIT {$number}"); } if ($type == "all" or $type == "page") { $comments_pages = query_full_array($sql = "SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, pages.title, pages.titlelink FROM " . prefix('comments') . " AS c, " . prefix('pages') . " AS pages " . $wherePages . " ORDER BY c.id DESC LIMIT {$number}"); } $comments = array(); foreach ($comments_news as $comment) { $comments[$comment['id']] = $comment; } foreach ($comments_pages as $comment) { $comments[$comment['id']] = $comment; } krsort($comments); return array_slice($comments, 0, $number); }
/** * Gets the feed item data in a comments feed * * @param array $item Array of a comment * @return array */ protected function getitemComments($item) { if ($item['anon']) { $author = ""; } else { $author = " " . gettext("by") . " " . $item['name']; } $commentpath = $imagetag = $title = ''; switch ($item['type']) { case 'images': $title = get_language_string($item['title']); $obj = newImage(array('folder' => $item['folder'], 'filename' => $item['filename'])); $link = $obj->getlink(); $feeditem['pubdate'] = date("r", strtotime($item['date'])); $category = get_language_string($item['albumtitle']); $website = $item['website']; $title = $category . ": " . $title; $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id']; break; case 'albums': $obj = newAlbum($item['folder']); $link = rtrim($obj->getLink(), '/'); $feeditem['pubdate'] = date("r", strtotime($item['date'])); $title = get_language_string($item['albumtitle']); $website = $item['website']; $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id']; break; case 'news': case 'pages': if (extensionEnabled('zenpage')) { $feeditem['pubdate'] = date("r", strtotime($item['date'])); $category = ''; $title = get_language_string($item['title']); $titlelink = $item['titlelink']; $website = $item['website']; if ($item['type'] == 'news') { $obj = newArticle($titlelink); } else { $obj = newPage($titlelink); } $commentpath = PROTOCOL . '://' . $this->host . html_encode($obj->getLink()) . "#" . $item['id']; } else { $commentpath = ''; } break; } $feeditem['title'] = getBare($title . $author); $feeditem['link'] = $commentpath; $feeditem['desc'] = $item['comment']; return $feeditem; }
// publish or un-publish page by click if (isset($_GET['publish'])) { XSRFdefender('update'); $obj = newPage(sanitize($_GET['titlelink'])); $obj->setShow(sanitize_numeric($_GET['publish'])); $obj->save(); } if (isset($_GET['commentson'])) { XSRFdefender('update'); $obj = newPage(sanitize($_GET['titlelink'])); $obj->setCommentsAllowed(sanitize_numeric($_GET['commentson'])); $obj->save(); } if (isset($_GET['hitcounter'])) { XSRFdefender('hitcounter'); $obj = newPage(sanitize($_GET['titlelink'])); $obj->set('hitcounter', 0); $obj->save(); $reports[] = '<p class="messagebox fade-message">' . gettext("Hitcounter reset") . '</p>'; } /* * 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('pages'); printSortableHead(); zenpageJSCSS(); updatePublished('pages');