Tag: haik
ブログのアーカイブ表示調整
「プログ アーカイブ」の表示は年毎にまとめる。表示の順番を並べ替え処理しないといけないかもしれません。データないので確認していません。
表示されたこの年の部分のリンクをクリックした時の表示が正常に動作しませんでした。もう少しプログラムを変更する必要があるようです。
- plugin/qblog_archives.inc.php
<?php
/**
* QBlog Achives Plugin
* -------------------------------------------
* ./plugin/qblog_archives.inc.php
*
* Copyright (c) 2012 hokuken
* http://hokuken.com/
*
* created : 12/07/27
* modified :
*
* Description
*
*
* Usage :
*
*/
function plugin_qblog_archives_convert()
{
global $vars, $script, $qblog_close;
//閉鎖中は何も表示しない
if ($qblog_close && ! ss_admin_check())
{
return '';
}
//---- キャッシュのための処理を登録 -----
$qt = get_qt();
if($qt->create_cache) {
$args = func_get_args();
return $qt->get_dynamic_plugin_mark(__FUNCTION__, $args);
}
//------------------------------------
$archives_file = CACHEQBLOG_DIR . 'qblog_archives.dat';
if( file_exists($archives_file) ){
$archives_list = file_get_contents($archives_file);
// vvvvv 2016-10-04
// $lastYear = date("Y", strtotime("-1 year"));
$lastYear = date("Y", strtotime("-0 year"));
$lines = explode("\n", $archives_list);
$ymCount = array();
for($i=0,$max=count($lines);$i<$max; $i++) {
list($year, $month, $num) = explode(",", rtrim($lines[$i]));
if ($year<=$lastYear) {
if (! isset($ymCount[$year.",0"])) {
$ymCount[$year.",0"] = 0;
}
$ymCount[$year.",0"] += $num;
} else {
$ymCount[$year.",".$month] = $num;
}
}
$archives_list = array();
foreach($ymCount as $k => $d) {
$archives_list[] = $k.",".$d;
}
// ^^^^^ 2016-10-04
}
else{
$archives_list = array();
}
$list = '';
$list .= '<ul class="qblog_archives">';
// foreach (explode("\n", $archives_list) as $line) // delete 2016-10-04
foreach ($archives_list as $line) // add 2016-10-04
{
if (rtrim($line) != '')
{
list($year, $month, $num) = explode(",", rtrim($line));
// vvvvv change
if ($month == "0") {
$archives_url = $script.'?QBlog&mode=archives&date='.rawurlencode($year);
$list .= '<li><a href="'.$archives_url.'">'.$year.'年 ('.$num.')'.'</a></li>';
} else {
$archives_url = $script.'?QBlog&mode=archives&date='.rawurlencode($year.$month);
$list .= '<li><a href="'.$archives_url.'">'.$year.'年'.$month.'月 ('.$num.')'.'</a></li>';
}
// ^^^^^ change
}
}
$list .= '</ul>';
return $list;
}
?>