3 class NP_ArchiveListEX extends NucleusPlugin {
7 return 'ArchiveListEX';
11 function getAuthor() {
15 // an URL to the plugin website
18 return 'http://nakahara21.com/';
21 // version of the plugin
22 function getVersion() {
26 function supportsFeature($what) {
28 case 'SqlTablePrefix':
35 // a description to be shown on the installed plugins listing
36 function getDescription() {
37 return 'Show all item title on each archive list. ';
40 function doAction($type) {
42 $archiveMonth = intRequestVar('a');
43 $bid = intRequestVar('b');
44 $tid = intRequestVar('t');
48 echo '<ul>'.$this->getArchives($tid, $bid, $archiveMonth).'</ul>';
51 return 'No such action';
56 function getArchives($tid, $bid, $archiveMonth){
58 $b =& $manager->getBlog($bid);
60 list($year, $month) = sscanf($archiveMonth, "%4s%2s");
62 $extraQuery = ' and SUBSTRING(itime,1,4)=' . $year
63 . ' and SUBSTRING(itime,6,2)=' . $month;
65 $template = TEMPLATE::getNameFromId($tid);
68 $b->readLogAmount($template, 0, $extraQuery, 0, 1, 0);
69 $contents = ob_get_contents();
72 if (_CHARSET != 'UTF-8'){
73 $contents = mb_convert_encoding($contents, 'UTF-8', _CHARSET);
80 function doSkinVar($skinType, $template = 'default/index', $mode = 'month', $limit = 0) {
81 global $manager, $blog, $CONF, $catid, $itemid;
83 $params = func_get_args();
84 if ($params[1]){ $template = $params[1]; }
86 if ($params[2] == 'month' | $params[2] == 'day'){ $mode = $params[2]; }
87 else{ $limit = intval($params[2]); }
89 if ($params[3]){ $limit = intval($params[3]); }
94 $b =& $manager->getBlog($CONF['DefaultBlog']);
98 $this->linkparams = array('catid' => $catid);
101 //switch($skinType) {
102 // case 'archivelist':
104 $tid = TEMPLATE::getIdFromName($template);
105 $template = TEMPLATE::read($template);
106 $data['blogid'] = $b->getID();
108 $jshref = $CONF['PluginURL'].'sharedlibs/miniajax.js';
109 $href = htmlspecialchars($CONF['ActionURL'], ENT_QUOTES) . '?action=plugin&name=ArchiveListEX&type=ga&t='.$tid.'&b='.$b->getID().'&a=';
113 <script type="text/javascript" src="<?php echo $jshref; ?>"></script>
114 <script type="text/javascript"><!--
115 function getData(id){
116 ajax.update("<?php echo $href; ?>"+id, "result"+id);
121 //===================================
122 $query = 'SELECT count(*) as sum, itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM '.sql_table('item')
123 . ' WHERE iblog=' . $b->getID()
124 . ' and itime <=' . mysqldate($b->getCorrectTime()) // don't show future items!
125 . ' and idraft=0'; // don't show draft items
128 $query .= ' and icat=' . intval($catid);
130 $query .= ' GROUP BY Year, Month';
135 // $query .= ' ORDER BY itime ASC';
136 $query .= ' ORDER BY itime DESC';
139 $query .= ' LIMIT ' . $limit;
141 $res = sql_query($query);
144 while ($current = mysql_fetch_object($res)) {
145 $current->itime = strtotime($current->itime); // string time -> unix timestamp
146 if ($mode == 'day') {
147 $archivedate = date('Y-m-d',$current->itime);
148 $archive['day'] = date('d',$current->itime);
150 $archivedate = date('Y-m',$current->itime);
152 $data['month'] = date('m',$current->itime);
153 $data['year'] = date('Y',$current->itime);
154 $data['archivelink'] = createArchiveLink($b->getID(),$archivedate,$this->linkparams);
155 $data['sum'] = $current->sum;
156 $data['monthid'] = $current->Year.$current->Month;
158 if($oldYear && $data['year'] != $oldYear){
159 $tempf = TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data);
160 echo $lastFooter = strftime($tempf,$current->itime);
163 if($data['year'] != $oldYear){
164 $temph = TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data);
165 echo strftime($temph,$current->itime);
168 $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data);
169 echo strftime($temp,$current->itime);
171 $oldYear = $data['year'];
174 mysql_free_result($res);
178 //===================================