4 * SHOW RECENT ITEMS PLUG-IN FOR NucleusCMS
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 * (see nucleus/documentation/index.html#license for more info)
13 * @author Original Author nakahara21
14 * @copyright 2005-2006 nakahara21
15 * @license http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991
17 * @link http://nakahara21.com
22 * 0.51 add BLOGID mode
24 class NP_RecentItems extends NucleusPlugin
38 return 'http://nakahara21.com';
46 function getDescription()
48 return 'Display Recent Items. Usage: <%RecentItems(blogname,templatename,5)%>';
51 function supportsFeature($what)
54 case 'SqlTablePrefix':
60 function doSkinVar($skinType, $blogName = '', $templateName = '', $amountEntries = 5)
64 if (is_numeric($blogName)) {
65 $query = 'SELECT bshortname as result FROM %s WHERE bnumber = %d';
66 $blogname = quickQuery(sprintf($query, sql_table('blog'), intval($blogName)));
68 if (!BLOG::exists($blogName)) {
71 if (!TEMPLATE::exists($templateName)) {
74 if ($amountEntries=='') {
78 $tempBid = getBlogIDFromName($blogName);
79 $b =& $manager->getBlog($tempBid);
80 $query = $this->_getsqlquery($b, $amountEntries, '');
81 $b->showUsingQuery($templateName, $query, 0, 1, 0);
84 function _getsqlquery($blogObj, $amountEntries, $extraQuery)
87 . ' i.inumber as itemid,'
88 . ' i.ititle as title,'
90 . ' m.mname as author,'
91 . ' m.mrealname as authorname,'
94 . ' m.mnumber as authorid,'
95 . ' m.memail as authormail,'
96 . ' m.murl as authorurl,'
97 . ' c.cname as category,'
99 . ' i.iclosed as closed'
100 . ' FROM ' // <mod by shizuki corresponds MySQL 5.0.x or later />
101 . sql_table('member') . ' as m, '
102 . sql_table('category') . ' as c,'
103 . sql_table('item') . ' as i'
104 . ' WHERE i.iblog = ' . intval($blogObj->getID())
105 . ' AND i.iauthor = m.mnumber'
106 . ' AND i.icat = c.catid'
107 . ' AND i.idraft = 0' // exclude drafts
108 // don't show future items
109 . ' AND i.itime <= ' . mysqldate($blogObj->getCorrectTime());
111 // if ($blogObj->getSelectedCategory())
112 // $query .= ' and i.icat=' . $blogObj->getSelectedCategory() . ' ';
114 $query .= $extraQuery
115 . ' ORDER BY i.itime DESC'
116 . ' LIMIT ' . intval($amountEntries);