Example #1
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_CMS;
    if (!extensionEnabled('zenpage')) {
        return FALSE;
    }
    $passwordcheck = '';
    $ids = array();
    $where = '';
    $tagWhere = "";
    switch ($mode) {
        case 'news':
            if (zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS)) {
                $published = 'all';
            } else {
                $published = 'published';
            }
            $type = 'news';
            $items = $_zp_CMS->getArticles(false, $published);
            foreach ($items as $item) {
                $obj = newArticle($item['titlelink']);
                if ($obj->checkAccess()) {
                    $ids[] = $obj->getID();
                }
            }
            break;
        case 'pages':
            $published = !zp_loggedin(ZENPAGE_NEWS_RIGHTS | ALL_NEWS_RIGHTS);
            $type = 'pages';
            $items = $_zp_CMS->getPages($published);
            foreach ($items as $item) {
                $obj = newPage($item['titlelink']);
                if ($obj->checkAccess()) {
                    $ids[] = $obj->getID();
                }
            }
            break;
    }
    $count = '';
    if (count($ids) == 0) {
        return FALSE;
    } else {
        $tagWhere = " WHERE ";
        foreach ($ids as $id) {
            $count++;
            $tagWhere .= '(o.objectid =' . $id . " AND o.tagid = t.id AND o.type = '" . $type . "')";
            if ($count != count($ids)) {
                $tagWhere .= " OR ";
            }
        }
    }
    if (empty($tagWhere)) {
        return FALSE;
    } else {
        $tags = query_full_array("SELECT DISTINCT t.name, t.id, (SELECT DISTINCT COUNT(*) FROM " . prefix('obj_to_tag') . " WHERE tagid = t.id AND o.type = '" . $type . "') AS count FROM " . prefix('obj_to_tag') . " AS o," . prefix('tags') . " AS t" . $tagWhere . " ORDER BY t.name");
    }
    return $tags;
}
Example #2
0
 public function getitems()
 {
     $items = array();
     if ($album = @$this->options['album']) {
         if ($image = @$this->options['image']) {
             if (!is_array($image)) {
                 $image = array($image);
             }
             foreach ($image as $filename) {
                 $obj = newImage(array('folder' => $album, 'filename' => $filename), true, true);
                 if ($obj->exists) {
                     $items[] = $obj;
                 }
             }
         } else {
             if (!is_array($album)) {
                 $album = array($album);
             }
             foreach ($album as $folder) {
                 $obj = newAlbum($folder, true);
                 if ($obj->exists) {
                     $items[] = $obj;
                 }
             }
         }
         return $items;
     }
     if ($this->feedtype == 'news' && ($news = @$this->options['titlelink'])) {
         if (!is_array($news)) {
             $news = array($news);
         }
         foreach ($news as $article) {
             $obj = newArticle($article, false);
             if ($obj->loaded) {
                 $items[] = array('titlelink' => $article);
             }
         }
         return $items;
     }
     if ($this->feedtype == 'pages' && ($pages = @$this->options['titlelink'])) {
         if (!is_array($pages)) {
             $pages = array($pages);
         }
         foreach ($pages as $page) {
             $obj = newPage($page, false);
             if ($obj->loaded) {
                 $items[] = array('titlelink' => $page);
             }
         }
         return $items;
     }
     return parent::getitems();
 }
/**
 * Gets latest comments for news articles and pages
 *
 * @param int $number how many comments you want.
 * @param string $type 	"all" for all latest comments for all news articles and all pages
 * 											"news" for the lastest comments of one specific news article
 * 											"page" for the lastest comments of one specific page
 * @param int $itemID the ID of the element to get the comments for if $type != "all"
 */
function getLatestZenpageComments($number, $type = "all", $itemID = "")
{
    $itemID = sanitize_numeric($itemID);
    $number = sanitize_numeric($number);
    $checkauth = zp_loggedin();
    if ($type == 'all' || $type == 'news') {
        $newspasswordcheck = "";
        if (zp_loggedin(MANAGE_ALL_NEWS_RIGHTS)) {
            $newsshow = '';
        } else {
            $newsshow = 'news.show=1 AND';
            $newscheck = query_full_array("SELECT * FROM " . prefix('news') . " ORDER BY date");
            foreach ($newscheck as $articlecheck) {
                $obj = newArticle($articlecheck['titlelink']);
                if ($obj->inProtectedCategory()) {
                    if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) {
                        $newsshow = '';
                    } else {
                        $excludenews = " AND id != " . $articlecheck['id'];
                        $newspasswordcheck = $newspasswordcheck . $excludenews;
                    }
                }
            }
        }
    }
    if ($type == 'all' || $type == 'page') {
        $pagepasswordcheck = "";
        if (zp_loggedin(MANAGE_ALL_PAGES_RIGHTS)) {
            $pagesshow = '';
        } else {
            $pagesshow = 'pages.show=1 AND';
            $pagescheck = query_full_array("SELECT * FROM " . prefix('pages') . " ORDER BY date");
            foreach ($pagescheck as $pagecheck) {
                $obj = newPage($pagecheck['titlelink']);
                if ($obj->isProtected()) {
                    if ($checkauth && $obj->isMyItem(LIST_RIGHTS)) {
                        $pagesshow = '';
                    } else {
                        $excludepages = " AND pages.id != " . $pagecheck['id'];
                        $pagepasswordcheck = $pagepasswordcheck . $excludepages;
                    }
                }
            }
        }
    }
    switch (strtolower($type)) {
        case "news":
            $whereNews = " WHERE {$newsshow} news.id = " . $itemID . " AND c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck;
            break;
        case "page":
            $wherePages = " WHERE {$pagesshow} pages.id = " . $itemID . " AND c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck;
            break;
        case "all":
            $whereNews = " WHERE {$newsshow} c.ownerid = news.id AND c.type = 'news' AND c.private = 0 AND c.inmoderation = 0" . $newspasswordcheck;
            $wherePages = " WHERE {$pagesshow} c.ownerid = pages.id AND c.type = 'pages' AND c.private = 0 AND c.inmoderation = 0" . $pagepasswordcheck;
            break;
    }
    $comments_news = array();
    $comments_pages = array();
    if ($type == "all" or $type == "news") {
        $comments_news = query_full_array("SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, news.title, news.titlelink FROM " . prefix('comments') . " AS c, " . prefix('news') . " AS news " . $whereNews . " ORDER BY c.id DESC LIMIT {$number}");
    }
    if ($type == "all" or $type == "page") {
        $comments_pages = query_full_array($sql = "SELECT c.id, c.name, c.type, c.website," . " c.date, c.anon, c.comment, pages.title, pages.titlelink FROM " . prefix('comments') . " AS c, " . prefix('pages') . " AS pages " . $wherePages . " ORDER BY c.id DESC LIMIT {$number}");
    }
    $comments = array();
    foreach ($comments_news as $comment) {
        $comments[$comment['id']] = $comment;
    }
    foreach ($comments_pages as $comment) {
        $comments[$comment['id']] = $comment;
    }
    krsort($comments);
    return array_slice($comments, 0, $number);
}
Example #4
0
/**
 * Gets an item object by id
 *
 * @param string $table database table to search
 * @param int $id id of the item to get
 * @return mixed
 */
function getItemByID($table, $id)
{
    if ($result = query_single_row('SELECT * FROM ' . prefix($table) . ' WHERE id =' . (int) $id)) {
        switch ($table) {
            case 'images':
                if ($alb = getItemByID('albums', $result['albumid'])) {
                    return newImage($alb, $result['filename'], true);
                }
                break;
            case 'albums':
                return newAlbum($result['folder'], false, true);
            case 'news':
                return newArticle($result['titlelink']);
            case 'pages':
                return newPage($result['titlelink']);
            case 'news_categories':
                return new Category($result['titlelink']);
        }
    }
    return NULL;
}
Example #5
0
 /**
  * Gets the feed item data in a comments feed
  *
  * @param array $item Array of a comment
  * @return array
  */
 protected function getitemComments($item)
 {
     if ($item['anon']) {
         $author = "";
     } else {
         $author = " " . gettext("by") . " " . $item['name'];
     }
     $commentpath = $imagetag = $title = '';
     switch ($item['type']) {
         case 'images':
             $title = get_language_string($item['title']);
             $obj = newImage(array('folder' => $item['folder'], 'filename' => $item['filename']));
             $link = $obj->getlink();
             $feeditem['pubdate'] = date("r", strtotime($item['date']));
             $category = get_language_string($item['albumtitle']);
             $website = $item['website'];
             $title = $category . ": " . $title;
             $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id'];
             break;
         case 'albums':
             $obj = newAlbum($item['folder']);
             $link = rtrim($obj->getLink(), '/');
             $feeditem['pubdate'] = date("r", strtotime($item['date']));
             $title = get_language_string($item['albumtitle']);
             $website = $item['website'];
             $commentpath = PROTOCOL . '://' . $this->host . $link . "#" . $item['id'];
             break;
         case 'news':
         case 'pages':
             if (extensionEnabled('zenpage')) {
                 $feeditem['pubdate'] = date("r", strtotime($item['date']));
                 $category = '';
                 $title = get_language_string($item['title']);
                 $titlelink = $item['titlelink'];
                 $website = $item['website'];
                 if ($item['type'] == 'news') {
                     $obj = newArticle($titlelink);
                 } else {
                     $obj = newPage($titlelink);
                 }
                 $commentpath = PROTOCOL . '://' . $this->host . html_encode($obj->getLink()) . "#" . $item['id'];
             } else {
                 $commentpath = '';
             }
             break;
     }
     $feeditem['title'] = getBare($title . $author);
     $feeditem['link'] = $commentpath;
     $feeditem['desc'] = $item['comment'];
     return $feeditem;
 }
/**
 * 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 getSitemapNewsArticles()
{
    global $_zp_CMS, $sitemap_number;
    //not splitted into several sitemaps yet
    if ($sitemap_number == 1) {
        $data = '';
        $sitemap_locales = generateLanguageList();
        $changefreq = getOption('sitemap_changefreq_news');
        $articles = $_zp_CMS->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 = newArticle($article['titlelink']);
                $lastchange = $date = substr($articleobj->getPublishDate(), 0, 10);
                if (!is_null($articleobj->getLastchange())) {
                    $lastchange = substr($articleobj->getLastchange(), 0, 10);
                }
                if ($date > $lastchange) {
                    $date = $lastchange;
                }
                if (!$articleobj->inProtectedCategory()) {
                    $base = $articleobj->getLink();
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = str_replace(WEBPATH, seo_locale::localePath(true, $locale), $base);
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = dynamic_locale::fullHostPath($locale) . $base;
                                $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = FULLHOSTPATH . $base;
                            $data .= sitemap_echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                }
            }
            $data .= sitemap_echonl('</urlset>');
            // End off the <urlset> tag
        }
        return $data;
    }
}
Example #7
0
 /**
  *
  * Creates the news article
  * @param object $obj
  */
 protected static function publishArticle($obj, $override = NULL)
 {
     global $_zp_CMS;
     $galleryitem_text = array();
     $locale = getOption('locale');
     switch ($type = $obj->table) {
         case 'albums':
             $album = $obj->name;
             $dbstring = getOption('galleryArticles_album_text');
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale));
             foreach (generateLanguageList() as $key) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($languagetext, $obj->getTitle($key));
                 }
             }
             $ref = '"' . $album . '"';
             $title = $folder = $album;
             $img = $obj->getAlbumThumbImage();
             $class = 'galleryarticles-newalbum';
             break;
         case 'images':
             $album = $obj->album->name;
             $image = $obj->filename;
             $dbstring = unserialize(getOption('galleryArticles_image_text'));
             $localtext = get_language_string($dbstring);
             $galleryitem_text[$locale] = sprintf($localtext, $obj->getTitle($locale), $obj->album->getTitle($locale));
             foreach (generateLanguageList() as $key => $val) {
                 $languagetext = get_language_string($dbstring, $key);
                 if ($localtext != $languagetext) {
                     $galleryitem_text[$key] = sprintf($localtext, $obj->getTitle($key), $obj->album->getTitle($key));
                 }
             }
             $ref = '"' . $album . '" "' . $image . '"';
             $folder = $obj->imagefolder;
             $title = $folder . '-' . $image;
             $img = $obj;
             $class = 'galleryarticles-newimage';
             break;
         default:
             //not a gallery object
             return;
     }
     $article = newArticle(seoFriendly('galleryArticles-' . $title));
     $article->setTitle(serialize($galleryitem_text));
     $imglink = $img->getCustomImage(getOption('galleryArticles_size'), NULL, NULL, NULL, NULL, NULL, NULL, -1);
     $desc = '<p><a class="' . $class . '" href="' . $obj->getLink() . '"><img src="' . $imglink . '"></a></p><p>[GALLERYARTICLEDESC ' . $ref . ']</p>';
     $article->setContent($desc);
     $date = $obj->getPublishDate();
     if (!$date) {
         $date = date('Y-m-d H:i:s');
     }
     $article->setDateTime($date);
     $article->setLastchange(date('Y-m-d H:i:s'));
     $article->setAuthor('galleryArticles');
     $article->setLastchangeauthor('galleryArticles');
     $article->setShow(true);
     $article->save();
     if ($override) {
         $cat = $override;
     } else {
         $cat = getOption('galleryArticles_category');
         if (getOption('galleryArticles_albumCategory')) {
             $catlist = $_zp_CMS->getAllCategories();
             foreach ($catlist as $category) {
                 if ($category['titlelink'] == $folder) {
                     $cat = $category['titlelink'];
                     break;
                 }
             }
         }
     }
     $article->setCategories(array($cat));
 }
Example #8
0
</th>
								<th><?php 
echo gettext('Expires');
?>
</th>
								<th class="subhead" colspan="8">
									<label style="float: right"><?php 
echo gettext("Check All");
?>
 <input type="checkbox" name="allbox" id="allbox" onclick="checkAll(this.form, 'ids[]', this.checked);" />
									</label>
								</th>
							</tr>
							<?php 
foreach ($result as $article) {
    $article = newArticle($article['titlelink']);
    ?>
								<tr class="newstr">
									<td>
										<?php 
    switch ($article->getSticky()) {
        case 1:
            $sticky = ' <small>[' . gettext('sticky') . ']</small>';
            break;
        case 9:
            $sticky = ' <small><strong>[' . gettext('sticky') . ']</strong></small>';
            break;
        default:
            $sticky = '';
            break;
    }
Example #9
0
</h3>
							</div>
						</div>
					<?php 
}
?>
					<?php 
$_zp_current_album = NULL;
?>
				</div>
				<br style="clear:both;" /><br />
				<h3 class="searchheader" >Latest words</h3>
				<?php 
$ln = getLatestNews(3);
foreach ($ln as $n) {
    $_zp_current_article = newArticle($n['titlelink']);
    ?>


					<div class="newsarticlewrapper"><div class="newsarticle" style="border-width: 0;">
							<h3><?php 
    printNewsURL();
    ?>
</h3>
							<div class="newsarticlecredit"><span class="newsarticlecredit-left"><?php 
    printNewsDate();
    ?>
 | <?php 
    echo gettext("Comments:");
    ?>
 <?php 
Example #10
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 = newArticle($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 = newCategory($cat['titlelink']);
         $categories .= get_language_string($catobj->getTitle('all'), $this->locale) . ', ';
     }
     $categories = rtrim($categories, ', ');
     $feeditem['desc'] = shortenContent($obj->getContent($this->locale), getOption('RSS_truncate_length'), '...');
     if (!empty($categories)) {
         $feeditem['category'] = html_encode($categories);
         $feeditem['title'] = $title . ' (' . $categories . ')';
     }
     $feeditem['link'] = PROTOCOL . '://' . $this->host . $link;
     $feeditem['media_content'] = '';
     $feeditem['media_thumbnail'] = '';
     $feeditem['pubdate'] = date("r", strtotime($item['date']));
     return $feeditem;
 }
Example #11
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 = newArticle($newID);
         $newobj->setTitle($newtitle);
         $newobj->setTags($this->getTags(false));
         $newobj->setDateTime('');
         $newobj->setShow(0);
         $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;
 }
Example #12
0
/**
 * Prints the x related articles based on a tag search
 *
 * @param int $number Number of items to get
 * @param string $type 'albums', 'images','news','pages', "all" for all combined.
 * @param string $specific If $type = 'albums' or 'images' name of album
 * @param bool $excerpt If a text excerpt (gallery items: description; Zenpage items: content) should be shown. NULL for none or number of length
 * @param bool $thumb For $type = 'albums' or 'images' if a thumb should be shown (default size as set on the options)
 */
function printRelatedItems($number = 5, $type = 'news', $specific = NULL, $excerpt = NULL, $thumb = false, $date = false)
{
    global $_zp_gallery, $_zp_current_album, $_zp_current_image;
    $label = array('albums' => gettext('Albums'), 'images' => gettext('Images'), 'news' => gettext('News'), 'pages' => gettext('Pages'));
    $result = getRelatedItems($type, $specific);
    $resultcount = count($result);
    if ($resultcount != 0) {
        ?>
		<h3 class="relateditems">
			<?php 
        printf(gettext('Related %s'), $type);
        ?>
		</h3>
		<ul id="relateditems">
			<?php 
        $count = 0;
        foreach ($result as $item) {
            $count++;
            ?>
				<li class="<?php 
            echo $item['type'];
            ?>
">
					<?php 
            $category = '';
            switch ($item['type']) {
                case 'albums':
                    $obj = newAlbum($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getDesc();
                    $category = gettext('Album');
                    break;
                case 'images':
                    $alb = newAlbum($item['album']);
                    $obj = newImage($alb, $item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getDesc();
                    $category = gettext('Image');
                    break;
                case 'news':
                    $obj = newArticle($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getContent();
                    $category = gettext('News');
                    break;
                case 'pages':
                    $obj = newPage($item['name']);
                    $url = $obj->getLink();
                    $text = $obj->getContent();
                    $category = gettext('Page');
                    break;
            }
            ?>
					<?php 
            if ($thumb) {
                $thumburl = false;
                switch ($item['type']) {
                    case 'albums':
                        $thumburl = $obj->getThumb();
                        break;
                    case 'images':
                        $thumburl = $obj->getThumb();
                        break;
                }
                if ($thumburl) {
                    ?>
							<a href="<?php 
                    echo html_encode(pathurlencode($url));
                    ?>
" title="<?php 
                    echo html_encode($obj->getTitle());
                    ?>
" class="relateditems_thumb">
								<img src="<?php 
                    echo html_encode(pathurlencode($thumburl));
                    ?>
" alt="<?php 
                    echo html_encode($obj->getTitle());
                    ?>
" />
							</a>
							<?php 
                }
            }
            ?>
					<h4><a href="<?php 
            echo html_encode(pathurlencode($url));
            ?>
" title="<?php 
            echo html_encode($obj->getTitle());
            ?>
"><?php 
            echo html_encode($obj->getTitle());
            ?>
</a>
						<?php 
            if ($date) {
                ?>
							<span class="relateditems_date">
								<?php 
                echo zpFormattedDate(DATE_FORMAT, strtotime($obj->getDateTime()));
                ?>
							</span>
							<?php 
            }
            ?>
						<?php 
            if ($type == 'all') {
                ?>
 (<small><?php 
                echo $category;
                ?>
</small>)<?php 
            }
            ?>

					</h4>
					<?php 
            if ($excerpt) {
                echo html_encodeTagged(shortenContent($text, $excerpt, '...', true));
            }
            ?>
				</li>
				<?php 
            if ($count == $number) {
                break;
            }
        }
        // foreach
        if ($count) {
            ?>
			</ul>
			<?php 
        }
    }
}
Example #13
0
/**
 * Processes the check box bulk actions
 *
 */
function processZenpageBulkActions($type)
{
    global $_zp_CMS;
    $action = false;
    if (isset($_POST['ids'])) {
        //echo "action for checked items:". $_POST['checkallaction'];
        $action = sanitize($_POST['checkallaction']);
        switch ($type) {
            case 'Article':
                $table = 'news';
                break;
            case 'Page':
                $table = 'pages';
                break;
            case 'Category':
                $table = 'news_categories';
                break;
        }
        $result = zp_apply_filter('processBulkCMSSave', NULL, $action, $table);
        $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') {
                    if (isset($_POST['addcategories'])) {
                        $cats = sanitize($_POST['addcategories']);
                    } else {
                        $cats = array();
                    }
                }
                $n = 0;
                foreach ($links as $titlelink) {
                    $obj = new $type($titlelink);
                    if (is_null($result)) {
                        switch ($action) {
                            case 'deleteall':
                                $obj->remove();
                                break;
                            case 'addtags':
                                $mytags = array_unique(array_merge($tags, $obj->getTags(false)));
                                $obj->setTags($mytags);
                                break;
                            case 'cleartags':
                                $obj->setTags(array());
                                break;
                            case 'alltags':
                                $allarticles = $obj->getArticles('', 'all', true);
                                foreach ($allarticles as $article) {
                                    $newsobj = newArticle($article['titlelink']);
                                    $mytags = array_unique(array_merge($tags, $newsobj->getTags(false)));
                                    $newsobj->setTags($mytags);
                                    $newsobj->save();
                                }
                                break;
                            case 'clearalltags':
                                $allarticles = $obj->getArticles('', 'all', true);
                                foreach ($allarticles as $article) {
                                    $newsobj = newArticle($article['titlelink']);
                                    $newsobj->setTags(array());
                                    $newsobj->save();
                                }
                                break;
                            case 'addcats':
                                $catarray = array();
                                $allcats = $obj->getCategories();
                                foreach ($cats as $cat) {
                                    $catitem = $_zp_CMS->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->setShow(1);
                                break;
                            case 'hideall':
                                $obj->setShow(0);
                                break;
                            case 'commentson':
                                $obj->setCommentsAllowed(1);
                                break;
                            case 'commentsoff':
                                $obj->setCommentsAllowed(0);
                                break;
                            case 'resethitcounter':
                                $obj->set('hitcounter', 0);
                                break;
                        }
                    } else {
                        $obj->set($action, $result);
                    }
                    $obj->save();
                }
            }
        }
    }
    return $action;
}
Example #14
0
								</form>
							</div>
							<?php 
    } else {
        echo gettext('No unpublished categories');
    }
    ?>
					</fieldset>
					<br class="clearall" />
					<?php 
    $visible = $report == 'news';
    $items = $_zp_CMS->getArticles(0, false);
    $output = '';
    $c = 0;
    foreach ($items as $key => $item) {
        $itemobj = newArticle($item['titlelink']);
        if (!$itemobj->getShow()) {
            $c++;
            $output .= '<li><label><input type="checkbox" name="' . $item['titlelink'] . '" value="' . $item['titlelink'] . '" class="catcheck" />' . $itemobj->getTitle() . '</label>';
            if ($desc = shortenContent($itemobj->getContent(), 50, '...')) {
                $output .= ' "' . strip_tags($desc) . '"';
            }
            $output .= ' <a href="' . html_encode($itemobj->getLink()) . '" title="' . html_encode($itemobj->getTitle()) . '">(' . gettext('View') . ') </a><a href="' . WEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/zenpage/admin-edit.php?newscategory&titlelink=' . html_encode($itemobj->getTitlelink()) . '">(' . gettext('Edit') . ')</a></li>';
        }
    }
    ?>
					<fieldset class="smallbox">
						<legend><?php 
    if ($c > 0) {
        reveal('newsbox', $visible);
    }
Example #15
0
 if ($action == "admin") {
     //
     //require_once("adminArt.html");
     if (!isset($_SESSION["name"])) {
         header("Location: DTTadmin.php?a=login");
     } else {
         $adminArt = $_GET["b"];
         //if null
         switch ($adminArt) {
             case null:
                 header("Location: index.php");
                 break;
             case "add":
                 $admin = file_get_contents("widgetAdmin.html");
                 echo setTitle($template, "New Article", $admin);
                 echo newArticle();
                 echo setFoot($link);
                 break;
             case "check":
                 $save = isset($_POST["save"]) ? $_POST["save"] : null;
                 $update = isset($_POST["update"]) ? $_POST["update"] : null;
                 $cancel = isset($_POST["cancel"]) ? $_POST["cancel"] : null;
                 if (isset($save)) {
                     $title = $_POST["artTit"];
                     $sumary = $_POST["sumary"];
                     $content = $_POST["Article"];
                     $date = $_POST["date"];
                     //who expects the own admin injectin bad querys?
                     $query = $pdo->prepare("INSERT INTO articleTable (title, sumary, article, publishdate) VALUES ('{$title}', '{$sumary}', '{$content}', '{$date}')");
                     $query->execute();
                     header("Location: DTTadmin.php?a=admin");
Example #16
0
         $obj = newAlbum($args['album']);
         $title = gettext('<em>album</em>: %s');
         $token = gettext('%s with link to album');
         $image = $obj->getThumb();
         $thumbobj = $obj->getAlbumThumbImage();
         $args['image'] = $thumbobj->getFilename();
         $args['album'] = $thumbobj->album->getFilename();
         $imageb = preg_replace('~&check=(.*)~', '', getIPSizedImage($size, $thumbobj));
     }
     $alt1 = $obj->getFileName();
     // an image type object
 } else {
     // a simple link
     $args['album'] = $args['image'] = $imagef = $imageb = $image = $alt1 = $title1 = NULL;
     if (isset($args['news'])) {
         $obj = newArticle($args['news']);
         $title = gettext('<em>news article</em>: %s');
         $token = gettext('title with link to news article');
     }
     if (isset($args['pages'])) {
         $obj = newPage($args['pages']);
         $title = gettext('<em>page</em>: %s');
         $token = gettext('title with link to page');
     }
     if (isset($args['news_categories'])) {
         $obj = newCategory($args['news_categories']);
         $title = gettext('<em>category</em>: %s');
         $token = gettext('title with link to category');
     }
 }
 $link = $obj->getLink();
Example #17
0
function printLatestNewsCustom($number = 5, $category = '', $showdate = true, $showcontent = true, $contentlength = 70, $showcat = true)
{
    global $_zp_gallery, $_zp_current_article;
    $latest = getLatestNews($number, $category);
    echo "\n<div id=\"latestnews-spotlight\">\n";
    $count = "";
    foreach ($latest as $item) {
        $count++;
        $category = "";
        $categories = "";
        $obj = newArticle($item['titlelink']);
        $title = htmlspecialchars($obj->getTitle());
        $link = getNewsURL($item['titlelink']);
        $count2 = 0;
        $category = $obj->getCategories();
        foreach ($category as $cat) {
            $catobj = new Category($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";
}
Example #18
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 = newArticle($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
/**
 * Loads a zenpage news article
 * Sets up $_zp_current_article and returns it as the function result.
 *
 * @param array $request an array with one member: the key is "date", "category", or "title" and specifies
 * what you want loaded. The value is the date or title of the article wanted
 *
 * @return object
 */
function load_zenpage_news($request)
{
    global $_zp_current_article, $_zp_current_category, $_zp_post_date;
    if (isset($request['date'])) {
        add_context(ZP_ZENPAGE_NEWS_DATE);
        $_zp_post_date = sanitize(rtrim($request['date'], '/'));
    }
    if (isset($request['category'])) {
        $titlelink = sanitize(rtrim($request['category'], '/'));
        $_zp_current_category = new Category($titlelink);
        if ($_zp_current_category->loaded) {
            add_context(ZP_ZENPAGE_NEWS_CATEGORY);
        } else {
            $_GET['p'] = 'CATEGORY:' . $titlelink;
            unset($_GET['category']);
            return false;
        }
    }
    if (isset($request['title'])) {
        $titlelink = sanitize(rtrim($request['title'], '/'));
        $sql = 'SELECT `id` FROM ' . prefix('news') . ' WHERE `titlelink`=' . db_quote($titlelink);
        $result = query_single_row($sql);
        if (is_array($result)) {
            add_context(ZP_ZENPAGE_NEWS_ARTICLE | ZP_ZENPAGE_SINGLE);
            $_zp_current_article = newArticle($titlelink);
        } else {
            $_GET['p'] = 'NEWS:' . $titlelink;
        }
        return $_zp_current_article;
    }
    return true;
}
Example #20
0
session_start();
$action = isset($_GET['action']) ? $_GET['action'] : "";
$username = isset($_SESSION['username']) ? $_SESSION['username'] : "";
if ($action != "login" && $action != "logout" && !$username) {
    login();
    exit;
}
switch ($action) {
    case 'login':
        login();
        break;
    case 'logout':
        logout();
        break;
    case 'newArticle':
        newArticle();
        break;
    case 'editArticle':
        editArticle();
        break;
    case 'deleteArticle':
        deleteArticle();
        break;
    default:
        listArticles();
}
function login()
{
    $results = array();
    $results['pageTitle'] = "Admin Login | Falcon";
    if (isset($_POST['login'])) {
Example #21
0
 /**
  *
  * filters query results for only news that should be shown. (that is fit to print?)
  * @param $sql query to return all candidates of interest
  * @param $offset skip this many legitimate items (used for pagination)
  * @param $limit return only this many items
  */
 protected function siftResults($sql, $offset, $limit)
 {
     $resource = $result = query($sql);
     if ($resource) {
         $result = array();
         while ($item = db_fetch_assoc($resource)) {
             if ($item['type'] == 'news') {
                 $article = newArticle($item['titlelink']);
                 if (!$article->categoryIsVisible()) {
                     continue;
                 }
             }
             $offset--;
             if ($offset < 0) {
                 $result[] = $item;
                 if ($limit && count($result) >= $limit) {
                     break;
                 }
             }
         }
         db_free_result($resource);
     }
     return $result;
 }