OSDN Git Service

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@865 1ca29b6e-896d...
[nucleus-jp/nucleus-plugins.git] / NP_OtherblogEX / trunk / NP_OtherblogEX.php
1 <? 
2 // plugin needs to work on Nucleus versions <=2.0 as well
3 if (!function_exists('sql_table')){
4         function sql_table($name) {
5                 return 'nucleus_' . $name;
6         }
7 }
8
9 class NP_OtherblogEX extends NucleusPlugin { 
10         function getEventList() { return array(); } 
11         function getName() { return 'OtherblogEX'; } 
12         function getAuthor() { return 'nakahara21'; } 
13         function getURL() { return 'http://xx.nakahara21.net/'; } 
14         function getVersion() { return '0.3'; } 
15         function getDescription() { 
16                 return 'OtherblogEX'; 
17         } 
18
19         function supportsFeature($what) {
20                 switch($what){
21                         case 'SqlTablePrefix':
22                                 return 1;
23                         default:
24                                 return 0;
25                 }
26         }
27         function doSkinVar($skinType, $blogname, $template, $amount = 10, $catname = '', $sort) { 
28
29                 list($limit, $offset) = sscanf($amount, '%d(%d)');
30                 if($sort == 'ASC'){
31                         $sort = 'ASC';
32                 }else{
33                         $sort = 'DESC';
34                 }
35                 $this->readLogAmountex($blogname,$template,$catname,$limit,'','',1,1,$offset, $startpos, $sort);
36         }// doSkinVar end
37
38         function readLogAmountex($blogname, $template, $catname, $amountEntries, $extraQuery, $highlight, $comments, $dateheads, $offset = 0, $startpos = 0, $sort) {
39                 global $manager;
40
41                 $b =& $manager->getBlog(getBlogIDFromName($blogname));
42                 if ($catname != '')
43                         $b->setSelectedCategoryByName($catname);
44                 else
45                         $b->setSelectedCategory($catid);
46
47                 $query =  'SELECT i.inumber as itemid, i.ititle as title, i.ibody as body, m.mname as author, m.mrealname as authorname, UNIX_TIMESTAMP(i.itime) as timestamp, i.imore as more, m.mnumber as authorid, m.memail as authormail, m.murl as authorurl, c.cname as category, i.icat as catid, i.iclosed as closed'
48                        . ' FROM '.sql_table('item').' as i, '.sql_table('member').' as m, '.sql_table('category').' as c'
49                        . ' WHERE i.iblog='.$b->getID()
50                        . ' and i.iauthor=m.mnumber'
51                        . ' and i.icat=c.catid'
52                        . ' and i.idraft=0'      // exclude drafts
53                                         // don't show future items
54                        . ' and i.itime<=' . mysqldate($b->getCorrectTime());
55
56                 if ($b->getSelectedCategory())
57                         $query .= ' and i.icat=' . $b->getSelectedCategory() . ' ';
58
59                 $query .= $extraQuery
60                        . ' ORDER BY i.itime '.$sort;
61
62                 if ($amountEntries > 0) {
63                         // $offset zou moeten worden:
64                         // (($startpos / $amountentries) + 1) * $offset ... later testen ...
65                        $query .= ' LIMIT ' . intval($startpos + $offset).',' . intval($amountEntries);
66                 }
67
68                 return $b->showUsingQuery($template, $query, $highlight, $comments, $dateheads);
69         }
70
71
72 ?>