Merge pull request #153 from BNoiZe/master

Initial version of newsfeed in admin dashboard, needs a setting to enable/disable
This commit is contained in:
Michael Kaufmann
2013-11-17 08:36:37 -08:00
4 changed files with 82 additions and 0 deletions

46
lib/ajax.php Normal file
View File

@@ -0,0 +1,46 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Roman Schmerold <bnoize@froxlor.org>
* @author Froxlor team <team@froxlor.org> (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) {
for ($i = 0; $i < 3; $i++) {
$item = $news->channel->item[$i];
$title = (string)$item->title;
$link = (string)$item->link;
$content = preg_replace("/[\r\n]+/", "", strip_tags($item->description));
echo "<div class=\"newsitem\"><a href=\"" . $link . "\" target=\"_blank\"><b>" . $title . "</b>" . $content . "</a></div>";
}
} else {
echo "";
}
} else {
echo "No action set.";
}

View File

@@ -4,6 +4,9 @@ $header
<img src="templates/{$theme}/assets/img/icons/domains_big.png" alt="" />
{$lng['panel']['dashboard']}
</h2>
<div class="dboarditemfull bradius" id="newsfeed" style="display: none"></div>
<br />
<br />
<div class="canvasitems" id="statsbox">
<div class="canvasbox">
<input type="hidden" id="customers" class="circular" data-used="{$overview['number_customers']}" data-available="{$userinfo['customers']}">

View File

@@ -490,6 +490,7 @@ nav {
float: left;
width:230px;
background-color:#f7f8fa;
min-height: 500px;
}
nav div:first-child {
display: none;
@@ -939,3 +940,27 @@ 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 a:hover {
text-decoration: none;
}
.newsitem a:hover b {
text-decoration: underline;
}
.newsitem b {
margin-right: 15px;
}

View File

@@ -32,6 +32,14 @@ $(document).ready(function() {
$('#maincontent').height(snheight - 60);
}
// Load Newsfeed
var ajax_load = "<div id='newsitem'>Loading newsfeed...</div>";
$("#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) {
var urlParams = decodeURI( window.location.search.substring(1) );