function printNewsHTML($num) { if (!$_REQUEST['words']) { return; } global $_zp_current_zenpage_news, $_zp_current_search; if (!defined('CROP_NEWS')) { define('CROP_NEWS', TRUE); } save_context(); add_context(ZP_ZENPAGE_NEWS_ARTICLE); $u = 0; processExpired('zenpage_news'); $articles = $_zp_current_search->getSearchNews(); if (count($articles) == 0) { return; } $articles = $this->sortArticles($articles, 'id'); echo "<div id='snr'>"; echo "<div>Also found " . count($articles) . " news"; if (count($articles) > 3) { echo " - showing the last 3</div>"; } else { echo "</div>"; } echo "</div>"; $len = count($articles); for ($u = $len - 1; $u >= 0 && $u > $len - 4; $u--) { $news = $articles[$u]; $_zp_current_zenpage_news = new ZenpageNews($news['titlelink']); Utils::render("tiles/news/template.php"); } restore_context(); }
/** * support to show an image from an album * The imagename is optional. If absent the album thumb image will be * used and the link will be to the album. If present the link will be * to the image. * * @param string $albumname * @param string $imagename * @param int $size the size to make the image. If omitted image will be 50% of 'image_size' option. * @param bool $linkalbum set true to link specific image to album instead of image */ function zenpageAlbumImage($albumname, $imagename = NULL, $size = NULL, $linkalbum = false) { global $_zp_gallery; echo '<br />'; $album = newAlbum($albumname); if ($album->loaded) { if (is_null($size)) { $size = floor(getOption('image_size') * 0.5); } $image = NULL; if (is_null($imagename)) { $linkalbum = true; $image = $album->getAlbumThumbImage(); } else { $image = newImage($album, $imagename); } if ($image && $image->loaded) { makeImageCurrent($image); if ($linkalbum) { rem_context(ZP_IMAGE); echo '<a href="' . html_encode($album->getLink()) . '" title="' . sprintf(gettext('View the %s album'), $albumname) . '">'; add_context(ZP_IMAGE); printCustomSizedImage(sprintf(gettext('View the album %s'), $albumname), $size); rem_context(ZP_IMAGE | ZP_ALBUM); echo '</a>'; } else { echo '<a href="' . html_encode(getImageURL()) . '" title="' . sprintf(gettext('View %s'), $imagename) . '">'; printCustomSizedImage(sprintf(gettext('View %s'), $imagename), $size); rem_context(ZP_IMAGE | ZP_ALBUM); echo '</a>'; } } else { ?> <span style="background:red;color:black;"> <?php printf(gettext('<code>zenpageAlbumImage()</code> did not find the image %1$s:%2$s'), $albumname, $imagename); ?> </span> <?php } } else { ?> <span style="background:red;color:black;"> <?php printf(gettext('<code>zenpageAlbumImage()</code> did not find the album %1$s'), $albumname); ?> </span> <?php } }
/** * Returns the next image on a page. * sets $_zp_current_image to the next image in the album. * Returns true if there is an image to be shown * * @param bool $all set to true disable pagination * @param int $firstPageCount the number of images which can go on the page that transitions between albums and images * Normally this parameter should be NULL so as to use the default computations. * @param bool $mine overridePassword the password check * @return bool * * @return bool */ function next_image($all = false, $firstPageCount = NULL, $mine = NULL) { global $_zp_images, $_zp_current_image, $_zp_current_album, $_zp_page, $_zp_current_image_restore, $_zp_current_search, $_zp_gallery, $_firstPageImages; if ($mine != NULL && gettype($mine) != 'boolean' || func_num_args() > 3) { internal_deprecations::next_image(); } if (is_null($firstPageCount)) { $firstPageCount = $_firstPageImages; } $imagePageOffset = getTotalPages(2); /* gives us the count of pages for album thumbs */ if ($all) { $imagePage = 1; $firstPageCount = 0; } else { $_firstPageImages = $firstPageCount; /* save this so pagination can see it */ $imagePage = $_zp_page - $imagePageOffset; } if ($firstPageCount > 0 && $imagePageOffset > 0) { $imagePage = $imagePage + 1; /* can share with last album page */ } if ($imagePage <= 0) { return false; /* we are on an album page */ } if (is_null($_zp_images)) { if (in_context(ZP_SEARCH)) { $_zp_images = $_zp_current_search->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine); } else { $_zp_images = $_zp_current_album->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine); } if (empty($_zp_images)) { return NULL; } $_zp_current_image_restore = $_zp_current_image; $img = array_shift($_zp_images); $_zp_current_image = newImage($_zp_current_album, $img, true, true); save_context(); add_context(ZP_IMAGE); return true; } else { if (empty($_zp_images)) { $_zp_images = NULL; $_zp_current_image = $_zp_current_image_restore; restore_context(); return false; } else { $img = array_shift($_zp_images); $_zp_current_image = newImage($_zp_current_album, $img, true, true); return true; } } }
/** * Loads a zenpage news article * Sets up $_zp_current_zenpage_news and returns it as the function result. * * @param array $request an array with one member: the key is "date", "category", or "title" and specifies * what you want loaded. The value is the date or title of the article wanted * * @return object */ function load_zenpage_news($request) { global $_zp_current_zenpage_news, $_zp_current_category, $_zp_post_date; if (isset($request['date'])) { add_context(ZP_ZENPAGE_NEWS_DATE); $_zp_post_date = zpFunctions::removeTrailingSlash(sanitize($request['date'])); } if (isset($request['category'])) { $titlelink = sanitize(rtrim($request['category'], '/')); $_zp_current_category = new ZenpageCategory($titlelink); if ($_zp_current_category->loaded) { add_context(ZP_ZENPAGE_NEWS_CATEGORY); } else { $_GET['p'] = 'CATEGORY:' . $titlelink; unset($_GET['category']); return false; } } if (isset($request['title'])) { $titlelink = sanitize(rtrim($request['title'], '/')); $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink); $result = query_single_row($sql); if (is_array($result)) { add_context(ZP_ZENPAGE_NEWS_ARTICLE | ZP_ZENPAGE_SINGLE); $_zp_current_zenpage_news = new ZenpageNews($titlelink); } else { $_GET['p'] = 'NEWS:' . $titlelink; } return $_zp_current_zenpage_news; } return true; }
static function loadScript($script, $request) { global $_zp_current_admin_obj, $_zp_gallery_page, $_myFavorites, $_zp_current_album, $_zp_conf_vars, $_myFavorites; if ($_myFavorites && isset($_REQUEST['instance'])) { $_myFavorites->instance = sanitize(rtrim($_REQUEST['instance'], '/')); if ($_myFavorites->instance) { $_myFavorites->setTitle($_myFavorites->getTitle() . '[' . $_myFavorites->instance . ']'); } } if ($_zp_gallery_page == "favorites.php") { if (zp_loggedin()) { $_zp_current_album = $_myFavorites; add_context(ZP_ALBUM); prepareAlbumPage(); $_zp_gallery_page = 'favorites.php'; } else { $script = false; } } return $script; }
/** * Returns the next image on a page. * sets $_zp_current_image to the next image in the album. * Returns true if there is an image to be shown * * @param bool $all set to true disable pagination * @param int $firstPageCount the number of images which can go on the page that transitions between albums and images * Normally this parameter should be NULL so as to use the default computations. * @param bool $mine overridePassword the password check * @return bool * * @return bool */ function next_image($all = false, $firstPageCount = NULL, $mine = NULL) { global $_zp_images, $_zp_current_image, $_zp_current_album, $_zp_page, $_zp_current_image_restore, $_zp_current_search, $_zp_gallery, $_firstPageImages, $_imagePageOffset; if (is_null($firstPageCount)) { $firstPageCount = $_firstPageImages; } if (is_null($_imagePageOffset)) { $_imagePageOffset = getTotalPages(2); /* gives us the count of pages for album thumbs */ } if ($all) { $imagePage = 1; $firstPageCount = 0; } else { $_firstPageImages = $firstPageCount; /* save this so pagination can see it */ $imagePage = $_zp_page - $_imagePageOffset; } if ($firstPageCount > 0 && $_imagePageOffset > 0) { $imagePage = $imagePage + 1; /* can share with last album page */ } if ($imagePage <= 0) { $result = false; /* we are on an album page */ } else { if (is_null($_zp_images)) { if (in_context(ZP_SEARCH)) { $_zp_images = $_zp_current_search->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine); } else { $_zp_images = $_zp_current_album->getImages($all ? 0 : $imagePage, $firstPageCount, NULL, NULL, true, $mine); } if (empty($_zp_images)) { $result = NULL; } else { $_zp_current_image_restore = $_zp_current_image; $img = array_shift($_zp_images); $_zp_current_image = newImage($_zp_current_album, $img, true, true); save_context(); add_context(ZP_IMAGE); $result = true; } } else { if (empty($_zp_images)) { $_zp_images = NULL; $_zp_current_image = $_zp_current_image_restore; restore_context(); $result = false; } else { $img = array_shift($_zp_images); $_zp_current_image = newImage($_zp_current_album, $img, true, true); $result = true; } } } return zp_apply_filter('next_object_loop', $result, $_zp_current_image); }
/** * Iterate through comments; use the ZP_COMMENT context. * Return true if there are more comments * @param bool $desc set true for desecnding order * * @return bool */ function next_comment($desc = false) { global $_zp_current_image, $_zp_current_album, $_zp_current_comment, $_zp_comments, $_zp_current_zenpage_page, $_zp_current_zenpage_news; //ZENPAGE: comments support if (is_null($_zp_current_comment)) { if (in_context(ZP_IMAGE) and in_context(ZP_ALBUM)) { if (is_null($_zp_current_image)) { return false; } $_zp_comments = $_zp_current_image->getComments(false, false, $desc); } else { if (!in_context(ZP_IMAGE) and in_context(ZP_ALBUM)) { $_zp_comments = $_zp_current_album->getComments(false, false, $desc); } } if (function_exists('is_NewsArticle')) { if (is_NewsArticle()) { $_zp_comments = $_zp_current_zenpage_news->getComments(false, false, $desc); } if (is_Pages()) { $_zp_comments = $_zp_current_zenpage_page->getComments(false, false, $desc); } } if (empty($_zp_comments)) { return false; } } else { if (empty($_zp_comments)) { $_zp_comments = NULL; $_zp_current_comment = NULL; rem_context(ZP_COMMENT); return false; } } $_zp_current_comment = array_shift($_zp_comments); if ($_zp_current_comment['anon']) { $_zp_current_comment['email'] = $_zp_current_comment['name'] = '<' . gettext("Anonymous") . '>'; } add_context(ZP_COMMENT); return true; }