Dotclear

source: plugins/infoBlog/_public.php @ 635

Revision 635, 2.7 KB checked in by Tomtom33, 15 years ago (diff)

Added infoBlog plugin - Version 1.0-RC3

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3#
4# This file is part of plugin infoBlog for Dotclear 2.
5# Copyright (c) 2008 Thomas Bouron.
6#
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK ------------------------------------
12
13/**
14 * Class infoBlogPublic
15 */
16class infoBlogPublic
17{
18     /**
19      * This function displays the infoBlog widget
20      *
21      * @param w    Widget object
22      *
23      * @return     string
24      */
25     public static function widget(&$w)
26     {
27          global $core;
28
29          if ($w->homeonly && $core->url->type != 'default') {
30               return;
31          }
32
33          $mask = '<li class="%1$s">%2$s</li>';
34
35          $title = (strlen($w->title) > 0) ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '';
36         
37          $res = '';
38
39          if ($w->displayentriesnumber) {
40               $post_count = $core->blog->getPosts(array(),true)->f(0);
41               $str_entries = ($post_count > 1) ? __('entries') : __('entry');
42               $res .= sprintf($mask,'entries-number',$post_count.' '.$str_entries);
43          }
44          if ($w->displaycommentsnumber) {
45               $comment_count = $core->blog->getComments(array(),true)->f(0);
46               $str_comments = ($comment_count > 1) ? __('comments') : __('comment');
47               $res .= sprintf($mask,'comments-number',$comment_count.' '.$str_comments);
48          }
49          if ($w->displaypingsnumber) {
50               $ping_count = $core->blog->getComments(array('comment_trackback' => true),true)->f(0);
51               $str_pings = ($comment_count > 1) ? __('pings') : __('ping');
52               $res .= sprintf($mask,'pings-number',$ping_count.' '.$str_pings);
53          }
54          if ($w->displaystartblogdate) {
55               $start = $core->blog->getPosts(array('order' => 'post_dt ASC','limit' => '1'));
56               $str_start = dt::dt2str($core->blog->settings->date_format,$start->post_dt);
57               $str_date = sprintf($w->displaystartblogdatetext,$str_start);
58               if (!empty($str_date)) {
59                    $res .= sprintf($mask,'start-date',$str_date);
60               }
61          }
62          if ($w->displayauthors) {
63               $list = '';
64               $users = $core->getUsers();
65               while ($users->fetch()){
66                    $str = '<li>%1$s</li>';
67                    if ($users->user_url) {
68                         $str = '<li><a href="%2$s">%1$s</a></li>';
69                    }
70                    if ($w->displayauthorstats) {
71                         $post_count = $core->blog->getPosts(array('user_id' => $users->user_id),true)->f(0);
72                         $str_authors =
73                              rsExtPost::getAuthorCN($users).' - '.$post_count.' '.
74                              (($post_count > 1) ? __('entries') : __('entry'));
75                    }
76                    else {
77                         $str_authors = rsExtPost::getAuthorCN($users);
78                    }
79                    $list .= sprintf($str,$str_authors,$users->user_url);
80               }
81               if (!empty($list)) {
82                    $list = sprintf('<ul class="%1$s">%2$s</ul>','authors-list',$list);
83                    $res .= sprintf($mask,'authors',__('Authors:').$list);
84               }
85          }
86         
87          $res = !empty($res) ? '<ul>'.$res.'</ul>' : '';
88
89          return
90               '<div id="info-blog">'.
91               $title.
92               $res.
93               '</div>';
94     }
95}
96
97?>
Note: See TracBrowser for help on using the repository browser.

Sites map