1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10: $plugin_is_filter = 7 | ADMIN_PLUGIN;
11: $plugin_description = gettext("Places the latest 3 news articles from Zenphoto.org on the admin overview page.");
12: $plugin_author = "Malte Müller (acrylian), Stephen Billard (sbillard)";
13: $plugin_disable = (!class_exists('DOMDocument')) ? gettext('PHP <em>DOM Object Model</em> is required.') : false;
14:
15: $option_interface = 'zenphoto_org_news';
16:
17: zp_register_filter('admin_overview', 'printNews');
18:
19: class zenphoto_org_news {
20:
21: function __construct() {
22: setOptionDefault('zenphoto_news_length', 0);
23: }
24:
25: function getOptionsSupported() {
26: return array(gettext('Truncation') => array('key' => 'zenphoto_news_length', 'type' => OPTION_TYPE_TEXTBOX,
27: 'desc' => gettext('The length of the article to display.'))
28: );
29: }
30:
31: }
32:
33: function printNews() {
34: ?>
35: <div class="box overview-utility">
36: <h2 class="h2_bordered"><?php echo gettext("News from Zenphoto.org"); ?></h2>
37: <?php
38: if (is_connected()) {
39: require_once(dirname(__FILE__) . '/zenphoto_news/rsslib.php');
40: require_once(SERVERPATH . '/' . ZENFOLDER . '/template-functions.php');
41: $recents = RSS_Retrieve("http://www.zenphoto.org/index.php?rss=news&withimages");
42: if ($recents) {
43: $opened = false;
44: $recents = array_slice($recents, 1, 5);
45: $shorten = getOption('zenphoto_news_length');
46: foreach ($recents as $article) {
47: $type = $article["type"];
48: if ($type == 0) {
49: if ($opened) {
50: ?>
51: </ul>
52: <?php
53: $opened = false;
54: }
55: ?>
56: <b />
57: <?php
58: } else {
59: if (!$opened) {
60: ?>
61: <ul>
62: <?php
63: $opened = true;
64: }
65: }
66: $title = $article["title"];
67: $date = zpFormattedDate(DATE_FORMAT, strtotime($article["pubDate"]));
68: $link = $article["link"];
69: if ($shorten) {
70: $description = shortenContent($article["description"], $shorten, '...');
71: } else {
72: $description = false;
73: }
74: ?>
75: <li><a href="<?php echo $link; ?>"><strong><?php echo $title; ?></strong> (<?php echo $date; ?>)</a>
76: <?php
77: if ($description != false) {
78: ?>
79: <br />
80: <?php
81: echo $description;
82: }
83: ?>
84: </li>
85: <?php
86: if ($type == 0) {
87: ?>
88: <br />
89: <?php
90: }
91: }
92: if ($opened) {
93: ?>
94: </ul>
95: <?php
96: }
97: } else {
98: ?>
99: <ul>
100: <li><?php printf(gettext('Failed to retrieve link <em>%s</em>'), 'http://www.zenphoto.org/index.php?rss=news&withimages'); ?></li>
101: </ul>
102: <?php
103: }
104: } else {
105: ?>
106: <ul>
107: <li><?php echo gettext('A connection to <em>Zenphoto.org</em> could not be established.'); ?>
108: </li>
109: </ul>
110: <?php
111: }
112: ?>
113: </div>
114: <?php
115: }
116: ?>