From c2bae1f25ae70c0233d94b8388554d886ab24842 Mon Sep 17 00:00:00 2001 From: BNoiZe Date: Fri, 15 Nov 2013 22:11:25 +0100 Subject: [PATCH] Initial version of newsfeed in admin dashboard --- lib/ajax.php | 48 +++++++++++++++++++++++++ templates/Sparkle/admin/index/index.tpl | 3 ++ templates/Sparkle/assets/css/main.css | 19 ++++++++++ templates/Sparkle/assets/js/main.js | 8 +++++ 4 files changed, 78 insertions(+) create mode 100644 lib/ajax.php diff --git a/lib/ajax.php b/lib/ajax.php new file mode 100644 index 00000000..1e43d4f6 --- /dev/null +++ b/lib/ajax.php @@ -0,0 +1,48 @@ + + * @author Froxlor team (2010-) + * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt + * @package AJAX + * + */ + +if(isset($_POST['action'])) { + $action = $_POST['action']; +} elseif(isset($_GET['action'])) { + $action = $_GET['action']; +} else { + $action = ""; +} + +if ($action == "newsfeed") { + $news = simplexml_load_file('http://froxlor.org/feed.rss.php', null, LIBXML_NOCDATA); + + if ($news !== false) { + $json = array(); + for ($i = 0; $i < 3; $i++) { + $item = $news->channel->item[$i]; + $json[] = array( + 'title'=> (string)$item->title, + 'url'=> (string)$item->link, + 'content' => preg_replace("/[\r\n]+/", "", strip_tags($item->description)) + ); + + echo ""; + } + } else { + echo ""; + } +} else { + echo "No action set."; +} \ No newline at end of file diff --git a/templates/Sparkle/admin/index/index.tpl b/templates/Sparkle/admin/index/index.tpl index dc6fb379..6abdc0a6 100644 --- a/templates/Sparkle/admin/index/index.tpl +++ b/templates/Sparkle/admin/index/index.tpl @@ -4,6 +4,9 @@ $header {$lng['panel']['dashboard']} + +
+
diff --git a/templates/Sparkle/assets/css/main.css b/templates/Sparkle/assets/css/main.css index 8fa80e99..06a40fe7 100644 --- a/templates/Sparkle/assets/css/main.css +++ b/templates/Sparkle/assets/css/main.css @@ -490,6 +490,7 @@ nav { float: left; width:230px; background-color:#f7f8fa; + min-height: 500px; } nav div:first-child { display: none; @@ -939,3 +940,21 @@ label.nobr { .canvasbox canvas { width: 120px; } + +/* NEWSFEED */ +.newsitem { + border-bottom: 1px solid #f1f2f3; + padding: 6px 10px 8px 10px; + height: 16px; + line-height: 20px; + margin: 0 10px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.newsitem a { + color: #333; +} +.newsitem b { + margin-right: 15px; +} diff --git a/templates/Sparkle/assets/js/main.js b/templates/Sparkle/assets/js/main.js index b49fa3a1..cf9a7307 100644 --- a/templates/Sparkle/assets/js/main.js +++ b/templates/Sparkle/assets/js/main.js @@ -31,6 +31,14 @@ $(document).ready(function() { if (snheight > mainheight) { $('#maincontent').height(snheight - 60); } + + // Load Newsfeed + var ajax_load = "
Loading newsfeed...
"; + $("#newsfeed").html(ajax_load).load("lib/ajax.php?action=newsfeed", function() { + if ($("#newsfeed").html() != "") { + $("#newsfeed").slideDown(); + } + }); // this is necessary for the special setting feature (ref #1010) $.getQueryVariable = function(key) {