- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2017-10-21T13:46:32+09:00","","")
* showrssプラグイン: RSS/Atomフィードを読み込みたい [#k674c059]
- ページ: [[BugTrack]]
- 投稿者: [[umorigu]]
- 優先順位: 低
- 状態: 提案
- カテゴリー: プラグイン
- 投稿日: 2017-10-21 (土) 13:46:32
- バージョン: 1.5.1
** メッセージ [#n0137ac0]
Atomフィードでのサイト情報配信が増えているが、showrssは対応していない。
[[BugTrack/2176]] より移動:
***[[Atom]] feed を読み込めない [#p0c8799f]
show''rss'' プラグインなので、場違いな気もしますが、[[official:質問箱4/435]] のような質問もあるので一応。
(2009-10-20 (火) 00:08:18 に、ソースの書き忘れ部分を加筆。これが無いと、<link href="URL" /> のhref="URL" 部分を読み込めない・・・)
// Tag start
function start_element($parser, $name, $attrs)
{
- if ($this->is_item) {
+ if ($this->is_item !== FALSE) {
$this->tag = $name;
+ if ($this->is_item == 'ENTRY' && $name == 'LINK' && isset($attrs['HREF'])) {
+ if (! isset($this->item[$name])) $this->item[$name] = '';
+ $this->item[$name] .= $attrs['HREF'];
+ }
} else if ($name == 'ITEM') {
- $this->is_item = TRUE;
+ $this->is_item = 'ITEM';
+ } else if ($name == 'ENTRY') {
+ $this->is_item = 'ENTRY';
}
}
// Tag end
function end_element($parser, $name)
{
- if (! $this->is_item || $name != 'ITEM') return;
+ if ($this->is_item === FALSE || $name != $this->is_item) return;
$item = array_map(array(& $this, 'escape'), $this->item);
$this->item = array();
if (isset($item['DC:DATE'])) {
$time = plugin_showrss_get_timestamp($item['DC:DATE']);
} else if (isset($item['PUBDATE'])) {
$time = plugin_showrss_get_timestamp($item['PUBDATE']);
+ } else if (isset($item['UPDATED'])) {
+ $time = plugin_showrss_get_timestamp($item['UPDATED'], $this->time);
+
} else if (isset($item['DESCRIPTION']) &&
($description = trim($item['DESCRIPTION'])) != '' &&
- ($time = strtotime($description)) != -1) {
+ ($time = strtotime($description)) != -1 && $time !== FALSE) {
$time -= LOCALZONE;
} else {
$time = time() - LOCALZONE;
}
$item['_TIMESTAMP'] = $time;
$date = get_date('Y-m-d', $item['_TIMESTAMP']);
$this->items[$date][] = $item;
$this->is_item = FALSE;
}
function character_data($parser, $data)
{
- if (! $this->is_item) return;
+ if ($this->is_item === FALSE) return;
if (! isset($this->item[$this->tag])) $this->item[$this->tag] = '';
$this->item[$this->tag] .= $data;
}
plugin_showrss_get_timestamp(''); だとUTIME を返してくるので
$str = '';
foreach(array('DC:DATE', 'PUBDATE', 'UPDATED', 'DESCRIPTION') as $key) {
if (isset($item[$key]) && $item[$key] != '') {
$str = $item[$key];
break;
}
}
$time = plugin_showrss_get_timestamp($str, $this->time);
でもいいかなとも思いましたが、とりあえず放置。(今は、'DESCRIPTION' だけtrim() してから比較してますし)
strtotime() のところはとりあえず変更。
--------
#comment