Nucleusプラグイン

インストールしたNucleusプラグインのメモ。

NP_NumberOfPosts

NP_NumberOfPostsのソースをNP_NumberOfPosts.phpという名前のファイルを作成して書き込み、プラグインインストール。
下記をカスタマイズ。

  • カッコを [] → () に変更
  • 全部表示させるのを「Show All」→「すべて表示」に変更

いろいろカスタマイズされたバージョンも配布されている。自分で使うにはシンプルなオリジナルの方が良いけど。参考用に。

 

NP_Calendar

Calendar 0.81aをさらに改造。変更点は下記。

  • 曜日ラベルのクラスおよび日付のクラスを、sun、mon、…、satと英名の先頭3文字に。
  • カレンダ内の日付のないセルのクラスをblankに。
  • 今日の日付はクラス名がtodayのdivで囲む。

次の内容をNP_Calendar.phpというファイルにEUCでセーブし、プラグインインストールすれば使える。

<?php
/**
* This plugin can be used to insert a calendar on your page
*
* History:
*   v0.2: initial plugin
*   v0.21: added doTemplateVar
*   v0.5: - moved table summary to constructor
*         - date headers now created according to locale
*   v0.51: fixed: calender was not limited to blog
*   v0.6: using options now instead of instance variables to keep options
*   v0.7: dates with future/draft posts are no longer linked
*   v0.71: last table cell was missing
*   v0.72: links to previous/next month added (by Roel)
*			 Fixed: "Passing locale category name as string is deprecated" by removing two quotes ;-)
*   v0.73: jhoover fixed the bug that appeared in the monthly archives
*			 (showing December 1999 everywhere) when using Fancy URL's
*   v0.75: short_open_tags: <? -> <?php (karma)
*   v0.76: use sql_table, add supportsFeature, add today highlight, merged w/ XE
*   v0.77: added option to change prev/next month link label
*          added option to change day label
*          added option to start week on Sun (integrated changes from Hop)
*   v0.78: added straight calendar mode (no links)
*   v0.78a: merged gRegor's category change
*   v0.79: fixed typo
*   v0.79a: disabled prev/next month link if SC mode is enabled
*   v0.80: fixed today highlight bug
*   v0.81: included hcgtv's improvement
*   v0.81a: typo
*
* For today highlight added this in default.css
*   table.calendar td.today { background-color: green;}
*
* Some example of customing the calendar
*   table.calendar {
*     font-size: small;
*     color: black;
*   }
*   tr.calendardateheaders {
*     font-size: small;
*     color: red;
*   }
*   td.days {
*     text-align: center;
*   }
*   td.today {
*     text-align: center;
*     color: green;
*     background-color: whitesmoke;
*   }
*/
if (!function_exists('sql_table'))
{
function sql_table($name) {
return 'nucleus_' . $name;
}
}
class NP_Calendar extends NucleusPlugin {
/**
* Plugin data to be shown on the plugin list
*/
function getName() {          return 'Calendar Plugin'; }
function getAuthor()  {       return 'karma / roel / jhoover / admun / hcgtv'; }
function getURL()  {          return 'http://nucleuscms.org/'; }
function getVersion() {       return '0.81'; }
function getDescription() {
return 'This plugin can be called from within skins to insert a calender on your site, by using <%Calendar%>.';
}
function supportsFeature($feature) {
switch($feature) {
case 'SqlTablePrefix':
return 1;
default:
return 0;
}
}
/**
* On plugin install, three options are created
*/
function install() {
// create some options
$this->createOption('Locale','Language (locale) to use','text','ja_JP');
$this->createOption('LinkAll','Create links for all days (even those that do not have posts?)','yesno','no');
$this->createOption('JustCal','Display a calendar with no link?  (override create links for all days above)','yesno','no');
$this->createOption('Summary','Summary text for the calendar table','text','Monthly calendar with links to each day¥'s posts');
$this->createOption('prevm','Label for previous month','text','<');
$this->createOption('nextm','Label for next month','text','>');
$this->createOption('mon','Label for Monday','text','Mon');
$this->createOption('tue','Label for Tuesday','text','Tue');
$this->createOption('wed','Label for Wednesday','text','Wed');
$this->createOption('thu','Label for Thursday','text','Thu');
$this->createOption('fri','Label for Friday','text','Fri');
$this->createOption('sat','Label for Saturday','text','Sat');
$this->createOption('sun','Label for Sunday','text','Sun');
$this->createOption('startsun','Should week start in Sunday?','yesno','no');
}
/**
* skinvar parameters:
*      - blogname (optional)
*/
function doSkinVar($skinType, $view = 'all', $blogName = '') {
global $manager, $blog, $CONF, $archive;
/*
find out which blog to use:
1. try the blog chosen in skinvar parameter
2. try to use the currently selected blog
3. use the default blog
*/
if ($blogName) {
$b =& $manager->getBlog(getBlogIDFromName($params[2]));
} else if ($blog) {
$b =& $blog;
} else {
$b =& $manager->getBlog($CONF['DefaultBlog']);
}
/*
select which month to show
- for archives: use that month
- otherwise: use current month
*/
switch($skinType) {
case 'archive':
sscanf($archive,'%d-%d-%d',$y,$m,$d);
$time = mktime(0,0,0,$m,1,$y);
break;
default:
$time = $b->getCorrectTime(time());
}
/*   Set $category if $view = 'limited'
This means only items from the specified category
will be displayed in the calendar.
Defaults to show all categories in calendar.
*/
$category = ($view == 'limited') ? $blog->getSelectedCategory() : 0;
$this->_drawCalendar($time, $b, $this->getOption('LinkAll'), $category);
}
/**
* This function draws the actual calendar as a table
*/
function _drawCalendar($timestamp, &$blog, $linkall, $category) {
$blogid = $blog->getID();
// set correct locale
setlocale(LC_TIME,$this->getOption('Locale'));
// get year/month etc
$date = getDate($timestamp);
$month = $date['mon'];
$year = $date['year'];
// get previous year-month
$last_month = $month - 1;
$last_year = $year;
if (!checkdate($last_month, 1, $last_year)) {
$last_month += 12;
$last_year --;
}
if ($last_month < 10) {
$last_month = "0".$last_month;
}
else {
$last_month >= 10;
$last_month = $last_month;
}
// get the next year-month
$next_month = $month + 1;
$next_year = $year;
if (!checkdate($next_month, 1, $next_year)) {
$next_year++;
$next_month -= 12;
}
if ($next_month < 10) {
$next_month = "0".$next_month;
}
else {
$next_month >= 10;
$next_month = $next_month;
}
$nolink = $this->getOption('JustCal');
// find out for which days we have posts
if ($linkall == 'no' && $nolink == 'no' ) {
$days = array();
$timeNow = $blog->getCorrectTime();
if ($category != 0) {
$res = sql_query('SELECT DAYOFMONTH(itime) as day FROM '.sql_table('item').' WHERE icat='.$category.' and MONTH(itime)='.$month.' and YEAR(itime)='.$year .' and iblog=' . $blogid . ' and idraft=0 and UNIX_TIMESTAMP(itime)<'.$timeNow.' GROUP BY day');
} else {
$res = sql_query('SELECT DAYOFMONTH(itime) as day FROM '.sql_table('item').' WHERE MONTH(itime)='.$month.' and YEAR(itime)='.$year .' and iblog=' . $blogid . ' and idraft=0 and UNIX_TIMESTAMP(itime)<'.$timeNow.' GROUP BY day');
}
while ($o = mysql_fetch_object($res)) {
$days[$o->day] = 1;
}
}
$prev = $this->getOption('prevm');
$next = $this->getOption('nextm');
// draw header
if ($nolink == "yes") {
?> <!-- kalendar start -->
<table class="calendar" summary="<?php echo htmlspecialchars($this->getOption('Summary'))?>">
<caption>
<?php echo strftime('%Y-%m',$timestamp); ?></a>
</caption>
<tr class="calendardateheaders">
<?php
} else {
?> <!-- kalendar start -->
<table class="calendar" summary="<?php echo htmlspecialchars($this->getOption('Summary'))?>">
<caption>
<a href="<?php echo createArchiveLink($blogid,$last_year.'-'.$last_month)?>"> <?php echo $prev; ?></a>
<a href="<?php echo createArchiveLink($blogid, strftime('%Y-%m',$timestamp))?>"> <?php echo strftime('%Y-%m',$timestamp)?></a>
<a href="<?php echo createArchiveLink($blogid,$next_year.'-'.$next_month)?>"><?php echo $next?></a>
</caption>
<tr class="calendardateheaders">
<?php
}
$startsun = $this->getOption('startsun');
// output localized weekday-abbreviations as column headers
if ($startsun == 'yes') {
$weekdayclass = array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat');
} else {
$weekdayclass = array('mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun');
}
foreach($weekdayclass as $class) {
$weekday = $this->getOption($class);
echo '<th class="' . $class. '">' . $weekday . '</th>';
}
?>
</tr>
<tr>
<?php
// draw empty cells for all days before start
$firstDay = getDate(mktime(0,0,0,$month,1,$year));
if ($startsun == 'yes') {
$wday = 1;
while ($wday <= $firstDay['wday']) {
$wday++;
echo '<td class="blank"> </td>';
}
}
else {
if ($firstDay['wday'] == 0)
$firstDay['wday'] = 7;
$wday = 1;
while ($wday < $firstDay['wday']) {
$wday++;
echo '<td class="blank"> </td>';
}
}
$mday = 1;
$to_day = date("j");
$this_month = date("n");
while (checkdate($month, $mday, $year)) {
echo '<td class="'.$weekdayclass[$wday-1].'">';
if ($mday == $to_day && $this_month == $month)
echo '<div class="today">';
if (($linkall == 'yes' && $nolink== 'no') || $days[$mday])
echo '<a href="',createArchiveLink($blogid,$year.'-'.$month.'-'.$mday) ,'">' ,  $mday, '</a></div></td>';
else
echo $mday,'</td>';
if ($mday == $to_day && $this_month == $month)
echo '</div>';
$mday++; $wday++;
if (($wday > 7) && (checkdate($month, $mday, $year))) {
echo '</tr><tr>';
$wday = 1;
}
}
while ($wday++ < 8)
echo '<td class="blank"> </td>';
echo '</tr>';
// footer
echo '</table>';
echo "¥n<!-- kalendar end -->¥n";
}
}
?>

 

NP_ItemCount

Web Artisanよりダウンロード。

 

NP_TodoList

NP_TodoListをダウンロードしてインストール。NP_ItemCountがないとインストールできない。

Windows上だと次のような警告が出てインストールに失敗する。対処方法不明…。

Warning:  _loadplugin(c:/apache/htdocs/nucleus/plugins/NP_TodoList.php): failed to open stream: Permission denied in c:¥apache¥htdocs¥nucleus¥libs¥MANAGER.php on line 198
Warning:  _loadplugin(): Failed opening 'c:/apache/htdocs/nucleus/plugins/NP_TodoList.php' for inclusion (include_path='.;c:¥php4¥pear') in c:¥apache¥htdocs¥nucleus¥libs¥MANAGER.php on line 198
タイトルとURLをコピーしました