newsfeed + more admin dashboard info
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
47
lib/ajax.php
47
lib/ajax.php
@@ -18,12 +18,14 @@
|
||||
require_once dirname(__DIR__) . '/vendor/autoload.php';
|
||||
|
||||
// Load the user settings
|
||||
if (! file_exists('./userdata.inc.php')) {
|
||||
if (!file_exists('./userdata.inc.php')) {
|
||||
die();
|
||||
}
|
||||
require './userdata.inc.php';
|
||||
require './tables.inc.php';
|
||||
|
||||
use Froxlor\UI\Panel\UI;
|
||||
|
||||
if (isset($_POST['action'])) {
|
||||
$action = $_POST['action'];
|
||||
} elseif (isset($_GET['action'])) {
|
||||
@@ -32,7 +34,12 @@ if (isset($_POST['action'])) {
|
||||
$action = "";
|
||||
}
|
||||
|
||||
$theme = $_GET['theme'] ?? 'Froxlor';
|
||||
|
||||
if ($action == "newsfeed") {
|
||||
|
||||
UI::initTwig();
|
||||
|
||||
if (isset($_GET['role']) && $_GET['role'] == "customer") {
|
||||
$feed = \Froxlor\Settings::Get("customer.news_feed_url");
|
||||
if (empty(trim($feed))) {
|
||||
@@ -56,16 +63,21 @@ if ($action == "newsfeed") {
|
||||
}
|
||||
|
||||
if ($news !== false) {
|
||||
for ($i = 0; $i < 3; $i ++) {
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$item = $news->channel->item[$i];
|
||||
|
||||
$title = (string) $item->title;
|
||||
$link = (string) $item->link;
|
||||
$date = date("Y-m-d G:i", strtotime($item->pubDate));
|
||||
$date = date("d.m.Y", strtotime($item->pubDate));
|
||||
$content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description));
|
||||
$content = substr($content, 0, 150) . "...";
|
||||
|
||||
outputItem($title, $content, $link, $date);
|
||||
echo UI::Twig()->render($theme . '/user/newsfeeditem.html.twig', [
|
||||
'link' => $link,
|
||||
'title' => $title,
|
||||
'date' => $date,
|
||||
'content' => $content
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
echo "";
|
||||
@@ -73,30 +85,3 @@ if ($action == "newsfeed") {
|
||||
} else {
|
||||
echo "No action set.";
|
||||
}
|
||||
|
||||
function outputItem($title, $content, $link = null, $date = null)
|
||||
{
|
||||
echo "<li class=\"clearfix\">
|
||||
<div class=\"newsfeed-body clearfix\">
|
||||
<div class=\"header\">
|
||||
<strong class=\"primary-font\">";
|
||||
if (! empty($link)) {
|
||||
echo "<a href=\"{$link}\" target=\"_blank\">";
|
||||
}
|
||||
echo $title;
|
||||
if (! empty($link)) {
|
||||
echo "</a>";
|
||||
}
|
||||
echo "</strong>";
|
||||
if (! empty($date)) {
|
||||
echo "<small class=\"pull-right text-muted\">
|
||||
<i class=\"fa fa-clock-o fa-fw\"></i> {$date}
|
||||
</small>";
|
||||
}
|
||||
echo "</div>
|
||||
<p>
|
||||
{$content}
|
||||
</p>
|
||||
</div>
|
||||
</li>";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user