Exemple #1
0
 /**
  * Gets news articles and images of a gallery to show them together on the news section
  *
  * NOTE: This function does not exclude articles that are password protected via a category
  *
  * @param int $articles_per_page The number of articles to get
  * @param string $mode 	"latestimages-thumbnail"
  * 											"latestimages-thumbnail-customcrop"
  * 											"latestimages-sizedimage"
  * 											"latestalbums-thumbnail"
  * 		 									"latestalbums-thumbnail-customcrop"
  * 		 									"latestalbums-sizedimage"
  * 		 									"latestimagesbyalbum-thumbnail"
  * 		 									"latestimagesbyalbum-thumbnail-customcrop"
  * 		 									"latestimagesbyalbum-sizedimage"
  * 		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
  * 		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
  * 		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
  * 	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
  *
  * @param string $published "published" for published articles,
  * 													"unpublished" for un-published articles,
  * 													"all" for all articles
  * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
  * @param bool $sticky set to true to place "sticky" articles at the front of the list.
  * @param string $direction 	"desc" or "asc"
  * @return array
  * @deprecated since version 1.4.6
  */
 protected function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = NULL, $sticky = true, $sortdirection = 'desc')
 {
     global $_zp_combiNews_cache, $_zp_gallery;
     if (is_null($published)) {
         if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) {
             $published = "all";
         } else {
             $published = "published";
         }
     }
     if (empty($mode)) {
         $mode = getOption('zenpage_combinews_mode');
     }
     if (isset($_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection])) {
         return $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection];
     }
     if ($published == "published") {
         $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
         $imagesshow = " AND images.show = 1 ";
     } else {
         $show = "";
         $imagesshow = "";
     }
     getAllAccessibleAlbums($_zp_gallery, $albumlist, false);
     if (empty($albumlist)) {
         $albumWhere = 'albums.`id` is NULL';
     } else {
         $albumWhere = 'albums.`id` in (' . implode(',', $albumlist) . ')';
     }
     if ($articles_per_page) {
         $offset = self::getOffset($articles_per_page);
     } else {
         $offset = 0;
     }
     if (empty($sortorder)) {
         $combinews_sortorder = getOption("zenpage_combinews_sortorder");
     } else {
         $combinews_sortorder = $sortorder;
     }
     $stickyorder = '';
     if ($sticky) {
         $stickyorder = 'sticky DESC,';
     }
     switch (strtolower($sortdirection)) {
         case 'desc':
         default:
             $sortdir = 'DESC';
             break;
         case 'asc':
             $sortdir = 'ASC';
             break;
     }
     $type3 = query("SET @type3:='0'");
     switch ($mode) {
         case "latestimages-thumbnail":
         case "latestimages-thumbnail-customcrop":
         case "latestimages-sizedimage":
         case "latestimages-sizedimage-maxspace":
         case "latestimages-fullimage":
             $albumWhere = ' AND ' . $albumWhere;
             $sortorder = $combinews_sortorder;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='images'");
             switch ($combinews_sortorder) {
                 case 'id':
                 case 'date':
                     $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
                 case 'publishdate':
                     $imagequery = "(SELECT albums.folder, images.filename, IFNULL(images.publishdate,images.date), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                 case 'mtime':
                     $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestalbums-thumbnail":
         case "latestalbums-thumbnail-customcrop":
         case "latestalbums-sizedimage":
         case "latestalbums-sizedimage-maxspace":
         case "latestalbums-fullimage":
         default:
             if (empty($show)) {
                 $albumWhere = ' WHERE ' . $albumWhere;
             } else {
                 $albumWhere = ' AND ' . $albumWhere;
             }
             $sortorder = $combinews_sortorder;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='albums'");
             switch ($combinews_sortorder) {
                 case 'id':
                 case 'date':
                     $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
                 case 'publishdate':
                     $albumquery = "(SELECT albums.folder, albums.title, IFNULL(albums.publishdate,albums.date), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
                 case 'mtime':
                 default:
                     $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestimagesbyalbum-thumbnail":
         case "latestimagesbyalbum-thumbnail-customcrop":
         case "latestimagesbyalbum-sizedimage":
         case "latestimagesbyalbum-sizedimage-maxspace":
         case "latestimagesbyalbum-fullimage":
             $albumWhere = ' AND ' . $albumWhere;
             $type1 = query("SET @type1:='news'");
             $type2 = query("SET @type2:='albums'");
             if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime" || $combinews_sortorder != "publishdate") {
                 $combinews_sortorder = "date";
             }
             $sortorder = "images." . $combinews_sortorder;
             switch ($combinews_sortorder) {
                 case "date":
                     $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.date,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
                 case "mtime":
                     $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.mtime,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                 case "publishdate":
                     $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.publishdate,'%Y-%m-%d'), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                     break;
             }
             $result = $this->siftResults("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By {$stickyorder} date " . $sortdir, $offset, $articles_per_page);
             break;
         case "latestupdatedalbums-thumbnail":
         case "latestupdatedalbums-thumbnail-customcrop":
         case "latestupdatedalbums-sizedimage":
         case "latestupdatedalbums-sizedimage-maxspace":
         case "latestupdatedalbums-fullimage":
             $latest = $this->getArticles($articles_per_page, NULL, true, 'date', $sortdirection);
             $counter = '';
             foreach ($latest as $news) {
                 $article = new ZenpageNews($news['titlelink']);
                 if ($article->checkAccess()) {
                     $counter++;
                     $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                 }
             }
             $albums = getAlbumStatistic($articles_per_page, "latestupdated", '', $sortdirection);
             $latestalbums = array();
             $counter = "";
             foreach ($albums as $album) {
                 $counter++;
                 $tempalbum = $album;
                 $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                 $timestamp = $tempalbum->get('mtime');
                 if ($timestamp == 0) {
                     $albumdate = $tempalbum->getDateTime();
                 } else {
                     $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                 }
                 $latestalbums[$counter] = array("albumname" => $tempalbum->getFileName(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
             }
             //$latestalbums = array_merge($latestalbums, $item);
             $latest = array_merge($latestnews, $latestalbums);
             $result = sortMultiArray($latest, "date", $sortdirection != 'asc');
             if (count($result) > $articles_per_page) {
                 $result = array_slice($result, 0, $articles_per_page);
             }
             break;
     }
     $_zp_combiNews_cache[$published . $mode . $sticky . $sortorder . $sortdirection] = $result;
     return $result;
 }
/**
 * Gets news articles and images of a gallery to show them together on the news section
 *
 * NOTE: This function does not exclude articles that are password protected via a category
 *
 * @param int $articles_per_page The number of articles to get
 * @param string $mode 	"latestimages-thumbnail"
 *											"latestimages-thumbnail-customcrop"
 *											"latestimages-sizedimage"
 *											"latestalbums-thumbnail"
 *		 									"latestalbums-thumbnail-customcrop"
 *		 									"latestalbums-sizedimage"
 *		 									"latestimagesbyalbum-thumbnail"
 *		 									"latestimagesbyalbum-thumbnail-customcrop"
 *		 									"latestimagesbyalbum-sizedimage"
 *		 									"latestupdatedalbums-thumbnail" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-thumbnail-customcrop" (for RSS and getLatestNews() used only)
 *		 									"latestupdatedalbums-sizedimage" (for RSS and getLatestNews() used only)
 *	NOTE: The "latestupdatedalbums" variants do NOT support pagination as required on the news loop!
 *
 * @param string $published "published" for published articles,
 * 													"unpublished" for un-published articles,
 * 													"all" for all articles
 * @param string $sortorder 	id, date or mtime, only for latestimages-... modes
 * @param bool $sticky set to true to place "sticky" articles at the front of the list.
 * @return array
 */
function getCombiNews($articles_per_page = '', $mode = '', $published = NULL, $sortorder = '', $sticky = true)
{
    deprecated_function_notify(gettext('Use the Zenpage class method instead.'));
    global $_zp_gallery, $_zp_flash_player;
    processExpired('news');
    if (is_null($published)) {
        if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
            $published = "all";
        } else {
            $published = "published";
        }
    }
    if (empty($mode)) {
        $mode = getOption("zenpage_combinews_mode");
    }
    if ($published == "published") {
        $show = " WHERE `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
        $imagesshow = " AND images.show = 1 ";
    } else {
        $show = "";
        $imagesshow = "";
    }
    $passwordcheck = "";
    if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
        $albumWhere = "";
        $passwordcheck = "";
    } else {
        $albumscheck = query_full_array("SELECT * FROM " . prefix('albums') . " ORDER BY title");
        foreach ($albumscheck as $albumcheck) {
            if (!checkAlbumPassword($albumcheck['folder'])) {
                $albumpasswordcheck = " AND albums.id != " . $albumcheck['id'];
                $passwordcheck = $passwordcheck . $albumpasswordcheck;
            }
        }
        $albumWhere = "AND albums.show=1" . $passwordcheck;
    }
    $limit = getLimitAndOffset($articles_per_page);
    if (empty($sortorder)) {
        $combinews_sortorder = getOption("zenpage_combinews_sortorder");
    } else {
        $combinews_sortorder = $sortorder;
    }
    $stickyorder = '';
    if ($sticky) {
        $stickyorder = 'sticky DESC,';
    }
    $type3 = query("SET @type3:='0'");
    switch ($mode) {
        case "latestimages-thumbnail":
        case "latestimages-thumbnail-customcrop":
        case "latestimages-sizedimage":
            $sortorder = "images." . $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='images'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $imagequery = "(SELECT albums.folder, images.filename, images.date, @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case 'mtime':
                    $imagequery = "(SELECT albums.folder, images.filename, FROM_UNIXTIME(images.mtime), @type2, @type3 as sticky FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestalbums-thumbnail":
        case "latestalbums-thumbnail-customcrop":
        case "latestalbums-sizedimage":
            $sortorder = $combinews_sortorder;
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            switch ($combinews_sortorder) {
                case 'id':
                case 'date':
                    $albumquery = "(SELECT albums.folder, albums.title, albums.date, @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
                case 'mtime':
                    $albumquery = "(SELECT albums.folder, albums.title, FROM_UNIXTIME(albums.mtime), @type2, @type3 as sticky FROM " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t" . $show . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type, sticky FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $albumquery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER BY {$stickyorder} date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            break;
        case "latestimagesbyalbum-thumbnail":
        case "latestimagesbyalbum-thumbnail-customcrop":
        case "latestimagesbyalbum-sizedimage":
            $type1 = query("SET @type1:='news'");
            $type2 = query("SET @type2:='albums'");
            if (empty($combinews_sortorder) || $combinews_sortorder != "date" || $combinews_sortorder != "mtime") {
                $combinews_sortorder = "date";
            }
            $combinews_sortorder = "date";
            $sortorder = "images." . $combinews_sortorder;
            switch ($combinews_sortorder) {
                case "date":
                    $imagequery = "(SELECT DISTINCT DATE_FORMAT(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`date`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
                case "mtime":
                    $imagequery = "(SELECT DISTINCT FROM_UNIXTIME(" . $sortorder . ",'%Y-%m-%d'), albums.folder, DATE_FORMAT(images.`mtime`,'%Y-%m-%d'), @type2 FROM " . prefix('images') . " AS images, " . prefix('albums') . " AS albums\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE albums.id = images.albumid " . $imagesshow . $albumWhere . ")";
                    break;
            }
            $result = query_full_array("(SELECT title as albumname, titlelink, date, @type1 as type FROM " . prefix('news') . " " . $show . ")\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $imagequery . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tORDER By date DESC {$limit}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
            //echo "<pre>"; print_r($result); echo "</pre>";
            //$result = "";
            break;
        case "latestupdatedalbums-thumbnail":
        case "latestupdatedalbums-thumbnail-customcrop":
        case "latestupdatedalbums-sizedimage":
            $latest = getNewsArticles($articles_per_page, '', NULL, true);
            $counter = '';
            foreach ($latest as $news) {
                $article = new ZenpageNews($news['titlelink']);
                if ($article->checkAccess($hint, $show)) {
                    $counter++;
                    $latestnews[$counter] = array("albumname" => $article->getTitle(), "titlelink" => $article->getTitlelink(), "date" => $article->getDateTime(), "type" => "news");
                }
            }
            $albums = getAlbumStatistic($articles_per_page, "latestupdated");
            $latestalbums = array();
            $counter = "";
            foreach ($albums as $album) {
                $counter++;
                $tempalbum = new Album($_zp_gallery, $album['folder']);
                $tempalbumthumb = $tempalbum->getAlbumThumbImage();
                $timestamp = $tempalbum->get('mtime');
                if ($timestamp == 0) {
                    $albumdate = $tempalbum->getDateTime();
                } else {
                    $albumdate = strftime('%Y-%m-%d %H:%M:%S', $timestamp);
                }
                $latestalbums[$counter] = array("albumname" => $tempalbum->getFolder(), "titlelink" => $tempalbum->getTitle(), "date" => $albumdate, "type" => 'albums');
            }
            //$latestalbums = array_merge($latestalbums, $item);
            $latest = array_merge($latestnews, $latestalbums);
            $result = sortMultiArray($latest, "date", true);
            if (count($result) > $articles_per_page) {
                $result = array_slice($result, 0, 10);
            }
            break;
    }
    //$result = "";
    return $result;
}
/**
 * Gets to the Zenpage news articles
 *
 * @param  string $changefreq One of the supported changefrequence values regarding sitemap.org. Default is empty or wrong is "daily".
 * @return string
 */
function getSitemapZenpageNewsArticles()
{
    global $_zp_zenpage, $sitemap_number;
    //not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_news');
        $articles = $_zp_zenpage->getArticles('', 'published', true, "date", "desc");
        if ($articles) {
            $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 ($articles as $article) {
                $articleobj = new ZenpageNews($article['titlelink']);
                $date = substr($articleobj->getDatetime(), 0, 10);
                $lastchange = '';
                if (!is_null($articleobj->getLastchange())) {
                    $lastchange = substr($articleobj->getLastchange(), 0, 10);
                }
                if ($date > $lastchange && !empty($lastchangedate)) {
                    $date = $lastchange;
                }
                if (!$articleobj->inProtectedCategory()) {
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = seo_locale::localePath(true, $locale) . '/' . _NEWS_ . '/' . urlencode($articleobj->getTitlelink());
                                $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 = rewrite_path(_NEWS_ . '/' . urlencode($articleobj->getTitlelink()), '?p=news&amp;title=' . urlencode($articleobj->getTitlelink()), dynamic_locale::fullHostPath($locale));
                                $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 = rewrite_path(_NEWS_ . '/' . urlencode($articleobj->getTitlelink()), '?p=news&amp;title=' . urlencode($articleobj->getTitlelink()), FULLWEBPATH);
                            $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;
    }
}
/**
 * Prints all available articles in Zenpage
 *
 * @return string
 */
function printNewsArticlesList($number)
{
    global $_zp_zenpage, $_zp_current_zenpage_news, $host;
    if (isset($_GET['zenpage']) && $_GET['zenpage'] == "articles") {
        echo "<h3>Zenpage: <em>" . gettext('Articles') . "</em> <small>" . gettext("(Click on article title to include a link)") . "</small></h3>";
        if (isset($_GET['category'])) {
            $cat = sanitize($_GET['category']);
            $catobj = new ZenpageCategory($cat);
            $items = $catobj->getArticles("", "all");
            $newscount = count($catobj->getArticles(0, 'all'));
        } else {
            $items = $_zp_zenpage->getArticles("", "all");
            $newscount = count($_zp_zenpage->getArticles(0, 'all'));
        }
        $news_per_page = $number;
        if (isset($_GET['page'])) {
            $currentpage = sanitize_numeric($_GET['page']);
        } else {
            $currentpage = 1;
        }
        $pagestotal = ceil($newscount / $news_per_page);
        for ($nr = 1; $nr <= $pagestotal; $nr++) {
            $startnews[$nr] = $nr * $news_per_page - $news_per_page;
            // get start image number
            $endnews[$nr] = $nr * $news_per_page - 1;
            // get end image number
        }
        $count = '';
        $number = $startnews[$currentpage];
        //category selector here later
        printTinyZenpageCategorySelector($currentpage);
        if ($newscount != 0) {
            printTinyPageNav($pagestotal, $currentpage, 'news');
            echo "<ul class='zenpagearticles'>";
            for ($nr = $number; $nr <= $news_per_page * $currentpage; $nr++) {
                if ($nr == $newscount) {
                    break;
                }
                $newsobj = new ZenpageNews($items[$nr]['titlelink']);
                $count++;
                echo "<li>";
                if ($_GET['zenpage'] == "articles") {
                    echo "<a href=\"javascript:ZenpageDialog.insert('','news/" . $newsobj->getTitlelink() . "','','','" . $newsobj->getTitlelink() . "','" . addslashes($newsobj->getTitle()) . "','','','articles','','','','');\" title='" . html_encode(truncate_string(getBare($newsobj->getContent()), 300)) . "'>" . addslashes($newsobj->getTitle()) . unpublishedZenpageItemCheck($newsobj) . "</a> <small><em>" . $newsobj->getDatetime() . "</em></small>";
                    echo " <a href='zoom.php?news=" . urlencode($newsobj->getTitlelink()) . "' title='Zoom' class='colorbox' style='outline: none;'><img src='img/magnify.png' alt='' style='border: 0' /></a><br />";
                    echo '<small><em>' . gettext('Categories:');
                    $cats = $newsobj->getCategories();
                    $count = '';
                    foreach ($cats as $cat) {
                        $count++;
                        $catobj = new ZenpageCategory($cat['titlelink']);
                        if ($count == 1) {
                            echo ' ';
                        } else {
                            echo ', ';
                        }
                        echo $catobj->getTitle();
                    }
                    echo '</em></small>';
                }
                echo "</li>";
                if ($nr === $endnews[$currentpage]) {
                    break;
                }
            }
            // for end
            echo "</ul>";
        }
    }
}
/**
 * Returns the title and the titlelink of the next or previous article in single news article pagination as an array
 * Returns false if there is none (or option is empty)
 *
 * NOTE: This is not available if using the CombiNews feature
 *
 * @param string $option "prev" or "next"
 * @param string $sortorder "desc" (default)or "asc" for descending or ascending news. Required if these for next_news() loop are changed.
 * @param string $sortdirection "date" (default) or "title" for sorting by date or title. Required if these for next_news() loop are changed.
 *
 * @return mixed
 */
function getNextPrevNews($option = '', $sortorder = 'date', $sortdirection = 'desc')
{
    global $_zp_zenpage, $_zp_current_zenpage_news;
    $article_url = array();
    if (!ZP_COMBINEWS) {
        $current = 0;
        if (!empty($option)) {
            $all_articles = $_zp_zenpage->getNewsArticles('', NULL, false, $sortorder, $sortdirection);
            $count = 0;
            foreach ($all_articles as $article) {
                $newsobj = new ZenpageNews($article['titlelink']);
                $count++;
                $title[$count] = $newsobj->getTitle();
                $titlelink[$count] = $newsobj->getTitlelink();
                if ($titlelink[$count] == $_zp_current_zenpage_news->getTitlelink()) {
                    $current = $count;
                }
            }
            switch ($option) {
                case "prev":
                    $prev = $current - 1;
                    if ($prev > 0) {
                        $articlelink = getNewsURL($title[$prev]);
                        $articletitle = $title[$prev];
                        $article_url = array("link" => getNewsURL($titlelink[$prev]), "title" => $title[$prev]);
                    }
                    break;
                case "next":
                    $next = $current + 1;
                    if ($next <= $count) {
                        $articlelink = getNewsURL($title[$next]);
                        $articletitle = $title[$next];
                        $article_url = array("link" => getNewsURL($titlelink[$next]), "title" => $title[$next]);
                    }
                    break;
            }
            return $article_url;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
Exemple #6
0
        break;
    case "withimages":
        $latest = getLatestNews($items, "with_latest_images_date");
        break;
}
$count = "";
foreach ($latest as $item) {
    $count++;
    $category = "";
    $categories = "";
    //get the type of the news item
    switch ($item['type']) {
        case 'news':
            $obj = new ZenpageNews($item['titlelink']);
            $title = get_language_string($obj->get('title'), $locale);
            $link = getNewsURL($obj->getTitlelink());
            $count2 = 0;
            $category = $obj->getCategories();
            foreach ($category as $cat) {
                $count2++;
                if ($count2 != 1) {
                    $categories = $categories . ", ";
                }
                $categories = $categories . get_language_string($cat['titlelink'], $locale);
            }
            $thumb = "";
            $filename = "";
            if (getOption('zenpage_rss_length') != "") {
                // empty value means full content!
                $content = shortenContent(get_language_string($obj->get('content'), $locale), getOption('zenpage_rss_length'), $elipsis = '...');
            }