コード例 #1
0
 /**
  * duplicates an article
  * @param string $newtitle the title for the new article
  */
 function copy($newtitle)
 {
     $newID = $newtitle;
     $id = parent::copy(array('titlelink' => $newID));
     if (!$id) {
         $newID = $newtitle . ':' . seoFriendly(date('Y-m-d_H-i-s'));
         $id = parent::copy(array('titlelink' => $newID));
     }
     if ($id) {
         $newobj = new ZenpageNews($newID);
         $newobj->setTitle($newtitle);
         $newobj->setTags($this->getTags());
         $newobj->save();
         $categories = array();
         foreach ($this->getCategories() as $cat) {
             $categories[] = $cat['cat_id'];
         }
         $result = query_full_array("SELECT * FROM " . prefix('news_categories') . " ORDER BY titlelink");
         foreach ($result as $cat) {
             if (in_array($cat['id'], $categories)) {
                 query("INSERT INTO " . prefix('news2cat') . " (cat_id, news_id) VALUES ('" . $cat['id'] . "', '" . $id . "')");
             }
         }
         return $newobj;
     }
     return false;
 }
コード例 #2
0
function makeArticle($class, $text)
{
    global $unique;
    $unique++;
    $i = strpos($text, '</a>');
    $j = strpos($text, '</h4>');
    $h4 = substr($text, $i + 4, $j - $i - 4);
    $text = substr($text, $j + 5);
    $text = str_replace('<hr />', '', $text);
    $text = str_replace('<hr/>', '', $text);
    $ts_news = new ZenpageNews(seoFriendly($class . '_' . trim(truncate_string(strip_tags($h4), 30, '')) . '_' . $unique), true);
    $ts_news->setShow(0);
    $ts_news->setDateTime(date('Y-m-d H:i:s'));
    $ts_news->setAuthor('TSGenerator');
    $ts_news->setTitle($h4);
    $ts_news->setContent($text);
    $ts_news->setCategories(array());
    $ts_news->setCategories(array('troubleshooting', 'troubleshooting-' . $class));
    $ts_news->save();
}
コード例 #3
0
ファイル: trouble.php プロジェクト: hatone/zenphoto-1.4.1.4
function listArticles($cat)
{
    global $counter;
    global $_zp_current_category;
    $_zp_current_category = $cat;
    $articles = $cat->getArticles();
    if (!empty($articles)) {
        ?>
		<ol class="trouble">
		<?php 
        foreach ($articles as $titlelink) {
            $titlelink = $titlelink['titlelink'];
            $article = new ZenpageNews($titlelink);
            $counter++;
            ?>
				<li>
				<h5><a name="<?php 
            echo $titlelink;
            ?>
"><a href="javascript:toggle('article_<?php 
            echo $counter;
            ?>
');"><?php 
            echo $article->getTitle();
            ?>
</a></h5>
				<div id="article_<?php 
            echo $counter;
            ?>
" style="display:none;" class="body">
					<?php 
            echo $article->getContent();
            ?>
				</div>
				<?php 
            ?>
			</li>
			<?php 
        }
        ?>
		</ol>
		<?php 
    }
}
コード例 #4
0
ファイル: zoom.php プロジェクト: hatone/zenphoto-1.4.1.4
						</object><a>';
            }
        }
    } else {
        ?>
	<img src="<?php 
        echo pathurlencode($imageobj->getSizedImage(440));
        ?>
" />
	<?php 
    }
} else {
    echo "<div style='text-align: left; width 450px; font-size:0.8em'>";
    if (isset($_GET['news'])) {
        $item = sanitize($_GET['news']);
        $obj = new ZenpageNews($item);
        $cats = $obj->getCategories();
        $categories = gettext('Categories: ');
        $count = '';
        if ($cats) {
            foreach ($cats as $cat) {
                $count++;
                $catobj = new ZenpageCategory($cat['titlelink']);
                if ($count != 1) {
                    $categories .= ', ';
                }
                $categories .= $catobj->getTitle();
            }
        }
    } elseif (isset($_GET['pages'])) {
        $item = sanitize($_GET['pages']);
コード例 #5
0
/**
 * 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>";
        }
    }
}
コード例 #6
0
ファイル: rss-news.php プロジェクト: hatone/zenphoto-1.4.1.4
    case "news":
        $latest = getLatestNews($items, "none");
        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!
コード例 #7
0
/**
 * 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 = new ZenpageNews($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 = new ZenpagePage($pagecheck['titlelink']);
                if ($obj->isProtected()) {
                    if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) {
                        $pagesshow = '';
                    } else {
                        $excludepages = " AND pages.id != " . $pagecheck['id'];
                        $pagepasswordcheck = $pagepasswordcheck . $excludepages;
                    }
                }
            }
        }
    }
    switch ($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);
}
コード例 #8
0
								</form>
							</div>
							<?php 
    } else {
        echo gettext('No unpublished categories');
    }
    ?>
					</fieldset>
					<br class="clearall" />
					<?php 
    $visible = $report == 'news';
    $items = $_zp_zenpage->getArticles(0, false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = new ZenpageNews($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="artcheck" />' . $itemobj->getTitle() . '</label><a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '"> (' . gettext('View') . ')</a></li>';
        }
    }
    ?>
					<fieldset class="smallbox">
						<legend><?php 
    reveal('newsbox', $visible);
    echo gettext('News articles not published');
    ?>
</legend>
						<?php 
    if ($output) {
        echo sprintf(ngettext('%u unpublished article', '%u unpublished articles', $c), $c);
コード例 #9
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.
 * @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;
}
コード例 #10
0
/**
 * Processes the check box bulk actions
 *
 */
function processZenpageBulkActions($type, &$reports)
{
    global $_zp_zenpage;
    if (isset($_POST['ids'])) {
        //echo "action for checked items:". $_POST['checkallaction'];
        $action = sanitize($_POST['checkallaction']);
        $links = $_POST['ids'];
        $total = count($links);
        $message = NULL;
        $sql = '';
        if ($action != 'noaction') {
            if ($total > 0) {
                if ($action == 'addtags' || $action == 'alltags') {
                    foreach ($_POST as $key => $value) {
                        $key = postIndexDecode($key);
                        if (substr($key, 0, 10) == 'mass_tags_') {
                            if ($value) {
                                $tags[] = substr($key, 10);
                            }
                        }
                    }
                    $tags = sanitize($tags, 3);
                }
                $n = 0;
                switch ($action) {
                    case 'deleteall':
                        $message = gettext('Selected items deleted');
                        break;
                    case 'showall':
                        $message = gettext('Selected items published');
                        break;
                    case 'hideall':
                        $message = gettext('Selected items unpublished');
                        break;
                    case 'commentson':
                        $message = gettext('Comments enabled for selected items');
                        break;
                    case 'commentsoff':
                        $message = gettext('Comments disabled for selected items');
                        break;
                    case 'resethitcounter':
                        $message = gettext('Hitcounter for selected items');
                        break;
                    case 'addtags':
                        $message = gettext('Tags added to selected items');
                        break;
                    case 'cleartags':
                        $message = gettext('Tags cleared from selected items');
                        break;
                    case 'alltags':
                        $message = gettext('Tags added to articles of selected items');
                        break;
                    case 'clearalltags':
                        $message = gettext('Tags cleared from articles of selected items');
                        break;
                }
                foreach ($links as $titlelink) {
                    $class = 'Zenpage' . $type;
                    $obj = new $class($titlelink);
                    switch ($action) {
                        case 'deleteall':
                            $obj->remove();
                            break;
                        case 'addtags':
                            $mytags = array_unique(array_merge($tags, $obj->getTags()));
                            $obj->setTags($mytags);
                            break;
                        case 'cleartags':
                            $obj->setTags(array());
                            break;
                        case 'alltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
                                $newsobj->setTags($mytags);
                                $newsobj->save();
                            }
                            break;
                        case 'clearalltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $newsobj->setTags(array());
                                $newsobj->save();
                            }
                            break;
                        case 'showall':
                            $obj->set('show', 1);
                            break;
                        case 'hideall':
                            $obj->set('show', 0);
                            break;
                        case 'commentson':
                            $obj->set('commentson', 1);
                            break;
                        case 'commentsoff':
                            $obj->set('commentson', 0);
                            break;
                        case 'resethitcounter':
                            $obj->set('hitcounter', 0);
                            break;
                    }
                    $obj->save();
                }
                if (!is_null($message)) {
                    $reports[] = "<p class='messagebox fade-message'>" . $message . "</p>";
                }
            }
        }
    }
}
コード例 #11
0
    zenpagePublish($obj, sanitize_numeric($_GET['publish']));
}
if (isset($_GET['skipscheduling'])) {
    XSRFdefender('update');
    $obj = new ZenpageNews(sanitize($_GET['titlelink']));
    skipScheduledPublishing($obj);
}
if (isset($_GET['commentson'])) {
    XSRFdefender('update');
    $obj = new ZenpageNews(sanitize($_GET['titlelink']));
    $obj->setCommentsAllowed(sanitize_numeric($_GET['commentson']));
    $obj->save();
}
if (isset($_GET['hitcounter'])) {
    XSRFdefender('hitcounter');
    $obj = new ZenpageNews(sanitize($_GET['titlelink']));
    $obj->set('hitcounter', 0);
    $obj->save();
    $reports[] = '<p class="messagebox fade-message">' . gettext("Hitcounter reset") . '</p>';
}
printAdminHeader('news', 'articles');
zenpageJSCSS();
datepickerJS();
?>

<script type="text/javascript">
	//<!-- <![CDATA[
	var deleteArticle = "<?php 
echo gettext("Are you sure you want to delete this article? THIS CANNOT BE UNDONE!");
?>
";
コード例 #12
0
/**
 * 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_zenpage;
    if (!getOption('zp_plugin_zenpage')) {
        return FALSE;
    }
    $passwordcheck = '';
    $ids = array();
    $where = '';
    $tagWhere = "";
    switch ($mode) {
        case 'news':
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
                $published = 'all';
            } else {
                $published = 'published';
            }
            $type = 'news';
            $items = $_zp_zenpage->getNewsArticles('', $published);
            foreach ($items as $item) {
                $obj = new ZenpageNews($item['titlelink']);
                if ($obj->checkAccess($hint, $show)) {
                    $ids[] = $obj->getID();
                }
            }
            break;
        case 'pages':
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS)) {
                $published = 'all';
            } else {
                $published = 'published';
            }
            $type = 'pages';
            $items = $_zp_zenpage->getPages('', '', $published);
            foreach ($items as $item) {
                $obj = new ZenpagePage($item['titlelink']);
                if ($obj->checkAccess($hint, $show)) {
                    $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;
}
コード例 #13
0
/**
 * @deprecated
 * @since 1.4.6
 */
function getNewsTitlePath($titlelink)
{
    deprecated_functions::notify(gettext('Create an object and use the object getLink'));
    $obj = new ZenpageNews($titlelink);
    return $obj->getLink();
}
コード例 #14
0
ファイル: functions.php プロジェクト: kokyandrei/Unsupported
function printLatestNewsCustom($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true)
{
    global $_zp_gallery, $_zp_current_zenpage_news;
    $latest = getLatestNews($number, $category);
    echo "\n<div class=\"latestnews-spotlight\">\n";
    $count = "";
    foreach ($latest as $item) {
        $count++;
        $category = "";
        $categories = "";
        $obj = new ZenpageNews($item['titlelink']);
        $title = htmlspecialchars($obj->getTitle());
        $link = getNewsURL($item['titlelink']);
        $count2 = 0;
        $category = $obj->getCategories();
        foreach ($category as $cat) {
            $catobj = new ZenpageCategory($cat['titlelink']);
            $count2++;
            if ($count2 != 1) {
                $categories = $categories . "; ";
            }
            $categories = $categories . $catobj->getTitle();
        }
        $content = strip_tags($obj->getContent());
        $date = zpFormattedDate(getOption('date_format'), strtotime($item['date']));
        $type = 'news';
        echo "<div>";
        echo "<h3><a href=\"" . $link . "\" title=\"" . strip_tags(htmlspecialchars($title, ENT_QUOTES)) . "\">" . htmlspecialchars($title) . "</a></h3>\n";
        echo "<div class=\"newsarticlecredit\">\n";
        echo "<span class=\"latestnews-date\">" . $date . "</span>\n";
        echo "<span class=\"latestnews-cats\">| Posted in " . $categories . "</span>\n";
        echo "</div>\n";
        echo "<p class=\"latestnews-desc\">" . html_encode(getContentShorten($content, $contentlength, '(...)', null, null)) . "</p>\n";
        echo "</div>\n";
        if ($count == $number) {
            break;
        }
    }
    echo "</div>\n";
}
コード例 #15
0
 private function getNextPrevNews($option = '')
 {
     global $_zp_current_zenpage_news, $_zp_loggedin;
     if (!getOption("zenpage_combinews")) {
         $current = 0;
         if (!empty($option)) {
             $all_articles = getNewsArticles("", "");
             $count = 0;
             foreach ($all_articles as $article) {
                 $newsobj = new ZenpageNews($article['titlelink']);
                 $count++;
                 $news[$count] = $newsobj;
                 if ($newsobj->getTitleLink() == $_zp_current_zenpage_news->getTitlelink()) {
                     $current = $count;
                 }
             }
             switch ($option) {
                 case "prev":
                     $prev = $current - 1;
                     if ($prev > 0) {
                         return $news[$prev];
                     }
                     break;
                 case "next":
                     $next = $current + 1;
                     if ($next <= $count) {
                         return $news[$next];
                     }
                     break;
             }
         }
     }
     return NULL;
 }
コード例 #16
0
 if (getcheckboxState('convertlinefeeds')) {
     $post['content'] = nl2br($post['content']);
 }
 $post['date'] = $post['date'];
 $post['lastchange'] = $post['lastchange'];
 $post['type'] = $post['type'];
 switch ($post['type']) {
     case 'post':
         //Add the post to Zenphoto database as Zenpage article
         if (query("INSERT INTO " . prefix('news') . " (title,titlelink,content,date,lastchange,`show`,permalink) VALUES (" . db_quote($post['title']) . "," . db_quote($titlelink) . "," . db_quote($post['content']) . "," . db_quote($post['date']) . "," . db_quote($post['lastchange']) . "," . $show . ",1)", false)) {
             $postinfo .= '<li class="import-success">' . sprintf(gettext('%1$s <em>%2$s</em> added'), $post['type'], $post['title']);
         } else {
             $postinfo .= '<li class="import-exists">' . sprintf(gettext('%1$s with the title/titlelink <em>%2$s</em> already exists!'), $post['type'], $post['title']);
         }
         // Get new id of the article
         $newarticle = new ZenpageNews($titlelink, true);
         $newarticleid = $newarticle->getID();
         // getting the categories and tags assigned to this post (Wordpress pages do not have tags or categories
         $termrelations = wp_query_full_array("\n\t\t\t\t\t\t\tSELECT rel.object_id, rel.term_taxonomy_id, tax.term_id, tax.taxonomy, terms.term_id, terms.name, terms.slug\n\t\t\t\t\t\t\tFROM " . wp_prefix('term_relationships', $wp_prefix) . " as rel,\n\t\t\t\t\t\t\t" . wp_prefix('term_taxonomy', $wp_prefix) . " as tax,\n\t\t\t\t\t\t\t" . wp_prefix('terms', $wp_prefix) . " as terms\n\t\t\t\t\t\t\tWHERE tax.term_taxonomy_id = rel.term_taxonomy_id\n\t\t\t\t\t\t\tAND tax.term_id = terms.term_id\n\t\t\t\t\t\t\tAND rel.object_id = '" . $post['id'] . "'", $wpdbconnection);
         //echo "<br /><strong>Categories:</strong><pre>"; print_r($termrelations); echo "</pre>"; // for debugging
         $postinfo .= "<ul>";
         if ($termrelations) {
             foreach ($termrelations as $term) {
                 $term['name'] = $_zp_UTF8->convert($term['name']);
                 $term['slug'] = $term['slug'];
                 $term['taxonomy'] = $term['taxonomy'];
                 switch ($term['taxonomy']) {
                     case 'category':
                         //Get new id of category
                         $getcat = query_single_row("SELECT titlelink, title,id from " . prefix('news_categories') . " WHERE titlelink = " . db_quote($term['slug']) . " AND title = " . db_quote($term['name']));
                         //Prevent double assignments
コード例 #17
0
ファイル: admin-edit.php プロジェクト: rauldobrota/zenphoto
                     $as = trim(sanitize($_POST['copy_object_as']));
                     if (empty($as)) {
                         $as = sprintf(gettext('copy of %s'), $result->getTitle());
                     }
                     $as = seoFriendly($as);
                     $result->copy($as);
                     $result = new ZenpageNews($as);
                     $_GET['titlelink'] = $as;
                     break;
                 case 'delete':
                     $reports[] = deleteArticle($result);
                     break;
             }
         }
     } else {
         $result = new ZenpageNews('');
         $result->setPermalink(1);
         $result->setDateTime(date('Y-m-d H:i:s'));
     }
 }
 if (isset($_GET['save'])) {
     XSRFdefender('save');
     $result = updateArticle($reports, true);
 }
 if (isset($_GET['delete'])) {
     XSRFdefender('delete');
     $msg = deleteArticle(sanitize($_GET['delete']));
     if (!empty($msg)) {
         $reports[] = $msg;
     }
 }
コード例 #18
0
ファイル: related_items.php プロジェクト: rb26/zenphoto
/**
 * 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, $_zp_current_zenpage_page, $_zp_current_zenpage_news;
    $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 = new ZenpageNews($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getContent();
                    $category = gettext('News');
                    break;
                case 'pages':
                    $obj = new ZenpagePage($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) {
                switch ($item['type']) {
                    case 'albums':
                    case 'images':
                        $d = $obj->getDateTime();
                        break;
                    case 'news':
                    case 'pages':
                        $d = $obj->getDateTime();
                        break;
                }
                ?>
							<span class="relateditems_date">
								<?php 
                echo zpFormattedDate(DATE_FORMAT, strtotime($d));
                ?>
							</span>
							<?php 
            }
            ?>
						<?php 
            if ($type == 'all') {
                ?>
 (<small><?php 
                echo $category;
                ?>
</small>)<?php 
            }
            ?>

					</h4>
					<?php 
            if ($excerpt) {
                echo shortenContent($text, $excerpt, '...', true);
            }
            ?>
				</li>
				<?php 
            if ($count == $number) {
                break;
            }
        }
        // foreach
        if ($count) {
            ?>
			</ul>
			<?php 
        }
    }
}
コード例 #19
0
/**
 * 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;
    }
}
コード例 #20
0
 /**
  *
  * Formats the message and calls sendTweet() on an object
  * @param object $obj
  */
 private static function publishArticle($obj, $override = NULL)
 {
     global $_zp_zenpage;
     $galleryitem_text = array();
     switch ($type = $obj->table) {
         case 'albums':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_album_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_album_text')), $obj->getTitle());
             }
             $title = $folder = $obj->name;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             if (getOption('multi_lingual')) {
                 $option_text = unserialize(getOption('galleryArticles_image_text'));
                 foreach ($option_text as $key => $val) {
                     $galleryitem_text[$key] = sprintf($option_text[$key], $obj->getTitle($key), $obj->album->getTitle($key));
                 }
                 $text = serialize($galleryitem_text);
             } else {
                 $text = sprintf(get_language_string(getOption('galleryArticles_image_text')), $obj->getTitle(), $obj->album->getTitle());
             }
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $obj->filename;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
     }
     $article = new ZenpageNews(seoFriendly('galleryArticles-' . $title));
     $article->setTitle($text);
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     if (getOption('multi_lingual')) {
         $desc = '';
         foreach ($option_text as $key => $val) {
             $desc[$key] = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc($key) . '</p>';
         }
         $desc = serialize($desc);
     } else {
         $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>' . $obj->getDesc() . '</p>';
     }
     $article->setContent($desc);
     $article->setShow(true);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setAuthor('galleryArticles');
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_zenpage->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }
コード例 #21
0
function processPlugins()
{
    global $_zp_current_admin_obj;
    $curdir = getcwd();
    $basepath = SERVERPATH . "/" . ZENFOLDER . '/' . PLUGIN_FOLDER . '/';
    chdir($basepath);
    $filelist = safe_glob('*.php');
    foreach ($filelist as $file) {
        $titlelink = stripSuffix(filesystemToInternal($file));
        $author = stripSuffix(basename(__FILE__));
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $result = query_single_row($sql);
        if (empty($result)) {
            $plugin_news = new ZenpageNews($titlelink);
            $fp = fopen($basepath . $file, 'r');
            $empty = true;
            $desc = '<p>';
            $tags = array($titlelink);
            $incomment = false;
            while ($line = fgets($fp)) {
                if (strpos($line, '/*') !== false) {
                    $incomment = true;
                }
                if ($incomment) {
                    if (strpos($line, '*/') !== false) {
                        break;
                    }
                    $i = strpos($line, '*');
                    $line = trim(trim(substr($line, $i + 1), '*'));
                    if (empty($line)) {
                        if (!$empty) {
                            $desc .= '<p>';
                        }
                        $empty = true;
                    } else {
                        if (strpos($line, '@') === 0) {
                            $line = trim($line, '@');
                            $i = strpos($line, ' ');
                            $mod = substr($line, 0, $i);
                            $line = trim(substr($line, $i + 1));
                            switch ($mod) {
                                case 'author':
                                    $desc .= 'Author: ' . html_encode($line) . ' ';
                                    $empty = false;
                                    preg_match_all('|\\((.+?)\\)|', $line, $matches);
                                    $tags = array_merge($tags, $matches[1]);
                                    $author = array_shift($matches[1]);
                                    break;
                                case 'package':
                                case 'subpackage':
                                    $tags[] = $line;
                                    break;
                                case 'tags':
                                    $pluginTags = explode(',', $line);
                                    foreach ($pluginTags as $tag) {
                                        $tags[] = trim(unQuote($tag));
                                    }
                                    break;
                            }
                        } else {
                            $desc .= html_encode($line) . ' ';
                            $empty = false;
                        }
                    }
                }
            }
            $desc .= '</p>';
            fclose($fp);
            $plugin_news->setShow(0);
            $plugin_news->setDateTime(date('Y-m-d H:i:s'), filemtime($file));
            $plugin_news->setAuthor($author);
            $plugin_news->setTitle($titlelink);
            $plugin_news->setContent($desc);
            $plugin_news->setTags($tags);
            $plugin_news->setCategories(array('officially-supported', 'extensions'));
            $plugin_news->setCustomData("http://www.zenphoto.org/documentation/plugins/_" . PLUGIN_FOLDER . "---" . $titlelink . ".html");
            $plugin_news->save();
        }
    }
    chdir($curdir);
}
コード例 #22
0
/**
 * Processes the check box bulk actions
 *
 */
function processZenpageBulkActions($type)
{
    global $_zp_zenpage;
    $action = false;
    if (isset($_POST['ids'])) {
        //echo "action for checked items:". $_POST['checkallaction'];
        $action = sanitize($_POST['checkallaction']);
        $links = sanitize($_POST['ids']);
        $total = count($links);
        $message = NULL;
        $sql = '';
        if ($action != 'noaction') {
            if ($total > 0) {
                if ($action == 'addtags' || $action == 'alltags') {
                    $tags = bulkTags();
                }
                if ($action == 'addcats') {
                    foreach ($_POST as $key => $value) {
                        $key = postIndexDecode($key);
                        if (substr($key, 0, 3) == 'cat') {
                            if ($value) {
                                $cats[] = substr($key, 3);
                            }
                        }
                    }
                    $cats = sanitize($cats, 3);
                }
                $n = 0;
                foreach ($links as $titlelink) {
                    $class = 'Zenpage' . $type;
                    $obj = new $class($titlelink);
                    switch ($action) {
                        case 'deleteall':
                            $obj->remove();
                            SearchEngine::clearSearchCache();
                            break;
                        case 'addtags':
                            $mytags = array_unique(array_merge($tags, $obj->getTags()));
                            $obj->setTags($mytags);
                            break;
                        case 'cleartags':
                            $obj->setTags(array());
                            break;
                        case 'alltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $mytags = array_unique(array_merge($tags, $newsobj->getTags()));
                                $newsobj->setTags($mytags);
                                $newsobj->save();
                            }
                            break;
                        case 'clearalltags':
                            $allarticles = $obj->getArticles('', 'all', true);
                            foreach ($allarticles as $article) {
                                $newsobj = new ZenpageNews($article['titlelink']);
                                $newsobj->setTags(array());
                                $newsobj->save();
                            }
                            break;
                        case 'addcats':
                            $catarray = array();
                            $allcats = $obj->getCategories();
                            foreach ($cats as $cat) {
                                $catitem = $_zp_zenpage->getCategory($cat);
                                $catarray[] = $catitem['titlelink'];
                                //to use the setCategories method we need an array with just the titlelinks!
                            }
                            $allcatsarray = array();
                            foreach ($allcats as $allcat) {
                                $allcatsarray[] = $allcat['titlelink'];
                                //same here!
                            }
                            $mycats = array_unique(array_merge($catarray, $allcatsarray));
                            $obj->setCategories($mycats);
                            break;
                        case 'clearcats':
                            $obj->setCategories(array());
                            break;
                        case 'showall':
                            $obj->set('show', 1);
                            break;
                        case 'hideall':
                            $obj->set('show', 0);
                            break;
                        case 'commentson':
                            $obj->set('commentson', 1);
                            break;
                        case 'commentsoff':
                            $obj->set('commentson', 0);
                            break;
                        case 'resethitcounter':
                            $obj->set('hitcounter', 0);
                            break;
                    }
                    $obj->save();
                }
            }
        }
    }
    return $action;
}
コード例 #23
0
 /**
  * Gets the feed item data in a Zenpage news feed
  *
  * @param array $item Titlelink a Zenpage article or filename of an image if a combined feed
  * @return array
  */
 protected function getItemNews($item)
 {
     $categories = '';
     $feeditem['enclosure'] = '';
     $obj = new ZenpageNews($item['titlelink']);
     $title = $feeditem['title'] = get_language_string($obj->getTitle('all'), $this->locale);
     $link = $obj->getLink();
     $count2 = 0;
     $plaincategories = $obj->getCategories();
     $categories = '';
     foreach ($plaincategories as $cat) {
         $catobj = new ZenpageCategory($cat['titlelink']);
         $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', ';
     }
     $categories = rtrim($categories, ', ');
     $desc = $obj->getContent($this->locale);
     $desc = str_replace('//<![CDATA[', '', $desc);
     $desc = str_replace('//]]>', '', $desc);
     $feeditem['desc'] = shortenContent($desc, getOption('externalFeed_truncate_length'), '...');
     if (!empty($categories)) {
         $feeditem['category'] = html_encode($categories);
         $feeditem['title'] = $title . ' (' . $categories . ')';
     }
     $feeditem['link'] = $link;
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     $feeditem['pubdate'] = date("r", strtotime($obj->getDateTime()));
     return $feeditem;
 }
コード例 #24
0
/**
 * Creates a "REWRITE" url given the query parameters that represent the link
 *
 * @param type $query
 * @return string
 */
function zpRewriteURL($query)
{
    $redirectURL = '';
    if (isset($query['p'])) {
        sanitize($query);
        switch ($query['p']) {
            case 'news':
                $redirectURL = _NEWS_;
                if (isset($query['category'])) {
                    $obj = new ZenpageCategory($query['category'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['category']);
                } else {
                    if (isset($query['date'])) {
                        $redirectURL = _NEWS_ARCHIVE_ . '/' . $query['date'];
                        unset($query['date']);
                    }
                }
                if (isset($query['title'])) {
                    $obj = new ZenpageNews($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'pages':
                $redirectURL = _PAGES_;
                if (isset($query['title'])) {
                    $obj = new ZenpagePage($query['title'], false);
                    if (!$obj->loaded) {
                        return '';
                    }
                    $redirectURL = $obj->getLink();
                    unset($query['title']);
                }
                break;
            case 'search':
                $redirectURL = _SEARCH_;
                if (isset($query['date'])) {
                    $redirectURL = _ARCHIVE_ . '/' . $query['date'];
                    unset($query['date']);
                } else {
                    if (isset($query['searchfields']) && $query['searchfields'] == 'tags') {
                        $redirectURL = _TAGS_;
                        unset($query['searchfields']);
                    }
                }
                if (isset($query['words'])) {
                    $redirectURL .= '/' . $query['words'];
                    unset($query['words']);
                }
                break;
            default:
                $redirectURL = getCustomPageURL($query['p']);
                break;
        }
        unset($query['p']);
        $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $redirectURL);
        if (isset($query['page'])) {
            $redirectURL .= '/' . $query['page'];
            unset($query['page']);
        }
        $q = http_build_query($query);
        if ($q) {
            $redirectURL .= '?' . $q;
        }
    } else {
        if (isset($query['album'])) {
            if (isset($query['image'])) {
                $obj = newImage(NULL, array('folder' => $query['album'], 'filename' => $query['image']), true);
                unset($query['image']);
            } else {
                $obj = newAlbum($query['album'], NULL, true);
            }
            unset($query['album']);
            if (!$obj->exists) {
                return '';
            }
            $redirectURL = preg_replace('~^' . WEBPATH . '/~', '', $obj->getLink());
            $q = http_build_query($query);
            if ($q) {
                $redirectURL .= '?' . $q;
            }
        }
    }
    return $redirectURL;
}
コード例 #25
0
ファイル: zenpage-class.php プロジェクト: rb26/zenphoto
 /**
  * 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;
 }
コード例 #26
0
 /**
  * Gets news articles titlelinks this category is attached to
  *
  * NOTE: Since this function only returns titlelinks for use with the object model it does not exclude articles that are password protected via a category
  *
  *
  * @param int $articles_per_page The number of articles to get
  * @param string $published "published" for published articles
  *													"published-unpublished" for published articles only from an unpublished category,
  * 													"unpublished" for unpublished articles,
  * 													"sticky" for sticky articles (published or not!) for Admin page use only,
  * 													"all" for all articles
  * @param boolean $ignorepagination Since also used for the news loop this function automatically paginates the results if the "page" GET variable is set. To avoid this behaviour if using it directly to get articles set this TRUE (default FALSE)
  * @param string $sortorder "date" for sorting by date (default)
  * 													"title" for sorting by title
  * 													This parameter is not used for date archives
  * @param string $sortdirection "desc" (default) for descending sort order
  * 													    "asc" for ascending sort order
  * 											        This parameter is not used for date archives
  * @param bool $sticky set to true to place "sticky" articles at the front of the list.
  * @return array
  */
 function getArticles($articles_per_page = '', $published = NULL, $ignorepagination = false, $sortorder = "date", $sortdirection = "desc", $sticky = true)
 {
     global $_zp_current_category, $_zp_post_date, $_zp_zenpage;
     $_zp_zenpage->processExpired('news');
     if (empty($published)) {
         $published = "published";
         if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | VIEW_NEWS_RIGHTS)) {
             $published = "all";
         }
     }
     $show = "";
     // new code to get nested cats
     $catid = $this->getID();
     $subcats = $this->getSubCategories();
     if ($subcats) {
         $cat = " (cat.cat_id = '" . $catid . "'";
         foreach ($subcats as $subcat) {
             $subcatobj = new ZenpageCategory($subcat);
             $cat .= "OR cat.cat_id = '" . $subcatobj->getID() . "' ";
         }
         $cat .= ") AND cat.news_id = news.id ";
     } else {
         $cat = " cat.cat_id = '" . $catid . "' AND cat.news_id = news.id ";
     }
     if (in_context(ZP_ZENPAGE_NEWS_DATE)) {
         $postdate = $_zp_post_date;
     } else {
         $postdate = NULL;
     }
     if ($sticky) {
         $sticky = 'sticky DESC,';
     }
     // sortorder and sortdirection
     switch ($sortorder) {
         case "date":
         default:
             $sort1 = "date";
             break;
         case "title":
             $sort1 = "title";
             break;
     }
     switch ($sortdirection) {
         case "desc":
         default:
             $dir = "DESC";
             break;
         case "asc":
             $dir = "ASC";
             $sticky = false;
             //makes no sense
             break;
     }
     /*** get articles by category ***/
     switch ($published) {
         case "published":
             $show = " AND `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = false;
             break;
         case "published-unpublished":
             $show = " AND `show` = 1 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = true;
             break;
         case "unpublished":
             $show = " AND `show` = 0 AND date <= '" . date('Y-m-d H:i:s') . "'";
             $getUnpublished = true;
             break;
         case 'sticky':
             $show = ' AND `sticky` <> 0';
             $getUnpublished = true;
             break;
         case "all":
             $getUnpublished = true;
             $show = "";
             break;
     }
     $order = " ORDER BY " . $sticky . "news.{$sort1} {$dir}";
     $sql = "SELECT DISTINCT news.titlelink FROM " . prefix('news') . " as news, " . prefix('news2cat') . " as cat WHERE" . $cat . $show . $order;
     $resource = $result = query($sql);
     if ($resource) {
         if ($ignorepagination) {
             $offset = 0;
         } else {
             $offset = $_zp_zenpage->getOffset($articles_per_page);
         }
         if (is_object($_zp_current_category)) {
             $currentcategory = $_zp_current_category->getTitlelink();
         } else {
             $currentcategory = false;
         }
         $result = array();
         while ($item = db_fetch_assoc($resource)) {
             $article = new ZenpageNews($item['titlelink']);
             if ($getUnpublished || $currentcategory && $article->inNewsCategory($currentcategory) || $article->categoryIsVisible()) {
                 $offset--;
                 if ($offset < 0) {
                     $result[] = $item;
                     if ($articles_per_page && count($result) >= $articles_per_page) {
                         break;
                     }
                 }
             }
         }
     }
     return $result;
 }