blob: 4285f414a81bb56c72e9cb66c503c1f45715ef67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
<?php
class Piwik_ExampleRssWidget extends Piwik_Plugin
{
public function getInformation()
{
return array(
// name must be the className prefix!
'name' => 'Example RSS Widget',
'description' => 'Simple example on how to create a new widget that reads a RSS feed',
'author' => 'Piwik',
'homepage' => 'http://piwik.org/',
'version' => '0.1',
);
}
}
Piwik_AddWidget('ExampleRssWidget', 'rssPiwik', 'Piwik.org Blog');
class Piwik_ExampleRssWidget_Controller extends Piwik_Controller
{
function rssPiwik()
{
require_once 'libs/Zend/Feed.php';
try {
$rss = Zend_Feed::import('http://feeds.feedburner.com/Piwik');
} catch (Zend_Feed_Exception $e) {
echo "Exception caught importing feed: {$e->getMessage()}\n";
exit;
}
echo $this->css();
echo '<div style="padding:10px 15px;"><ul class="rss">';
$i = 0;
foreach($rss as $post)
{
$title = $post->title();
$date = strftime("%B %e, %Y", strtotime($post->pubDate()));
$description = $post->description();
$link = $post->link();
echo '<li>
<a class="rss-title" title="" href="'.$link.'">'.$title.'</a>
<span class="rss-date">'.$date.'</span>
<div class="rss-description">'.$description.'</div>
</li>';
if(++$i == 3) break;
}
echo '</ul></div>';
}
function css()
{
return "<style>
.rss ul {
list-style-image:none;
list-style-position:outside;
list-style-type:none;
padding:0pt;
}
.rss li {
line-height:140%;
margin-bottom:6px;
margin:0.5em 0pt 1em;
}
.rss-title, .rss-date {
float:left;
font-size:14px;
line-height:140%;
}
.rss-title{
color:#2583AD;
margin:0pt 0.5em 0.2em 0pt;
font-weight:bold;
}
.rss-date {
color:#999999;
margin:0pt;
}
.rss-description {
clear:both;
line-height:1.5em;
font-size:11px;
color:#333333;
}
</style>";
}
}
|