variable('url');
$title = $this->variable('title');
$fetch_num = $this->variable('items');
$fetch_num = is_int($fetch_num)? $fetch_num : 20;
$target_year = date("Y");
$target_month = date("m");
$go_back = 3;
$rss_items = array();
$browser = new Browser();
$tag = new SimpleTag();
$rss20 = new Rss20();
$rss20->setChannel($title, $title, $base_url, "ja");
if ($base_url{strlen($base_url)-1} !== '/') {
$base_url .= '/';
}
while (($fetch_num > 0)&&($go_back > 0)) {
$target_name = date("Y-F", mktime(0, 0, 0, $target_month, 1, $target_year));
$target_url = $base_url . $target_name ."/date.html";
$page = StringUtil::encoding($browser->get($target_url));
if ($page) {
$tag->set($page);
if (preg_match_all('!
(.*?)\n \n(.*?)\n!ms', $page, $matches, PREG_SET_ORDER)) {
krsort($matches);
foreach ($matches as $iteminfo) {
$article_url = $base_url . $target_name . "/". $iteminfo[1];
$article_title = $iteminfo[2];
$article_author = $iteminfo[4];
$ctag = new SimpleTag();
$cpage = StringUtil::encoding($browser->get($article_url));
$ctag->set($cpage);
$msg_begin = strpos($cpage, "");
$msg_end = strpos($cpage, "");
$msg = substr($cpage, $msg_begin, ($msg_end - $msg_begin));
$pubdate = $ctag->getInValue("I");
$pubdate = preg_replace("/(\d+)年\s*(\d+)月\s*(\d+)日[^\d]*(\d+):(\d+):(\d+)\s*JST/", "$1/$2/$3 $4:$5:$6", $pubdate);
$item = new RssItem20();
$item->setTitle($article_title);
$item->setLink($article_url);
$item->setAuthor($article_author);
$item->setDescription($msg);
$item->setPubDate($pubdate);
$rss20->setItem($item);
if (--$fetch_num <= 0) {
break;
}
}
}
}
$go_back--;
$target_month--;
}
$rss20 = $this->merge($variable,$rss20);
return $rss20;
}
function description() {
return "Mailmanのpipemail URLからcustom feedを生成します";
}
function config() {
$config = array(
'url' => array("取得対象MLのURL", "text", "", true),
'title' => array("取得対象MLのタイトル", "text", "", true),
'items' => array("取得件数", "text", "20"),
);
return $config;
}
}
?>