OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@815 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_BlogList / NP_BlogList.php
1 <?
2
3 /*
4         Version history:
5         - 0.1 (2003-08-13): initial version
6 */
7 class NP_BlogList extends NucleusPlugin {
8
9         function getName()
10         {
11                 return 'Blog List';
12         }
13
14         function getAuthor()
15         {
16                 return 'Ben Osman + nakahara21 + shizuki';
17         }
18
19         function getURL()
20         {
21                 return 'http://www.justletgo.org/';
22         }
23
24         function getVersion()
25         {
26                 return '0.3';
27         }
28
29         function getDescription()
30         { 
31                 return 'List can be shown using &lt;%BlogList%&gt; OR &lt;%BlogList(bpublic = 1)%&gt;. <br /> It has following parameters : filter, header, list, footer)';
32         }
33
34         function supportsFeature($what)
35         {
36                 switch ($what) {
37                         case 'SqlTablePrefix':
38                                 return 1;
39                         default:
40                                 return 0;
41                 }
42         }
43
44         function install()
45         {
46                 $this->createOption('OrderBy',  'Field that list is sorted by', 'text',         'bnumber ASC');
47                 $this->createOption('Header',   'Header Template',                              'text',         '<ul class="nobullets">');
48                 $this->createOption('List',             'List Template ',                                       'text',         '<li><a href="<%bloglink%>"><%blogname%></a><%flag%></li>');
49                 $this->createOption('Footer',   'Footer Template',                              'text',         '</ul>');
50         }
51         
52   function doSkinVar($skinType, $filter ='', $header ='', $list='', $footer='')
53   { 
54 //              global $CONF, $blog;
55                 global $CONF, $blogid;
56                 if (is_numeric($blogid)) {
57                         $blogid = intval($blogid);
58                 } else {
59                         $blog_id = getBlogIDFromName($blogid);
60                         $blogid = intval($blogid);
61                 }
62                 // determine arguments next to catids
63                 // I guess this can be done in a better way, but it works
64                 if (empty($header)) {
65                   $header = $this->getOption('Header');
66                 }
67                 if (empty($list)) {
68                   $list = $this->getOption('List');
69                 }
70                 if (empty($footer)) {
71                   $footer = $this->getOption('Footer');
72                 }
73                         
74                 //$blogurl = $this->getURL() . $qargs;
75                 //$blogurl = createBlogLink($this->getURL(), $linkparams);
76                 $blogurl = createBlogLink($blogid);
77
78                 $template = TEMPLATE::read($template);
79
80 //              echo TEMPLATE::fill($header, array());
81                 echo $header;
82
83                 $where = '';
84                 if ($filter <> '') {
85                         $where =  'WHERE '.$filter;
86                 }
87
88 //              $query = 'SELECT *,b.bnumber as blogid, b.bname as blogname, b.burl as bloglink  FROM nucleus_blog      as b ' . $where . ' ORDER BY ' . $this->getOption('OrderBy');
89 //              $query = 'SELECT *,b.bnumber as blogid, b.bname as blogname  FROM '.sql_table('blog').' as b ' . $where . ' ORDER BY ' . $this->getOption('OrderBy');
90                 $query = 'SELECT bnumber, bname FROM ' . sql_table('blog') . ' ORDER BY ' . $this->getOption('OrderBy');
91
92                 $res = sql_query($query);
93                 while ($data = mysql_fetch_assoc($res)) {
94 //                      $data['self'] = $CONF['Self'];
95 //                      $data['bloglink'] = createBlogidLink($data['blogid'], '');
96                         $listdata = array(
97                                                         bloglink => createBlogLink($data['bnumber']),
98                                                         blogname => $data['bname']
99                                                 );
100 //                      if ( $data['blogid'] == $blog->getID() ){
101                         if ($data['bnumber'] == $blogid) {
102 //                              $data['flag'] = " &laquo;";     //mark this blog!
103                                 $listdata['flag'] = " &laquo;";         //mark this blog!
104                         }
105
106 //                      $temp = TEMPLATE::fill($list, $data);
107                         $temp = TEMPLATE::fill($list, $listdata);
108 //                      echo TEMPLATE::fill($list, $listdata);
109                         echo strftime($temp, $current->itime);
110
111                 }
112                 
113                 mysql_free_result($res);
114
115 //              echo TEMPLATE::fill($footer, array());
116                 echo $footer;
117         }
118 }
119 ?>