Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 32e74abbda0012b4099201b644f55883571e1f04 (tree) |
---|---|
Time | 2009-02-04 15:12:49 |
Author | shizuki <shizuki@1ca2...> |
Commiter | shizuki |
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@898 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -0,0 +1,269 @@ | ||
1 | +<? | |
2 | + | |
3 | +class NP_ArchiveListEX extends NucleusPlugin { | |
4 | + | |
5 | + // name of plugin | |
6 | + function getName() { | |
7 | + return 'ArchiveListEX'; | |
8 | + } | |
9 | + | |
10 | + // author of plugin | |
11 | + function getAuthor() { | |
12 | + return 'nakahara21'; | |
13 | + } | |
14 | + | |
15 | + // an URL to the plugin website | |
16 | + function getURL() | |
17 | + { | |
18 | + return 'http://xx.nakahara21.net/'; | |
19 | + } | |
20 | + | |
21 | + // version of the plugin | |
22 | + function getVersion() { | |
23 | + return '0.6'; | |
24 | + } | |
25 | + | |
26 | + // a description to be shown on the installed plugins listing | |
27 | + function getDescription() { | |
28 | + return 'Show all item title on each archive list. <br />[Required] template: name of the template to use <br />[Optional] mode: [month]shows an entry for each month , [day]shows an entry for each day <br />[Optional] limit: limits the amount of links shown (e.g. if you only want to show links to the past 3 months)<br /><br />Usage1: <%ArchiveListEX(default)%> or <%ArchiveListEX(default,month)%> instead of <%archivelist(default)%>,<br />Usage2: <%ArchiveListEX(default,day,5)%> instead of <%archivedaylist(default,5)%>,<br />Usage3: <%ArchiveListEX(default,5)%>'; | |
29 | + } | |
30 | + | |
31 | + function doSkinVar($skinType, $template = 'default', $mode = 'month', $limit = 0) { | |
32 | + global $manager, $blog, $CONF, $catid, $itemid; | |
33 | + | |
34 | + $params = func_get_args(); | |
35 | + if ($params[1]){ $template = $params[1]; } | |
36 | + if ($params[2]){ | |
37 | + if ($params[2] == 'month' | $params[2] == 'day'){ $mode = $params[2]; } | |
38 | + else{ $limit = intval($params[2]); } | |
39 | + } | |
40 | + if ($params[3]){ $limit = intval($params[3]); } | |
41 | + | |
42 | + if ($blog) { | |
43 | + $b =& $blog; | |
44 | + } else { | |
45 | + $b =& $manager->getBlog($CONF['DefaultBlog']); | |
46 | + } | |
47 | + $blogid = $b->getID(); | |
48 | + | |
49 | + if ($catid) { | |
50 | + $this->linkparams = array('catid' => $catid); | |
51 | + } | |
52 | + | |
53 | +switch($skinType) { | |
54 | + case 'archivelist': | |
55 | + | |
56 | +//********************************************** | |
57 | +if($_REQUEST['mode'] == "remarks"){ | |
58 | + | |
59 | + $numberOfWritebacks = 50; // defaults to 50 | |
60 | + | |
61 | + // select | |
62 | + $query = "SELECT c.cnumber, c.cuser, c.cbody, c.citem, c.cmember, c.ctime ,UNIX_TIMESTAMP(c.ctime) as ctimest ,i.inumber, i.ititle | |
63 | + FROM nucleus_comment c ,nucleus_item i | |
64 | + WHERE c.citem = i.inumber | |
65 | + ORDER by ctime DESC | |
66 | + LIMIT 0,".$numberOfWritebacks; | |
67 | + | |
68 | + $comments = mysql_query($query); | |
69 | +// echo ' <ul class="nobullets"> '; | |
70 | + | |
71 | + while($row = mysql_fetch_object($comments)) { | |
72 | + $cid = $row->cnumber; | |
73 | + $ititle = htmlspecialchars(strip_tags($row->ititle)); | |
74 | + $ct = $row->ctimest; | |
75 | + $ctst = date("Y-m-d H:i",$ct); | |
76 | + $ctext = $row->cbody; | |
77 | +// $ctext = strip_tags($text); | |
78 | +// $ctext = substr($text, 0, $numberOfCharacters); | |
79 | +// $ctext = mb_substr($ctext, 0, -1); | |
80 | + | |
81 | + if (!$row->cmember) $myname = $row->cuser; | |
82 | + else { | |
83 | + $mem = new MEMBER; | |
84 | + $mem->readFromID(intval($row->cmember)); | |
85 | + $myname = $mem->getDisplayName(); | |
86 | + } | |
87 | + $itemid= $row->citem; | |
88 | + $itemlink = createItemLink($row->citem, ''); | |
89 | + $l_comments = "<li class=itembody>■ <span class=\"iteminfo\"><a href=\"".$b->getURL().$itemlink."#c".$cid."\">『".$ititle."』 へのコメント</a></span><br />".$ctext."<br /><span class=\"iteminfo\">".$myname." posted on $ctst</span></li>" ; | |
90 | +// echo $l_comments; | |
91 | + | |
92 | + if(!$arr_res){$arr_res = array();} | |
93 | +// array_push($arr_res,array($ct => $l_comments)); | |
94 | + $arr_res[$ct] = $l_comments; | |
95 | + | |
96 | + } | |
97 | + | |
98 | + | |
99 | +//========================= | |
100 | + | |
101 | + $query = "SELECT t.title, t.excerpt, t.tb_id, t.blog_name, t.timestamp ,UNIX_TIMESTAMP(t.timestamp) as ttimest ,t.url ,i.inumber, i.ititle | |
102 | + FROM nucleus_plugin_tb t ,nucleus_item i | |
103 | + WHERE t.tb_id = i.inumber | |
104 | + ORDER by timestamp DESC | |
105 | + LIMIT 0,".$numberOfWritebacks; | |
106 | + | |
107 | + $comments = mysql_query($query); | |
108 | + | |
109 | + while($row = mysql_fetch_object($comments)) { | |
110 | + $text = $row->excerpt; | |
111 | +// $text = strip_tags($text); | |
112 | +// $ctext = mb_substr($text, 0, $numberOfCharacters); | |
113 | + | |
114 | + $title = $row->title; | |
115 | +// $ctitle = substr($title, 0, $numberOfTitleCharacters+1); | |
116 | +// $ctitle = mb_substr($ctitle, 0, -1); | |
117 | + | |
118 | + $blogname = $row->blog_name; | |
119 | + $tbtime = $row->ttimest; | |
120 | + $ititle = htmlspecialchars(strip_tags($row->ititle)); | |
121 | + $url = $row->url; | |
122 | + $ttst = date("Y-m-d H:i",$tbtime); | |
123 | + | |
124 | + $itemlink = createItemLink($row->tb_id, ''); | |
125 | +// echo "<li><a href=\"".$b->getURL().$itemlink."#trackback\">■".$tbtime.":"; | |
126 | +// echo $blogname."から"; | |
127 | +// echo $ctitle.$ctext; | |
128 | +// echo "....</a></li>"; | |
129 | + | |
130 | + $l_tbs = "<li class=itembody>◆ <span class=\"iteminfo\"><a href=\"".$b->getURL().$itemlink."#trackback\">『".$ititle."』へのトラックバック</a></span><br />## ".$title." ##<br />".$text."<br /><span class=\"iteminfo\">『<a href=\"$url\">{$blogname}</a>』 pinged on ".$ttst."</span></li>"; | |
131 | + | |
132 | +// if(!$arr_res){$arr_res = array();} | |
133 | +// array_push($arr_res,$l_tbs); | |
134 | + $arr_res[$tbtime] = $l_tbs; | |
135 | + | |
136 | + | |
137 | + | |
138 | + } | |
139 | +//========================= | |
140 | + | |
141 | + | |
142 | + | |
143 | +krsort ($arr_res); | |
144 | +$output = array_slice ($arr_res, 0, $numberOfWritebacks); | |
145 | +// print_r($output); | |
146 | + | |
147 | + echo '<h3>コメントとトラックバック 最新'.$numberOfWritebacks.'件</h3>'; | |
148 | + echo ' <ul class="nobullets"> '; | |
149 | + | |
150 | + foreach($output as $key => $value){ | |
151 | + echo $value."\n"; | |
152 | + } | |
153 | + echo " </ul> "; | |
154 | + | |
155 | +//********************************************** | |
156 | +}else{ | |
157 | + | |
158 | + $template = TEMPLATE::read($template); | |
159 | + $data['blogid'] = $blogid; | |
160 | +//=================================== | |
161 | + echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data); | |
162 | +//=================================== | |
163 | + echo '<a href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'">HOME</a> '; | |
164 | + if($catid){ | |
165 | + $catName = $blog->getCategoryName($catid); //カテゴリの名前をget | |
166 | +// $catName = $blog->getCategoryDesc($catid); //カテゴリの説明をget | |
167 | + $archivealllistlink = createArchiveListLink($blogid,""); | |
168 | + echo ' > <a href="'.$archivealllistlink.'">Archive List</a>'; | |
169 | + echo ' > Category : <u> '.$catName.' </u> '; | |
170 | + }else{ | |
171 | +// echo 'Category : 選択していません'; | |
172 | + echo ' > Archive List'; | |
173 | + echo ''; | |
174 | + } | |
175 | +//=================================== | |
176 | + echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data); | |
177 | +//=================================== | |
178 | + echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data); | |
179 | + $now = time(); | |
180 | + $query = 'SELECT UNIX_TIMESTAMP(itime) as itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM nucleus_item' | |
181 | + . ' WHERE iblog=' . $blogid | |
182 | + . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! | |
183 | + . ' and idraft=0'; // don't show draft items | |
184 | + | |
185 | + if ($catid) | |
186 | + $query .= ' and icat=' . intval($catid); | |
187 | + | |
188 | + $query .= ' GROUP BY Year, Month'; | |
189 | + if ($mode == 'day') | |
190 | + $query .= ', Day'; | |
191 | + | |
192 | + | |
193 | +// $query .= ' ORDER BY itime ASC'; //アーカイブリスト昇順 | |
194 | + $query .= ' ORDER BY itime DESC'; //アーカイブリスト降順 | |
195 | + | |
196 | + if ($limit > 0) | |
197 | + $query .= ' LIMIT ' . $limit; | |
198 | + | |
199 | + $res = sql_query($query); | |
200 | + | |
201 | + while ($current = mysql_fetch_object($res)) { | |
202 | + if ($mode == 'day') { | |
203 | + $archivedate = date('Y-m-d',$current->itime); | |
204 | + $archive['day'] = date('d',$current->itime); | |
205 | + } else { | |
206 | + $archivedate = date('Y-m',$current->itime); | |
207 | + } | |
208 | + $data['month'] = date('m',$current->itime); | |
209 | + $data['year'] = date('Y',$current->itime); | |
210 | + $data['archivelink'] = createArchiveLink($blogid,$archivedate,$this->linkparams); | |
211 | + | |
212 | + $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data); | |
213 | + echo strftime($temp,$current->itime); | |
214 | + | |
215 | + //====================================================== | |
216 | + echo '<ul>'; | |
217 | + $adquery = 'SELECT inumber, ititle, icat FROM nucleus_item' | |
218 | + . ' WHERE iblog=' . $blogid | |
219 | + . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! | |
220 | + . ' and idraft=0' // don't show draft items | |
221 | + . ' and SUBSTRING(itime,1,4)=' . $data['year'] // year | |
222 | + . ' and SUBSTRING(itime,6,2)=' . $data['month']; // month | |
223 | + if ($mode == 'day') | |
224 | + $adquery .= ' and SUBSTRING(itime,9,2)=' . $archive['day']; //day | |
225 | + | |
226 | + if ($catid) | |
227 | + $adquery .= ' and icat=' . intval($catid); | |
228 | + | |
229 | +// $adquery .= ' ORDER BY itime ASC'; //タイトル一覧昇順 | |
230 | + $adquery .= ' ORDER BY itime DESC'; //タイトル一覧降順 | |
231 | + | |
232 | +// if ($limit > 0) | |
233 | +// $adquery .= ' LIMIT ' . $limit; | |
234 | + | |
235 | + $adres = sql_query($adquery); | |
236 | + | |
237 | + while ($adcurrent = mysql_fetch_object($adres)) { | |
238 | + $ititle = htmlspecialchars(strip_tags($adcurrent->ititle)); | |
239 | + $inumber = $adcurrent->inumber; | |
240 | + $itemlink = createItemLink($inumber,$this->linkparams); | |
241 | + | |
242 | + if($catid){ | |
243 | + echo '<li><a href="'.$itemlink.'">'. $ititle . '</a></li>'."\n"; | |
244 | + }else{ | |
245 | + $icatName = $blog->getCategoryName($adcurrent->icat); //カテゴリの名前をget | |
246 | +// $icatName = $blog->getCategoryDesc($adcurrent->icat); //カテゴリの説明をget | |
247 | + //タイトル一覧に続いてカテゴリ名を表示 | |
248 | +// echo '<li><a href="'.$itemlink.'">'. $ititle . ' <small>::' . $icatName .'</small></a></li>'."\n"; | |
249 | + //タイトル一覧にマウスをあわせるとカテゴリ名をフロート表示 | |
250 | + echo '<li><a href="'.$itemlink.'" title="Category:'.$icatName.'">'. $ititle . '</a></li>'."\n"; | |
251 | + } | |
252 | + } | |
253 | + mysql_free_result($adres); | |
254 | + echo '</ul>'; | |
255 | + //====================================================== | |
256 | + } | |
257 | + mysql_free_result($res); | |
258 | + echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data); | |
259 | + | |
260 | +} | |
261 | + | |
262 | + break; | |
263 | +//=================================== | |
264 | + default: | |
265 | +// echo "tttt"; | |
266 | + } | |
267 | + } | |
268 | +} | |
269 | +?> | |
\ No newline at end of file |
@@ -15,20 +15,69 @@ class NP_ArchiveListEX extends NucleusPlugin { | ||
15 | 15 | // an URL to the plugin website |
16 | 16 | function getURL() |
17 | 17 | { |
18 | - return 'http://xx.nakahara21.net/'; | |
18 | + return 'http://nakahara21.com/'; | |
19 | 19 | } |
20 | 20 | |
21 | 21 | // version of the plugin |
22 | 22 | function getVersion() { |
23 | - return '0.6'; | |
23 | + return '1.01'; | |
24 | 24 | } |
25 | 25 | |
26 | + function supportsFeature($what) { | |
27 | + switch($what){ | |
28 | + case 'SqlTablePrefix': | |
29 | + return 1; | |
30 | + default: | |
31 | + return 0; | |
32 | + } | |
33 | + } | |
34 | + | |
26 | 35 | // a description to be shown on the installed plugins listing |
27 | 36 | function getDescription() { |
28 | - return 'Show all item title on each archive list. <br />[Required] template: name of the template to use <br />[Optional] mode: [month]shows an entry for each month , [day]shows an entry for each day <br />[Optional] limit: limits the amount of links shown (e.g. if you only want to show links to the past 3 months)<br /><br />Usage1: <%ArchiveListEX(default)%> or <%ArchiveListEX(default,month)%> instead of <%archivelist(default)%>,<br />Usage2: <%ArchiveListEX(default,day,5)%> instead of <%archivedaylist(default,5)%>,<br />Usage3: <%ArchiveListEX(default,5)%>'; | |
37 | + return 'Show all item title on each archive list. '; | |
38 | + } | |
39 | + | |
40 | + function doAction($type) { | |
41 | + | |
42 | + $archiveMonth = intRequestVar('a'); | |
43 | + $bid = intRequestVar('b'); | |
44 | + $tid = intRequestVar('t'); | |
45 | + | |
46 | + switch ($type) { | |
47 | + case 'ga' : | |
48 | + echo '<ul>'.$this->getArchives($tid, $bid, $archiveMonth).'</ul>'; | |
49 | + break; | |
50 | + default : | |
51 | + return 'No such action'; | |
52 | + break; | |
53 | + } | |
54 | + } | |
55 | + | |
56 | + function getArchives($tid, $bid, $archiveMonth){ | |
57 | + global $manager; | |
58 | + $b =& $manager->getBlog($bid); | |
59 | + | |
60 | + list($year, $month) = sscanf($archiveMonth, "%4s%2s"); | |
61 | + | |
62 | + $extraQuery = ' and SUBSTRING(itime,1,4)=' . $year | |
63 | + . ' and SUBSTRING(itime,6,2)=' . $month; | |
64 | + | |
65 | + $template = TEMPLATE::getNameFromId($tid); | |
66 | + | |
67 | + ob_start(); | |
68 | + $b->readLogAmount($template, 0, $extraQuery, 0, 1, 0); | |
69 | + $contents = ob_get_contents(); | |
70 | + ob_end_clean(); | |
71 | + | |
72 | + if (_CHARSET != 'UTF-8'){ | |
73 | + $contents = mb_convert_encoding($contents, 'UTF-8', _CHARSET); | |
74 | + } | |
75 | + | |
76 | + return $contents; | |
29 | 77 | } |
30 | 78 | |
31 | - function doSkinVar($skinType, $template = 'default', $mode = 'month', $limit = 0) { | |
79 | + | |
80 | + function doSkinVar($skinType, $template = 'default/index', $mode = 'month', $limit = 0) { | |
32 | 81 | global $manager, $blog, $CONF, $catid, $itemid; |
33 | 82 | |
34 | 83 | $params = func_get_args(); |
@@ -44,161 +93,56 @@ class NP_ArchiveListEX extends NucleusPlugin { | ||
44 | 93 | } else { |
45 | 94 | $b =& $manager->getBlog($CONF['DefaultBlog']); |
46 | 95 | } |
47 | - $blogid = $b->getID(); | |
48 | 96 | |
49 | 97 | if ($catid) { |
50 | 98 | $this->linkparams = array('catid' => $catid); |
51 | 99 | } |
52 | 100 | |
53 | -switch($skinType) { | |
54 | - case 'archivelist': | |
55 | - | |
56 | -//********************************************** | |
57 | -if($_REQUEST['mode'] == "remarks"){ | |
58 | - | |
59 | - $numberOfWritebacks = 50; // defaults to 50 | |
60 | - | |
61 | - // select | |
62 | - $query = "SELECT c.cnumber, c.cuser, c.cbody, c.citem, c.cmember, c.ctime ,UNIX_TIMESTAMP(c.ctime) as ctimest ,i.inumber, i.ititle | |
63 | - FROM nucleus_comment c ,nucleus_item i | |
64 | - WHERE c.citem = i.inumber | |
65 | - ORDER by ctime DESC | |
66 | - LIMIT 0,".$numberOfWritebacks; | |
67 | - | |
68 | - $comments = mysql_query($query); | |
69 | -// echo ' <ul class="nobullets"> '; | |
70 | - | |
71 | - while($row = mysql_fetch_object($comments)) { | |
72 | - $cid = $row->cnumber; | |
73 | - $ititle = htmlspecialchars(strip_tags($row->ititle)); | |
74 | - $ct = $row->ctimest; | |
75 | - $ctst = date("Y-m-d H:i",$ct); | |
76 | - $ctext = $row->cbody; | |
77 | -// $ctext = strip_tags($text); | |
78 | -// $ctext = substr($text, 0, $numberOfCharacters); | |
79 | -// $ctext = mb_substr($ctext, 0, -1); | |
80 | - | |
81 | - if (!$row->cmember) $myname = $row->cuser; | |
82 | - else { | |
83 | - $mem = new MEMBER; | |
84 | - $mem->readFromID(intval($row->cmember)); | |
85 | - $myname = $mem->getDisplayName(); | |
86 | - } | |
87 | - $itemid= $row->citem; | |
88 | - $itemlink = createItemLink($row->citem, ''); | |
89 | - $l_comments = "<li class=itembody>■ <span class=\"iteminfo\"><a href=\"".$b->getURL().$itemlink."#c".$cid."\">『".$ititle."』 へのコメント</a></span><br />".$ctext."<br /><span class=\"iteminfo\">".$myname." posted on $ctst</span></li>" ; | |
90 | -// echo $l_comments; | |
91 | - | |
92 | - if(!$arr_res){$arr_res = array();} | |
93 | -// array_push($arr_res,array($ct => $l_comments)); | |
94 | - $arr_res[$ct] = $l_comments; | |
95 | - | |
96 | - } | |
97 | - | |
98 | - | |
99 | -//========================= | |
100 | - | |
101 | - $query = "SELECT t.title, t.excerpt, t.tb_id, t.blog_name, t.timestamp ,UNIX_TIMESTAMP(t.timestamp) as ttimest ,t.url ,i.inumber, i.ititle | |
102 | - FROM nucleus_plugin_tb t ,nucleus_item i | |
103 | - WHERE t.tb_id = i.inumber | |
104 | - ORDER by timestamp DESC | |
105 | - LIMIT 0,".$numberOfWritebacks; | |
106 | - | |
107 | - $comments = mysql_query($query); | |
108 | - | |
109 | - while($row = mysql_fetch_object($comments)) { | |
110 | - $text = $row->excerpt; | |
111 | -// $text = strip_tags($text); | |
112 | -// $ctext = mb_substr($text, 0, $numberOfCharacters); | |
113 | - | |
114 | - $title = $row->title; | |
115 | -// $ctitle = substr($title, 0, $numberOfTitleCharacters+1); | |
116 | -// $ctitle = mb_substr($ctitle, 0, -1); | |
117 | - | |
118 | - $blogname = $row->blog_name; | |
119 | - $tbtime = $row->ttimest; | |
120 | - $ititle = htmlspecialchars(strip_tags($row->ititle)); | |
121 | - $url = $row->url; | |
122 | - $ttst = date("Y-m-d H:i",$tbtime); | |
123 | - | |
124 | - $itemlink = createItemLink($row->tb_id, ''); | |
125 | -// echo "<li><a href=\"".$b->getURL().$itemlink."#trackback\">■".$tbtime.":"; | |
126 | -// echo $blogname."から"; | |
127 | -// echo $ctitle.$ctext; | |
128 | -// echo "....</a></li>"; | |
129 | - | |
130 | - $l_tbs = "<li class=itembody>◆ <span class=\"iteminfo\"><a href=\"".$b->getURL().$itemlink."#trackback\">『".$ititle."』へのトラックバック</a></span><br />## ".$title." ##<br />".$text."<br /><span class=\"iteminfo\">『<a href=\"$url\">{$blogname}</a>』 pinged on ".$ttst."</span></li>"; | |
131 | - | |
132 | -// if(!$arr_res){$arr_res = array();} | |
133 | -// array_push($arr_res,$l_tbs); | |
134 | - $arr_res[$tbtime] = $l_tbs; | |
101 | +//switch($skinType) { | |
102 | +// case 'archivelist': | |
135 | 103 | |
104 | + $tid = TEMPLATE::getIdFromName($template); | |
105 | + $template = TEMPLATE::read($template); | |
106 | + $data['blogid'] = $b->getID(); | |
136 | 107 | |
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='; | |
137 | 110 | |
138 | - } | |
139 | -//========================= | |
140 | - | |
141 | - | |
142 | - | |
143 | -krsort ($arr_res); | |
144 | -$output = array_slice ($arr_res, 0, $numberOfWritebacks); | |
145 | -// print_r($output); | |
146 | - | |
147 | - echo '<h3>コメントとトラックバック 最新'.$numberOfWritebacks.'件</h3>'; | |
148 | - echo ' <ul class="nobullets"> '; | |
149 | - | |
150 | - foreach($output as $key => $value){ | |
151 | - echo $value."\n"; | |
152 | - } | |
153 | - echo " </ul> "; | |
154 | 111 | |
155 | -//********************************************** | |
156 | -}else{ | |
112 | +?> | |
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); | |
117 | +} | |
118 | +// --></script> | |
119 | +<?php | |
157 | 120 | |
158 | - $template = TEMPLATE::read($template); | |
159 | - $data['blogid'] = $blogid; | |
160 | -//=================================== | |
161 | - echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data); | |
162 | -//=================================== | |
163 | - echo '<a href="http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME'].'">HOME</a> '; | |
164 | - if($catid){ | |
165 | - $catName = $blog->getCategoryName($catid); //カテゴリの名前をget | |
166 | -// $catName = $blog->getCategoryDesc($catid); //カテゴリの説明をget | |
167 | - $archivealllistlink = createArchiveListLink($blogid,""); | |
168 | - echo ' > <a href="'.$archivealllistlink.'">Archive List</a>'; | |
169 | - echo ' > Category : <u> '.$catName.' </u> '; | |
170 | - }else{ | |
171 | -// echo 'Category : 選択していません'; | |
172 | - echo ' > Archive List'; | |
173 | - echo ''; | |
174 | - } | |
175 | 121 | //=================================== |
176 | - echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data); | |
177 | -//=================================== | |
178 | - echo TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data); | |
179 | - $now = time(); | |
180 | - $query = 'SELECT UNIX_TIMESTAMP(itime) as itime, SUBSTRING(itime,1,4) AS Year, SUBSTRING(itime,6,2) AS Month, SUBSTRING(itime,9,2) as Day FROM nucleus_item' | |
181 | - . ' WHERE iblog=' . $blogid | |
182 | - . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! | |
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! | |
183 | 125 | . ' and idraft=0'; // don't show draft items |
184 | 126 | |
185 | 127 | if ($catid) |
186 | 128 | $query .= ' and icat=' . intval($catid); |
187 | - | |
129 | +/**/ | |
188 | 130 | $query .= ' GROUP BY Year, Month'; |
189 | 131 | if ($mode == 'day') |
190 | 132 | $query .= ', Day'; |
191 | 133 | |
192 | 134 | |
193 | -// $query .= ' ORDER BY itime ASC'; //アーカイブリスト昇順 | |
194 | - $query .= ' ORDER BY itime DESC'; //アーカイブリスト降順 | |
135 | +// $query .= ' ORDER BY itime ASC'; | |
136 | + $query .= ' ORDER BY itime DESC'; | |
195 | 137 | |
196 | 138 | if ($limit > 0) |
197 | 139 | $query .= ' LIMIT ' . $limit; |
198 | 140 | |
199 | 141 | $res = sql_query($query); |
200 | 142 | |
143 | + $oldYear = 0; | |
201 | 144 | while ($current = mysql_fetch_object($res)) { |
145 | + $current->itime = strtotime($current->itime); // string time -> unix timestamp | |
202 | 146 | if ($mode == 'day') { |
203 | 147 | $archivedate = date('Y-m-d',$current->itime); |
204 | 148 | $archive['day'] = date('d',$current->itime); |
@@ -207,63 +151,34 @@ $output = array_slice ($arr_res, 0, $numberOfWritebacks); | ||
207 | 151 | } |
208 | 152 | $data['month'] = date('m',$current->itime); |
209 | 153 | $data['year'] = date('Y',$current->itime); |
210 | - $data['archivelink'] = createArchiveLink($blogid,$archivedate,$this->linkparams); | |
154 | + $data['archivelink'] = createArchiveLink($b->getID(),$archivedate,$this->linkparams); | |
155 | + $data['sum'] = $current->sum; | |
156 | + $data['monthid'] = $current->Year.$current->Month; | |
157 | + | |
158 | + if($oldYear && $data['year'] != $oldYear){ | |
159 | + $tempf = TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data); | |
160 | + echo $lastFooter = strftime($tempf,$current->itime); | |
161 | + } | |
162 | + | |
163 | + if($data['year'] != $oldYear){ | |
164 | + $temph = TEMPLATE::fill($template['ARCHIVELIST_HEADER'],$data); | |
165 | + echo strftime($temph,$current->itime); | |
166 | + } | |
211 | 167 | |
212 | 168 | $temp = TEMPLATE::fill($template['ARCHIVELIST_LISTITEM'],$data); |
213 | 169 | echo strftime($temp,$current->itime); |
214 | - | |
215 | - //====================================================== | |
216 | - echo '<ul>'; | |
217 | - $adquery = 'SELECT inumber, ititle, icat FROM nucleus_item' | |
218 | - . ' WHERE iblog=' . $blogid | |
219 | - . ' and UNIX_TIMESTAMP(itime)<=' . $now // don't show future items! | |
220 | - . ' and idraft=0' // don't show draft items | |
221 | - . ' and SUBSTRING(itime,1,4)=' . $data['year'] // year | |
222 | - . ' and SUBSTRING(itime,6,2)=' . $data['month']; // month | |
223 | - if ($mode == 'day') | |
224 | - $adquery .= ' and SUBSTRING(itime,9,2)=' . $archive['day']; //day | |
225 | - | |
226 | - if ($catid) | |
227 | - $adquery .= ' and icat=' . intval($catid); | |
228 | - | |
229 | -// $adquery .= ' ORDER BY itime ASC'; //タイトル一覧昇順 | |
230 | - $adquery .= ' ORDER BY itime DESC'; //タイトル一覧降順 | |
231 | - | |
232 | -// if ($limit > 0) | |
233 | -// $adquery .= ' LIMIT ' . $limit; | |
234 | - | |
235 | - $adres = sql_query($adquery); | |
236 | - | |
237 | - while ($adcurrent = mysql_fetch_object($adres)) { | |
238 | - $ititle = htmlspecialchars(strip_tags($adcurrent->ititle)); | |
239 | - $inumber = $adcurrent->inumber; | |
240 | - $itemlink = createItemLink($inumber,$this->linkparams); | |
241 | 170 | |
242 | - if($catid){ | |
243 | - echo '<li><a href="'.$itemlink.'">'. $ititle . '</a></li>'."\n"; | |
244 | - }else{ | |
245 | - $icatName = $blog->getCategoryName($adcurrent->icat); //カテゴリの名前をget | |
246 | -// $icatName = $blog->getCategoryDesc($adcurrent->icat); //カテゴリの説明をget | |
247 | - //タイトル一覧に続いてカテゴリ名を表示 | |
248 | -// echo '<li><a href="'.$itemlink.'">'. $ititle . ' <small>::' . $icatName .'</small></a></li>'."\n"; | |
249 | - //タイトル一覧にマウスをあわせるとカテゴリ名をフロート表示 | |
250 | - echo '<li><a href="'.$itemlink.'" title="Category:'.$icatName.'">'. $ititle . '</a></li>'."\n"; | |
251 | - } | |
252 | - } | |
253 | - mysql_free_result($adres); | |
254 | - echo '</ul>'; | |
255 | - //====================================================== | |
171 | + $oldYear = $data['year']; | |
172 | + | |
256 | 173 | } |
257 | 174 | mysql_free_result($res); |
258 | - echo TEMPLATE::fill($template['ARCHIVELIST_FOOTER'],$data); | |
259 | - | |
260 | -} | |
175 | + echo $lastFooter; | |
261 | 176 | |
262 | - break; | |
177 | +// break; | |
263 | 178 | //=================================== |
264 | - default: | |
179 | +// default: | |
265 | 180 | // echo "tttt"; |
266 | - } | |
181 | +// } | |
267 | 182 | } |
268 | 183 | } |
269 | 184 | ?> |
\ No newline at end of file |
@@ -0,0 +1,12 @@ | ||
1 | +function $(e){if(typeof e=='string')e=document.getElementById(e);return e}; | |
2 | +function collect(a,f){var n=[];for(var i=0;i<a.length;i++){var v=f(a[i]);if(v!=null)n.push(v)}return n}; | |
3 | + | |
4 | +ajax={}; | |
5 | +ajax.x=function(){try{return new ActiveXObject('Msxml2.XMLHTTP')}catch(e){try{return new ActiveXObject('Microsoft.XMLHTTP')}catch(e){return new XMLHttpRequest()}}}; | |
6 | +ajax.serialize=function(f){var g=function(n){return f.getElementsByTagName(n)};var nv=function(e){if(e.name)return encodeURIComponent(e.name)+'='+encodeURIComponent(e.value);else return ''};var i=collect(g('input'),function(i){if((i.type!='radio'&&i.type!='checkbox')||i.checked)return nv(i)});var s=collect(g('select'),nv);var t=collect(g('textarea'),nv);return i.concat(s).concat(t).join('&');}; | |
7 | +ajax.send=function(u,f,m,a){var x=ajax.x();x.open(m,u,true);x.onreadystatechange=function(){if(x.readyState==4)f(x.responseText)};if(m=='POST')x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(a)}; | |
8 | +ajax.get=function(url,func){ajax.send(url,func,'GET')}; | |
9 | +ajax.gets=function(url){var x=ajax.x();x.open('GET',url,false);x.send(null);return x.responseText}; | |
10 | +ajax.post=function(url,func,args){ajax.send(url,func,'POST',args)}; | |
11 | +ajax.update=function(url,elm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.get(url,f)}; | |
12 | +ajax.submit=function(url,elm,frm){var e=$(elm);var f=function(r){e.innerHTML=r};ajax.post(url,f,ajax.serialize(frm))}; |