Code

Added RSS reader
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Jun 2010 10:21:01 +0000 (10:21 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 30 Jun 2010 10:21:01 +0000 (10:21 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18883 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/dashBoard/dbInformation/class_dbInformation.inc
gosa-core/plugins/generic/dashBoard/dbInformation/class_rssReader.inc [new file with mode: 0644]
gosa-core/plugins/generic/dashBoard/dbInformation/contents.tpl

index f04d4e65ae800d5f588042ffbd56187036418193..d9e9fc97815f58c73e8b174147a190f185d8136a 100644 (file)
@@ -5,11 +5,32 @@ class dbInformation extends plugin
     function __construct($config)
     {
         parent::__construct($config, NULL);
+
+        // Construct the plugin list.
+        $this->feedList = new sortableListing();
+        $this->feedList->setDeleteable(false);
+        $this->feedList->setEditable(false);
+#        $this->feedList->setColspecs(array('30px','120px','*','100px'));
+#        $this->feedList->setHeader(array('?',_("Name"),_("Descriptio"),_("Status")));
+        $this->feedList->setWidth("100%");
+#        $this->feedList->setDefaultSortColumn(1);
+        $this->feedList->setHeight("200px");
+        $this->feedList->setAcl("rwcdm");
     }
 
     function execute()
     {
         $smarty = get_smarty();
+        $feeds = rssReader::feadToArray('http://www.computerbild.de/rssfeed_2261.html?node=10');
+
+        $data = $lData = array();
+        foreach($feeds as $key => $feed){
+            $data[$key] = $feed;
+            $lData[$key] = array('data'=> array(date('H:i:s', $feed['timestamp']),$feed['title']));
+        }
+        $this->feedList->setListData($data, $lData);
+        $this->feedList->update();
+        $smarty->assign('feedList', $this->feedList->render());
         return($smarty->fetch(get_template_path('dbInformation/contents.tpl', TRUE)));
     }
 
diff --git a/gosa-core/plugins/generic/dashBoard/dbInformation/class_rssReader.inc b/gosa-core/plugins/generic/dashBoard/dbInformation/class_rssReader.inc
new file mode 100644 (file)
index 0000000..11e8a79
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+
+class rssReader{
+
+    static function feadToArray($url)
+    {
+
+        $doc = new DOMDocument();
+        $doc->load($url);
+        $entries = array();
+        foreach ($doc->getElementsByTagName('item') as $item) {
+            $entry = array ( 
+                    'title' => $item->getElementsByTagName('title')->item(0)->nodeValue,
+                    'desc' => $item->getElementsByTagName('description')->item(0)->nodeValue,
+                    'link' => $item->getElementsByTagName('link')->item(0)->nodeValue,
+                    'date' => $item->getElementsByTagName('pubDate')->item(0)->nodeValue,
+                    'timestamp' => strtotime($item->getElementsByTagName('pubDate')->item(0)->nodeValue)
+                    );
+            $entries[$entry['timestamp']."-".$entry['date']] = $entry;
+        }
+        return($entries);
+    }
+} 
+
+?>