/**
 * Prints out latest comments for news articles and pages as a unordered list
 *
 * @param int $number how many comments you want.
 * @param string $shorten the number of characters to shorten the comment display
 * @param string $id The css id to style the list
 * @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 printLatestZenpageComments($number, $shorten = '123', $id = 'showlatestcomments', $type = "all", $itemID = "")
{
    if (empty($class)) {
        $id = "";
    } else {
        $id = "id='" . $id . " ";
    }
    $comments = getLatestZenpageComments($number, $type, $itemID);
    echo "<ul {$id}>\n";
    foreach ($comments as $comment) {
        if ($comment['anon']) {
            $author = "";
        } else {
            $author = " " . gettext("by") . " " . $comment['name'];
        }
        $date = $comment['date'];
        $title = get_language_string($comment['title']);
        $titlelink = $comment['titlelink'];
        $website = $comment['website'];
        $shortcomment = truncate_string($comment['comment'], $shorten);
        $url = "";
        switch ($comment['type']) {
            case "news":
                $url = getNewsURL($titlelink);
                break;
            case "pages":
                $url = getPageLinkURL($titlelink);
                break;
        }
        echo "<li><a href=\"" . html_encode($url) . "\" class=\"commentmeta\">" . $title . $author . "</a><br />\n";
        echo "<span class=\"commentbody\">" . $shortcomment . "</span></li>";
    }
    echo "</ul>\n";
}
示例#2
0
 /**
  * Gets the feed items
  *
  * @return array
  */
 public function getitems()
 {
     global $_zp_CMS;
     switch ($this->feedtype) {
         case 'gallery':
             if ($this->mode == "albums") {
                 $items = getAlbumStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, 0, $this->sortdirection);
             } else {
                 $items = getImageStatistic($this->itemnumber, $this->sortorder, $this->albumfolder, $this->collection, 0, $this->sortdirection);
             }
             break;
         case 'news':
             switch ($this->newsoption) {
                 case "category":
                     if ($this->sortorder) {
                         $items = getZenpageStatistic($this->itemnumber, 'categories', $this->sortorder, $this->sortdirection);
                     } else {
                         $items = getLatestNews($this->itemnumber, $this->catlink, false, $this->sortdirection);
                     }
                     break;
                 default:
                 case "news":
                     if ($this->sortorder) {
                         $items = getZenpageStatistic($this->itemnumber, 'news', $this->sortorder, $this->sortdirection);
                     } else {
                         // Needed baceause type variable "news" is used by the feed item method and not set by the class method getArticles!
                         $items = getLatestNews($this->itemnumber, '', false, $this->sortdirection);
                     }
                     break;
             }
             break;
         case "pages":
             if ($this->sortorder) {
                 $items = getZenpageStatistic($this->itemnumber, 'pages', $this->sortorder, $this->sortdirection);
             } else {
                 $items = $_zp_CMS->getPages(NULL, false, $this->itemnumber);
             }
             break;
         case 'comments':
             switch ($type = $this->commentfeedtype) {
                 case 'gallery':
                     $items = getLatestComments($this->itemnumber, 'all');
                     break;
                 case 'album':
                     $items = getLatestComments($this->itemnumber, 'album', $this->id);
                     break;
                 case 'image':
                     $items = getLatestComments($this->itemnumber, 'image', $this->id);
                     break;
                 case 'zenpage':
                     $type = 'all';
                 case 'news':
                 case 'page':
                     if (function_exists('getLatestZenpageComments')) {
                         $items = getLatestZenpageComments($this->itemnumber, $type, $this->id);
                     }
                     break;
                 case 'allcomments':
                     $items = getLatestComments($this->itemnumber, 'all');
                     $items_zenpage = array();
                     if (function_exists('getLatestZenpageComments')) {
                         $items_zenpage = getLatestZenpageComments($this->itemnumber, 'all', $this->id);
                         $items = array_merge($items, $items_zenpage);
                         $items = sortMultiArray($items, 'date', true);
                         $items = array_slice($items, 0, $this->itemnumber);
                     }
                     break;
             }
             break;
     }
     if (isset($items)) {
         return $items;
     }
     if (TEST_RELEASE) {
         zp_error(gettext('Bad ' . $this->feed . ' feed:' . $this->feedtype), E_USER_WARNING);
     }
     return NULL;
 }
示例#3
0
    case 'zenpage':
    case 'news':
    case 'page':
        if ($type == 'zenpage') {
            $type = 'all';
        }
        if (function_exists('getLatestZenpageComments')) {
            $comments = getLatestZenpageComments($items, $type, $id);
        }
        break;
    case 'allcomments':
        $type = 'all';
        $comments = getLatestComments($items, $type, $id);
        $comments_zenpage = array();
        if (function_exists('getLatestZenpageComments')) {
            $comments_zenpage = getLatestZenpageComments($items, $type, $id);
            $comments = array_merge($comments, $comments_zenpage);
            $comments = sortMultiArray($comments, 'id', true);
            $comments = array_slice($comments, 0, $items);
        }
        break;
}
foreach ($comments as $comment) {
    if ($comment['anon']) {
        $author = "";
    } else {
        $author = " " . gettext("by") . " " . $comment['name'];
    }
    $imagetag = "";
    $title = '';
    switch ($comment['type']) {