/**
 * Prints the statistics Zenpage items as an unordered list
 *
 * @param int $number The number of news items to get
 * @param string $option "all" pages and articles
 * 											 "news" for news articles
 * 											 "pages" for pages
 * @param string $mode "popular" most viewed for pages, news articles and categories
 * 										 "mostrated" for news articles and pages
 * 										 "toprated" for news articles and pages
 * 										 "random" for pages, news articles and categories
 * @param bool $showstats if the value should be shown
 * @param bool $showtype if the type should be shown
 * @param bool $showdate if the date should be shown (news articles and pages only)
 * @param bool $showcontent if the content should be shown (news articles and pages only)
 * @param bool $contentlength The shortened lenght of the content
 * @param string $sortdir "asc" for ascending or "desc" for descending (default)
 */
function printZenpageStatistic($number = 10, $option = "all", $mode = "popular", $showstats = true, $showtype = true, $showdate = true, $showcontent = true, $contentlength = 40, $sortdir = 'desc')
{
    $stats = getZenpageStatistic($number, $option, $mode);
    $contentlength = sanitize_numeric($contentlength);
    switch ($mode) {
        case 'popular':
            $cssid = "'zenpagemostpopular'";
            break;
        case 'mostrated':
            $cssid = "'zenpagemostrated'";
            break;
        case 'toprated':
            $cssid = "'zenpagetoprated'";
            break;
        case 'random':
            $cssid = "'zenpagerandom'";
            break;
    }
    echo "<ul id={$cssid}>";
    foreach ($stats as $item) {
        switch ($mode) {
            case 'popular':
                $statsvalue = $item['hitcounter'];
                break;
            case 'mostrated':
                $statsvalue = $item['total_votes'];
                break;
            case 'toprated':
                $statsvalue = $item['rating'];
                break;
        }
        switch ($item['type']) {
            case 'Page':
                $titlelink = html_encode(getPageURL($item['titlelink']));
            case 'News':
                $titlelink = html_encode(getNewsURL($item['titlelink']));
                break;
            case 'Category':
                $titlelink = html_encode(getNewsCategoryURL($item['titlelink']));
                break;
        }
        echo '<li><a href = "' . $titlelink . '" title = "' . html_encode(getBare($item['title'])) . '"><h3>' . $item['title'];
        echo '<small>';
        if ($showtype) {
            echo ' [' . $item['type'] . ']';
        }
        if ($showstats && ($item['type'] != 'Category' && $mode != 'mostrated' && $mode != 'toprated')) {
            echo ' (' . $statsvalue . ')';
        }
        echo '</small>';
        echo '</h3></a>';
        if ($showdate && $item['type'] != 'Category') {
            echo "<p>" . zpFormattedDate(DATE_FORMAT, strtotime($item['date'])) . "</p>";
        }
        if ($showcontent && $item['type'] != 'Category') {
            echo '<p>' . truncate_string($item['content'], $contentlength) . '</p>';
        }
        echo '</li>';
    }
    echo '</ul>';
}
Esempio 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;
 }