Database refactoring and improving blog comments, blog post history and more
This commit is contained in:
parent
56aed78b00
commit
7f887a99b0
|
@ -55,6 +55,7 @@
|
||||||
$route['r/(:any)'] = 'redirect/p/$1';
|
$route['r/(:any)'] = 'redirect/p/$1';
|
||||||
$route['admin/(:any)'] = 'admin/$1';
|
$route['admin/(:any)'] = 'admin/$1';
|
||||||
$route['admin'] = 'admin/dashboard/index';
|
$route['admin'] = 'admin/dashboard/index';
|
||||||
|
$route['admin/blog/history/(:any)/compare/(:any)/(:any)'] = 'admin/blog/history_compare/$1/$2/$3';
|
||||||
$route['tools/csgo/(:any)'] = 'tools/csgo/index/$1';
|
$route['tools/csgo/(:any)'] = 'tools/csgo/index/$1';
|
||||||
$route['tools'] = 'tools/tools/index';
|
$route['tools'] = 'tools/tools/index';
|
||||||
$route['watch/(:any)/(:any)'] = 'watch/index/$1/$2';
|
$route['watch/(:any)/(:any)'] = 'watch/index/$1/$2';
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
class Blog extends MY_Controller {
|
class Blog extends MY_Controller
|
||||||
|
{
|
||||||
|
|
||||||
function __construct() {
|
function __construct()
|
||||||
|
{
|
||||||
parent::__construct('blog');
|
parent::__construct('blog');
|
||||||
$this->load->model('BlogModel', '', TRUE);
|
$this->load->model('BlogModel', '', TRUE);
|
||||||
$this->load->helper('url');
|
$this->load->helper('url');
|
||||||
}
|
}
|
||||||
|
|
||||||
function index() {
|
function index()
|
||||||
|
{
|
||||||
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
||||||
$data = $this->BlogModel->getAllPosts('', 5, $offset);
|
$data = $this->BlogModel->getAllPosts('', 5, $offset);
|
||||||
|
|
||||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||||
|
|
||||||
if(!empty($data)) {
|
if (!empty($data)) {
|
||||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,13 +28,14 @@ class Blog extends MY_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->load->view('footer', ['additionalScripts' => ['lib/jquery.twbsPagination.min.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['lib/jquery.twbsPagination.min.js']]);
|
||||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
$this->load->view('blog/pagination', ['pageCount' => $pageCount, 'page' => $offset]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function search($query = null) {
|
function search($query = null)
|
||||||
if(isset($_GET['q'])) {
|
{
|
||||||
|
if (isset($_GET['q'])) {
|
||||||
redirect(base_url('blog/search/' . urlencode($this->input->get('q'))));
|
redirect(base_url('blog/search/' . urlencode($this->input->get('q'))));
|
||||||
} elseif($query == null) {
|
} elseif ($query == null) {
|
||||||
redirect(base_url('blog'));
|
redirect(base_url('blog'));
|
||||||
} else {
|
} else {
|
||||||
$query = $this->security->xss_clean(urldecode($query));
|
$query = $this->security->xss_clean(urldecode($query));
|
||||||
|
@ -41,7 +45,7 @@ class Blog extends MY_Controller {
|
||||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||||
|
|
||||||
if(!empty($data)) {
|
if (!empty($data)) {
|
||||||
$pageCount = $this->BlogModel->getPostPageCount($query, 5);
|
$pageCount = $this->BlogModel->getPostPageCount($query, 5);
|
||||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -54,8 +58,9 @@ class Blog extends MY_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function category($category = null) {
|
function category($category = null)
|
||||||
if($category == null) {
|
{
|
||||||
|
if ($category == null) {
|
||||||
redirect(base_url('blog'));
|
redirect(base_url('blog'));
|
||||||
} else {
|
} else {
|
||||||
$category = urldecode($category);
|
$category = urldecode($category);
|
||||||
|
@ -65,7 +70,7 @@ class Blog extends MY_Controller {
|
||||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||||
|
|
||||||
if(!empty($data)) {
|
if (!empty($data)) {
|
||||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -78,18 +83,19 @@ class Blog extends MY_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tag($tag = null) {
|
public function tag($tag = null)
|
||||||
if($tag == null) {
|
{
|
||||||
|
if ($tag == null) {
|
||||||
redirect(base_url('blog'));
|
redirect(base_url('blog'));
|
||||||
}
|
}
|
||||||
$tag = urldecode($tag);
|
$tag = urldecode($tag);
|
||||||
$offset = isset($_GET['page']) ? intval($_GET['page']) -1 : 0;
|
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
||||||
$data = $this->BlogModel->getTagPosts($tag, 5, $offset);
|
$data = $this->BlogModel->getTagPosts($tag, 5, $offset);
|
||||||
|
|
||||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||||
|
|
||||||
if(!empty($data)) {
|
if (!empty($data)) {
|
||||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -101,48 +107,51 @@ class Blog extends MY_Controller {
|
||||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function add() {
|
function add()
|
||||||
if(isset($_SESSION['user']) && $this->hasPermission('blog.create')) {
|
{
|
||||||
|
if (isset($_SESSION['user']) && $this->hasPermission('blog.create')) {
|
||||||
redirect('/admin/blog/add');
|
redirect('/admin/blog/add');
|
||||||
} else {
|
} else {
|
||||||
redirect('/blog');
|
redirect('/blog');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function post($postTitle = null) {
|
function post($postTitle = null)
|
||||||
if($postTitle == null) {
|
{
|
||||||
|
if ($postTitle == null) {
|
||||||
redirect("/blog");
|
redirect("/blog");
|
||||||
} elseif(isset($_GET['q'])) {
|
} elseif (isset($_GET['q'])) {
|
||||||
redirect('/blog?q=' . $_GET['q']);
|
redirect('/blog?q=' . $_GET['q']);
|
||||||
} else {
|
} else {
|
||||||
$post = $this->BlogModel->getPost($postTitle);
|
$post = $this->BlogModel->getPost($postTitle);
|
||||||
if(empty($post)) {
|
if (empty($post)) {
|
||||||
redirect('/blog');
|
redirect('/blog');
|
||||||
} else {
|
} else {
|
||||||
$post['randomPosts'] = $this->BlogModel->getRandomPosts($post['postID']);
|
$post['randomPosts'] = $this->BlogModel->getRandomPosts($post['ID']);
|
||||||
$post['comments'] = $this->BlogModel->getComments($post['postID']);
|
$post['comments'] = $this->BlogModel->getComments($post['ID']);
|
||||||
$post['tags'] = $this->BlogModel->getTags($post['postID']);
|
$post['tags'] = $this->BlogModel->getTags($post['ID']);
|
||||||
$post['hasLiked'] = isset($_SESSION['user']) && !empty($_SESSION['user']) ? $this->BlogModel->hasAlreadyLiked($post['postID'], $_SESSION['user']['ID']) : false;
|
$post['hasLiked'] = isset($_SESSION['user']) && !empty($_SESSION['user']) ? $this->BlogModel->hasAlreadyLiked($post['ID'], $_SESSION['user']['ID']) : false;
|
||||||
$sameCategoryPosts = $this->BlogModel->getCategoryPostsByID($post['postCategoryID'], 3, $post['postID']);
|
$sameCategoryPosts = $this->BlogModel->getCategoryPostsByID($post['categories'], 3, $post['ID']);
|
||||||
|
|
||||||
$post['prevPost'] = $this->BlogModel->getPrevPost($post['postID']);
|
$post['prevPost'] = $this->BlogModel->getPrevPost($post['initialRelease']);
|
||||||
$post['nextPost'] = $this->BlogModel->getNextPost($post['postID']);
|
$post['nextPost'] = $this->BlogModel->getNextPost($post['initialRelease']);
|
||||||
|
|
||||||
$this->BlogModel->incrementViews($post['postID']);
|
$this->BlogModel->incrementViews($post['ID']);
|
||||||
|
|
||||||
$this->load->view('header', ['active' => 'blog', 'title' => $post['postTitle'], 'additionalStyles' => ['posts_list.css', 'blog.css']]);
|
$this->load->view('header', ['active' => 'blog', 'title' => $post['title'], 'additionalStyles' => ['posts_list.css', 'blog.css']]);
|
||||||
$this->load->view('blog/first', ['categoryPosts' => $sameCategoryPosts, 'categories' => $this->BlogModel->getCategories()]);
|
$this->load->view('blog/first', ['categoryPosts' => $sameCategoryPosts, 'categories' => $this->BlogModel->getCategories()]);
|
||||||
$this->load->view('blog/post', $post);
|
$this->load->view('blog/post', $post);
|
||||||
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js', 'comment-item.js']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function like() {
|
function like()
|
||||||
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
{
|
||||||
|
if (!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
||||||
echo "no-user";
|
echo "no-user";
|
||||||
} else {
|
} else {
|
||||||
if(!$this->BlogModel->hasAlreadyLiked($_POST['postID'], $_SESSION['user']['ID'])) {
|
if (!$this->BlogModel->hasAlreadyLiked($_POST['postID'], $_SESSION['user']['ID'])) {
|
||||||
echo 'true:';
|
echo 'true:';
|
||||||
echo $this->BlogModel->addLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
|
echo $this->BlogModel->addLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,37 +161,176 @@ class Blog extends MY_Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function comment() {
|
function comment()
|
||||||
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
{
|
||||||
$result = ['type' => 'error', 'message' => 'Nicht eingeloggt'];
|
if (!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
||||||
|
$result = [
|
||||||
|
'success' => false,
|
||||||
|
'message' => '<b>Nicht eingeloggt!</b> Du musst in deinem Account angemeldet sein, um Kommentare auf Blog-Posts zu verfassen. Die Registrierung ist völlig kostenlos!',
|
||||||
|
];
|
||||||
} else {
|
} else {
|
||||||
$url = $this->input->post('url');
|
$url = $this->input->post('url');
|
||||||
|
|
||||||
$url = str_replace('/blog/post/', '', $url);
|
$url = str_replace('/blog/post/', '', $url);
|
||||||
|
|
||||||
$comment = $this->BlogModel->addCommentByUrl($url, $_SESSION['user']['ID'], $this->input->post('comment'), false, NULL);
|
$comment = $this->BlogModel->addCommentByUrl($url, $_SESSION['user']['ID'], $this->input->post('comment'), NULL);
|
||||||
$result = ['type' => 'success', 'content' => [
|
|
||||||
|
if ($comment == NULL) {
|
||||||
|
$result = [
|
||||||
|
'success' => false,
|
||||||
|
'message' => '<b>Post nicht gefunden.</b> Bitte lade die Seite erneut oder kontaktiere das Support-Team!',
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$result = [
|
||||||
|
'success' => true,
|
||||||
|
'content' => [
|
||||||
'username' => $_SESSION['user']['username'],
|
'username' => $_SESSION['user']['username'],
|
||||||
'displayname' => $_SESSION['user']['displayname'],
|
'displayname' => $_SESSION['user']['displayname'],
|
||||||
'profilePic' => $_SESSION['user']['profilePic'],
|
'profilePicture' => $_SESSION['user']['profilePic'],
|
||||||
'date' => date('d.m.Y H: i \\U\\h\\r', strtotime($comment['date_created']))
|
]
|
||||||
]];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getComments() {
|
function getComments()
|
||||||
|
{
|
||||||
$url = $this->input->get('url');
|
$url = $this->input->get('url');
|
||||||
|
|
||||||
$url = str_replace('/blog/post/', '', $url);
|
$url = str_replace('/blog/post/', '', $url);
|
||||||
|
|
||||||
|
$authorCache = [];
|
||||||
|
|
||||||
$comments = $this->BlogModel->getCommentsByUrl($url);
|
$comments = $this->BlogModel->getCommentsByUrl($url);
|
||||||
foreach($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$comment['author'] = $this->BlogModel->getAuthorData($comment['user_id']);
|
$userID = $comment['userID'];
|
||||||
$this->load->view('blog/comment', $comment);
|
if (isset($authorCache[$userID])) {
|
||||||
|
$author = $authorCache[$userID];
|
||||||
|
} else {
|
||||||
|
$author = $this->BlogModel->getAuthorData($userID);
|
||||||
|
$authorCache[$userID] = $author;
|
||||||
|
}
|
||||||
|
$this->load->view('network/blog/comment_item', ['data' => $author, 'c' => $comment]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public function getReportModal()
|
||||||
|
{
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$body = $this->load->view('blog/report_modal', [], true);
|
||||||
|
echo json_encode([
|
||||||
|
'success' => true,
|
||||||
|
'title' => 'Kommentar melden',
|
||||||
|
'body' => $body
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reportComment()
|
||||||
|
{
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$commentID = intval($this->input->post('ID'));
|
||||||
|
|
||||||
|
if ($commentID == 0) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Kommentar existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$reason = $this->input->post('reason');
|
||||||
|
$reasonText = trim($this->input->post('explanation'));
|
||||||
|
|
||||||
|
if ($reason == '') {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen Grund für deine Meldung aus.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allowedReasons = ['hatespeech', 'racism', 'terrorism', 'abuse', 'violence', 'copyright', 'spam', 'technical-issue'];
|
||||||
|
|
||||||
|
if (!array_search($reason, $allowedReasons)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen standardmäßig vorhandenen und validen Grund für die Meldung aus.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->BlogModel->isCommentIDValid($commentID)) {
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Der ausgewählte Kommentar ist nicht (mehr) vorhanden. Sollte es sich hierbei um ein Irrtum handeln, verfasse bitte über den Button unten rechts ein Feedback.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->BlogModel->reportComment($commentID, $reason, $reasonText);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Vielen Dank für das Melden dieses Kommentars. Wir werden schnellstmöglich angemessene Aktionen unternehmen.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDeleteModal()
|
||||||
|
{
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
if (!isset($_SESSION['user'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commentID = intval($this->input->post('ID'));
|
||||||
|
|
||||||
|
if ($commentID == 0) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Kommentar existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$comment = $this->BlogModel->getComment($commentID);
|
||||||
|
|
||||||
|
if ($comment == NULL) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Kommentar existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$author = $this->BlogModel->getAuthorData($comment['userID']);
|
||||||
|
|
||||||
|
if ($author == NULL || $author['ID'] !== $_SESSION['user']['ID']) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Du kannst keine Kommentare löschen, die dir nicht gehören.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$body = $this->load->view('blog/delete_modal', ['author' => $author, 'comment' => $comment], true);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'title' => 'Kommentar löschen', 'body' => $body]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteComment()
|
||||||
|
{
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
if (!isset($_SESSION['user'])) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$commentID = intval($this->input->post('ID'));
|
||||||
|
|
||||||
|
if ($commentID == 0) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Kommentar existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$comment = $this->BlogModel->getComment($commentID);
|
||||||
|
|
||||||
|
if ($comment == null) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Kommentar existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$author = $this->BlogModel->getAuthorData($comment['userID']);
|
||||||
|
|
||||||
|
if ($author == NULL || $author['ID'] !== $_SESSION['user']['ID']) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Du kannst keine Kommentare löschen, die dir nicht gehören.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->BlogModel->deleteComment($_SESSION['user']['ID'], $commentID);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true, 'message' => 'Der Kommentar wurde erfolgreich gelöscht.']);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ class File extends MY_Controller
|
||||||
if ($title == null) {
|
if ($title == null) {
|
||||||
redirect(base_url());
|
redirect(base_url());
|
||||||
} else {
|
} else {
|
||||||
$file = $this->db->query('SELECT name, type, path, isUserData FROM files WHERE name = ?', [urldecode($title)])->result_array();
|
$file = $this->db->query('SELECT name, type, path FROM files WHERE name = ?', [urldecode($title)])->result_array();
|
||||||
|
|
||||||
if (!empty($file)) {
|
if (!empty($file)) {
|
||||||
$file = $file[0];
|
$file = $file[0];
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
$rememberMe = isset($_POST['rememberMe']) ? $_POST['rememberMe'] : 'off';
|
$rememberMe = isset($_POST['rememberMe']) ? $_POST['rememberMe'] : 'off';
|
||||||
$this->LoginModel->login($_POST['loginname'], $_POST['loginPassword'], $rememberMe);
|
$this->LoginModel->login($_POST['loginname'], $_POST['loginPassword'], $rememberMe);
|
||||||
|
|
||||||
isset($_GET['r']) && !empty($_GET['r']) ? redirect(base64_decode(urldecode($_GET['r']))) : redirect(base_url('login'));
|
// isset($_GET['r']) && !empty($_GET['r']) ? redirect(base64_decode(urldecode($_GET['r']))) : redirect(base_url('login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$notice = isset($_SESSION['notice']) ? $_SESSION['notice'] : '';
|
$notice = isset($_SESSION['notice']) ? $_SESSION['notice'] : '';
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
{
|
{
|
||||||
// TODO: Add twitch, instagram and 500px as further services
|
// TODO: Add twitch, instagram and 500px as further services
|
||||||
|
|
||||||
$video = $this->YoutubePlayerModel->newestVids(1)[0];
|
$video = $this->SocialMediaModel->newestVids(1)[0];
|
||||||
|
|
||||||
$currentlyActiveUsers = $this->UserModel->getActiveUsers(5);
|
$currentlyActiveUsers = $this->UserModel->getActiveUsers(5);
|
||||||
$newestUsers = $this->UserModel->getNewestUsers(5);
|
$newestUsers = $this->UserModel->getNewestUsers(5);
|
||||||
|
@ -43,8 +43,8 @@
|
||||||
}
|
}
|
||||||
$font_sizes = [27, 27, 24, 24, 24, 20, 16, 16, 14, 14, 12, 11, 10];
|
$font_sizes = [27, 27, 24, 24, 24, 20, 16, 16, 14, 14, 12, 11, 10];
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
$post_date = $item['post_date'];
|
$date = strtotime($item['date']);
|
||||||
$item['post_date'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$post_date"), $_SESSION['site_lang']);
|
$item['date'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']);
|
||||||
$item['font_sizes'] = $font_sizes;
|
$item['font_sizes'] = $font_sizes;
|
||||||
$this->load->view('post_list_entry', $item);
|
$this->load->view('post_list_entry', $item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,10 @@
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postUUID = $this->input->post('postUUID');
|
$hashID = $this->input->post('postUUID');
|
||||||
|
|
||||||
$isLiked = $this->PostsModel->addPostLikeByUUID($postUUID, $_SESSION['user']['ID']);
|
$isLiked = $this->PostsModel->addPostLikeByHashID($hashID, $_SESSION['user']['ID']);
|
||||||
$likeCount = $this->PostsModel->getPostLikeCountByUUID($postUUID);
|
$likeCount = $this->PostsModel->getPostLikeCountByHashID($hashID);
|
||||||
|
|
||||||
echo json_encode([
|
echo json_encode([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
$users = $this->UserModel->searchUsers($query, $rank, $country, $lang, $userAmount, $userOffset);
|
$users = $this->UserModel->searchUsers($query, $rank, $country, $lang, $userAmount, $userOffset);
|
||||||
|
|
||||||
if (!empty($users)) {
|
if (!empty($users)) {
|
||||||
if($offset == 0) {
|
if ($offset == 0) {
|
||||||
echo '<h2>Nutzer (' . sizeof($users) . ')</h2>';
|
echo '<h2>Nutzer (' . sizeof($users) . ')</h2>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +142,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvailableCountries() {
|
public function getAvailableCountries()
|
||||||
|
{
|
||||||
$countries = $this->UserModel->getAvailableCountries();
|
$countries = $this->UserModel->getAvailableCountries();
|
||||||
|
|
||||||
foreach ($countries as $i => $country) {
|
foreach ($countries as $i => $country) {
|
||||||
|
@ -153,7 +154,8 @@
|
||||||
echo json_encode(['countries' => $countries]);
|
echo json_encode(['countries' => $countries]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvailableLanguages() {
|
public function getAvailableLanguages()
|
||||||
|
{
|
||||||
$languages = $this->UserModel->getAvailableLanguages();
|
$languages = $this->UserModel->getAvailableLanguages();
|
||||||
|
|
||||||
foreach ($languages as $i => $language) {
|
foreach ($languages as $i => $language) {
|
||||||
|
@ -164,54 +166,69 @@
|
||||||
echo json_encode(['languages' => $languages]);
|
echo json_encode(['languages' => $languages]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getReportModal() {
|
public function getReportModal()
|
||||||
|
{
|
||||||
$this->load->view('network/posts/report_modal');
|
$this->load->view('network/posts/report_modal');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reportPost() {
|
public function reportPost()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
$uuid = $this->input->post('uuid');
|
$hashID = $this->input->post('hashID');
|
||||||
|
|
||||||
|
if ($hashID == NULL) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$reason = $this->input->post('reason');
|
$reason = $this->input->post('reason');
|
||||||
$reasonText = $this->input->post('explanation');
|
$reasonText = $this->input->post('explanation');
|
||||||
|
|
||||||
if($reason == '') {
|
if ($reason == '') {
|
||||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen Grund für deine Meldung aus.']);
|
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen Grund für deine Meldung aus.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allowedReasons = ['hatespeech', 'racism', 'terrorism', 'abuse', 'violence', 'copyright', 'spam', 'technical-issue'];
|
$allowedReasons = ['hatespeech', 'racism', 'terrorism', 'abuse', 'violence', 'copyright', 'spam', 'technical-issue'];
|
||||||
|
|
||||||
if(!array_search($reason, $allowedReasons)) {
|
if (!array_search($reason, $allowedReasons)) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen standardmäßig vorhandenen und validen Grund für die Meldung aus.']);
|
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen standardmäßig vorhandenen und validen Grund für die Meldung aus.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$this->PostsModel->isUUIDValid($uuid)) {
|
if (!$this->PostsModel->isHashIDValid($hashID)) {
|
||||||
echo json_encode(['success' => true, 'message' => 'Der ausgewählte Post ist nicht (mehr) vorhanden. Sollte es sich hierbei um ein Irrtum handeln, verfasse bitte über den Button unten rechts ein Feedback.']);
|
echo json_encode(['success' => true, 'message' => 'Der ausgewählte Post ist nicht (mehr) vorhanden. Sollte es sich hierbei um ein Irrtum handeln, verfasse bitte über den Button unten rechts ein Feedback.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->PostsModel->reportPost($uuid, $reason, $reasonText);
|
$this->PostsModel->reportPost($hashID, $reason, $reasonText);
|
||||||
|
|
||||||
echo json_encode(['success' => true, 'message' => 'Vielen Dank für das Melden dieses Posts. Wir werden schnellstmöglich angemessene Aktionen unternehmen.']);
|
echo json_encode(['success' => true, 'message' => 'Vielen Dank für das Melden dieses Posts. Wir werden schnellstmöglich angemessene Aktionen unternehmen.']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDeleteModal() {
|
public function getDeleteModal()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if(!isset($_SESSION['user'])) {
|
if (!isset($_SESSION['user'])) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uuid = $this->input->post('uuid');
|
$hashID = $this->input->post('hashID');
|
||||||
$post = $this->PostsModel->getPostByUUID($uuid);
|
|
||||||
|
|
||||||
if(empty($post)) {
|
if ($hashID == NULL) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
|
$post = $this->PostsModel->getPostByHashID($hashID);
|
||||||
|
|
||||||
|
if (empty($post)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($post[0]['userID'] != $_SESSION['user']['ID']) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -222,27 +239,34 @@
|
||||||
echo json_encode(['success' => true, 'title' => 'Post löschen', 'body' => $body]);
|
echo json_encode(['success' => true, 'title' => 'Post löschen', 'body' => $body]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletePost() {
|
public function deletePost()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if(!isset($_SESSION['user'])) {
|
if (!isset($_SESSION['user'])) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uuid = $this->input->post('uuid');
|
$hashID = $this->input->post('hashID');
|
||||||
$post = $this->PostsModel->getPostByUUID($uuid);
|
|
||||||
|
|
||||||
if(empty($post)) {
|
if ($hashID == NULL) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($post[0]['user_id'] != $_SESSION['user']['ID']) {
|
$post = $this->PostsModel->getPostByHashID($hashID);
|
||||||
|
|
||||||
|
if (empty($post)) {
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($post[0]['userID'] != $_SESSION['user']['ID']) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
echo json_encode(['success' => false, 'message' => 'Du kannst keine Posts löschen, die dir nicht gehören.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->PostsModel->deletePost($_SESSION['user']['ID'], $uuid);
|
$this->PostsModel->deletePost($_SESSION['user']['ID'], $hashID);
|
||||||
|
|
||||||
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich gelöscht.']);
|
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich gelöscht.']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ class Projects extends MY_Controller
|
||||||
|
|
||||||
public function index($album = 'all')
|
public function index($album = 'all')
|
||||||
{
|
{
|
||||||
$collections = $this->ProjectsModel->getCategories($album);
|
$categories = $this->ProjectsModel->getCategories($album);
|
||||||
$content = $this->ProjectsModel->getEntries('all');
|
$content = $this->ProjectsModel->getEntries('all');
|
||||||
|
|
||||||
$this->load->view('header', ['active' => 'projects', 'title' => lang('projects_sitetitle'), 'additionalStyles' => ['sortlist.css', 'projects.css']]);
|
$this->load->view('header', ['active' => 'projects', 'title' => lang('projects_sitetitle'), 'additionalStyles' => ['sortlist.css', 'projects.css']]);
|
||||||
$this->load->view('projects', ['content' => $content, 'album' => $album, 'collections' => $collections]);
|
$this->load->view('projects', ['content' => $content, 'album' => $album, 'categories' => $categories]);
|
||||||
$this->load->view('footer', ['additionalScripts' => ['lib/isotope.pkgd.min.js', 'projects.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['lib/isotope.pkgd.min.js', 'projects.js']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,24 +20,24 @@
|
||||||
$title = "Error - Profile";
|
$title = "Error - Profile";
|
||||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
||||||
} else {
|
} else {
|
||||||
$user_data = $this->UserModel->getUser($user);
|
$userData = $this->UserModel->getUser($user);
|
||||||
$user_exists = !empty($user_data);
|
$userExists = !empty($userData);
|
||||||
if ($user_exists) {
|
if ($userExists) {
|
||||||
$user_data = $user_data[0];
|
$userData = $userData[0];
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$userStats = $this->UserModel->getUserStats($userData['ID']);
|
||||||
|
|
||||||
$user_posts = $this->PostsModel->getUserPosts($user_data['ID'], 3, 0, 192);
|
$userPosts = $this->PostsModel->getUserPosts($userData['ID'], 3, 0, 192);
|
||||||
$user_comments = $this->UserModel->getUserComments($user_data['ID'], 3, 0);
|
$userComments = $this->UserModel->getUserComments($userData['ID'], 3, 0);
|
||||||
$user_blog_posts = $this->UserModel->getUserBlogPosts($user_data['ID'], 3, 0);
|
$userBlogPosts = $this->UserModel->getUserBlogPosts($userData['ID'], 3, 0);
|
||||||
|
|
||||||
$date_created = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($userData['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
|
$userData['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$title = $user_data['displayname'] . " - Profile";
|
$title = $userData['displayname'] . " - Profile";
|
||||||
$isCurrentUserFollowing = false;
|
$isCurrentUserFollowing = false;
|
||||||
if (isset($_SESSION['user']['ID']))
|
if (isset($_SESSION['user']['ID']))
|
||||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $userData['ID']);
|
||||||
|
|
||||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
$_SESSION['currentProfilePage'] = $userData['ID'];
|
||||||
} else {
|
} else {
|
||||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||||
$title = "Error - Profile";
|
$title = "Error - Profile";
|
||||||
|
@ -48,10 +48,10 @@
|
||||||
if (isset($message)) {
|
if (isset($message)) {
|
||||||
$this->load->view('network/message', $message);
|
$this->load->view('network/message', $message);
|
||||||
}
|
}
|
||||||
if (isset($user_data) && isset($user_stats) && isset($user_posts) && isset($user_comments) && isset($user_blog_posts)) {
|
if (isset($userData) && isset($userStats) && isset($userPosts) && isset($userComments) && isset($userBlogPosts)) {
|
||||||
$this->load->view('network/user/profile_page', ['data' => $user_data, 'stats' => $user_stats, 'posts' => $user_posts, 'comments' => $user_comments, 'blog_posts' => $user_blog_posts, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
$this->load->view('network/user/profile_page', ['data' => $userData, 'stats' => $userStats, 'posts' => $userPosts, 'comments' => $userComments, 'blog_posts' => $userBlogPosts, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||||
}
|
}
|
||||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['profile_page.js', 'comment-item.js']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function comments($user = "")
|
public function comments($user = "")
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
$user_exists = !empty($user_data);
|
$user_exists = !empty($user_data);
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$user_data = $user_data[0];
|
$user_data = $user_data[0];
|
||||||
$dateCreated = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($user_data['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||||
$title = $user_data['displayname'] . " - Blog-Kommentare";
|
$title = $user_data['displayname'] . " - Blog-Kommentare";
|
||||||
|
@ -87,7 +87,7 @@
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$this->load->view('network/blog/user_comments', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
$this->load->view('network/blog/user_comments', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||||
}
|
}
|
||||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['profile_page.js', 'comment-item.js']]);
|
||||||
$this->load->view('network/blog/user_comments_end', ['data' => $user_data]);
|
$this->load->view('network/blog/user_comments_end', ['data' => $user_data]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@
|
||||||
$user_exists = !empty($user_data);
|
$user_exists = !empty($user_data);
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$user_data = $user_data[0];
|
$user_data = $user_data[0];
|
||||||
$dateCreated = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($user_data['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||||
$title = $user_data['displayname'] . " - Posts";
|
$title = $user_data['displayname'] . " - Posts";
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
$user_exists = !empty($user_data);
|
$user_exists = !empty($user_data);
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$user_data = $user_data[0];
|
$user_data = $user_data[0];
|
||||||
$dateCreated = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($user_data['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||||
$title = $user_data['displayname'] . " - Posts";
|
$title = $user_data['displayname'] . " - Posts";
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
||||||
redirect(base_url());
|
redirect(base_url());
|
||||||
|
|
||||||
if(empty($_FILES) || !isset($_FILES['postMedia']))
|
if (empty($_FILES) || !isset($_FILES['postMedia']))
|
||||||
redirect(base_url());
|
redirect(base_url());
|
||||||
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
@ -229,23 +229,25 @@
|
||||||
echo json_encode(['success' => true, 'type' => $mediaType, 'path' => $path]);
|
echo json_encode(['success' => true, 'type' => $mediaType, 'path' => $path]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletePostMedia() {
|
public function deletePostMedia()
|
||||||
|
{
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
||||||
redirect(base_url());
|
redirect(base_url());
|
||||||
|
|
||||||
if(empty($_POST) || !isset($_POST['path']))
|
if (empty($_POST) || !isset($_POST['path']))
|
||||||
redirect(base_url());
|
redirect(base_url());
|
||||||
|
|
||||||
$url = $_POST['path'];
|
$url = $_POST['path'];
|
||||||
|
|
||||||
$filePath = $this->FileModel->getFilePath(substr($url, 3), $_SESSION['user']['ID']);
|
$filePath = $this->FileModel->getFilePath(substr($url, 3), $_SESSION['user']['ID']);
|
||||||
|
|
||||||
if($filePath != null)
|
if ($filePath != null)
|
||||||
unlink($filePath);
|
unlink($filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publishPost()
|
public function publishPost()
|
||||||
{
|
{
|
||||||
|
header('Content-Type: application/json');
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||||
echo json_encode(['success' => false,
|
echo json_encode(['success' => false,
|
||||||
'title' => lang('post_error_login_title'),
|
'title' => lang('post_error_login_title'),
|
||||||
|
@ -255,29 +257,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->input->post('content');
|
$content = $this->input->post('content');
|
||||||
|
$content = trim($content);
|
||||||
if (strlen($content) >= 10000) {
|
if (strlen($content) >= 10000) {
|
||||||
?>
|
echo json_encode(['success' => false,
|
||||||
<div class="alert alert-warning" role="alert">
|
'title' => lang('post_error_too_long_title'),
|
||||||
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Dein Post ist leider zu lang. Er darf maximal 10.000
|
'message' => lang('post_error_too_long_lines')
|
||||||
Zeichen umfassen.
|
]);
|
||||||
</div>
|
exit;
|
||||||
<?php
|
}
|
||||||
|
|
||||||
|
if (strlen($content) == 0 && empty($media)) {
|
||||||
|
echo json_encode(['success' => false,
|
||||||
|
'title' => lang('post_error_no_content_title'),
|
||||||
|
'message' => lang('post_error_no_content_lines')
|
||||||
|
]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$replyTo = $this->input->post('replyTo');
|
$replyTo = $this->input->post('replyTo');
|
||||||
if ($replyTo !== "-1" && !$this->PostsModel->isUUIDValid($replyTo)) {
|
if ($replyTo !== "-1" && !$this->PostsModel->isHashIDValid($replyTo)) {
|
||||||
?>
|
echo json_encode(['success' => false,
|
||||||
<div class="alert alert-warning" role="alert">
|
'title' => lang('post_error_reply_title'),
|
||||||
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Der Post, an den du deine Antwort richten willst,
|
'message' => lang('post_error_reply_lines')
|
||||||
existiert nicht (mehr).<br>
|
]);
|
||||||
Solltest du dies für einen Fehler halten, versuche es später erneut oder kontaktiere uns.
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postID = -1;
|
|
||||||
if ($replyTo !== "-1") {
|
if ($replyTo !== "-1") {
|
||||||
$postID = $this->PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
|
$postID = $this->PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
|
||||||
} else {
|
} else {
|
||||||
|
@ -321,15 +326,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
echo json_encode(['success' => true,
|
||||||
<div class="alert alert-success" role="alert">
|
'title' => lang('post_success_title'),
|
||||||
<b>Dein Post wurde erfolgreich veröffentlicht!</b> Möchtest du nun deine Posts ansehen? <br>
|
'message' => lang('post_success_lines'),
|
||||||
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Nein</button>
|
'buttons' => [
|
||||||
<a href='<?= base_url('user/' . $_SESSION['user']['username'] . '/posts') ?>'
|
[
|
||||||
class='btn btn-sm btn-primary'>Ja
|
'type' => 'default',
|
||||||
</a>
|
'text' => lang('post_success_no')
|
||||||
</div>
|
],
|
||||||
<?php
|
[
|
||||||
|
'type' => 'primary',
|
||||||
|
'action' => base_url('user/' . $_SESSION['user']['username'] . '/posts'),
|
||||||
|
'text' => lang('post_success_yes')
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function followers($user = "")
|
public function followers($user = "")
|
||||||
|
@ -343,7 +354,7 @@
|
||||||
$user_exists = !empty($user_data);
|
$user_exists = !empty($user_data);
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$user_data = $user_data[0];
|
$user_data = $user_data[0];
|
||||||
$dateCreated = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($user_data['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||||
$followers = $this->UserModel->getFollowers($user_data['ID']);
|
$followers = $this->UserModel->getFollowers($user_data['ID']);
|
||||||
|
@ -379,7 +390,7 @@
|
||||||
$user_exists = !empty($user_data);
|
$user_exists = !empty($user_data);
|
||||||
if ($user_exists) {
|
if ($user_exists) {
|
||||||
$user_data = $user_data[0];
|
$user_data = $user_data[0];
|
||||||
$dateCreated = strtotime($user_data['date_created']);
|
$dateCreated = strtotime($user_data['dateCreated']);
|
||||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||||
$following = $this->UserModel->getFollowing($user_data['ID']);
|
$following = $this->UserModel->getFollowing($user_data['ID']);
|
||||||
|
@ -460,6 +471,13 @@
|
||||||
// Update Settings
|
// Update Settings
|
||||||
$newData = [];
|
$newData = [];
|
||||||
// TODO: Error messages
|
// TODO: Error messages
|
||||||
|
|
||||||
|
foreach ($_POST as $key => $item) {
|
||||||
|
if (isset($user_data[$key]) && $user_data[$key] == $item) {
|
||||||
|
unset($_POST[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Username
|
// Username
|
||||||
if (isset($_POST['username'])) {
|
if (isset($_POST['username'])) {
|
||||||
if (!preg_match('/[^A-Za-z0-9._]/', $_POST['username'])) {
|
if (!preg_match('/[^A-Za-z0-9._]/', $_POST['username'])) {
|
||||||
|
@ -474,7 +492,7 @@
|
||||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Nutzername bereits vergeben!</b> Ein anderer Nutzer hat anscheinend diesen Namen bereits gewählt.</div>";
|
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Nutzername bereits vergeben!</b> Ein anderer Nutzer hat anscheinend diesen Namen bereits gewählt.</div>";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Nutzername!</b> Dein Name darf nur Groß- (A-Z) und Kleinbuchstaben (a-z), Zahlen (0-9) und Punkte (.) sowie Unterstriche (_).</div>";
|
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Nutzername!</b> Dein Name darf nur Groß- (A-Z) und Kleinbuchstaben (a-z), Zahlen (0-9) und Punkte (.) sowie Unterstriche (_) enthalten.</div>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Gender
|
// Gender
|
||||||
|
@ -506,25 +524,25 @@
|
||||||
$newData['country'] = $_POST['country'];
|
$newData['country'] = $_POST['country'];
|
||||||
}
|
}
|
||||||
// Biography/About
|
// Biography/About
|
||||||
if (isset($_POST['biography'])) {
|
if (isset($_POST['about'])) {
|
||||||
$newData['about'] = $_POST['biography'];
|
$newData['about'] = trim($_POST['about']);
|
||||||
}
|
}
|
||||||
// Avatar
|
// Avatar
|
||||||
if (isset($_FILES['avatar'])) {
|
if (isset($_FILES['avatar'])) {
|
||||||
$image = $this->FileModel->uploadCroppedImage('avatar', 4096, $_FILES['avatar']['name'], 500, 500);
|
$image = $this->FileModel->uploadCroppedImage('avatar', 4096, $_FILES['avatar']['name'], 500, 500);
|
||||||
if ($image != null)
|
if ($image != null)
|
||||||
$newData['profile_picture'] = $image;
|
$newData['profilePicture'] = $image;
|
||||||
unset($_FILES['avatar']);
|
unset($_FILES['avatar']);
|
||||||
}
|
}
|
||||||
// Header
|
// Header
|
||||||
if (isset($_FILES['header'])) {
|
if (isset($_FILES['header'])) {
|
||||||
$image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
|
$image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
|
||||||
if ($image != null)
|
if ($image != null)
|
||||||
$newData['header_image'] = $image;
|
$newData['headerImage'] = $image;
|
||||||
unset($_FILES['header']);
|
unset($_FILES['header']);
|
||||||
}
|
}
|
||||||
// Social Networks
|
// Social Networks
|
||||||
if (isset($_POST['social-networks'])) {
|
if (isset($_POST['sociaNetworks'])) {
|
||||||
|
|
||||||
}
|
}
|
||||||
// Profile color
|
// Profile color
|
||||||
|
@ -611,7 +629,7 @@
|
||||||
// Add entry to history
|
// Add entry to history
|
||||||
unset($user_data['rankName']);
|
unset($user_data['rankName']);
|
||||||
unset($_SESSION['user']);
|
unset($_SESSION['user']);
|
||||||
$this->UserModel->insertIntoHistory($user_data);
|
$this->UserModel->insertIntoHistory($newData);
|
||||||
// Update profile
|
// Update profile
|
||||||
$this->UserModel->updateProfile($newData, $user_data['ID']);
|
$this->UserModel->updateProfile($newData, $user_data['ID']);
|
||||||
$this->db->cache_delete('user', $user_data['username']);
|
$this->db->cache_delete('user', $user_data['username']);
|
||||||
|
@ -651,38 +669,36 @@
|
||||||
$this->load->view('footer', ['additionalScripts' => ['single-post-page.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['single-post-page.js']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function single_post_data($username = null, $uuid = null)
|
public function single_post_data($username = null, $hashID = null)
|
||||||
{
|
{
|
||||||
$message = "";
|
|
||||||
$post = [];
|
|
||||||
$replies = [];
|
|
||||||
if ($username == null) {
|
if ($username == null) {
|
||||||
$message .= '<div class="alert alert-danger" role="alert"><b>Es wurde kein Nutzer angegeben!</b> Es können keine Posts von einem undefinierten Nutzer gefunden werden.</div>';
|
echo '<div class="alert alert-danger" role="alert"><b>Es wurde kein Nutzer angegeben!</b> Es können keine Posts von einem undefinierten Nutzer gefunden werden.</div>';
|
||||||
goto display;
|
exit;
|
||||||
}
|
}
|
||||||
if ($uuid == null) {
|
|
||||||
$message .= '<div class="alert alert-danger" role="alert"><b>Es wurde keine Post-ID angegeben!</b> Es können keine undefinierten Posts gefunden werden.</div>';
|
if ($hashID == null) {
|
||||||
goto display;
|
echo '<div class="alert alert-danger" role="alert"><b>Es wurde keine Post-ID angegeben!</b> Es können keine undefinierten Posts gefunden werden.</div>';
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->UserModel->getUser($username);
|
$user = $this->UserModel->getUser($username);
|
||||||
if (empty($user)) {
|
if (empty($user)) {
|
||||||
$message .= '<div class="alert alert-warning" role="alert"><b>Es wurde kein Nutzer mit dem angegebenen Namen gefunden!</b> Vielleicht kannst du ja diese Lücke füllen?</div>';
|
echo '<div class="alert alert-warning" role="alert"><b>Es wurde kein Nutzer mit dem angegebenen Namen gefunden!</b> Vielleicht kannst du ja diese Lücke füllen?</div>';
|
||||||
goto display;
|
exit;
|
||||||
}
|
}
|
||||||
$user = $user[0];
|
$user = $user[0];
|
||||||
|
|
||||||
$post = $this->PostsModel->getPostDetails($user['ID'], $uuid);
|
$post = $this->PostsModel->getPostDetails($user['ID'], $hashID);
|
||||||
if (empty($post)) {
|
if (empty($post)) {
|
||||||
$message .= '<div class="alert alert-warning" role="alert"><b>Es wurde kein Post mit der angegebenen ID gefunden!</b> Vielleicht kannst du ja diesen neuen Content erschaffen?</div>';
|
echo '<div class="alert alert-warning" role="alert"><b>Es wurde kein Post mit der angegebenen ID gefunden!</b> Vielleicht kannst du ja diesen neuen Content erschaffen?</div>';
|
||||||
goto display;
|
exit;
|
||||||
}
|
}
|
||||||
$post = $post[0];
|
$post = $post[0];
|
||||||
|
|
||||||
$replies = $this->PostsModel->getPostReplies($post['ID']);
|
$replies = $this->PostsModel->getPostReplies($post['ID']);
|
||||||
|
|
||||||
display:
|
display:
|
||||||
$this->load->view('network/posts/user_post_content', ['message' => $message, 'post' => $post, 'replies' => $replies]);
|
$this->load->view('network/posts/user_post_content', ['post' => $post, 'replies' => $replies]);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
class Blog extends MY_Controller
|
require_once './vendor/Diff/htmLawed.php';
|
||||||
{
|
use SebastianBergmann\Diff\Differ;
|
||||||
|
|
||||||
|
class Blog extends MY_Controller
|
||||||
|
{
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -15,12 +18,14 @@ class Blog extends MY_Controller
|
||||||
{
|
{
|
||||||
$this->neededPermission('blog.view');
|
$this->neededPermission('blog.view');
|
||||||
$posts = $this->BlogModel->getPostList(false);
|
$posts = $this->BlogModel->getPostList(false);
|
||||||
|
|
||||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
||||||
$this->load->view('admin/blog_posts', ['posts' => $posts]);
|
$this->load->view('admin/blog_posts', ['posts' => $posts]);
|
||||||
$this->load->view('admin/footer');
|
$this->load->view('admin/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tags() {
|
public function tags()
|
||||||
|
{
|
||||||
$this->neededPermission('blog.view');
|
$this->neededPermission('blog.view');
|
||||||
|
|
||||||
$tags = $this->BlogModel->getAllTags();
|
$tags = $this->BlogModel->getAllTags();
|
||||||
|
@ -47,65 +52,77 @@ class Blog extends MY_Controller
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contentID = $this->input->post('contentID');
|
$versionID = $this->input->post('versionID');
|
||||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
$versionID = is_numeric($versionID) && is_int(intval($versionID)) ? intval($versionID) : -2;
|
||||||
|
|
||||||
$translationID = $this->input->post('translationID');
|
$image = $this->input->post('postImage');
|
||||||
$translationID = is_numeric($translationID) && is_int(intval($translationID)) ? intval($translationID) : -2;
|
$title = $this->input->post('postTitle');
|
||||||
|
$description = $this->input->post('postDescription');
|
||||||
|
$content = $this->input->post('postContent');
|
||||||
|
|
||||||
$postImage = $this->input->post('postImage');
|
$initialRelease = $this->input->post('postPublishDate');
|
||||||
$postTitle = $this->input->post('postTitle');
|
$initialRelease = date("Y-m-d H:i:s", strtotime($initialRelease));
|
||||||
$postDescription = $this->input->post('postDescription');
|
|
||||||
$postContent = $this->input->post('postContent');
|
|
||||||
|
|
||||||
$postPublishDate = $this->input->post('postPublishDate');
|
$url = $this->input->post('postUrl');
|
||||||
$postPublishDate = date("Y-m-d H:i:s", strtotime($postPublishDate));
|
$categories = $this->input->post('postCategories');
|
||||||
|
$tags = $this->input->post('postTags');
|
||||||
|
|
||||||
$postUrl = $this->input->post('postUrl');
|
$lang = $this->input->post('postLanguage');
|
||||||
$postCategory = $this->input->post('postCategory');
|
$lang = $lang !== NULL ? $lang : 'de';
|
||||||
$postTags = $this->input->post('postTags');
|
|
||||||
|
|
||||||
$postLang = $this->input->post('postLanguage');
|
if (strlen($url) == 0) {
|
||||||
$postLang = $postLang !== NULL ? $postLang : 'de';
|
|
||||||
|
|
||||||
if(strlen($postUrl) == 0) {
|
|
||||||
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
|
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if(strlen($postUrl) < 4) {
|
if (strlen($url) < 4) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL ist zu kurz. Sie muss mindestens 4 Zeichen umfassen, um eine eindeutige Zuordnung zu ermöglichen.']);
|
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL ist zu kurz. Sie muss mindestens 4 Zeichen umfassen, um eine eindeutige Zuordnung zu ermöglichen.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($postID == -1 || $translationID == -1) { // Create new blog post
|
if ($postID == -1) { // Create new blog post
|
||||||
if ($postID == -1) {
|
if ($postID == -1) {
|
||||||
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
|
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
|
||||||
|
|
||||||
if($this->BlogModel->postUrlExisting($postUrl)) {
|
if ($this->BlogModel->postUrlExisting($url)) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
|
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$translationID = $this->BlogModel->createNewTranslation($postID, $postLang);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($contentID < 0) {
|
if ($versionID < 0) {
|
||||||
$contentID = $this->BlogModel->createNewContentDraft($postID);
|
$versionID = $this->BlogModel->createNewTranslationDraft($postID, $_SESSION['user']['ID'], $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->BlogModel->updatePostDraft($postID, $postUrl, $postCategory, $postPublishDate, $postImage);
|
$this->BlogModel->updatePostDraft($postID, $initialRelease, $image);
|
||||||
$this->BlogModel->updateContentDraft($contentID, $postContent, $postLang);
|
$this->BlogModel->updateTranslationDraft($versionID, $url, $title, $description, $content, $lang);
|
||||||
$this->BlogModel->updateTranslation($translationID, $postTitle, $postDescription);
|
|
||||||
|
|
||||||
if(!empty($postTags)) {
|
if(!empty($categories)) {
|
||||||
|
$this->BlogModel->deleteAllPostCategories($postID);
|
||||||
|
foreach ($categories as $category) {
|
||||||
|
if($category == 'new-category') {
|
||||||
|
$name = strtolower($this->input->post('newCategoryName'));
|
||||||
|
$displayname = $this->input->post('newCategoryDisplayName');
|
||||||
|
|
||||||
|
$category = $this->BlogModel->createCategory($name, $displayname, 'de');
|
||||||
|
$newCategoryID = $category;
|
||||||
|
}
|
||||||
|
$this->BlogModel->addPostCategoryByID($postID, $category);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($tags)) {
|
||||||
$this->BlogModel->deleteAllPostTags($postID);
|
$this->BlogModel->deleteAllPostTags($postID);
|
||||||
foreach ($postTags as $postTag) {
|
foreach ($tags as $postTag) {
|
||||||
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
|
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
|
||||||
$this->BlogModel->addPostTagByID($postID, $tagID);
|
$this->BlogModel->addPostTagByID($postID, $tagID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'contentID' => $contentID, 'translationID' => $translationID]);
|
$result = ['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'versionID' => $versionID];
|
||||||
|
if(isset($newCategoryID))
|
||||||
|
$result['newCategoryID'] = $newCategoryID;
|
||||||
|
echo json_encode($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publishPost()
|
public function publishPost()
|
||||||
|
@ -124,16 +141,16 @@ class Blog extends MY_Controller
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contentIDs = $this->input->post('contentIDs');
|
$versionIDs = $this->input->post('versionIDs');
|
||||||
$contentPublished = FALSE;
|
$contentPublished = FALSE;
|
||||||
foreach ($contentIDs as $lang => $contentID) {
|
foreach ($versionIDs as $lang => $versionID) {
|
||||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
$versionID = is_numeric($versionID) && is_int(intval($versionID)) ? intval($versionID) : -2;
|
||||||
|
|
||||||
if($contentID < 0) {
|
if ($versionID < 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->BlogModel->publishContentDraft($_SESSION['user']['ID'], $contentID, $postID, $lang);
|
$this->BlogModel->publishTranslationDraft($postID, $versionID, $_SESSION['user']['ID'], $lang);
|
||||||
$contentPublished = TRUE;
|
$contentPublished = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +184,8 @@ class Blog extends MY_Controller
|
||||||
echo json_encode(['status' => 'success', 'translations' => $translations]);
|
echo json_encode(['status' => 'success', 'translations' => $translations]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPost() {
|
public function getPost()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||||
|
@ -176,14 +194,14 @@ class Blog extends MY_Controller
|
||||||
|
|
||||||
$postID = intval($this->input->post('postID'));
|
$postID = intval($this->input->post('postID'));
|
||||||
|
|
||||||
if(!is_numeric($postID)) {
|
if (!is_numeric($postID)) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postData = $this->BlogModel->getPostDataByID($postID);
|
$postData = $this->BlogModel->getPostDataByID($postID);
|
||||||
|
|
||||||
if(empty($postData)) {
|
if (empty($postData)) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
|
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -191,69 +209,39 @@ class Blog extends MY_Controller
|
||||||
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
|
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContent() {
|
public function getVersion() {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postID = intval($this->input->post('postID'));
|
$postID = intval($this->input->post('postID'));
|
||||||
$contentID = intval($this->input->post('contentID'));
|
$versionID = intval($this->input->post('versionID'));
|
||||||
$language = $this->input->post('lang');
|
$language = $this->input->post('lang');
|
||||||
|
|
||||||
if(!is_numeric($postID)) {
|
if ($postID == 0) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_numeric($contentID)) {
|
if ($versionID == 0) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
echo json_encode(['status' => 'error', 'message' => 'Es wurde keine Version mit der angegebenen Versions-ID gefunden.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$contentData = $this->BlogModel->getContentDataByID($postID, $contentID, $language);
|
$versionData = $this->BlogModel->getPostTranslationByID($postID, $versionID, $language);
|
||||||
|
|
||||||
if(empty($contentData)) {
|
if (empty($versionData)) {
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
echo json_encode(['status' => 'error', 'message' => 'Es wurde keine Version mit der angegebenen Versions-ID gefunden.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode(['status' => 'success', 'contentData' => $contentData[0]]);
|
echo json_encode(array_merge(['status' => 'success'], $versionData[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranslationData() {
|
public function getPostTags()
|
||||||
header('Content-Type: application/json');
|
{
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$postID = intval($this->input->post('postID'));
|
|
||||||
$translationID = intval($this->input->post('translationID'));
|
|
||||||
$language = $this->input->post('lang');
|
|
||||||
|
|
||||||
if(!is_numeric($postID)) {
|
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!is_numeric($translationID)) {
|
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$translationData = $this->BlogModel->getTranslationDataByID($postID, $translationID, $language);
|
|
||||||
|
|
||||||
if(empty($translationData)) {
|
|
||||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
echo json_encode(['status' => 'success', 'translationData' => $translationData[0]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPostTags() {
|
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||||
|
@ -262,7 +250,7 @@ class Blog extends MY_Controller
|
||||||
|
|
||||||
$postID = intval($this->input->post('postID'));
|
$postID = intval($this->input->post('postID'));
|
||||||
|
|
||||||
if(!is_numeric($postID)) {
|
if (!is_numeric($postID)) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -276,26 +264,20 @@ class Blog extends MY_Controller
|
||||||
{
|
{
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||||
|
|
||||||
$translations = ['de' => -1];
|
$versions = ['de' => -1];
|
||||||
$contents = ['de' => -1];
|
|
||||||
|
|
||||||
if(!$postID != -1) {
|
if (!$postID != -1) {
|
||||||
if($this->BlogModel->postIDExisting($postID)) {
|
if ($this->BlogModel->postIDExisting($postID)) {
|
||||||
$postTranslations = $this->BlogModel->getPostTranslationIDs($postID);
|
$postVersions = $this->BlogModel->getPostVersionIDs($postID);
|
||||||
foreach ($postTranslations as $postTranslation) {
|
foreach ($postVersions as $postVersion) {
|
||||||
$translations[$postTranslation['language']] = $postTranslation['postTranslationID'];
|
$versions[$postVersion['lang']] = $postVersion['ID'];
|
||||||
}
|
|
||||||
|
|
||||||
$postContents = $this->BlogModel->getPostContentIDs($postID);
|
|
||||||
foreach ($postContents as $postContent) {
|
|
||||||
$contents[$postContent['language']] = $postContent['contentID'];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = $this->BlogModel->getCategories();
|
$categories = $this->BlogModel->getCategories();
|
||||||
$this->load->view('admin/sidebar', ['title' => 'Blog-Post erstellen', 'additionalStyles' => ['lib/bootstrap-tagsinput.css', 'lib/bootstrap-tagsinput-typeahead.css']]);
|
$this->load->view('admin/sidebar', ['title' => 'Blog-Post erstellen', 'additionalStyles' => ['lib/bootstrap-tagsinput.css', 'lib/bootstrap-tagsinput-typeahead.css']]);
|
||||||
$this->load->view('admin/blog_edit', ['categories' => $categories, 'postID' => $postID, 'contents' => $contents, 'translations' => $translations, 'postLanguage' => $lang]);
|
$this->load->view('admin/blog_edit', ['categories' => $categories, 'postID' => $postID, 'versions' => $versions, 'lang' => $lang]);
|
||||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/typeahead.bundle.min.js', 'lib/bootstrap-tagsinput.min.js', 'lib/highlight.pack.js', 'lib/quill.min.js', 'blog-edit.js']]);
|
$this->load->view('admin/footer', ['additionalScripts' => ['lib/typeahead.bundle.min.js', 'lib/bootstrap-tagsinput.min.js', 'lib/highlight.pack.js', 'lib/quill.min.js', 'blog-edit.js']]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -305,13 +287,35 @@ class Blog extends MY_Controller
|
||||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||||
if ($postID === NULL) redirect(base_url('admin/blog'));
|
if ($postID === NULL) redirect(base_url('admin/blog'));
|
||||||
|
|
||||||
$content['de'] = $this->BlogModel->getAllContentVersions($postID, 'de');
|
$content['de'] = $this->BlogModel->getAllPostVersions($postID, 'de');
|
||||||
$content['en'] = $this->BlogModel->getAllContentVersions($postID, 'en');
|
$content['en'] = $this->BlogModel->getAllPostVersions($postID, 'en');
|
||||||
$content['fr'] = $this->BlogModel->getAllContentVersions($postID, 'fr');
|
$content['fr'] = $this->BlogModel->getAllPostVersions($postID, 'fr');
|
||||||
|
|
||||||
$this->load->view('admin/sidebar', ['title' => 'Geschichte']);
|
$this->load->view('admin/sidebar', ['title' => 'Änderungen']);
|
||||||
$this->load->view('admin/blog_history', ['content' => $content]);
|
$this->load->view('admin/blog_history', ['content' => $content]);
|
||||||
$this->load->view('admin/footer');
|
$this->load->view('admin/footer', ['additionalScripts' => ['blog-history.js']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function history_compare($postID = NULL, $version1 = NULL, $version2 = NULL) {
|
||||||
|
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||||
|
if ($postID === NULL) redirect(base_url('admin/blog'));
|
||||||
|
if ($version1 === NULL || $version2 === NULL) redirect(base_url('admin/blog/' . $postID));
|
||||||
|
|
||||||
|
$content[] = $this->BlogModel->getPostTranslationByHashID($version1);
|
||||||
|
$content[] = $this->BlogModel->getPostTranslationByHashID($version2);
|
||||||
|
|
||||||
|
$differ = new Differ;
|
||||||
|
$diff['content'] = $differ->diff(
|
||||||
|
htmlspecialchars(hl_tidy($content[0]['content'], 't', 'div')),
|
||||||
|
htmlspecialchars(hl_tidy($content[1]['content'], 't', 'div'))
|
||||||
|
);
|
||||||
|
|
||||||
|
// var_dump($diff);
|
||||||
|
var_dump(htmlspecialchars($content[0]['content']),
|
||||||
|
htmlspecialchars($content[1]['content']));
|
||||||
|
|
||||||
|
$this->load->view('admin/sidebar', ['title' => 'Vergleich']);
|
||||||
|
$this->load->view('admin/footer', ['additionalScripts' => ['blog-history.js']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function new_category()
|
public function new_category()
|
||||||
|
@ -362,26 +366,27 @@ class Blog extends MY_Controller
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$result = array_map(function($value) {
|
$result = array_map(function ($value) {
|
||||||
return $value['display_name'];
|
return $value['displayname'];
|
||||||
}, $this->BlogModel->getAllTags());
|
}, $this->BlogModel->getAllTags());
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
// echo json_encode($this->BlogModel->getAllTags());
|
// echo json_encode($this->BlogModel->getAllTags());
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updatePreview() {
|
public function updatePreview()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
if(!$this->hasPermission('blog.create')) {
|
if (!$this->hasPermission('blog.create')) {
|
||||||
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um die Vorschau anzusehen.']);
|
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um die Vorschau anzusehen.']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($_POST['postTitle']) || !isset($_POST['postDesc']) || !isset($_POST['postContent'])) {
|
if (!isset($_POST['postTitle']) || !isset($_POST['postDesc']) || !isset($_POST['postContent'])) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($_POST['previewID'])) {
|
if (!isset($_POST['previewID'])) {
|
||||||
$previewID = substr(md5(uniqid() . date(time())), 0, 16);
|
$previewID = substr(md5(uniqid() . date(time())), 0, 16);
|
||||||
} else {
|
} else {
|
||||||
$previewID = $_POST['previewID'];
|
$previewID = $_POST['previewID'];
|
||||||
|
@ -397,10 +402,11 @@ class Blog extends MY_Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function getTemplates() {
|
public function getTemplates()
|
||||||
|
{
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
if(!$this->hasPermission('blog.create')) {
|
if (!$this->hasPermission('blog.create')) {
|
||||||
echo json_encode([]);
|
echo json_encode([]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
@ -416,12 +422,13 @@ class Blog extends MY_Controller
|
||||||
echo json_encode($templates);
|
echo json_encode($templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function preview() {
|
public function preview()
|
||||||
|
{
|
||||||
$this->neededPermission('blog.create');
|
$this->neededPermission('blog.create');
|
||||||
|
|
||||||
$previewID = $_GET['id'];
|
$previewID = $_GET['id'];
|
||||||
|
|
||||||
if(!isset($_SESSION['preview_' . $previewID])) {
|
if (!isset($_SESSION['preview_' . $previewID])) {
|
||||||
redirect('admin/blog');
|
redirect('admin/blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,9 +437,10 @@ class Blog extends MY_Controller
|
||||||
$this->load->view('admin/blog_post_preview', $_SESSION['preview_' . $previewID]);
|
$this->load->view('admin/blog_post_preview', $_SESSION['preview_' . $previewID]);
|
||||||
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
|
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Template {
|
class Template
|
||||||
|
{
|
||||||
public $title;
|
public $title;
|
||||||
public $desc;
|
public $desc;
|
||||||
public $content;
|
public $content;
|
||||||
|
@ -449,4 +457,4 @@ class Template {
|
||||||
$this->desc = $desc;
|
$this->desc = $desc;
|
||||||
$this->content = $content;
|
$this->content = $content;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
$this->neededPermission('projects.view');
|
$this->neededPermission('projects.view');
|
||||||
|
|
||||||
$entries = $this->ProjectsModel->getEntries('all');
|
$entries = $this->ProjectsModel->getEntries('all');
|
||||||
$categories = $this->ProjectsModel->getCategories('all');
|
$categories = $this->ProjectsModel->getCategoriesRaw('all');
|
||||||
|
|
||||||
$this->load->view('admin/sidebar', ['title' => 'Projekte verwalten']);
|
$this->load->view('admin/sidebar', ['title' => 'Projekte verwalten']);
|
||||||
$this->load->view('admin/projects', ['entries' => $entries, 'categories' => $categories]);
|
$this->load->view('admin/projects', ['entries' => $entries, 'categories' => $categories]);
|
||||||
|
|
|
@ -127,8 +127,8 @@ class Users extends MY_Controller
|
||||||
'displayname' => $userData['displayname'],
|
'displayname' => $userData['displayname'],
|
||||||
'email' => $userData['email'],
|
'email' => $userData['email'],
|
||||||
'rank' => $userData['rank'],
|
'rank' => $userData['rank'],
|
||||||
'profile_picture' => $userData['profile_picture'],
|
'profilePicture' => $userData['profilePicture'],
|
||||||
'header_image' => $userData['header_image'],
|
'headerImage' => $userData['headerImage'],
|
||||||
'social_networks' => $userData['social_networks'],
|
'social_networks' => $userData['social_networks'],
|
||||||
'showAds' => $userData['showAds'],
|
'showAds' => $userData['showAds'],
|
||||||
'about' => $userData['about'],
|
'about' => $userData['about'],
|
||||||
|
|
|
@ -81,7 +81,9 @@
|
||||||
'Du hast uns leider keinen Inhalt angegeben, den wir veröffentlichen können.',
|
'Du hast uns leider keinen Inhalt angegeben, den wir veröffentlichen können.',
|
||||||
'Sollte es sich dabei um ein Irrtum handeln, so kontaktiere uns bitte über das Kontakt-Formular.',
|
'Sollte es sich dabei um ein Irrtum handeln, so kontaktiere uns bitte über das Kontakt-Formular.',
|
||||||
];
|
];
|
||||||
$lang['post_success_title'] = '';
|
$lang['post_success_title'] = 'Dein Post wurde erfolgreich veröffentlicht!';
|
||||||
$lang['post_success_lines'] = [
|
$lang['post_success_lines'] = [
|
||||||
'',
|
'Möchtest du nun deine Posts ansehen?'
|
||||||
];
|
];
|
||||||
|
$lang['post_success_yes'] = 'Ja, Posts ansehen';
|
||||||
|
$lang['post_success_no'] = 'Nein';
|
||||||
|
|
7
application/language/fr/projects_lang.php
Normal file
7
application/language/fr/projects_lang.php
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: tetri
|
||||||
|
* Date: 05.01.2019
|
||||||
|
* Time: 17:46
|
||||||
|
*/
|
|
@ -16,101 +16,215 @@
|
||||||
$this->load->model('UserModel', '', TRUE);
|
$this->load->model('UserModel', '', TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function transfer() {
|
||||||
|
$data = $this->db->query('SELECT * FROM kingofdog.blog_posts')->result_array();
|
||||||
|
foreach ($data as $item) {
|
||||||
|
extract($item);
|
||||||
|
// $this->db->query('INSERT INTO kingofdog_new.blog_post_versions (postID, lang, active, title, description, content, contentWordsCount, authorID, changes, edited) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', [
|
||||||
|
// $postID, $language, $isActive, "", "", $content, $wordCount, $contentAuthorID, $versionMessage, $contentDate
|
||||||
|
// ]);
|
||||||
|
// $this->db->query('UPDATE kingofdog_new.blog_post_versions SET title = ?, description = ? WHERE postID = ? AND lang = ?', [
|
||||||
|
// $postTitle, $postDesc, $postID, $language
|
||||||
|
// ]);
|
||||||
|
// $this->db->query('UPDATE kingofdog_new.blog_post_versions SET url = ? WHERE postID = ?', [$postUrl, $postID]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPostIDByUrl($url) {
|
||||||
|
$data = $this->db->query('SELECT postID FROM blog_post_versions WHERE url = ? AND lang = ? AND active ORDER BY edited DESC LIMIT 1', [$url, $_SESSION['site_lang']])->result_array();
|
||||||
|
return !empty($data) ? $data[0]['postID'] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
function getAllPosts($search, $amount, $offset = 0)
|
function getAllPosts($search, $amount, $offset = 0)
|
||||||
{
|
{
|
||||||
$offset *= $amount;
|
$offset *= $amount;
|
||||||
if ($search !== '') {
|
if ($search !== '') {
|
||||||
|
$search = strtolower($search);
|
||||||
$posts = $this->db->query('
|
$posts = $this->db->query('
|
||||||
SELECT
|
SELECT
|
||||||
p.*,
|
p.*
|
||||||
ca.name categoryName,
|
FROM blog_post p
|
||||||
ca.display_name categoryDisplayName,
|
WHERE ((SELECT LOWER(title) RLIKE ? OR LOWER(description) RLIKE ? OR LOWER(content) RLIKE ? FROM blog_post_versions WHERE postID = p.ID AND lang = ?)
|
||||||
(SELECT count(*)
|
OR (SELECT LOWER(displayname) RLIKE ? FROM blog_categories c WHERE c.lang = ? AND c.categoryID IN (SELECT categoryID FROM blog_post_categories pc WHERE pc.postID = p.ID)))
|
||||||
FROM blog_comments
|
AND state = 1
|
||||||
WHERE post_id = p.postID) commentCount,
|
ORDER BY initialRelease DESC
|
||||||
(SELECT count(*)
|
LIMIT ? OFFSET ?', [$search, $search, $search, $_SESSION['site_lang'], $search, $_SESSION['site_lang'], $amount, $offset])->result_array();
|
||||||
FROM blog_post_likes
|
|
||||||
WHERE post_id = p.postID) likeCount,
|
|
||||||
(SELECT wordCount FROM blog_content c WHERE c.postID = p.postID AND isActive = TRUE AND c.language = ? ORDER BY c.contentDate DESC LIMIT 1) wordCount
|
|
||||||
FROM blog_posts p, blog_categories ca
|
|
||||||
WHERE ca.id = p.postCategoryID
|
|
||||||
AND (CONCAT((SELECT t.postTitle FROM blog_translations t WHERE t.postID = p.postID AND language = ?), postUrl, (SELECT t.postDesc FROM blog_translations t WHERE t.postID = p.postID AND language = ?)) RLIKE ?
|
|
||||||
OR (SELECT content
|
|
||||||
FROM blog_content
|
|
||||||
WHERE blog_content.postID = p.postID AND isActive = TRUE
|
|
||||||
LIMIT 1) RLIKE ?)
|
|
||||||
AND postState = 1
|
|
||||||
ORDER BY postPublishDate DESC
|
|
||||||
LIMIT ? OFFSET ?', [$_SESSION['site_lang'], $_SESSION['site_lang'], $_SESSION['site_lang'], $search, $search, $amount, $offset])->result_array();
|
|
||||||
} else {
|
} else {
|
||||||
$posts = $this->db->query('
|
$posts = $this->db->query('
|
||||||
SELECT p.*,
|
SELECT *
|
||||||
ca.name categoryName,
|
FROM blog_post
|
||||||
ca.display_name categoryDisplayName,
|
WHERE state = 1
|
||||||
(SELECT count(*) FROM blog_comments WHERE post_id = p.postID) commentCount,
|
ORDER BY initialRelease DESC
|
||||||
(SELECT count(*) FROM blog_post_likes WHERE post_id = p.postID) likeCount,
|
LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
||||||
(SELECT wordCount FROM blog_content c WHERE c.postID = p.postID AND isActive = TRUE AND c.language = ? ORDER BY c.contentDate DESC LIMIT 1) wordCount
|
|
||||||
FROM blog_posts p, blog_categories ca
|
|
||||||
WHERE ca.id = p.postCategoryID
|
|
||||||
AND postState = 1
|
|
||||||
ORDER BY postPublishDate DESC
|
|
||||||
LIMIT ? OFFSET ?', [$_SESSION['site_lang'], $amount, $offset])->result_array();
|
|
||||||
}
|
}
|
||||||
$posts = $this->mergePostTitleDesc($posts);
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
$posts = $this->mergePostCategories($posts);
|
||||||
|
$posts = $this->mergePostStats($posts);
|
||||||
$posts = $this->mergePostAuthorData($posts);
|
$posts = $this->mergePostAuthorData($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function mergePostTranslation($posts, $content = FALSE, $language = NULL, $indexID = 'ID')
|
||||||
|
{
|
||||||
|
$language = ($language == NULL ? $_SESSION['site_lang'] : $language);
|
||||||
|
foreach ($posts as $i => $post) {
|
||||||
|
$translationData = $this->getPostTranslation($post[$indexID], $content, $language);
|
||||||
|
if(isset($translationData['error']) && $translationData['error']) {
|
||||||
|
unset($posts[$i]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$posts[$i] += $translationData;
|
||||||
|
}
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mergePostCategories($posts, $language = NULL)
|
||||||
|
{
|
||||||
|
$language = $language == NULL ? $_SESSION['site_lang'] : $language;
|
||||||
|
foreach ($posts as $i => $post) {
|
||||||
|
$categories = $this->getPostCategories($post['ID'], $language);
|
||||||
|
$posts[$i]['categories'] = $categories;
|
||||||
|
}
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPostCategories($postID, $language)
|
||||||
|
{
|
||||||
|
$data = $this->db->query('SELECT ID, name, displayname FROM blog_categories WHERE categoryID IN (SELECT categoryID FROM blog_post_categories WHERE postID = ?) AND lang = ?', [$postID, $language])->result_array();
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mergePostStats($posts, $language = NULL)
|
||||||
|
{
|
||||||
|
$language = $language == NULL ? $_SESSION['site_lang'] : $language;
|
||||||
|
foreach ($posts as $i => $post) {
|
||||||
|
$stats = $this->getPostStats($post['ID'], $language);
|
||||||
|
$posts[$i] += $stats;
|
||||||
|
}
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mergePostState($posts) {
|
||||||
|
$states = [
|
||||||
|
1 => "Veröffentlicht",
|
||||||
|
2 => "Entwurf",
|
||||||
|
3 => "Geplant",
|
||||||
|
4 => "Im Papierkorb",
|
||||||
|
];
|
||||||
|
foreach ($posts as $i => $post) {
|
||||||
|
$posts[$i]['stateName'] = $states[$post['state']];
|
||||||
|
}
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPostStats($postID, $language)
|
||||||
|
{
|
||||||
|
$comments = $this->db->query('SELECT COUNT(*) count FROM blog_post_comments WHERE postID = ?', [$postID])->result_array()[0]['count'];
|
||||||
|
$likes = $this->db->query('SELECT COUNT(*) count FROM blog_post_likes WHERE postID = ?', [$postID])->result_array()[0]['count'];
|
||||||
|
$words = $this->db->query('SELECT contentWordsCount count FROM blog_post_versions WHERE postID = ? AND active AND lang = ?', [$postID, $language])->result_array();
|
||||||
|
|
||||||
|
$words = empty($words) ? 0 : $words[0]['count'];
|
||||||
|
|
||||||
|
return [
|
||||||
|
'commentCount' => $comments,
|
||||||
|
'likeCount' => $likes,
|
||||||
|
'wordCount' => $words,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function mergePostAuthorData($posts)
|
||||||
|
{
|
||||||
|
foreach ($posts as $i => $post) {
|
||||||
|
$authorData = $this->getAuthorData($post['authorID']);
|
||||||
|
$posts[$i]['author'] = $authorData;
|
||||||
|
}
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAuthorData($authorID)
|
||||||
|
{
|
||||||
|
$author = $this->db->query('SELECT u.ID, u.username, u.displayname, u.rank, s.profilePicture, s.headerImage, s.about FROM users u LEFT JOIN user_settings s ON u.ID = s.ID WHERE u.ID = ?', [$authorID])->result_array();
|
||||||
|
|
||||||
|
$author = $this->UserModel->setDefaultImages($author);
|
||||||
|
|
||||||
|
if (empty($author)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $author[0];
|
||||||
|
}
|
||||||
|
|
||||||
public function getPostPageCount($search, $postsPerPage)
|
public function getPostPageCount($search, $postsPerPage)
|
||||||
{
|
{
|
||||||
if ($search !== '') {
|
if ($search !== '') {
|
||||||
|
$search = strtolower($search);
|
||||||
$data = $this->db->query('
|
$data = $this->db->query('
|
||||||
SELECT COUNT(*) pageCount
|
SELECT COUNT(*) pageCount
|
||||||
FROM blog_posts p, blog_categories ca
|
FROM blog_post p
|
||||||
WHERE ca.id = p.postCategoryID
|
WHERE ((SELECT LOWER(title) RLIKE ? OR LOWER(description) RLIKE ? OR LOWER(content) RLIKE ? FROM blog_post_versions v WHERE v.postID = p.ID AND v.lang = ? AND active)
|
||||||
AND (CONCAT((SELECT t.postTitle FROM blog_translations t WHERE t.postID = p.postID AND language = ?), postUrl, (SELECT t.postDesc FROM blog_translations t WHERE t.postID = p.postID AND language = ?)) RLIKE ?
|
OR (SELECT LOWER(displayname) RLIKE ? FROM blog_categories c WHERE c.lang = ? AND c.categoryID IN (SELECT categoryID FROM blog_post_categories pc WHERE pc.postID = p.ID)))
|
||||||
OR (SELECT content FROM blog_content WHERE blog_content.postID = p.postID AND isActive = TRUE LIMIT 1) RLIKE ?)
|
AND state = 1', [$search, $search, $_SESSION['site_lang'], $search, $_SESSION['site_lang']])->result_array();
|
||||||
AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $search])->result_array();
|
|
||||||
} else {
|
} else {
|
||||||
$data = $this->db->query('SELECT COUNT(*) pageCount FROM blog_posts')->result_array();
|
$data = $this->db->query('SELECT COUNT(*) pageCount FROM blog_post')->result_array();
|
||||||
}
|
}
|
||||||
return ($data[0]['pageCount']) / $postsPerPage;
|
return ($data[0]['pageCount']) / $postsPerPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategoryPosts($category, $amount, $offset = 0)
|
function getCategoryPosts($category, $amount, $offset = 0)
|
||||||
{
|
{
|
||||||
|
$category = $this->db->query('SELECT ID FROM blog_categories WHERE name = ? AND lang = ?', [$category, $_SESSION['site_lang']])->result_array();
|
||||||
|
|
||||||
|
if(empty($category)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
$offset *= $amount;
|
$offset *= $amount;
|
||||||
$posts = $this->db->query('
|
$posts = $this->db->query('SELECT * FROM blog_post p WHERE ID IN (SELECT postID FROM blog_post_categories pc WHERE pc.categoryID = ?) LIMIT ? OFFSET ?', [$category[0]['ID'], $amount, $offset])->result_array();
|
||||||
SELECT p.*, ca.name categoryName, ca.display_name categoryDisplayName, (SELECT count(*) FROM blog_comments WHERE post_id = p.postID) commentCount, (SELECT count(*) FROM blog_post_likes WHERE post_id = p.postID) likeCount
|
$posts = $this->mergePostTranslation($posts);
|
||||||
FROM blog_posts p, blog_categories ca
|
$posts = $this->mergePostCategories($posts);
|
||||||
WHERE ca.id = p.postCategoryID
|
$posts = $this->mergePostStats($posts);
|
||||||
AND postState = 1
|
|
||||||
AND ca.name = ?
|
|
||||||
ORDER BY postPublishDate DESC
|
|
||||||
LIMIT ? OFFSET ?', [$category, $amount, $offset])->result_array();
|
|
||||||
$posts = $this->mergePostTitleDesc($posts);
|
|
||||||
$posts = $this->mergePostAuthorData($posts);
|
$posts = $this->mergePostAuthorData($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCategoryPostsByID($categoryID, $amount = 3, $postID = NULL)
|
public function getCategoryPostsByID($categories, $amount = 3, $postID = NULL)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT * FROM blog_posts WHERE postCategoryID = ? AND postID != ? AND blog_posts.postState = 1 ORDER BY postPublishDate DESC LIMIT ?', [$categoryID, $postID, $amount])->result_array();
|
function getIDs($val) {
|
||||||
return $this->mergePostTitleDesc($posts);
|
return $val['ID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTagPosts($tag, $amount, $offset = 0) {
|
if(empty($categories)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = array_map('getIDs', $categories);
|
||||||
|
|
||||||
|
$posts = $this->db->query('SELECT * FROM blog_post WHERE ID IN (SELECT postID FROM blog_post_categories WHERE categoryID IN ?) AND ID != ? AND state = 1 ORDER BY initialRelease DESC LIMIT ?', [$categories, $postID, $amount])->result_array();
|
||||||
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
return $posts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTagPosts($tag, $amount, $offset = 0)
|
||||||
|
{
|
||||||
$offset *= $amount;
|
$offset *= $amount;
|
||||||
$posts = $this->db->query('SELECT p.*, ca.name categoryName, ca.display_name categoryDisplayName, (SELECT count(*) FROM blog_comments WHERE post_id = p.postID) commentCount, (SELECT count(*) FROM blog_post_likes WHERE post_id = p.postID) likeCount FROM blog_posts p LEFT JOIN blog_categories ca ON ca.ID = p.postCategoryID WHERE postState = 1 AND EXISTS(SELECT post_id FROM blog_post_tags WHERE tag_id = (SELECT ID FROM blog_tags t WHERE t.name = ?) AND post_id = p.postID) ORDER BY postPublishDate DESC LIMIT ? OFFSET ?', [$tag, $amount, $offset])->result_array();
|
$tag = strtolower($tag);
|
||||||
$posts = $this->mergePostTitleDesc($posts);
|
$tagID = $this->db->query('SELECT ID FROM blog_tags WHERE name = ? AND lang = ?', [$tag, $_SESSION['site_lang']])->result_array();
|
||||||
|
|
||||||
|
if(empty($tagID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$posts = $this->db->query('SELECT * FROM blog_post p WHERE state = 1 AND ID IN (SELECT postID FROM blog_post_tags WHERE tagID = ?) ORDER BY initialRelease DESC LIMIT ? OFFSET ?', [$tagID[0]['ID'], $amount, $offset])->result_array();
|
||||||
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
$posts = $this->mergePostCategories($posts);
|
||||||
|
$posts = $this->mergePostStats($posts);
|
||||||
$posts = $this->mergePostAuthorData($posts);
|
$posts = $this->mergePostAuthorData($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategoryIDAfterInsert($name, $display_name)
|
function getCategoryIDAfterInsert($name, $display_name)
|
||||||
{
|
{
|
||||||
if (!$this->db->simple_query('INSERT INTO blog_categories (name, display_name) VALUES (?, ?)', [$name, $display_name])) {
|
if (!$this->db->simple_query('INSERT INTO blog_categories (name, displayname) VALUES (?, ?)', [$name, $display_name])) {
|
||||||
$return = $this->db->query('SELECT ID FROM blog_categories WHERE name = ? AND display_name = ? LIMIT 1', [$name, $display_name])->result_array()[0];
|
$return = $this->db->query('SELECT ID FROM blog_categories WHERE name = ? AND displayname = ? LIMIT 1', [$name, $display_name])->result_array()[0];
|
||||||
$return = $return['ID'];
|
$return = $return['ID'];
|
||||||
} else {
|
} else {
|
||||||
$return = $this->db->query('SELECT LAST_INSERT_ID() ID')->result_array()[0]['ID'];
|
$return = $this->db->query('SELECT LAST_INSERT_ID() ID')->result_array()[0]['ID'];
|
||||||
|
@ -120,7 +234,9 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
function incrementViews($id)
|
function incrementViews($id)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE blog_posts SET postViews = postViews+1 WHERE postID = ?', [$id]);
|
$this->db->query('INSERT IGNORE INTO blog_post_stats (ID) VALUES (?)', [$id]);
|
||||||
|
|
||||||
|
$this->db->query('UPDATE blog_post_stats SET views = views + 1 WHERE ID = ?', [$id]);
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,172 +251,157 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
public function getPost($postUrl)
|
public function getPost($postUrl)
|
||||||
{
|
{
|
||||||
$content = $this->db->query('
|
$content = $this->db->query('
|
||||||
SELECT p.*,
|
SELECT p.*
|
||||||
ca.name categoryName,
|
FROM blog_post p
|
||||||
ca.display_name categoryDisplayName,
|
WHERE (SELECT postID FROM blog_post_versions v WHERE v.postID = p.ID AND (v.lang = ? OR v.lang = "de") AND active AND url = ? ORDER BY edited DESC LIMIT 1) = p.ID AND state = 1
|
||||||
COUNT(co.comment) commentCount,
|
GROUP BY ID', [$_SESSION['site_lang'], $postUrl])->result_array(); //TODO: language integration
|
||||||
(SELECT count(*) FROM blog_post_likes l WHERE l.post_id = p.postID) likeCount
|
|
||||||
FROM blog_posts p
|
|
||||||
LEFT JOIN blog_categories ca ON p.postCategoryID = ca.ID
|
|
||||||
LEFT JOIN blog_comments co ON p.postID = co.post_id
|
|
||||||
LEFT JOIN blog_post_likes l ON p.postID = l.post_id
|
|
||||||
WHERE postUrl = ? AND postState = 1
|
|
||||||
GROUP BY p.postID', [$postUrl])->result_array(); //TODO: language integration
|
|
||||||
|
|
||||||
$content = $this->mergePostTitleDesc($content);
|
$content = $this->mergePostTranslation($content, true);
|
||||||
|
$content = $this->mergePostStats($content);
|
||||||
|
$content = $this->mergePostCategories($content);
|
||||||
$content = $this->mergePostAuthorData($content);
|
$content = $this->mergePostAuthorData($content);
|
||||||
$content = $this->mergePostContent($content, $_SESSION['site_lang']);
|
|
||||||
return $content[0];
|
return $content[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostDataByID($postID)
|
public function getPostDataByID($postID)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('
|
$data = $this->db->query('
|
||||||
SELECT p.*,
|
SELECT *
|
||||||
ca.name AS categoryName,
|
FROM blog_post
|
||||||
ca.display_name AS categoryDisplayName,
|
WHERE ID = ?', [$postID])->result_array();
|
||||||
COUNT(co.comment) AS commentCount,
|
|
||||||
COUNT(l.post_id) AS likeCount
|
$data = $this->mergePostCategories($data);
|
||||||
FROM blog_posts p
|
|
||||||
LEFT JOIN blog_categories ca ON p.postCategoryID = ca.ID
|
|
||||||
LEFT JOIN blog_comments co ON p.postID = co.post_id
|
|
||||||
LEFT JOIN blog_post_likes l ON p.postID = l.post_id
|
|
||||||
WHERE postID = ?
|
|
||||||
GROUP BY p.postID', [$postID])->result_array();
|
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContentDataByID($postID, $contentID, $lang)
|
|
||||||
{
|
|
||||||
$data = $this->db->query('SELECT * FROM blog_content WHERE postID = ? AND contentID = ? AND language = ?', [$postID, $contentID, $lang])->result_array();
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTranslationDataByID($postID, $translationID, $lang)
|
|
||||||
{
|
|
||||||
$data = $this->db->query('SELECT * FROM blog_translations WHERE postID = ? AND postTranslationID = ? AND language = ?', [$postID, $translationID, $lang])->result_array();
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getPostContentByID($postID, $language)
|
|
||||||
{
|
|
||||||
$content = $this->db->query('SELECT * FROM blog_content WHERE postID = ? AND isActive = TRUE AND language = ? ORDER BY contentDate DESC LIMIT 1', [$postID, $language])->result_array();
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRandomPosts($postID)
|
public function getRandomPosts($postID)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT * FROM blog_posts WHERE postID <> ? AND postState = 1 ORDER BY RAND() LIMIT 3', [$postID])->result_array();
|
$posts = $this->db->query('SELECT * FROM blog_post WHERE ID <> ? AND state = 1 ORDER BY RAND() LIMIT 3', [$postID])->result_array();
|
||||||
$posts = $this->mergePostTitleDesc($posts);
|
$posts = $this->mergePostTranslation($posts);
|
||||||
$posts = $this->mergePostAuthorData($posts);
|
$posts = $this->mergePostAuthorData($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergePostTitleDesc($posts, $language = NULL)
|
public function getPostTranslation($postID, $showContent, $language)
|
||||||
{
|
{
|
||||||
$language = ($language == NULL ? $_SESSION['site_lang'] : $language);
|
$data = $this->db->query('SELECT * FROM blog_post_versions WHERE postID = ? AND active ORDER BY lang ASC', [$postID])->result_array();
|
||||||
foreach ($posts as $i => $post) {
|
|
||||||
$titleDesc = $this->getPostTitleDesc($post['postID'], $language);
|
|
||||||
$posts[$i]['postTitle'] = $titleDesc['title'];
|
|
||||||
$posts[$i]['postDesc'] = $titleDesc['desc'];
|
|
||||||
}
|
|
||||||
return $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function mergePostAuthorData($posts)
|
|
||||||
{
|
|
||||||
foreach ($posts as $i => $post) {
|
|
||||||
$authorData = $this->getAuthorData($post['postAuthorID']);
|
|
||||||
$posts[$i]['postAuthorDisplayname'] = $authorData['displayname'];
|
|
||||||
$posts[$i]['postAuthorUsername'] = $authorData['username'];
|
|
||||||
$posts[$i]['postAuthorProfilePicture'] = $authorData['profile_picture'];
|
|
||||||
$posts[$i]['postAuthorHeaderImage'] = $authorData['header_image'];
|
|
||||||
$posts[$i]['postAuthorRank'] = $authorData['rank'];
|
|
||||||
$posts[$i]['postAuthorAbout'] = $authorData['about'];
|
|
||||||
}
|
|
||||||
return $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function mergePostContent($posts, $language)
|
|
||||||
{
|
|
||||||
$language = ($language == NULL ? $_SESSION['site_lang'] : $language);
|
|
||||||
foreach ($posts as $i => $post) {
|
|
||||||
$content = $this->getPostContentByID($post['postID'], $language);
|
|
||||||
if (empty($content) && $_SESSION['site_lang'] !== 'de') {
|
|
||||||
$content = $this->getPostContentByID($post['postID'], 'de');
|
|
||||||
}
|
|
||||||
if (!empty($content)) {
|
|
||||||
$content = $content[0];
|
|
||||||
$posts[$i]['postContent'] = $content['content'];
|
|
||||||
$posts[$i]['postWordCount'] = $content['wordCount'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $posts;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPostTitleDesc($postID, $language)
|
|
||||||
{
|
|
||||||
$data = $this->db->query('SELECT * FROM blog_translations WHERE postID = ? ORDER BY blog_translations.language ASC', [$postID])->result_array();
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return ['title' => 'Nicht vorhandener Post', 'desc' => 'Aus unbekannten Gründen ist dieser Blog-Post nicht vorhanden. Bitte versuche es später erneut oder kontaktiere das Support-Team'];
|
return ['error' => true, 'title' => 'Nicht vorhandener Post', 'description' => 'Aus unbekannten Gründen ist dieser Blog-Post nicht vorhanden. Bitte versuche es später erneut oder kontaktiere das Support-Team'];
|
||||||
}
|
}
|
||||||
$postTitle = $data[0]['postTitle'];
|
|
||||||
$postDesc = $data[0]['postDesc'];
|
$url = $data[0]['url'];
|
||||||
|
$title = $data[0]['title'];
|
||||||
|
$description = $data[0]['description'];
|
||||||
|
$content = $data[0]['content'];
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
if ($row['language'] == $language) {
|
if ($row['lang'] == $language) {
|
||||||
$postTitle = $row['postTitle'];
|
$url = $row['url'];
|
||||||
$postDesc = $row['postDesc'];
|
$title = $row['title'];
|
||||||
|
$description = $row['description'];
|
||||||
|
$content = $row['content'];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ['title' => $postTitle, 'desc' => $postDesc];
|
|
||||||
|
$return = [
|
||||||
|
'url' => $url,
|
||||||
|
'title' => $title,
|
||||||
|
'description' => $description,
|
||||||
|
];
|
||||||
|
if($showContent) {
|
||||||
|
$return['content'] = $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAuthorData($authorID)
|
return $return;
|
||||||
{
|
|
||||||
$author = $this->db->query('SELECT ID, username, displayname, rank, profile_picture, header_image, about FROM users WHERE ID = ?', [$authorID])->result_array();
|
|
||||||
|
|
||||||
$author = $this->UserModel->setDefaultImages($author);
|
|
||||||
|
|
||||||
if(empty($author)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
return $author[0];
|
|
||||||
|
public function getPostTranslationByID($postID, $versionID, $lang) {
|
||||||
|
$data = $this->db->query('SELECT * FROM blog_post_versions WHERE postID = ? AND ID = ? AND lang = ?', [$postID, $versionID, $lang])->result_array();
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostTranslationByHashID($versionID) {
|
||||||
|
$data = $this->db->query('SELECT * FROM blog_post_versions WHERE MD5(ID) = ?', [$versionID])->result_array();
|
||||||
|
return !empty($data) ? $data[0] : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getComments($postID)
|
public function getComments($postID)
|
||||||
{
|
{
|
||||||
$comments = $this->db->query('SELECT * FROM blog_comments WHERE post_id = ? ORDER BY date_created DESC', [$postID])->result_array();
|
$comments = $this->db->query('SELECT * FROM blog_post_comments WHERE postID = ? ORDER BY date DESC', [$postID])->result_array();
|
||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCommentsByUrl($postUrl)
|
public function getCommentsByUrl($postUrl)
|
||||||
{
|
{
|
||||||
return $this->db->query('SELECT * FROM blog_comments WHERE post_id = (SELECT postID FROM blog_posts WHERE postUrl = ?) ORDER BY date_created DESC', [$postUrl])->result_array();
|
$ID = $this->getPostIDByUrl($postUrl);
|
||||||
|
if($ID !== NULL) {
|
||||||
|
return $this->getComments($ID);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addComment($postID, $userID, $comment, $reply, $replyTo)
|
public function getComment($commentID) {
|
||||||
{
|
$comment = $this->db->query('SELECT * FROM blog_post_comments WHERE ID = ?', [$commentID])->result_array();
|
||||||
$this->db->query('INSERT INTO blog_comments (post_id, user_id, comment, reply, replyTo_id) VALUES (?, ?, ?, ?, ?)', [$postID, $userID, $comment, $reply, $replyTo]);
|
return !empty($comment) ? $comment[0] : NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isCommentIDValid($commentID) {
|
||||||
|
$comment = $this->db->query('SELECT ID FROM blog_post_comments WHERE ID = ?', [$commentID])->result_array();
|
||||||
|
return !empty($comment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addCommentByUrl($postUrl, $userID, $comment, $replyTo)
|
||||||
|
{
|
||||||
|
$postID = $this->getPostIDByUrl($postUrl);
|
||||||
|
|
||||||
|
if($postID == NULL) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->addComment($postID, $userID, $comment, $replyTo);
|
||||||
|
|
||||||
|
return $this->db->query('SELECT * FROM blog_post_comments WHERE postID = ? AND userID = ? ORDER BY ID DESC LIMIT 1', [$postID, $userID])->result_array()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addComment($postID, $userID, $comment, $replyTo)
|
||||||
|
{
|
||||||
|
$this->db->query('INSERT INTO blog_post_comments (postID, userID, comment, replyToID) VALUES (?, ?, ?, ?)', [$postID, $userID, $comment, $replyTo]);
|
||||||
|
|
||||||
|
$this->db->cache_delete('user', 'getComments');
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
$this->db->cache_delete('blog', 'comment');
|
$this->db->cache_delete('blog', 'comment');
|
||||||
$this->db->cache_delete('blog', 'getComments');
|
$this->db->cache_delete('blog', 'getComments');
|
||||||
|
$this->db->cache_delete('blog', 'getReportModal');
|
||||||
|
$this->db->cache_delete('blog', 'reportModal');
|
||||||
|
$this->db->cache_delete('blog', 'getDeleteModal');
|
||||||
|
$this->db->cache_delete('blog', 'deleteComment');
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addCommentByUrl($postUrl, $userID, $comment, $reply, $replyTo)
|
public function reportComment($commentID, $reason, $reasonText) {
|
||||||
{
|
$this->db->query('INSERT INTO blog_post_comments_reports (commentID, reason, reasonText) VALUES (?, ?, ?)', [$commentID, $reason, $reasonText]);
|
||||||
$postID = $this->db->query('SELECT postID FROM blog_posts WHERE postUrl = ?', [$postUrl])->result_array();
|
|
||||||
if(empty($postID)) {
|
$this->db->cache_delete('admin', 'blog');
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addComment($postID[0]['postID'], $userID, $comment, $reply, $replyTo);
|
public function deleteComment($userID, $commentID) {
|
||||||
|
$this->db->query('DELETE FROM blog_post_comments WHERE replyToID = ?', [$commentID]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_comments WHERE userID = ? AND ID = ?', [$userID, $commentID]);
|
||||||
|
|
||||||
return $this->db->query('SELECT * FROM blog_comments WHERE post_id = ? AND user_id = ? ORDER BY ID DESC LIMIT 1', [$postID[0]['postID'], $userID])->result_array()[0];
|
$this->db->cache_delete('user', 'getComments');
|
||||||
|
$this->db->cache_delete('blog', 'index');
|
||||||
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
$this->db->cache_delete('blog', 'comment');
|
||||||
|
$this->db->cache_delete('blog', 'getComments');
|
||||||
|
$this->db->cache_delete('blog', 'getReportModal');
|
||||||
|
$this->db->cache_delete('blog', 'reportModal');
|
||||||
|
$this->db->cache_delete('blog', 'getDeleteModal');
|
||||||
|
$this->db->cache_delete('blog', 'deleteComment');
|
||||||
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllTags()
|
public function getAllTags()
|
||||||
|
@ -310,13 +411,14 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function getTags($postID)
|
public function getTags($postID)
|
||||||
{
|
{
|
||||||
$tags = $this->db->query('SELECT t.* FROM blog_tags t WHERE ID IN (SELECT tag_id FROM blog_post_tags WHERE post_id = ?)', [$postID])->result_array();
|
$tags = $this->db->query('SELECT t.* FROM blog_tags t WHERE ID IN (SELECT tagID FROM blog_post_tags WHERE postID = ?)', [$postID])->result_array();
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeTagInfo($tags) {
|
public function mergeTagInfo($tags)
|
||||||
|
{
|
||||||
foreach ($tags as $i => $tag) {
|
foreach ($tags as $i => $tag) {
|
||||||
$data = $this->db->query('SELECT count(*) countUsed, SUM(postViews) totalViews FROM blog_posts WHERE postID = (SELECT post_id FROM blog_post_tags WHERE tag_id = ? AND post_id = postID)', [$tag['ID']])->result_array();
|
$data = $this->db->query('SELECT count(*) countUsed, SUM(postViews) totalViews FROM blog_posts WHERE postID = (SELECT postID FROM blog_post_tags WHERE tag_id = ? AND postID = postID)', [$tag['ID']])->result_array();
|
||||||
$data = $data[0];
|
$data = $data[0];
|
||||||
$tags[$i]['countUsed'] = $data['countUsed'];
|
$tags[$i]['countUsed'] = $data['countUsed'];
|
||||||
$tags[$i]['totalViews'] = $data['totalViews'] != '' ? $data['totalViews'] : 0;
|
$tags[$i]['totalViews'] = $data['totalViews'] != '' ? $data['totalViews'] : 0;
|
||||||
|
@ -326,7 +428,7 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function hasAlreadyLiked($postID, $userID)
|
public function hasAlreadyLiked($postID, $userID)
|
||||||
{
|
{
|
||||||
$getLikes = $this->db->query('SELECT * FROM blog_post_likes WHERE post_id = ? AND user_id = ?', [$postID, $userID])->result_array();
|
$getLikes = $this->db->query('SELECT * FROM blog_post_likes WHERE postID = ? AND userID = ?', [$postID, $userID])->result_array();
|
||||||
if (empty($getLikes)) {
|
if (empty($getLikes)) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -336,53 +438,49 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function addLike($postID, $userID)
|
public function addLike($postID, $userID)
|
||||||
{
|
{
|
||||||
$this->db->query('INSERT INTO blog_post_likes (post_id, user_id) VALUES (?, ?)', [$postID, $userID]);
|
$this->db->query('INSERT INTO blog_post_likes (postID, userID) VALUES (?, ?)', [$postID, $userID]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
$this->db->cache_delete('blog', 'like');
|
$this->db->cache_delete('blog', 'like');
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
|
||||||
return $this->db->query('SELECT count(*) likeCount FROM blog_post_likes WHERE post_id = ?', [$postID])->result_array()[0];
|
return $this->db->query('SELECT count(*) likeCount FROM blog_post_likes WHERE postID = ?', [$postID])->result_array()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeLike($postID, $userID)
|
public function removeLike($postID, $userID)
|
||||||
{
|
{
|
||||||
$this->db->query('DELETE FROM blog_post_likes WHERE post_id = ? AND user_id = ?', [$postID, $userID]);
|
$this->db->query('DELETE FROM blog_post_likes WHERE postID = ? AND userID = ?', [$postID, $userID]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
$this->db->cache_delete('blog', 'like');
|
$this->db->cache_delete('blog', 'like');
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
|
||||||
return $this->db->query('SELECT count(*) likeCount FROM blog_post_likes WHERE post_id = ?', [$postID])->result_array()[0];
|
return $this->db->query('SELECT count(*) likeCount FROM blog_post_likes WHERE postID = ?', [$postID])->result_array()[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostList($onlyTrash)
|
public function getPostList($onlyTrash)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT p.*,
|
if($onlyTrash) {
|
||||||
ca.name categoryName,
|
$posts = $this->db->query('SELECT p.*, s.views
|
||||||
ca.display_name categoryDisplayName,
|
FROM blog_trash p LEFT JOIN blog_post_stats s ON s.ID = p.ID')->result_array();
|
||||||
(SELECT count(*)
|
} else {
|
||||||
FROM blog_comments
|
$posts = $this->db->query('SELECT p.*, s.views
|
||||||
WHERE post_id = p.postID) commentCount,
|
FROM blog_post p LEFT JOIN blog_post_stats s ON s.ID = p.ID')->result_array();
|
||||||
(SELECT count(*)
|
}
|
||||||
FROM blog_post_likes
|
|
||||||
WHERE post_id = p.postID) likeCount,
|
$posts = $this->mergePostTranslation($posts);
|
||||||
(SELECT display_name
|
$posts = $this->mergePostCategories($posts);
|
||||||
FROM blog_states
|
$posts = $this->mergePostStats($posts);
|
||||||
WHERE ID = p.postState) postStateDisplay
|
|
||||||
FROM blog_posts p
|
|
||||||
LEFT JOIN blog_categories ca ON ca.ID = p.postCategoryID
|
|
||||||
WHERE postIsDeleted = ?', [$onlyTrash])->result_array();
|
|
||||||
$posts = $this->mergePostTitleDesc($posts);
|
|
||||||
$posts = $this->mergePostAuthorData($posts);
|
$posts = $this->mergePostAuthorData($posts);
|
||||||
|
$posts = $this->mergePostState($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllContentVersions($postID, $lang)
|
public function getAllPostVersions($postID, $lang)
|
||||||
{
|
{
|
||||||
$content = $this->db->query('SELECT * FROM blog_content WHERE postID = ? AND language = ? ORDER BY contentDate DESC', [$postID, $lang])->result_array();
|
$content = $this->db->query('SELECT *, MD5(ID) hashID FROM blog_post_versions WHERE postID = ? AND lang = ? ORDER BY edited DESC', [$postID, $lang])->result_array();
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +489,7 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$tagData = $this->db->query('SELECT ID FROM blog_tags WHERE name = ?', [strtolower($tag)])->result_array();
|
$tagData = $this->db->query('SELECT ID FROM blog_tags WHERE name = ?', [strtolower($tag)])->result_array();
|
||||||
if (empty($tagData)) {
|
if (empty($tagData)) {
|
||||||
$this->db->query('INSERT INTO blog_tags (name, display_name) VALUES (?, ?)', [strtolower($tag), $tag]);
|
$this->db->query('INSERT INTO blog_tags (name, displayname) VALUES (?, ?)', [strtolower($tag), $tag]);
|
||||||
$tagData = $this->db->query('SELECT ID FROM blog_tags WHERE name = ?', [strtolower($tag)])->result_array();
|
$tagData = $this->db->query('SELECT ID FROM blog_tags WHERE name = ?', [strtolower($tag)])->result_array();
|
||||||
}
|
}
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
@ -401,7 +499,7 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function addPostTagByID($postID, $tagID)
|
public function addPostTagByID($postID, $tagID)
|
||||||
{
|
{
|
||||||
$this->db->query('INSERT INTO blog_post_tags (post_id, tag_id) VALUES (?, ?) ON DUPLICATE KEY UPDATE post_id = post_id', [$postID, $tagID]);
|
$this->db->query('INSERT INTO blog_post_tags (postID, tagID) VALUES (?, ?) ON DUPLICATE KEY UPDATE postID = postID', [$postID, $tagID]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
@ -411,7 +509,7 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function deleteAllPostTags($postID)
|
public function deleteAllPostTags($postID)
|
||||||
{
|
{
|
||||||
$this->db->query('DELETE FROM blog_post_tags WHERE post_id = ?', [$postID]);
|
$this->db->query('DELETE FROM blog_post_tags WHERE postID = ?', [$postID]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
@ -419,6 +517,25 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addPostCategoryByID($postID, $categoryID)
|
||||||
|
{
|
||||||
|
$this->db->query('INSERT INTO blog_post_categories (postID, categoryID) VALUES (?, ?) ON DUPLICATE KEY UPDATE postID = postID', [$postID, $categoryID]);
|
||||||
|
|
||||||
|
$this->db->cache_delete('blog', 'index');
|
||||||
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
$this->db->cache_delete('blog', 'like');
|
||||||
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteAllPostCategories($postID)
|
||||||
|
{
|
||||||
|
$this->db->query('DELETE FROM blog_post_categories WHERE postID = ?', [$postID]);
|
||||||
|
|
||||||
|
$this->db->cache_delete('blog', 'index');
|
||||||
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
$this->db->cache_delete('blog', 'category');
|
||||||
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
}
|
||||||
// TODO: Update
|
// TODO: Update
|
||||||
public function prepareContentForRelease($content)
|
public function prepareContentForRelease($content)
|
||||||
{
|
{
|
||||||
|
@ -469,7 +586,8 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function deletePost($id)
|
public function deletePost($id)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE blog_posts SET postIsDeleted = TRUE, postDeletedDate = NOW(), postState = 4 WHERE postID = ? LIMIT 1', [$id]);
|
$this->db->query('INSERT INTO blog_trash SELECT * FROM blog_post WHERE ID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post WHERE ID = ?', [$id]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
@ -481,7 +599,8 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function restorePost($id)
|
public function restorePost($id)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE blog_posts SET postIsDeleted = FALSE, postDeletedDate = NULL, postState = 1 WHERE postID = ? LIMIT 1', [$id]);
|
$this->db->query('INSERT INTO blog_post SELECT * FROM blog_trash WHERE ID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_trash WHERE ID = ?', [$id]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
@ -493,11 +612,19 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function deletePostFinally($id)
|
public function deletePostFinally($id)
|
||||||
{
|
{
|
||||||
$this->db->query('DELETE FROM blog_content WHERE postID = ? AND (SELECT postIsDeleted FROM blog_posts WHERE postID = ?) = TRUE', [$id, $id]);
|
$data = $this->db->query('SELECT ID FROM blog_trash WHERE ID = ?', [$id])->result_array();
|
||||||
$this->db->query('DELETE FROM blog_post_likes WHERE post_id = ? AND (SELECT postIsDeleted FROM blog_posts WHERE postID = ?) = TRUE', [$id, $id]);
|
|
||||||
$this->db->query('DELETE FROM blog_post_tags WHERE post_id = ? AND (SELECT postIsDeleted FROM blog_posts WHERE postID = ?) = TRUE', [$id, $id]);
|
if(empty($data)) {
|
||||||
$this->db->query('DELETE FROM blog_comments WHERE post_id = ? AND (SELECT postIsDeleted FROM blog_posts WHERE postID = ?) = TRUE', [$id, $id]);
|
return;
|
||||||
$this->db->query('DELETE FROM blog_posts WHERE postID = ? AND postIsDeleted = TRUE LIMIT 1', [$id]);
|
}
|
||||||
|
|
||||||
|
$this->db->query('DELETE FROM blog_post_categories WHERE postID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_comments WHERE postID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_likes WHERE postID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_stats WHERE ID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_tags WHERE postID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_post_versions WHERE postID = ?', [$id]);
|
||||||
|
$this->db->query('DELETE FROM blog_trash WHERE ID = ? LIMIT 1', [$id]);
|
||||||
|
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
@ -507,47 +634,29 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPrevPost($id)
|
public function getPrevPost($initialRelease)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT postID, postUrl, postImage FROM blog_posts WHERE postPublishDate < (SELECT postPublishDate FROM blog_posts WHERE postID = ?) AND postState = 1 ORDER BY postPublishDate DESC LIMIT 1', [$id])->result_array();
|
$posts = $this->db->query('SELECT ID, image FROM blog_post WHERE initialRelease < ? AND state = 1 ORDER BY initialRelease DESC LIMIT 1', [$initialRelease])->result_array();
|
||||||
return $this->mergePostTitleDesc($posts);
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNextPost($id)
|
public function getNextPost($initialRelease)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT postID, postUrl, postImage FROM blog_posts WHERE postPublishDate > (SELECT postPublishDate FROM blog_posts WHERE postID = ?) AND postState = 1 ORDER BY postPublishDate ASC LIMIT 1', [$id])->result_array();
|
$posts = $this->db->query('SELECT ID, image FROM blog_post WHERE initialRelease > ? AND state = 1 ORDER BY initialRelease ASC LIMIT 1', [$initialRelease])->result_array();
|
||||||
return $this->mergePostTitleDesc($posts);
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMostRecentPosts($count)
|
public function getMostRecentPosts($count)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT postID, postImage, postUrl, postPublishDate FROM blog_posts WHERE postState = 1 ORDER BY postPublishDate DESC LIMIT ?', [$count])->result_array();
|
$posts = $this->db->query('SELECT ID, image, initialRelease FROM blog_post WHERE state = 1 ORDER BY initialRelease DESC LIMIT ?', [$count])->result_array();
|
||||||
return $this->mergePostTitleDesc($posts);
|
$posts = $this->mergePostTranslation($posts);
|
||||||
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function countWords($text)
|
public function getReadingTime($wordCount)
|
||||||
{
|
{
|
||||||
$text = preg_replace("/<[a-zA-Z0-9\/ .,:;\-_+!?&%=\"]+>/", '', $text);
|
|
||||||
return str_word_count($text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReadingTime($postID)
|
|
||||||
{
|
|
||||||
$data = $this->db->query('SELECT wordCount, language FROM blog_content c WHERE postID = ? AND isActive = TRUE AND (c.language = ? OR c.language = "de") ORDER BY contentDate DESC', [$postID, $_SESSION['site_lang']])->result_array();
|
|
||||||
|
|
||||||
if (empty($data)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
$wordCount = $data[0]['wordCount'];
|
|
||||||
|
|
||||||
foreach ($data as $entry) {
|
|
||||||
if ($entry['language'] == $_SESSION['site_lang']) {
|
|
||||||
$wordCount = $entry['wordCount'];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$wordsPerSecond = 3;
|
$wordsPerSecond = 3;
|
||||||
$duration = $wordCount / $wordsPerSecond;
|
$duration = $wordCount / $wordsPerSecond;
|
||||||
$duration /= 60;
|
$duration /= 60;
|
||||||
|
@ -557,53 +666,46 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
|
|
||||||
public function createNewPostDraft($authorID)
|
public function createNewPostDraft($authorID)
|
||||||
{
|
{
|
||||||
$this->db->query('INSERT INTO blog_posts (postAuthorID, postState) VALUE (?, 2)', [$authorID]);
|
$this->db->query('INSERT INTO blog_post (authorID, state) VALUE (?, 2)', [$authorID]);
|
||||||
$data = $this->db->query('SELECT postID FROM blog_posts WHERE postState = 2 ORDER BY postID DESC LIMIT 1')->result_array();
|
|
||||||
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
$data = $this->db->query('SELECT ID FROM blog_post WHERE state = 2 ORDER BY ID DESC LIMIT 1')->result_array();
|
||||||
|
|
||||||
return intval($data[0]['postID']);
|
return intval($data[0]['postID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createNewContentDraft($postID)
|
public function createNewTranslationDraft($postID, $authorID, $lang) {
|
||||||
{
|
$this->db->query('INSERT INTO blog_post_versions (postID, authorID, active, lang) VALUES (?, ?, 0, ?)', [$postID, $authorID, $lang]);
|
||||||
$this->db->query('INSERT INTO blog_content (postID, isActive) VALUES (?, 0)', [$postID]);
|
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
$data = $this->db->query('SELECT contentID FROM blog_content WHERE postID = ? ORDER BY contentID DESC LIMIT 1', [$postID])->result_array();
|
|
||||||
return intval($data[0]['contentID']);
|
$data = $this->db->query('SELECT ID FROM blog_post_versions WHERE postID = ? ORDER BY ID DESC LIMIT 1', [$postID])->result_array();
|
||||||
|
|
||||||
|
return intval($data[0]['ID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createNewTranslation($postID, $language)
|
public function updatePostDraft($postID, $initialRelease, $postImage)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT postTranslationID FROM blog_translations WHERE postID = ? AND language = ?', [$postID, $language])->result_array();
|
$this->db->query('UPDATE blog_post SET initialRelease = ?, image = ? WHERE ID = ?', [$initialRelease, $postImage, $postID]);
|
||||||
|
|
||||||
if (empty($data)) {
|
|
||||||
$this->db->query('INSERT INTO blog_translations (postID, language) VALUES (?, ?)', [$postID, $language]);
|
|
||||||
$data = $this->db->query('SELECT postTranslationID FROM blog_translations WHERE postID = ? AND language = ? ORDER BY postTranslationID DESC', [$postID, $language])->result_array();
|
|
||||||
}
|
|
||||||
|
|
||||||
return intval($data[0]['postTranslationID']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updatePostDraft($postID, $postUrl, $postCategory, $postPublishDate, $postImage)
|
|
||||||
{
|
|
||||||
$this->db->query('UPDATE blog_posts SET postUrl = ?, postCategoryID = ?, postPublishDate = ?, postImage = ? WHERE postID = ?', [$postUrl, $postCategory, $postPublishDate, $postImage, $postID]);
|
|
||||||
$this->db->cache_delete('admin', 'edit');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function updateContentDraft($contentID, $postContent, $postLang)
|
|
||||||
{
|
|
||||||
$wordCount = $this->countWords($postContent);
|
|
||||||
$this->db->query('UPDATE blog_content SET content = ?, language = ?, contentDate = NOW(), wordCount = ? WHERE contentID = ?', [$postContent, $postLang, $wordCount, $contentID]);
|
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateTranslation($translationID, $postTitle, $postDesc)
|
public function updateTranslationDraft($versionID, $url, $title, $description, $content, $lang)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE blog_translations SET postTitle = ?, postDesc = ? WHERE postTranslationID = ?', [$postTitle, $postDesc, $translationID]);
|
$wordCount = $this->countWords($content);
|
||||||
|
$this->db->query('UPDATE blog_post_versions SET lang = ?, url = ?, title = ?, description = ?, content = ?, contentWordsCount = ?, edited = NOW() WHERE ID = ?', [$lang, $url, $title, $description, $content, $wordCount, $versionID]);
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function countWords($text)
|
||||||
|
{
|
||||||
|
$text = preg_replace("/<[a-zA-Z0-9\/ .,:;\-_+!?&%=\"]+>/", '', $text);
|
||||||
|
return str_word_count($text);
|
||||||
|
}
|
||||||
|
|
||||||
public function publishPostDraft($postID)
|
public function publishPostDraft($postID)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE blog_posts SET postPublishDate = NOW(), postLastEdit = NOW(), postState = 1 WHERE postID = ?', [$postID]);
|
$this->db->query('UPDATE blog_post SET initialRelease = NOW(), lastEdit = NOW(), state = 1 WHERE ID = ?', [$postID]);
|
||||||
|
$this->db->query('INSERT INTO blog_post_stats (ID) VALUES (?)', [$postID]);
|
||||||
$this->db->cache_delete('blog', 'index');
|
$this->db->cache_delete('blog', 'index');
|
||||||
$this->db->cache_delete('blog', 'post');
|
$this->db->cache_delete('blog', 'post');
|
||||||
$this->db->cache_delete('blog', 'tag');
|
$this->db->cache_delete('blog', 'tag');
|
||||||
|
@ -612,54 +714,65 @@ AND postState = 1', [$_SESSION['site_lang'], $_SESSION['site_lang'], $search, $s
|
||||||
$this->db->cache_delete('admin', 'blog');
|
$this->db->cache_delete('admin', 'blog');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function publishContentDraft($authorID, $contentID, $postID, $lang)
|
public function publishTranslationDraft($postID, $versionID, $authorID, $lang)
|
||||||
{
|
{
|
||||||
$firstContent = $this->db->query('SELECT contentID FROM blog_content WHERE postID = ? AND contentID != ? AND language = ?', [$postID, $contentID, $lang])->result_array();
|
$this->db->query('UPDATE blog_post_versions SET active = FALSE WHERE postID = ? AND lang = ?', [$postID, $lang]);
|
||||||
$isNative = TRUE;
|
$this->db->query('UPDATE blog_post_versions SET active = TRUE, edited = NOW(), authorID = ? WHERE postID = ? AND ID = ?', [$authorID, $postID, $versionID]);
|
||||||
if(!empty($firstContent)) {
|
|
||||||
$isNative = FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->query('UPDATE blog_content SET isActive = FALSE WHERE postID = ?', [$postID]);
|
public function getPostVersionIDs($postID) {
|
||||||
$this->db->query('UPDATE blog_content SET isActive = TRUE, isNativePost = ?, contentDate = NOW(), contentAuthorID = ? WHERE contentID = ?', [$isNative, $authorID, $contentID]);
|
$data = $this->db->query('SELECT ID, lang FROM blog_post_versions WHERE postID = ? GROUP BY lang ORDER BY active DESC, edited DESC, ID DESC', [$postID])->result_array();
|
||||||
}
|
|
||||||
|
|
||||||
public function getPostTranslationIDs($postID) {
|
|
||||||
$data = $this->db->query('SELECT postTranslationID, language FROM blog_translations WHERE postID = ?', [$postID])->result_array();
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostContentIDs($postID) {
|
public function getPostVersions($postID) {
|
||||||
$data = $this->db->query('SELECT (SELECT contentID FROM blog_content WHERE language = c.language ORDER BY contentID DESC LIMIT 1) contentID, language FROM blog_content c WHERE postID = ? AND language IS NOT NULL GROUP BY language ORDER BY contentID DESC', [$postID])->result_array();
|
function getIDs($val) {
|
||||||
return $data;
|
return $val['ID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostTranslations($postID)
|
$versionIDs = $this->getPostVersionIDs($postID);
|
||||||
{
|
$versionIDs = array_map("getIDs", $versionIDs);
|
||||||
$data = $this->db->query('SELECT * FROM blog_translations t LEFT JOIN blog_content c ON c.postID = t.postID AND c.language = t.language WHERE t.postID = ?', [$postID])->result_array();
|
$data = $this->db->query('SELECT * FROM blog_post_versions WHERE ID IN ?', [$versionIDs])->result_array();
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postIDExisting($postID)
|
public function postIDExisting($postID)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT postID FROM blog_posts WHERE postID = ?', [$postID])->result_array();
|
$data = $this->db->query('SELECT ID FROM blog_post WHERE ID = ?', [$postID])->result_array();
|
||||||
return !empty($data);
|
return !empty($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function contentIDExisting($postID, $contentID)
|
public function versionIDExisting($postID, $versionID)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT contentID FROM blog_content WHERE postID = ? AND contentID = ?', [$postID, $contentID])->result_array();
|
$data = $this->db->query('SELECT ID FROM blog_post_versions WHERE postID = ? AND ID = ?', [$postID, $versionID])->result_array();
|
||||||
return !empty($data);
|
return !empty($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function translationIDExisting($postID, $translationID)
|
public function postUrlExisting($postUrl)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT postTranslationID FROM blog_translations WHERE postID = ? AND postTranslationID = ?', [$postID, $translationID])->result_array();
|
$data = $this->db->query('SELECT url FROM blog_post_versions WHERE url = ?', [$postUrl])->result_array();
|
||||||
return !empty($data);
|
return !empty($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postUrlExisting($postUrl) {
|
public function createCategory($name, $displayname, $lang, $categoryID = null) {
|
||||||
$data = $this->db->query('SELECT postUrl FROM blog_posts WHERE postUrl = ?', [$postUrl])->result_array();
|
$sameName = $this->db->query('SELECT categoryID FROM blog_categories WHERE name = ? AND displayname = ? AND lang = ?', [$name, $displayname, $lang])->result_array();
|
||||||
return !empty($data);
|
if(!empty($sameName)) {
|
||||||
|
return $sameName[0]['categoryID'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($categoryID == null) {
|
||||||
|
$highestCategoryID = $this->db->query('SELECT categoryID FROM blog_categories ORDER BY categoryID DESC LIMIT 1')->result_array();
|
||||||
|
$categoryID = !empty($highestCategoryID) ? $highestCategoryID[0]['categoryID'] + 1 : 1;
|
||||||
|
}
|
||||||
|
$this->db->query('INSERT INTO blog_categories (categoryID, lang, name, displayname) VALUES (?, ?, ?, ?)', [$categoryID, $lang, $name, $displayname]);
|
||||||
|
$this->db->cache_delete('admin', 'blog');
|
||||||
|
$this->db->cache_delete('blog', 'index');
|
||||||
|
$this->db->cache_delete('blog', 'category');
|
||||||
|
$this->db->cache_delete('blog', 'tag');
|
||||||
|
$this->db->cache_delete('blog', 'search');
|
||||||
|
$this->db->cache_delete('blog', 'post');
|
||||||
|
|
||||||
|
return $categoryID;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -12,15 +12,16 @@ class DatabaseModel extends CI_Model
|
||||||
public function createMissingDatabases()
|
public function createMissingDatabases()
|
||||||
{
|
{
|
||||||
//$this->createDatabases();
|
//$this->createDatabases();
|
||||||
$this->createTables();
|
// TODO: Update data base generation
|
||||||
|
// $this->createTables();
|
||||||
//$this->addIndices();
|
//$this->addIndices();
|
||||||
//$this->addAutoIncrements();
|
//$this->addAutoIncrements();
|
||||||
//$this->addConstraints();
|
//$this->addConstraints();
|
||||||
|
|
||||||
$this->fillBlogTables();
|
//$this->fillBlogTables();
|
||||||
$this->fillFeedbackTable();
|
//$this->fillFeedbackTable();
|
||||||
$this->fillMainTable();
|
//$this->fillMainTable();
|
||||||
$this->fillProjectsTable();
|
//$this->fillProjectsTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createDatabases()
|
private function createDatabases()
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendMail($recipient, $subject, $template, $templateData) {
|
function sendMail($recipient, $subject, $template, $templateData) {
|
||||||
|
if(base_url() == 'http://192.168.178.39/') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->load->library('email');
|
$this->load->library('email');
|
||||||
|
|
||||||
$config['mailtype'] = 'html';
|
$config['mailtype'] = 'html';
|
||||||
|
|
|
@ -26,7 +26,7 @@ class FileModel extends CI_Model
|
||||||
$userID = $user;
|
$userID = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->query('INSERT INTO files (name, original_name, type, size, path, user) VALUES (?, ?, ?, ?, ?, ?)', [$name, $originalName, $type, $size, $path, $userID]);
|
$this->db->query('INSERT INTO files (name, originalName, type, size, path, user) VALUES (?, ?, ?, ?, ?, ?)', [$name, $originalName, $type, $size, $path, $userID]);
|
||||||
|
|
||||||
$this->db->cache_delete('admin', 'files');
|
$this->db->cache_delete('admin', 'files');
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
|
|
||||||
$return = '';
|
$return = '';
|
||||||
foreach ($posts as $result) {
|
foreach ($posts as $result) {
|
||||||
$date = strtotime($result['postPublishDate']);
|
$date = strtotime($result['initialRelease']);
|
||||||
$return .= '<div class="media">';
|
$return .= '<div class="media">';
|
||||||
|
|
||||||
if ($result['postImage'] != '') {
|
if ($result['image'] != '') {
|
||||||
$return .= '<img src="' . $result['postImage'] . '?w=100" style="width:75px" class="img-fluid mr-3">';
|
$return .= '<img src="' . $result['image'] . '?w=100" style="width:75px" class="img-fluid mr-3">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$return .= '<div class="media-body">
|
$return .= '<div class="media-body">
|
||||||
<h6 class="my-0"><a href="#">' . $result['postTitle'] . '</a></h6>
|
<h6 class="my-0"><a href="#">' . $result['title'] . '</a></h6>
|
||||||
<small class="text-white-50">' . lang('footer_published') . ' ' . DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']) . '</small>
|
<small class="text-white-50">' . lang('footer_published') . ' ' . DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']) . '</small>
|
||||||
</div>
|
</div>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$encryptedPassword = $this->getPasswordHash($password, $logindata['original_name']);
|
$encryptedPassword = $this->getPasswordHash($password, $logindata['originalName']);
|
||||||
|
|
||||||
if ($encryptedPassword == $logindata['password']) {
|
if ($encryptedPassword == $logindata['password']) {
|
||||||
$this->startLoginSession($logindata, $rememberMe);
|
$this->startLoginSession($logindata, $rememberMe);
|
||||||
|
@ -40,15 +40,15 @@
|
||||||
public function getLoginData($username)
|
public function getLoginData($username)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$return = $this->db->query('SELECT * FROM users WHERE (username = lower(?) OR email = lower(?)) AND is_activated = TRUE LIMIT 1',
|
$return = $this->db->query('SELECT u.ID, u.username, u.displayname, u.originalName, u.email, u.rank, u.loginMethod, u.password, u.isDeleted, s.profilePicture, s.showAds FROM users u INNER JOIN user_settings s ON s.ID = u.ID WHERE (username = lower(?) OR email = lower(?)) AND activated = TRUE LIMIT 1',
|
||||||
[htmlspecialchars($username, ENT_QUOTES), $username])->result_array();
|
[htmlspecialchars($username, ENT_QUOTES), $username])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPasswordHash($password, $original_name)
|
public function getPasswordHash($password, $originalName)
|
||||||
{
|
{
|
||||||
$salt = md5($original_name);
|
$salt = md5($originalName);
|
||||||
$passwordHash = hash('sha256', $salt . $password . $salt);
|
$passwordHash = hash('sha256', $salt . $password . $salt);
|
||||||
return $passwordHash;
|
return $passwordHash;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@
|
||||||
'displayname' => $displayname,
|
'displayname' => $displayname,
|
||||||
'rank' => $rank,
|
'rank' => $rank,
|
||||||
'showAds' => $ads,
|
'showAds' => $ads,
|
||||||
'profile_picture' => $avatar,
|
'profilePicture' => $avatar,
|
||||||
) = $logindata;
|
) = $logindata;
|
||||||
|
|
||||||
$this->session->set_userdata('user', [
|
$this->session->set_userdata('user', [
|
||||||
|
@ -131,7 +131,7 @@
|
||||||
|
|
||||||
public function isAvailable($username)
|
public function isAvailable($username)
|
||||||
{
|
{
|
||||||
$registered = $this->db->query('SELECT * FROM users WHERE username = lower(?) OR original_name = lower(?)', [$username, $username])->result_array();
|
$registered = $this->db->query('SELECT * FROM users WHERE username = lower(?) OR originalName = lower(?)', [$username, $username])->result_array();
|
||||||
|
|
||||||
if (empty($registered)) {
|
if (empty($registered)) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -144,7 +144,7 @@
|
||||||
{
|
{
|
||||||
$encryptedPassword = $this->LoginModel->getPasswordHash($password, strtolower($username));
|
$encryptedPassword = $this->LoginModel->getPasswordHash($password, strtolower($username));
|
||||||
$activation_key = hash("sha512", uniqid(rand(), true)) . hash("sha512", uniqid(rand(), true));
|
$activation_key = hash("sha512", uniqid(rand(), true)) . hash("sha512", uniqid(rand(), true));
|
||||||
$this->db->query('INSERT INTO users (original_name, username, displayname, login_method, password, email, rank, is_activated, activation_key) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', [strtolower($username), strtolower($username), $username, $login_method, $encryptedPassword, $email, 1, false, $activation_key]);
|
$this->db->query('INSERT INTO users (originalName, username, displayname, login_method, password, email, rank, activated, activation_key) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', [strtolower($username), strtolower($username), $username, $login_method, $encryptedPassword, $email, 1, false, $activation_key]);
|
||||||
|
|
||||||
$this->db->cache_delete('admin', 'users');
|
$this->db->cache_delete('admin', 'users');
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
|
|
||||||
public function hashMailExists($emailHash, $activation_key)
|
public function hashMailExists($emailHash, $activation_key)
|
||||||
{
|
{
|
||||||
$results = $this->db->query('SELECT ID FROM users WHERE MD5(email) = ? AND is_activated = 0 AND activation_key = ?', [$emailHash, $activation_key])->result_array();
|
$results = $this->db->query('SELECT ID FROM users WHERE MD5(email) = ? AND activated = 0 AND activation_key = ?', [$emailHash, $activation_key])->result_array();
|
||||||
if (!empty($results)) {
|
if (!empty($results)) {
|
||||||
return $results[0]['ID'];
|
return $results[0]['ID'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -188,7 +188,7 @@
|
||||||
|
|
||||||
public function activateMail($id)
|
public function activateMail($id)
|
||||||
{
|
{
|
||||||
$this->db->query('UPDATE users SET is_activated = 1, activation_key = NULL WHERE ID = ? LIMIT 1', [$id]);
|
$this->db->query('UPDATE users SET activated = 1, activation_key = NULL WHERE ID = ? LIMIT 1', [$id]);
|
||||||
|
|
||||||
// Clear cached queries
|
// Clear cached queries
|
||||||
$username = $this->db->query('SELECT username FROM users WHERE ID = ?', [$id])->result_array();
|
$username = $this->db->query('SELECT username FROM users WHERE ID = ?', [$id])->result_array();
|
||||||
|
@ -199,14 +199,14 @@
|
||||||
public function changeMailAddress($email, $username)
|
public function changeMailAddress($email, $username)
|
||||||
{
|
{
|
||||||
$activation_key = hash("sha512", uniqid(rand(), true)) . hash("sha512", uniqid(rand(), true));
|
$activation_key = hash("sha512", uniqid(rand(), true)) . hash("sha512", uniqid(rand(), true));
|
||||||
$this->db->query('UPDATE users SET email = lower(?), is_activated = FALSE, activation_key = ? WHERE username = ?', [$email, $activation_key, $username]);
|
$this->db->query('UPDATE users SET email = lower(?), activated = FALSE, activation_key = ? WHERE username = ?', [$email, $activation_key, $username]);
|
||||||
$this->db->cache_delete('admin', 'users');
|
$this->db->cache_delete('admin', 'users');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changePassword($newPassword, $original_name)
|
public function changePassword($newPassword, $originalName)
|
||||||
{
|
{
|
||||||
$encryptedPassword = $this->getPasswordHash($newPassword, $original_name);
|
$encryptedPassword = $this->getPasswordHash($newPassword, $originalName);
|
||||||
$this->db->query('UPDATE users SET password = ? WHERE original_name = ?', [$encryptedPassword, $original_name]);
|
$this->db->query('UPDATE users SET password = ? WHERE originalName = ?', [$encryptedPassword, $originalName]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkPassword($password)
|
public function checkPassword($password)
|
||||||
|
|
|
@ -27,7 +27,14 @@
|
||||||
public function getUserNotificationsRaw($userID, $limit = 20, $offset = 0)
|
public function getUserNotificationsRaw($userID, $limit = 20, $offset = 0)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$rawData = $this->db->query('SELECT n.*, count(*) count, s.username senderName, s.displayname senderDisplayname, s.profile_picture senderPicture, r.username recipientName, r.displayName recipientDisplayname FROM notifications n LEFT JOIN users s ON n.senderID = s.ID LEFT JOIN users r ON n.recipientID = r.ID WHERE recipientID = ? GROUP BY type, referenceID ORDER BY createdAt DESC, unread DESC LIMIT ? OFFSET ?', [$userID, $limit, $offset])->result_array();
|
$rawData = $this->db->query('SELECT n.*, count(*) count, s.username senderName, s.displayname senderDisplayname, ss.profilePicture senderPicture, r.username recipientName, r.displayName recipientDisplayname
|
||||||
|
FROM notifications n
|
||||||
|
LEFT JOIN users s ON n.senderID = s.ID
|
||||||
|
LEFT JOIN user_settings ss ON s.ID = ss.ID
|
||||||
|
LEFT JOIN users r ON n.recipientID = r.ID
|
||||||
|
WHERE recipientID = ?
|
||||||
|
GROUP BY type, referenceID
|
||||||
|
ORDER BY createdAt DESC, unread DESC LIMIT ? OFFSET ?', [$userID, $limit, $offset])->result_array();
|
||||||
|
|
||||||
$notifications = [];
|
$notifications = [];
|
||||||
foreach ($rawData as $notification) {
|
foreach ($rawData as $notification) {
|
||||||
|
@ -36,7 +43,13 @@
|
||||||
if ($notificationGroup['count'] == 1) {
|
if ($notificationGroup['count'] == 1) {
|
||||||
$notificationGroup['items'] = [$notification];
|
$notificationGroup['items'] = [$notification];
|
||||||
} else {
|
} else {
|
||||||
$notificationGroup['items'] = $this->db->query('SELECT n.*, s.username senderName, s.displayname senderDisplayname, s.profile_picture senderPicture, r.username recipientName, r.displayName recipientDisplayname FROM notifications n LEFT JOIN users s ON n.senderID = s.ID LEFT JOIN users r ON n.recipientID = r.ID WHERE recipientID = ? AND type = ? AND referenceID = ? LIMIT 5', [$userID, $notification['type'], $notification['referenceID']])->result_array();
|
$notificationGroup['items'] = $this->db->query('SELECT n.*, s.username senderName, s.displayname senderDisplayname, ss.profilePicture senderPicture, r.username recipientName, r.displayName recipientDisplayname
|
||||||
|
FROM notifications n
|
||||||
|
LEFT JOIN users s ON n.senderID = s.ID
|
||||||
|
LEFT JOIN user_settings ss ON s.ID = ss.ID
|
||||||
|
LEFT JOIN users r ON n.recipientID = r.ID
|
||||||
|
WHERE recipientID = ? AND type = ? AND referenceID = ?
|
||||||
|
LIMIT 5', [$userID, $notification['type'], $notification['referenceID']])->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$notifications[] = $notificationGroup;
|
$notifications[] = $notificationGroup;
|
||||||
|
|
|
@ -15,43 +15,30 @@
|
||||||
return $this->addReply($userID, $content, NULL);
|
return $this->addReply($userID, $content, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addReply($userID, $content, $replyToUUID)
|
public function addReply($userID, $content, $replyToHashID)
|
||||||
{
|
{
|
||||||
$content = $this->preparePostContent($content);
|
$content = $this->preparePostContent($content);
|
||||||
$uuid = $this->generatePostUUID($userID, $content);
|
$hashID = $this->generatePostHashID($userID, $content);
|
||||||
$replyTo = NULL;
|
$replyTo = NULL;
|
||||||
if ($replyToUUID !== NULL) {
|
if ($replyToHashID !== NULL) {
|
||||||
$replyToID = $this->db->query('SELECT ID FROM user_posts WHERE uuid = ?', [$replyToUUID])->result_array();
|
$replyToID = $this->db->query('SELECT ID FROM user_posts WHERE hashID = ?', [$replyToHashID])->result_array();
|
||||||
$replyTo = !empty($replyToID) ? $replyToID[0]['ID'] : NULL;
|
$replyTo = !empty($replyToID) ? $replyToID[0]['ID'] : NULL;
|
||||||
}
|
}
|
||||||
$this->db->query('INSERT INTO user_posts (user_id, content, uuid, reply_to) VALUES (?, ?, ?, ?)', [$userID, $content, $uuid, $replyTo]);
|
$this->db->query('INSERT INTO user_posts (userID, content, hashID, replyToPostID) VALUES (?, ?, ?, ?)', [$userID, $content, $hashID, $replyTo]);
|
||||||
|
|
||||||
|
|
||||||
$insertedPost = $this->db->query('SELECT ID, user_id FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
|
$insertedPost = $this->db->query('SELECT ID, userID FROM user_posts WHERE hashID = ?', [$hashID])->result_array();
|
||||||
$this->addPostMentions($insertedPost[0]['ID'], $content, $uuid);
|
$this->addPostMentions($insertedPost[0]['ID'], $content, $hashID);
|
||||||
$this->addPostHashtags($insertedPost[0]['ID'], $content);
|
$this->addPostHashtags($insertedPost[0]['ID'], $content);
|
||||||
|
|
||||||
// Send notification to user whose post was replied to
|
// Send notification to user whose post was replied to
|
||||||
if ($userID != $insertedPost[0]['user_id']) {
|
if ($userID != $insertedPost[0]['userID']) {
|
||||||
$this->NotificationModel->userNotificationPostReply($userID, $insertedPost[0]['user_id'], $insertedPost[0]['ID'], $uuid);
|
$this->NotificationModel->userNotificationPostReply($userID, $insertedPost[0]['userID'], $insertedPost[0]['ID'], $hashID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $insertedPost[0]['ID'];
|
return $insertedPost[0]['ID'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deletePost($userID, $uuid) {
|
|
||||||
$postID = $this->db->query('SELECT ID FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid])->result_array()[0]['ID'];
|
|
||||||
$this->db->query('DELETE FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid]);
|
|
||||||
$this->db->query('DELETE FROM user_posts_hashtags WHERE postID = ?', [$postID]);
|
|
||||||
$this->db->query('DELETE FROM user_posts_mentions WHERE postID = ?', [$postID]);
|
|
||||||
$this->db->query('DELETE FROM user_posts_likes WHERE postID = ?', [$postID]);
|
|
||||||
$this->db->query('DELETE FROM user_posts_media WHERE postID = ?', [$postID]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addMediaToPost($postID, $type, $fileID) {
|
|
||||||
$this->db->query('INSERT INTO user_posts_media (postID, mediaType, fileID) VALUES (?, ?, ?)', [$postID, $type, $fileID]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function preparePostContent($content)
|
public function preparePostContent($content)
|
||||||
{
|
{
|
||||||
if ($this->endsWith($content, '<br> ')) {
|
if ($this->endsWith($content, '<br> ')) {
|
||||||
|
@ -69,12 +56,7 @@
|
||||||
(substr($haystack, -$length) === $needle);
|
(substr($haystack, -$length) === $needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generatePostUUID($userID, $content)
|
public function addPostMentions($postID, $content, $postHashID)
|
||||||
{
|
|
||||||
return md5($userID . $content . date("Y-m-d H:i:s"));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function addPostMentions($postID, $content, $postUUID)
|
|
||||||
{
|
{
|
||||||
preg_match_all('/@([A-Za-z0-9._]+)/', $content, $mentions, PREG_OFFSET_CAPTURE);
|
preg_match_all('/@([A-Za-z0-9._]+)/', $content, $mentions, PREG_OFFSET_CAPTURE);
|
||||||
foreach ($mentions[1] as $mention) {
|
foreach ($mentions[1] as $mention) {
|
||||||
|
@ -83,16 +65,16 @@
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$mentionedUser = $mentionedUser[0];
|
$mentionedUser = $mentionedUser[0];
|
||||||
$this->addMention($postID, $_SESSION['user']['ID'], $mentionedUser['ID'], $mention[1], $postUUID);
|
$this->addMention($postID, $_SESSION['user']['ID'], $mentionedUser['ID'], $mention[1], $postHashID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addMention($postID, $userID, $mentionedUserID, $position, $postUUID)
|
public function addMention($postID, $userID, $mentionedUserID, $position, $postHashID)
|
||||||
{
|
{
|
||||||
$this->db->query('INSERT INTO user_posts_mentions (userID, postID, mentionedUserID, position) VALUES (?, ?, ?, ?)', [$userID, $postID, $mentionedUserID, $position]);
|
$this->db->query('INSERT INTO user_posts_mentions (userID, postID, mentionedUserID, position) VALUES (?, ?, ?, ?)', [$userID, $postID, $mentionedUserID, $position]);
|
||||||
|
|
||||||
// Send notification
|
// Send notification
|
||||||
$this->NotificationModel->userNotificationPostMentioned($userID, $mentionedUserID, $postID, $postUUID);
|
$this->NotificationModel->userNotificationPostMentioned($userID, $mentionedUserID, $postID, $postHashID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addPostHashtags($postID, $content)
|
public function addPostHashtags($postID, $content)
|
||||||
|
@ -108,10 +90,30 @@
|
||||||
$this->db->query('INSERT INTO user_posts_hashtags (userID, postID, hashtag, position) VALUES (?, ?, ?, ?)', [$userID, $postID, $hashtag, $position]);
|
$this->db->query('INSERT INTO user_posts_hashtags (userID, postID, hashtag, position) VALUES (?, ?, ?, ?)', [$userID, $postID, $hashtag, $position]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function deletePost($userID, $hashID)
|
||||||
|
{
|
||||||
|
$postID = $this->db->query('SELECT ID FROM user_posts WHERE userID = ? AND hashID = ?', [$userID, $hashID])->result_array()[0]['ID'];
|
||||||
|
$this->db->query('DELETE FROM user_posts WHERE userID = ? AND hashID = ?', [$userID, $hashID]);
|
||||||
|
$this->db->query('DELETE FROM user_posts_hashtags WHERE postID = ?', [$postID]);
|
||||||
|
$this->db->query('DELETE FROM user_posts_mentions WHERE postID = ?', [$postID]);
|
||||||
|
$this->db->query('DELETE FROM user_posts_likes WHERE postID = ?', [$postID]);
|
||||||
|
$this->db->query('DELETE FROM user_posts_media WHERE postID = ?', [$postID]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addMediaToPost($postID, $type, $fileID)
|
||||||
|
{
|
||||||
|
$this->db->query('INSERT INTO user_posts_media (postID, mediaType, fileID) VALUES (?, ?, ?)', [$postID, $type, $fileID]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function generatePostHashID($userID, $content)
|
||||||
|
{
|
||||||
|
return md5($userID . $content . date("Y-m-d H:i:s"));
|
||||||
|
}
|
||||||
|
|
||||||
function getUserPosts($id, $count, $offset, $maxLength = 250)
|
function getUserPosts($id, $count, $offset, $maxLength = 250)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$posts = $this->db->query('SELECT * FROM user_posts p WHERE user_id = ? ORDER BY date DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
$posts = $this->db->query('SELECT * FROM user_posts p WHERE userID = ? ORDER BY date DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$posts = $this->preparePostList($posts, $maxLength);
|
$posts = $this->preparePostList($posts, $maxLength);
|
||||||
|
@ -136,38 +138,32 @@
|
||||||
$post = $this->mergeUserHasLiked($post, $_SESSION['user']['ID']);
|
$post = $this->mergeUserHasLiked($post, $_SESSION['user']['ID']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($post['reply_to'] != NULL) {
|
if ($post['replyToPostID'] != NULL) {
|
||||||
$post = $this->mergeReplyData($post);
|
$post = $this->mergeReplyData($post);
|
||||||
}
|
}
|
||||||
|
|
||||||
$postList[$i] = $post;
|
$postList[$i] = $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
$postList = $this->UserModel->setDefaultImages($postList);
|
$postList = $this->UserModel->setDefaultImages($postList);
|
||||||
|
|
||||||
return $postList;
|
return $postList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostMedia($postID) {
|
|
||||||
$result = $this->db->query('SELECT m.mediaType type, f.name name FROM user_posts_media m LEFT JOIN files f ON f.ID = m.fileID WHERE postID = ?', [$postID])->result_array();
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function mergePostUserData($post)
|
private function mergePostUserData($post)
|
||||||
{
|
{
|
||||||
$user = $this->UserModel->getUserByID($post['user_id']);
|
$user = $this->UserModel->getUserByID($post['userID']);
|
||||||
$user = $user[0];
|
$user = $user[0];
|
||||||
|
|
||||||
$post['username'] = $user['username'];
|
$post['username'] = $user['username'];
|
||||||
$post['displayname'] = $user['displayname'];
|
$post['displayname'] = $user['displayname'];
|
||||||
$post['profile_picture'] = $user['profile_picture'];
|
$post['profilePicture'] = $user['profilePicture'];
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostReplyCountByID($postID)
|
public function getPostReplyCountByID($postID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT count(*) replyCount FROM user_posts WHERE reply_to = ?', [$postID])->result_array();
|
$data = $this->db->query('SELECT count(*) replyCount FROM user_posts WHERE replyToPostID = ?', [$postID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
return $data[0]['replyCount'];
|
return $data[0]['replyCount'];
|
||||||
|
@ -214,10 +210,16 @@
|
||||||
return $finalContent;
|
return $finalContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPostMedia($postID)
|
||||||
|
{
|
||||||
|
$result = $this->db->query('SELECT m.mediaType type, f.name name FROM user_posts_media m LEFT JOIN files f ON f.ID = m.fileID WHERE postID = ?', [$postID])->result_array();
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
private function mergeUserHasLiked($post, $userID)
|
private function mergeUserHasLiked($post, $userID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT * FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE uuid = ?) AND likerUserID = ?', [$post['uuid'], $userID])->result_array();
|
$data = $this->db->query('SELECT * FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE hashID = ?) AND likerUserID = ?', [$post['hashID'], $userID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
|
@ -228,10 +230,11 @@
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function mergeReplyData($post) {
|
private function mergeReplyData($post)
|
||||||
$data = $this->db->query('SELECT p.*, username, displayname FROM user_posts p LEFT JOIN users ON users.ID = p.user_id WHERE p.ID = ?', [$post['reply_to']])->result_array();
|
{
|
||||||
|
$data = $this->db->query('SELECT p.* FROM user_posts p WHERE p.ID = ?', [$post['replyToPostID']])->result_array();
|
||||||
$data = $this->preparePostList($data);
|
$data = $this->preparePostList($data);
|
||||||
if(!empty($data)) {
|
if (!empty($data)) {
|
||||||
$post['replyToPost'] = $data[0];
|
$post['replyToPost'] = $data[0];
|
||||||
} else {
|
} else {
|
||||||
$post['replyToPost'] = [
|
$post['replyToPost'] = [
|
||||||
|
@ -259,7 +262,7 @@
|
||||||
public function getFeedPosts($userID, $amount, $offset)
|
public function getFeedPosts($userID, $amount, $offset)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT * FROM user_posts WHERE user_id IN (SELECT followedUserID FROM user_followers WHERE followerUserID = ?) OR ID IN(SELECT postID FROM user_posts_mentions WHERE mentionedUserID = ?) OR ID IN (SELECT postID FROM user_posts_likes WHERE likedUserID = ?) OR user_id = ? ORDER BY date DESC LIMIT ? OFFSET ?', [$userID, $userID, $userID, $userID, $amount, $offset])->result_array();
|
$data = $this->db->query('SELECT * FROM user_posts WHERE userID IN (SELECT followedUserID FROM user_followers WHERE followerUserID = ?) OR ID IN(SELECT postID FROM user_posts_mentions WHERE mentionedUserID = ?) OR ID IN (SELECT postID FROM user_posts_likes WHERE likedUserID = ?) OR userID = ? ORDER BY date DESC LIMIT ? OFFSET ?', [$userID, $userID, $userID, $userID, $amount, $offset])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$data = $this->preparePostList($data);
|
$data = $this->preparePostList($data);
|
||||||
|
@ -270,7 +273,7 @@
|
||||||
public function getPopularPosts($amount, $offset)
|
public function getPopularPosts($amount, $offset)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT * FROM user_posts p ORDER BY ((SELECT count(*) FROM user_posts_likes WHERE postID = p.ID) + (SELECT count(*) FROM user_posts WHERE reply_to = p.ID)) DESC, date DESC LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
$data = $this->db->query('SELECT * FROM user_posts p ORDER BY ((SELECT count(*) FROM user_posts_likes WHERE postID = p.ID) + (SELECT count(*) FROM user_posts WHERE replyToPostID = p.ID)) DESC, date DESC LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$data = $this->preparePostList($data);
|
$data = $this->preparePostList($data);
|
||||||
|
@ -278,10 +281,10 @@
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostDetails($userID, $uuid)
|
public function getPostDetails($userID, $hashID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT * FROM user_posts WHERE user_id = ? AND uuid = ?', [$userID, $uuid])->result_array();
|
$data = $this->db->query('SELECT * FROM user_posts WHERE userID = ? AND hashID = ?', [$userID, $hashID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$data = $this->preparePostList($data, -1);
|
$data = $this->preparePostList($data, -1);
|
||||||
|
@ -292,7 +295,7 @@
|
||||||
public function getPostReplies($postID)
|
public function getPostReplies($postID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$replies = $this->db->query('SELECT * FROM user_posts WHERE reply_to = ? ORDER BY date', [$postID])->result_array();
|
$replies = $this->db->query('SELECT * FROM user_posts WHERE replyToPostID = ? ORDER BY date', [$postID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$replies = $this->preparePostList($replies);
|
$replies = $this->preparePostList($replies);
|
||||||
|
@ -300,33 +303,34 @@
|
||||||
return $replies;
|
return $replies;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostByUUID($uuid) {
|
public function getPostByHashID($hashID)
|
||||||
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$result = $this->db->query('SELECT * FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
|
$result = $this->db->query('SELECT * FROM user_posts WHERE hashID = ?', [$hashID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addPostLikeByUUID($uuid, $userID)
|
public function addPostLikeByHashID($hashID, $userID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT * FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE uuid = ?) AND likerUserID = ?', [$uuid, $userID])->result_array();
|
$data = $this->db->query('SELECT * FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE hashID = ?) AND likerUserID = ?', [$hashID, $userID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
// IDs needed for handling notifications later
|
// IDs needed for handling notifications later
|
||||||
$postUser = $this->db->query('SELECT ID FROM users WHERE ID = (SELECT user_id FROM user_posts WHERE uuid = ?)', [$uuid])->result_array();
|
$postUser = $this->db->query('SELECT ID FROM users WHERE ID = (SELECT userID FROM user_posts WHERE hashID = ?)', [$hashID])->result_array();
|
||||||
$postID = $this->db->query('SELECT ID FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
|
$postID = $this->db->query('SELECT ID FROM user_posts WHERE hashID = ?', [$hashID])->result_array();
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
$this->db->query('INSERT INTO user_posts_likes (postID, likedUserID, likerUserID) VALUES ((SELECT ID FROM user_posts WHERE uuid = ?), (SELECT user_id FROM user_posts WHERE uuid = ?), ?)', [$uuid, $uuid, $userID]);
|
$this->db->query('INSERT INTO user_posts_likes (postID, likedUserID, likerUserID) VALUES ((SELECT ID FROM user_posts WHERE hashID = ?), (SELECT userID FROM user_posts WHERE hashID = ?), ?)', [$hashID, $hashID, $userID]);
|
||||||
|
|
||||||
// Send like notification
|
// Send like notification
|
||||||
if ($postUser[0]['ID'] != $userID) {
|
if ($postUser[0]['ID'] != $userID) {
|
||||||
$this->NotificationModel->userNotificationPostLike($userID, $postUser[0]['ID'], $postID[0]['ID'], $uuid);
|
$this->NotificationModel->userNotificationPostLike($userID, $postUser[0]['ID'], $postID[0]['ID'], $hashID);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
$this->db->query('DELETE FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE uuid = ?) AND likerUserID = ?', [$uuid, $userID]);
|
$this->db->query('DELETE FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE hashID = ?) AND likerUserID = ?', [$hashID, $userID]);
|
||||||
|
|
||||||
// Remove existing notification
|
// Remove existing notification
|
||||||
$this->NotificationModel->removeNotification($userID, $postUser[0]['ID'], $postID[0]['ID'], 'users.likedPost');
|
$this->NotificationModel->removeNotification($userID, $postUser[0]['ID'], $postID[0]['ID'], 'users.likedPost');
|
||||||
|
@ -336,18 +340,18 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostLikeCountByUUID($uuid)
|
public function getPostLikeCountByHashID($hashID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT count(*) likeCount FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE uuid = ?)', [$uuid])->result_array();
|
$data = $this->db->query('SELECT count(*) likeCount FROM user_posts_likes WHERE postID = (SELECT ID FROM user_posts WHERE hashID = ?)', [$hashID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
return $data[0]['likeCount'];
|
return $data[0]['likeCount'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isUUIDValid($uuid)
|
public function isHashIDValid($hashID)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$data = $this->db->query('SELECT ID FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
|
$data = $this->db->query('SELECT ID FROM user_posts WHERE hashID = ?', [$hashID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
return !empty($data);
|
return !empty($data);
|
||||||
}
|
}
|
||||||
|
@ -376,7 +380,7 @@
|
||||||
public function searchPosts($query, $limit = 20, $offset = 0)
|
public function searchPosts($query, $limit = 20, $offset = 0)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$results = $this->db->query('SELECT * FROM user_posts WHERE content RLIKE ? OR (SELECT username FROM users WHERE ID = user_id) RLIKE ? ORDER BY (SELECT count(*) FROM user_posts_likes WHERE postID = ID) DESC, (SELECT count(*) FROM user_posts WHERE user_posts.reply_to = ID) DESC, date DESC LIMIT ? OFFSET ?', [$query, $query, $limit, $offset])->result_array();
|
$results = $this->db->query('SELECT * FROM user_posts WHERE content RLIKE ? OR (SELECT username FROM users WHERE ID = userID) RLIKE ? ORDER BY (SELECT count(*) FROM user_posts_likes WHERE postID = ID) DESC, (SELECT count(*) FROM user_posts WHERE replyToPostID = ID) DESC, date DESC LIMIT ? OFFSET ?', [$query, $query, $limit, $offset])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
|
||||||
$results = $this->preparePostList($results);
|
$results = $this->preparePostList($results);
|
||||||
|
@ -384,14 +388,15 @@
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reportPost($uuid, $reason, $reasonText) {
|
public function reportPost($hashID, $reason, $reasonText)
|
||||||
$this->db->query('INSERT INTO user_posts_reports (postID, reason, reasonText) VALUES ((SELECT ID FROM user_posts WHERE uuid = ?), ?, ?)', [$uuid, $reason, $reasonText]);
|
{
|
||||||
|
$this->db->query('INSERT INTO user_posts_reports (postID, reason, reasonText) VALUES ((SELECT ID FROM user_posts WHERE hashID = ?), ?, ?)', [$hashID, $reason, $reasonText]);
|
||||||
$this->db->cache_delete('admin', 'reports');
|
$this->db->cache_delete('admin', 'reports');
|
||||||
|
|
||||||
// Send notification
|
// Send notification
|
||||||
$postID = $this->db->query('SELECT ID FROM user_posts WHERE uuid = ?', [$uuid])->result_array();
|
$postID = $this->db->query('SELECT ID FROM user_posts WHERE hashID = ?', [$hashID])->result_array();
|
||||||
$this->NotificationModel->rankNotificationPostReport(
|
$this->NotificationModel->rankNotificationPostReport(
|
||||||
isset($_SESSION['user']) ? $_SESSION['user']['ID'] : -1,
|
isset($_SESSION['user']) ? $_SESSION['user']['ID'] : -1,
|
||||||
8, $postID[0]['ID'], $uuid);
|
8, $postID[0]['ID'], $hashID);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -26,18 +26,38 @@
|
||||||
public function mergeTranslationData($postList, $lang = 'de')
|
public function mergeTranslationData($postList, $lang = 'de')
|
||||||
{
|
{
|
||||||
foreach ($postList as $i => $post) {
|
foreach ($postList as $i => $post) {
|
||||||
$data = $this->db->query('SELECT * FROM projects_translations WHERE projectID = ? AND (lang = ? OR lang = ?) ORDER BY lang', [$post['ID'], 'de', $lang])->result_array();
|
$data = $this->db->query('SELECT title, description, content, downloadName, openSourceName, customLinkName FROM projects_translations WHERE projectID = ? AND lang = ? ORDER BY lang', [$post['ID'], 'de'])->result_array();
|
||||||
if (sizeof($data) == 1) {
|
|
||||||
$postList[$i] = array_merge($post, $data[0]);
|
if(empty($data)) {
|
||||||
|
$postList[$i] = array_merge($post, [
|
||||||
|
'title' => 'Not found',
|
||||||
|
'description' => 'Not found',
|
||||||
|
'content' => 'Not found',
|
||||||
|
]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$data = $data[0];
|
||||||
|
if($lang == 'de') {
|
||||||
|
$postList[$i] = array_merge($post, $data);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataLang = $this->db->query('SELECT title, description, content, downloadName, openSourceName, customLinkName FROM projects_translations WHERE projectID = ? AND lang = ? ORDER BY lang', [$post['ID'], $lang])->result_array();
|
||||||
|
|
||||||
|
if (empty($dataLang)) {
|
||||||
|
$postList[$i] = array_merge($post, $data);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$dataLang = $dataLang[0];
|
||||||
|
|
||||||
$merged = [];
|
$merged = [];
|
||||||
foreach ($data[0] as $key => $value) {
|
foreach ($data as $key => $value) {
|
||||||
if (($value == NULL && $data[1][$key] == NULL) || ($value != NULL && $data[1][$key] == NULL)) {
|
if (($value == NULL && $dataLang[$key] == NULL) || ($value != NULL && $dataLang[$key] == NULL)) {
|
||||||
$merged[$key] = $value;
|
$merged[$key] = $value;
|
||||||
} else {
|
} else {
|
||||||
$merged[$key] = $data[1][$key];
|
$merged[$key] = $dataLang[$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +68,29 @@
|
||||||
|
|
||||||
public function getCategories()
|
public function getCategories()
|
||||||
{
|
{
|
||||||
$collections = $this->db->query('SELECT c.*, count(p.projectID) count FROM projects_categories c LEFT JOIN projects_entry_categories p ON c.ID = p.categoryID GROUP BY c.ID ORDER BY c.collection')->result_array();
|
$collections = $this->db->query('SELECT c.*, count(p.projectID) count FROM projects_categories c LEFT JOIN projects_entry_categories p ON c.categoryID = p.categoryID GROUP BY c.categoryID ORDER BY c.name')->result_array();
|
||||||
|
|
||||||
|
if($_SESSION['site_lang'] !== 'de') {
|
||||||
|
$collectionsLang = $this->db->query('SELECT categoryID, name, displayname FROM projects_categories WHERE lang = ?', [$_SESSION['site_lang']])->result_array();
|
||||||
|
|
||||||
|
$categoryIDs = array_column($collections, 'categoryID');
|
||||||
|
foreach ($collectionsLang as $item) {
|
||||||
|
$key = array_search($item['categoryID'], $categoryIDs);
|
||||||
|
$collections[$key] = array_merge($collections[$key], $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $collections;
|
return $collections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getCategoriesRaw() {
|
||||||
|
$categories = $this->db->query('SELECT ID, GROUP_CONCAT(c.name) name, GROUP_CONCAT(c.displayname) displayname, (SELECT COUNT(*) FROM projects_entry_categories p WHERE c.categoryID = p.categoryID) count
|
||||||
|
FROM projects_categories c
|
||||||
|
GROUP BY c.categoryID
|
||||||
|
ORDER BY ID')->result_array();
|
||||||
|
return $categories;
|
||||||
|
}
|
||||||
|
|
||||||
public function editEntry($data, $id)
|
public function editEntry($data, $id)
|
||||||
{
|
{
|
||||||
$this->db->update('projects', $data, ['id' => $id]);
|
$this->db->update('projects', $data, ['id' => $id]);
|
||||||
|
@ -120,7 +159,19 @@
|
||||||
|
|
||||||
public function getEntryCategories($id)
|
public function getEntryCategories($id)
|
||||||
{
|
{
|
||||||
return $this->db->query('SELECT * FROM projects_categories WHERE ID IN (SELECT categoryID FROM projects_entry_categories WHERE projectID = ?)', [$id])->result_array();
|
$categories = $this->db->query('SELECT * FROM projects_categories WHERE ID IN (SELECT categoryID FROM projects_entry_categories WHERE projectID = ?) AND lang = "de"', [$id])->result_array();
|
||||||
|
|
||||||
|
if($_SESSION['site_lang'] != 'de') {
|
||||||
|
$categoriesLang = $this->db->query('SELECT categoryID, name, displayname FROM projects_categories WHERE lang = ?', [$_SESSION['site_lang']])->result_array();
|
||||||
|
|
||||||
|
$categoryIDs = array_column($categories, 'categoryID');
|
||||||
|
foreach ($categoriesLang as $item) {
|
||||||
|
$key = array_search($item['categoryID'], $categoryIDs);
|
||||||
|
$categories[$key] = array_merge($categories[$key], $item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateCategories($postID, $categories)
|
public function updateCategories($postID, $categories)
|
||||||
|
|
|
@ -50,44 +50,44 @@
|
||||||
|
|
||||||
$possibilities = [
|
$possibilities = [
|
||||||
'blogPost' => [
|
'blogPost' => [
|
||||||
'sql' => 'SELECT "blogPost" type, bp.postUrl url, bp.postAuthorID author, bp.postImage image, bt.postTitle title, bt.postDesc content, bp.postPublishDate date
|
'sql' => 'SELECT "blogPost" type, v.url url, bp.authorID author, bp.image image, v.title title, v.description content, bp.initialRelease date
|
||||||
FROM blog_posts bp
|
FROM blog_post bp
|
||||||
INNER JOIN blog_translations bt ON bt.postID = bp.postID AND bt.language = ?
|
INNER JOIN blog_post_versions v ON v.postID = bp.ID AND v.lang = ? AND active
|
||||||
LEFT JOIN blog_content bc ON bc.postID = bp.postID AND bc.isActive = TRUE AND bc.language = ?
|
WHERE (LOWER(v.title) RLIKE ?
|
||||||
WHERE (LOWER(bt.postTitle) RLIKE ?
|
OR LOWER(v.description) RLIKE ?
|
||||||
OR LOWER(bt.postDesc) RLIKE ?
|
OR LOWER(v.content) RLIKE ?
|
||||||
OR LOWER(bc.content) RLIKE ?
|
OR bp.ID IN (SELECT bpt.postID FROM blog_post_tags bpt WHERE bpt.tagID IN (SELECT bt.tagID FROM blog_tags bt WHERE (bt.name RLIKE ? OR LOWER(bt.displayname) RLIKE ?) AND lang = ?))
|
||||||
OR bp.postID IN (SELECT bpt.post_id FROM blog_post_tags bpt WHERE bpt.tag_id IN(SELECT bt.ID FROM blog_tags bt WHERE bt.name RLIKE ? OR LOWER(bt.display_name) RLIKE ?))
|
OR bp.ID IN (SELECT bpc.postID FROM blog_post_categories bpc WHERE bpc.categoryID IN (SELECT bc.categoryID FROM blog_categories bc WHERE (bc.name RLIKE ? OR LOWER(bc.displayname) RLIKE ?) AND lang = ?))
|
||||||
OR (SELECT username FROM users WHERE ID = bp.postAuthorID) RLIKE ?
|
OR (SELECT username FROM users WHERE ID = bp.authorID) RLIKE ?)
|
||||||
OR (SELECT display_name FROM blog_categories WHERE ID = bp.postCategoryID) RLIKE ?)
|
AND state = 1',
|
||||||
AND postState = 1 AND postIsDeleted = FALSE',
|
'attributes' => 'lqqqqqlqqlq'
|
||||||
'attributes' => 'llqqqqqqq'
|
|
||||||
],
|
],
|
||||||
'blogCategory' => [
|
'blogCategory' => [
|
||||||
'sql' => 'SELECT "blogCategory" type, c.name url, 1 author, null image, c.display_name title, null content, null date
|
'sql' => 'SELECT "blogCategory" type, c.name url, 1 author, null image, c.displayname title, null content, null date
|
||||||
FROM blog_categories c
|
FROM blog_categories c
|
||||||
WHERE c.name RLIKE ? OR LOWER(c.display_name) RLIKE ?',
|
WHERE (c.name RLIKE ? OR LOWER(c.displayname) RLIKE ?) AND lang = ?',
|
||||||
'attributes' => 'qq'
|
'attributes' => 'qql'
|
||||||
],
|
],
|
||||||
'blogTag' => [
|
'blogTag' => [
|
||||||
'sql' => 'SELECT "blogTag" type, t.name url, 1 author, null image, t.display_name title, null content, null date
|
'sql' => 'SELECT "blogTag" type, t.name url, 1 author, null image, t.displayname title, null content, null date
|
||||||
FROM blog_tags t
|
FROM blog_tags t
|
||||||
WHERE t.name RLIKE ? OR LOWER(t.display_name) RLIKE ?',
|
WHERE (t.name RLIKE ? OR LOWER(t.displayname) RLIKE ?) AND lang = ?',
|
||||||
'attributes' => 'qq'
|
'attributes' => 'qql'
|
||||||
],
|
],
|
||||||
'user' => [
|
'user' => [
|
||||||
'sql' => 'SELECT "user" type, u.username url, u.ID author, u.header_image image, u.displayname title, u.about content, u.date_created date
|
'sql' => 'SELECT "user" type, u.username url, u.ID author, s.headerImage image, u.displayname title, s.about content, u.dateCreated date
|
||||||
FROM users u
|
FROM users u
|
||||||
|
INNER JOIN user_settings s ON u.ID = s.ID
|
||||||
WHERE (username RLIKE ?
|
WHERE (username RLIKE ?
|
||||||
OR lower(about) RLIKE ?)
|
OR lower(about) RLIKE ?)
|
||||||
AND is_activated AND isDeleted = FALSE',
|
AND activated AND isDeleted = FALSE',
|
||||||
'attributes' => 'qq',
|
'attributes' => 'qq',
|
||||||
],
|
],
|
||||||
'userPost' => [
|
'userPost' => [
|
||||||
'sql' => 'SELECT "userPost" type, p.uuid url, p.user_id author, null image, p.content title, null content, p.date date
|
'sql' => 'SELECT "userPost" type, p.hashID url, p.userID author, null image, p.content title, null content, p.date date
|
||||||
FROM user_posts p
|
FROM user_posts p
|
||||||
WHERE LOWER(p.content) RLIKE ?
|
WHERE LOWER(p.content) RLIKE ?
|
||||||
OR (SELECT username FROM users WHERE ID = p.user_id) RLIKE ?',
|
OR (SELECT username FROM users WHERE ID = p.userID) RLIKE ?',
|
||||||
'attributes' => 'qq',
|
'attributes' => 'qq',
|
||||||
],
|
],
|
||||||
'project' => [
|
'project' => [
|
||||||
|
@ -100,9 +100,9 @@
|
||||||
'attributes' => 'lqqq',
|
'attributes' => 'lqqq',
|
||||||
],
|
],
|
||||||
'projectCategory' => [
|
'projectCategory' => [
|
||||||
'sql' => 'SELECT "projectCategory" type, c.collection url, 1 author, null image, c.displayname title, c.displayname content, null date
|
'sql' => 'SELECT "projectCategory" type, c.name url, 1 author, null image, c.displayname title, c.displayname content, null date
|
||||||
FROM projects_categories c
|
FROM projects_categories c
|
||||||
WHERE lower(collection) RLIKE ?
|
WHERE name RLIKE ?
|
||||||
OR lower(displayname) RLIKE ?',
|
OR lower(displayname) RLIKE ?',
|
||||||
'attributes' => 'qq'
|
'attributes' => 'qq'
|
||||||
],
|
],
|
||||||
|
@ -136,7 +136,6 @@
|
||||||
{
|
{
|
||||||
foreach ($results as $i => $result) {
|
foreach ($results as $i => $result) {
|
||||||
list(
|
list(
|
||||||
'author' => $author,
|
|
||||||
'authorDisplayname' => $displayname,
|
'authorDisplayname' => $displayname,
|
||||||
'authorName' => $username,
|
'authorName' => $username,
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
|
|
|
@ -1,113 +1,126 @@
|
||||||
<?php
|
<?php
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
class SocialMediaModel extends CI_Model
|
class SocialMediaModel extends CI_Model
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getSslPage($url) {
|
// private function getSslPage($url) {
|
||||||
$ch = curl_init();
|
// $ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||||
curl_setopt($ch, CURLOPT_HEADER, false);
|
// curl_setopt($ch, CURLOPT_HEADER, false);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
curl_setopt($ch, CURLOPT_URL, $url);
|
// curl_setopt($ch, CURLOPT_URL, $url);
|
||||||
curl_setopt($ch, CURLOPT_REFERER, $url);
|
// curl_setopt($ch, CURLOPT_REFERER, $url);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||||
$result = curl_exec($ch);
|
// $result = curl_exec($ch);
|
||||||
curl_close($ch);
|
// curl_close($ch);
|
||||||
return $result;
|
// return $result;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// public function getYouTubeVideos()
|
||||||
|
// {
|
||||||
|
// $apiUrl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=20&playlistId=UUEDHiXaIhm2VFu-hi6CcOWw&key=AIzaSyDAZ_TwVMZeiKDQxgWM2OYRq3YskEpY9yw';
|
||||||
|
// $apiResult = json_decode($this->getSslPage($apiUrl));
|
||||||
|
// $items = $apiResult->items;
|
||||||
|
// foreach ($items as $item) {
|
||||||
|
// $snippet = $item->snippet;
|
||||||
|
// $published = $snippet->publishedAt;
|
||||||
|
// $author = $snippet->channelTitle;
|
||||||
|
// $author_url = "https://youtube.com/channel/" . $snippet->channelId;
|
||||||
|
// $title = $snippet->title;
|
||||||
|
// if (isset($snippet->thumbnails->maxres->url)) $thumbnail = $snippet->thumbnails->maxres->url;
|
||||||
|
// else $thumbnail = $snippet->thumbnails->standard->url;
|
||||||
|
// $url = "http://youtu.be/" . $snippet->resourceId->videoId;
|
||||||
|
//
|
||||||
|
// $this->db->query('INSERT INTO social_posts (origin, post_content, post_url, post_author, post_author_url, date, post_img_source) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE post_content = ?, post_img_source = ?;', ["YouTube", $title, $url, $author, $author_url, strtotime($published), $thumbnail, $title, $thumbnail]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public function getTwitterPosts()
|
||||||
|
// {
|
||||||
|
// $consumer_key = 'TsUzd4stukv9Ix7TGG7RdYq4k';
|
||||||
|
// $consumer_key_secret = 'sTRq4WcELJZuciTrkNUttGgWhEiGaUkuqNhISgaG4uHRFgzm0B';
|
||||||
|
// $access_token = '1880071790-Nij2RaBDVRGVWoWW2PSJUwAvuLAOaQFAAr5tAtC';
|
||||||
|
// $access_token_secret = 'ldhLg0SP3ycrrdIqhNcddj0042pdGY9vmZMKQJRClmDkD';
|
||||||
|
//
|
||||||
|
// $oauth_hash = 'count=20&oauth_consumer_key=' . $consumer_key . '&oauth_nonce=' . time() . '&oauth_signature_method=HMAC-SHA1&oauth_timestamp=' . time() . '&oauth_token=' . $access_token . '&oauth_version=1.0';
|
||||||
|
// $base = 'GET&' . urlencode('https://api.twitter.com/1.1/statuses/user_timeline.json') . '&' . rawurlencode($oauth_hash);
|
||||||
|
// $key = rawurlencode($consumer_key_secret) . '&' . rawurlencode($access_token_secret);
|
||||||
|
// $signature = base64_encode(hash_hmac('sha1', $base, $key, true));
|
||||||
|
// $signature = rawurlencode($signature);
|
||||||
|
//
|
||||||
|
// $oauth_header = 'oauth_consumer_key="' . $consumer_key . '", oauth_nonce="' . time() . '", oauth_signature="' . $signature . '", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . time() . '", oauth_token="' . $access_token . '", oauth_version="1.0", ';
|
||||||
|
// $curl_header = array("Authorization: Oauth {$oauth_header}", 'Expect:');
|
||||||
|
//
|
||||||
|
// $curl_request = curl_init();
|
||||||
|
// curl_setopt($curl_request, CURLOPT_HTTPHEADER, $curl_header);
|
||||||
|
// curl_setopt($curl_request, CURLOPT_HEADER, false);
|
||||||
|
// curl_setopt($curl_request, CURLOPT_URL, 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=20');
|
||||||
|
// curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
// curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
|
||||||
|
// $json = curl_exec($curl_request);
|
||||||
|
// curl_close($curl_request);
|
||||||
|
//
|
||||||
|
// $posts = json_decode($json);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// foreach ($posts as $post) {
|
||||||
|
// $content = str_replace("\n", "<br>", $post->text);
|
||||||
|
// $author = $post->user->screen_name;
|
||||||
|
// $author_url = 'https://twitter.com/' . $author;
|
||||||
|
// $url = $author_url . '/status/' . $post->id_str;
|
||||||
|
// $published = strtotime($post->created_at);
|
||||||
|
// $original_id = $post->id_str;
|
||||||
|
// if (isset($post->extended_entities->media[0]->media_url)) {
|
||||||
|
// $image = $post->extended_entities->media[0]->media_url;
|
||||||
|
// } else {
|
||||||
|
// $image = '';
|
||||||
|
// }
|
||||||
|
// $this->db->query('INSERT INTO social_posts (origin, post_content, post_url, post_author, post_author_url, date, post_img_source, post_original_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE post_content = ?, post_author_url = ?, post_original_id = ?;', ["Twitter", $content, $url, $author, $author_url, $published, $image, $original_id, $content, $author_url, $original_id]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
public function getYouTubeVideos()
|
|
||||||
|
public function newestVids($vidCount)
|
||||||
{
|
{
|
||||||
$apiUrl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet%2CcontentDetails&maxResults=20&playlistId=UUEDHiXaIhm2VFu-hi6CcOWw&key=AIzaSyDAZ_TwVMZeiKDQxgWM2OYRq3YskEpY9yw';
|
$data = $this->db->query('SELECT * FROM social_posts WHERE origin = "YouTube" ORDER BY date DESC LIMIT ?', [$vidCount])->result_array();
|
||||||
$apiResult = json_decode($this->getSslPage($apiUrl));
|
|
||||||
$items = $apiResult->items;
|
|
||||||
foreach ($items as $item) {
|
|
||||||
$snippet = $item->snippet;
|
|
||||||
$published = $snippet->publishedAt;
|
|
||||||
$author = $snippet->channelTitle;
|
|
||||||
$author_url = "https://youtube.com/channel/" . $snippet->channelId;
|
|
||||||
$title = $snippet->title;
|
|
||||||
if (isset($snippet->thumbnails->maxres->url)) $thumbnail = $snippet->thumbnails->maxres->url;
|
|
||||||
else $thumbnail = $snippet->thumbnails->standard->url;
|
|
||||||
$url = "http://youtu.be/" . $snippet->resourceId->videoId;
|
|
||||||
|
|
||||||
$this->db->query('INSERT INTO social_posts (post_plattform, post_content, post_url, post_author, post_author_url, post_date, post_img_source) VALUES (?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE post_content = ?, post_img_source = ?;', ["YouTube", $title, $url, $author, $author_url, strtotime($published), $thumbnail, $title, $thumbnail]);
|
if (!empty($data)) {
|
||||||
}
|
return $data;
|
||||||
}
|
|
||||||
|
|
||||||
public function getTwitterPosts()
|
|
||||||
{
|
|
||||||
$consumer_key = 'TsUzd4stukv9Ix7TGG7RdYq4k';
|
|
||||||
$consumer_key_secret = 'sTRq4WcELJZuciTrkNUttGgWhEiGaUkuqNhISgaG4uHRFgzm0B';
|
|
||||||
$access_token = '1880071790-Nij2RaBDVRGVWoWW2PSJUwAvuLAOaQFAAr5tAtC';
|
|
||||||
$access_token_secret = 'ldhLg0SP3ycrrdIqhNcddj0042pdGY9vmZMKQJRClmDkD';
|
|
||||||
|
|
||||||
$oauth_hash = 'count=20&oauth_consumer_key=' . $consumer_key . '&oauth_nonce=' . time() . '&oauth_signature_method=HMAC-SHA1&oauth_timestamp=' . time() . '&oauth_token=' . $access_token . '&oauth_version=1.0';
|
|
||||||
$base = 'GET&' . urlencode('https://api.twitter.com/1.1/statuses/user_timeline.json') . '&' . rawurlencode($oauth_hash);
|
|
||||||
$key = rawurlencode($consumer_key_secret) . '&' . rawurlencode($access_token_secret);
|
|
||||||
$signature = base64_encode(hash_hmac('sha1', $base, $key, true));
|
|
||||||
$signature = rawurlencode($signature);
|
|
||||||
|
|
||||||
$oauth_header = 'oauth_consumer_key="' . $consumer_key . '", oauth_nonce="' . time() . '", oauth_signature="' . $signature . '", oauth_signature_method="HMAC-SHA1", oauth_timestamp="' . time() . '", oauth_token="' . $access_token . '", oauth_version="1.0", ';
|
|
||||||
$curl_header = array("Authorization: Oauth {$oauth_header}", 'Expect:');
|
|
||||||
|
|
||||||
$curl_request = curl_init();
|
|
||||||
curl_setopt($curl_request, CURLOPT_HTTPHEADER, $curl_header);
|
|
||||||
curl_setopt($curl_request, CURLOPT_HEADER, false);
|
|
||||||
curl_setopt($curl_request, CURLOPT_URL, 'https://api.twitter.com/1.1/statuses/user_timeline.json?count=20');
|
|
||||||
curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
curl_setopt($curl_request, CURLOPT_SSL_VERIFYPEER, false);
|
|
||||||
$json = curl_exec($curl_request);
|
|
||||||
curl_close($curl_request);
|
|
||||||
|
|
||||||
$posts = json_decode($json);
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($posts as $post) {
|
|
||||||
$content = str_replace("\n", "<br>", $post->text);
|
|
||||||
$author = $post->user->screen_name;
|
|
||||||
$author_url = 'https://twitter.com/' . $author;
|
|
||||||
$url = $author_url . '/status/' . $post->id_str;
|
|
||||||
$published = strtotime($post->created_at);
|
|
||||||
$original_id = $post->id_str;
|
|
||||||
if (isset($post->extended_entities->media[0]->media_url)) {
|
|
||||||
$image = $post->extended_entities->media[0]->media_url;
|
|
||||||
} else {
|
} else {
|
||||||
$image = '';
|
return null;
|
||||||
}
|
|
||||||
$this->db->query('INSERT INTO social_posts (post_plattform, post_content, post_url, post_author, post_author_url, post_date, post_img_source, post_original_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE post_content = ?, post_author_url = ?, post_original_id = ?;', ["Twitter", $content, $url, $author, $author_url, $published, $image, $original_id, $content, $author_url, $original_id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAllPosts()
|
public function getAllPosts()
|
||||||
{
|
{
|
||||||
$this->getTwitterPosts();
|
$this->getTwitterPosts();
|
||||||
$items = $this->db->query('SELECT * FROM social_posts ORDER BY post_date DESC')->result_array();
|
$items = $this->db->query('SELECT * FROM social_posts ORDER BY date DESC')->result_array();
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPosts($amount, $offset)
|
public function getPosts($amount, $offset)
|
||||||
{
|
{
|
||||||
if($offset == 0) {
|
if ($offset == 0) {
|
||||||
$items = $this->db->query('SELECT * FROM social_posts ORDER BY post_date DESC LIMIT ?', [$amount])->result_array();
|
$items = $this->db->query('SELECT * FROM social_posts ORDER BY date DESC LIMIT ?', [$amount])->result_array();
|
||||||
} else {
|
} else {
|
||||||
$items = $this->db->query('SELECT * FROM social_posts ORDER BY post_date DESC LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
$items = $this->db->query('SELECT * FROM social_posts ORDER BY date DESC LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostsOfCategory($amount, $offset, $category) {
|
public function getPostsOfCategory($amount, $offset, $category)
|
||||||
if($offset == 0) {
|
{
|
||||||
$items = $this->db->query('SELECT * FROM social_posts WHERE post_plattform LIKE ? ORDER BY post_date DESC LIMIT ?', [$category, $amount])->result_array();
|
if ($offset == 0) {
|
||||||
|
$items = $this->db->query('SELECT * FROM social_posts WHERE origin LIKE ? ORDER BY date DESC LIMIT ?', [$category, $amount])->result_array();
|
||||||
} else {
|
} else {
|
||||||
$items = $this->db->query('SELECT * FROM social_posts WHERE post_plattform LIKE ? ORDER BY post_date DESC LIMIT ? OFFSET ?', [$category, $amount, $offset])->result_array();
|
$items = $this->db->query('SELECT * FROM social_posts WHERE origin LIKE ? ORDER BY date DESC LIMIT ? OFFSET ?', [$category, $amount, $offset])->result_array();
|
||||||
}
|
}
|
||||||
return $items;
|
return $items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
function getUser($username)
|
function getUser($username)
|
||||||
{
|
{
|
||||||
$result = $this->db->query('SELECT ID, username, displayname, email, rank, profile_picture, header_image, about, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE username = ? AND is_activated = TRUE AND isDeleted = FALSE LIMIT 1', [$username])->result_array();
|
$result = $this->db->query('SELECT u.ID, u.username, u.displayname, u.email, u.rank, u.dateCreated, s.profilePicture, s.headerImage, s.about, s.socialNetworks, s.showAds, s.gender, s.language, s.country, s.birthdate, s.birthyear, s.receiveEmails, s.receiveNewsletter FROM users u INNER JOIN user_settings s ON s.ID = u.ID WHERE username = ? AND activated = TRUE AND isDeleted = FALSE LIMIT 1', [strtolower($username)])->result_array();
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -25,11 +25,11 @@
|
||||||
public function setDefaultImages($userList)
|
public function setDefaultImages($userList)
|
||||||
{
|
{
|
||||||
for ($i = 0; $i < sizeof($userList); $i++) {
|
for ($i = 0; $i < sizeof($userList); $i++) {
|
||||||
if ((isset($userList[$i]['header_image']) && ($userList[$i]['header_image'] == '' || $userList[$i]['header_image'] == NULL)) || !isset($userList[$i]['header_image'])) {
|
if ((isset($userList[$i]['headerImage']) && ($userList[$i]['headerImage'] == '' || $userList[$i]['headerImage'] == NULL)) || !isset($userList[$i]['headerImage'])) {
|
||||||
$userList[$i]['header_image'] = 'https://cdn.kinogofdog.eu' . '/' . $userList[$i]['displayname'];
|
$userList[$i]['headerImage'] = 'https://cdn.kinogofdog.eu' . '/' . $userList[$i]['displayname'];
|
||||||
}
|
}
|
||||||
if (isset($userList[$i]['profile_picture']) && $userList[$i]['profile_picture'] == '') {
|
if (isset($userList[$i]['profilePicture']) && $userList[$i]['profilePicture'] == '') {
|
||||||
$userList[$i]['profile_picture'] = base_url('/f/8d204712d8132b36d765640ce775ce15');
|
$userList[$i]['profilePicture'] = base_url('/f/8d204712d8132b36d765640ce775ce15');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $userList;
|
return $userList;
|
||||||
|
@ -51,7 +51,18 @@
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeFollowerCount($users) {
|
public function getFollowers($id)
|
||||||
|
{
|
||||||
|
$this->db->cache_off();
|
||||||
|
$followers = $this->db->query('SELECT u.ID, followedSince, username, displayname, profilePicture, headerImage FROM user_followers LEFT JOIN users u ON u.ID = followerUserID LEFT JOIN user_settings s ON s.ID = followerUserID WHERE followedUserID = ? AND u.activated = TRUE AND u.isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
|
||||||
|
$this->db->cache_on();
|
||||||
|
$followers = $this->setDefaultImages($followers);
|
||||||
|
$followers = $this->mergeFollowerCount($followers);
|
||||||
|
return $followers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mergeFollowerCount($users)
|
||||||
|
{
|
||||||
foreach ($users as $i => $user) {
|
foreach ($users as $i => $user) {
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$followerCount = $this->db->query('SELECT count(*) followerCount FROM user_followers WHERE followedUserID = ?', [$user['ID']])->result_array();
|
$followerCount = $this->db->query('SELECT count(*) followerCount FROM user_followers WHERE followedUserID = ?', [$user['ID']])->result_array();
|
||||||
|
@ -61,19 +72,9 @@
|
||||||
return $users;
|
return $users;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFollowers($id)
|
|
||||||
{
|
|
||||||
$this->db->cache_off();
|
|
||||||
$followers = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followerUserID WHERE followedUserID = ? AND is_activated = TRUE AND isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
|
|
||||||
$this->db->cache_on();
|
|
||||||
$followers = $this->setDefaultImages($followers);
|
|
||||||
$followers = $this->mergeFollowerCount($followers);
|
|
||||||
return $followers;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getUserByID($id)
|
function getUserByID($id)
|
||||||
{
|
{
|
||||||
$result = $this->db->query('SELECT ID, original_name, username, displayname, email, rank, profile_picture, header_image, is_activated, about, lastLogin, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE ID = ? AND is_activated = TRUE AND isDeleted = FALSE LIMIT 1', [$id])->result_array();
|
$result = $this->db->query('SELECT u.ID, originalName, username, displayname, email, rank, profilePicture, headerImage, activated, about, lastLogin, socialNetworks, showAds, dateCreated, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users u LEFT JOIN user_settings s ON s.ID = u.ID WHERE u.ID = ? AND activated = TRUE AND isDeleted = FALSE LIMIT 1', [$id])->result_array();
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -82,15 +83,16 @@
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserEmailByID($id) {
|
function getUserEmailByID($id)
|
||||||
$result = $this->db->query('SELECT email FROM users WHERE ID = ? AND is_activated = TRUE AND isDeleted = TRUE', [$id])->result_array();
|
{
|
||||||
|
$result = $this->db->query('SELECT email FROM users WHERE ID = ? AND activated = TRUE AND isDeleted = TRUE', [$id])->result_array();
|
||||||
return !empty($result) ? $result[0]['email'] : '';
|
return !empty($result) ? $result[0]['email'] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFollowing($id)
|
public function getFollowing($id)
|
||||||
{
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$following = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followedUserID WHERE followerUserID = ? AND isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
|
$following = $this->db->query('SELECT u.ID, followedSince, username, displayname, profilePicture, headerImage FROM user_followers LEFT JOIN users u ON u.ID = followedUserID LEFT JOIN user_settings s ON s.ID = followedUserID WHERE followerUserID = ? AND isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
$following = $this->setDefaultImages($following);
|
$following = $this->setDefaultImages($following);
|
||||||
$following = $this->mergeFollowerCount($following);
|
$following = $this->mergeFollowerCount($following);
|
||||||
|
@ -99,15 +101,15 @@
|
||||||
|
|
||||||
function getUserComments($id, $count, $offset)
|
function getUserComments($id, $count, $offset)
|
||||||
{
|
{
|
||||||
$comments = $this->db->query('SELECT *, p.postUrl FROM blog_comments c LEFT JOIN blog_posts p ON p.postID = c.post_id WHERE user_id = ? ORDER BY date_created DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
$comments = $this->db->query('SELECT c.* FROM blog_post_comments c WHERE userID = ? ORDER BY date DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
||||||
$comments = $this->BlogModel->mergePostTitleDesc($comments);
|
$comments = $this->BlogModel->mergePostTranslation($comments, false, null, 'postID');
|
||||||
return $comments;
|
return $comments;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserBlogPosts($id, $count, $offset)
|
function getUserBlogPosts($id, $count, $offset)
|
||||||
{
|
{
|
||||||
$posts = $this->db->query('SELECT * FROM blog_posts WHERE postIsDeleted = FALSE AND postState = 1 AND postAuthorID = ? ORDER BY postPublishDate DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
$posts = $this->db->query('SELECT * FROM blog_post WHERE state = 1 AND authorID = ? ORDER BY initialRelease DESC LIMIT ? OFFSET ?', [$id, $count, $offset])->result_array();
|
||||||
$posts = $this->BlogModel->mergePostTitleDesc($posts);
|
$posts = $this->BlogModel->mergePostTranslation($posts);
|
||||||
return $posts;
|
return $posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,11 +127,11 @@
|
||||||
FROM user_followers
|
FROM user_followers
|
||||||
WHERE followerUserID = ?) followedCount
|
WHERE followerUserID = ?) followedCount
|
||||||
FROM user_posts
|
FROM user_posts
|
||||||
WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
WHERE userID = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
$result['postCount'] = $user['postCount'];
|
$result['postCount'] = $user['postCount'];
|
||||||
$result['followerCount'] = $user['followerCount'];
|
$result['followerCount'] = $user['followerCount'];
|
||||||
$result['followedCount'] = $user['followedCount'];
|
$result['followedCount'] = $user['followedCount'];
|
||||||
$blogResults = $this->db->query('SELECT COUNT(*) blogCount, (SELECT COUNT(*) FROM blog_comments WHERE user_id = ?) commentCount FROM blog_posts WHERE postIsDeleted = FALSE AND postState = 1 AND postAuthorID = ?', [$userID, $userID])->result_array()[0];
|
$blogResults = $this->db->query('SELECT COUNT(*) blogCount, (SELECT COUNT(*) FROM blog_post_comments WHERE userID = ?) commentCount FROM blog_post WHERE state = 1 AND authorID = ?', [$userID, $userID])->result_array()[0];
|
||||||
$result['blogCount'] = $blogResults['blogCount'];
|
$result['blogCount'] = $blogResults['blogCount'];
|
||||||
$result['commentCount'] = $blogResults['commentCount'];
|
$result['commentCount'] = $blogResults['commentCount'];
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
@ -162,19 +164,39 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
|
|
||||||
function updateProfile($data, $id)
|
function updateProfile($data, $id)
|
||||||
{
|
{
|
||||||
|
function in_data1($val) {
|
||||||
|
return in_array($val, ['username', 'displayname', 'email', 'password']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data1 = array_filter($data, "in_data1");
|
||||||
|
if(!empty($data1)) {
|
||||||
$this->db->where('ID', $id);
|
$this->db->where('ID', $id);
|
||||||
$this->db->update('users', $data);
|
$this->db->update('users', $data1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data2 = array_diff($data, $data1);
|
||||||
|
if(!empty($data2)) {
|
||||||
|
$this->db->where('ID', $id);
|
||||||
|
$this->db->update('user_settings', $data2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertIntoHistory($data)
|
function insertIntoHistory($data)
|
||||||
{
|
{
|
||||||
unset($data['date_created']);
|
if(isset($data['password'])) {
|
||||||
$this->db->insert('users_history', $data);
|
unset($data['password']);
|
||||||
|
$data['passwordChanged'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->db->insert('user_settings_history', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserList($amount, $offset)
|
function getUserList($amount, $offset)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT ID, username, displayname, rank, profile_picture, header_image, is_activated, showAds, receiveEmails, receiveNewsletter, date_created, isCurrentlyOnline, lastLogin, login_method, language, country, gender FROM users LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
$data = $this->db->query('SELECT u.ID, username, displayname, rank, profilePicture, headerImage, activated, showAds, receiveEmails, receiveNewsletter, dateCreated, isCurrentlyOnline, lastLogin, loginMethod, language, country, gender
|
||||||
|
FROM users u
|
||||||
|
LEFT JOIN user_settings s ON u.ID = s.ID
|
||||||
|
LIMIT ? OFFSET ?', [$amount, $offset])->result_array();
|
||||||
$data = $this->setDefaultImages($data);
|
$data = $this->setDefaultImages($data);
|
||||||
$data = $this->setRankname($data);
|
$data = $this->setRankname($data);
|
||||||
return $data;
|
return $data;
|
||||||
|
@ -187,34 +209,35 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
|
|
||||||
function getActiveUsers($count)
|
function getActiveUsers($count)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT username, displayname, profile_picture, lastLogin, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE isCurrentlyOnline = TRUE AND is_activated = TRUE AND isDeleted = FALSE ORDER BY lastLogin DESC LIMIT ?', [$count])->result_array();
|
$data = $this->db->query('SELECT username, displayname, profilePicture, lastLogin, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = u.ID) follower_count FROM users u LEFT JOIN user_settings s ON s.ID = u.ID WHERE isCurrentlyOnline = TRUE AND activated = TRUE AND isDeleted = FALSE ORDER BY lastLogin DESC LIMIT ?', [$count])->result_array();
|
||||||
$data = $this->setDefaultImages($data);
|
$data = $this->setDefaultImages($data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNewestUsers($count)
|
public function getNewestUsers($count)
|
||||||
{
|
{
|
||||||
$data = $this->db->query('SELECT username, displayname, profile_picture, date_created, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE is_activated = TRUE AND isDeleted = FALSE ORDER BY date_created DESC LIMIT ?', [$count])->result_array();
|
$data = $this->db->query('SELECT username, displayname, profilePicture, dateCreated, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = u.ID) follower_count FROM users u LEFT JOIN user_settings s ON s.ID = u.ID WHERE activated = TRUE AND isDeleted = FALSE ORDER BY dateCreated DESC LIMIT ?', [$count])->result_array();
|
||||||
$data = $this->setDefaultImages($data);
|
$data = $this->setDefaultImages($data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchUsers($query, $rank = '', $region = '', $lang = '', $amount = 3, $offset = 0) {
|
public function searchUsers($query, $rank = '', $region = '', $lang = '', $amount = 3, $offset = 0)
|
||||||
|
{
|
||||||
$conditions = [];
|
$conditions = [];
|
||||||
$inputs = [];
|
$inputs = [];
|
||||||
if($query !== '') {
|
if ($query !== '') {
|
||||||
$conditions[] = 'username RLIKE ?';
|
$conditions[] = 'username RLIKE ?';
|
||||||
$inputs[] = $query;
|
$inputs[] = $query;
|
||||||
}
|
}
|
||||||
if($rank !== '') {
|
if ($rank !== '') {
|
||||||
$conditions[] = 'rank = ?';
|
$conditions[] = 'rank = ?';
|
||||||
$inputs[] = $rank;
|
$inputs[] = $rank;
|
||||||
}
|
}
|
||||||
if($region !== '') {
|
if ($region !== '') {
|
||||||
$conditions[] = 'country = ?';
|
$conditions[] = 'country = ?';
|
||||||
$inputs[] = $region;
|
$inputs[] = $region;
|
||||||
}
|
}
|
||||||
if($lang !== '') {
|
if ($lang !== '') {
|
||||||
$conditions[] = 'language = ?';
|
$conditions[] = 'language = ?';
|
||||||
$inputs[] = $lang;
|
$inputs[] = $lang;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +245,7 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
$dbClause = join(' AND ', $conditions);
|
$dbClause = join(' AND ', $conditions);
|
||||||
$inputs[] = $amount;
|
$inputs[] = $amount;
|
||||||
$inputs[] = $offset;
|
$inputs[] = $offset;
|
||||||
$data = $this->db->query('SELECT username, displayname, profile_picture, header_image, about, rank FROM users WHERE is_activated = TRUE AND isDeleted = FALSE AND ' . $dbClause . ' LIMIT ? OFFSET ?', $inputs)->result_array();
|
$data = $this->db->query('SELECT username, displayname, profilePicture, headerImage, about, rank FROM users u LEFT JOIN user_settings s ON s.ID = u.ID WHERE activated = TRUE AND isDeleted = FALSE AND ' . $dbClause . ' LIMIT ? OFFSET ?', $inputs)->result_array();
|
||||||
|
|
||||||
$data = $this->setDefaultImages($data);
|
$data = $this->setDefaultImages($data);
|
||||||
$data = $this->setRankname($data);
|
$data = $this->setRankname($data);
|
||||||
|
@ -230,19 +253,23 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvailableCountries() {
|
public function getAvailableCountries()
|
||||||
return $this->db->query('SELECT country, count(*) countryUserCount FROM users WHERE country IS NOT NULL AND country != "" GROUP BY country ORDER BY country')->result_array();
|
{
|
||||||
|
return $this->db->query('SELECT country, count(*) countryUserCount FROM user_settings WHERE country IS NOT NULL AND country != "" GROUP BY country ORDER BY country')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getAvailableLanguages() {
|
public function getAvailableLanguages()
|
||||||
return $this->db->query('SELECT language, count(*) langUserCount FROM users GROUP BY language ORDER BY language')->result_array();
|
{
|
||||||
|
return $this->db->query('SELECT language, count(*) langUserCount FROM user_settings GROUP BY language ORDER BY language')->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteUser($id) {
|
public function deleteUser($id)
|
||||||
|
{
|
||||||
$this->db->query('UPDATE users SET isDeleted = TRUE, isCurrentlyOnline = FALSE, lastOnlineUpdate = NULL WHERE ID = ?', [$id])->result_array();
|
$this->db->query('UPDATE users SET isDeleted = TRUE, isCurrentlyOnline = FALSE, lastOnlineUpdate = NULL WHERE ID = ?', [$id])->result_array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPermissions($userID) {
|
public function getPermissions($userID)
|
||||||
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$result = $this->db->query('SELECT * FROM user_permissions WHERE userID = ?', [$userID])->result_array();
|
$result = $this->db->query('SELECT * FROM user_permissions WHERE userID = ?', [$userID])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
|
@ -256,18 +283,21 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
|
||||||
return $perms;
|
return $perms;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasPermission($userID, $permType, $permName) {
|
public function hasPermission($userID, $permType, $permName)
|
||||||
|
{
|
||||||
$this->db->cache_off();
|
$this->db->cache_off();
|
||||||
$result = $this->db->query('SELECT ID FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permType, $permName])->result_array();
|
$result = $this->db->query('SELECT ID FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permType, $permName])->result_array();
|
||||||
$this->db->cache_on();
|
$this->db->cache_on();
|
||||||
return !empty($result);
|
return !empty($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addPermission($userID, $permissionGroup, $permissionName, $givenBy) {
|
public function addPermission($userID, $permissionGroup, $permissionName, $givenBy)
|
||||||
|
{
|
||||||
$this->db->query('INSERT INTO user_permissions (userID, permissionType, permissionName, givenBy) VALUES (?, ?, ?, ?)', [$userID, $permissionGroup, $permissionName, $givenBy]);
|
$this->db->query('INSERT INTO user_permissions (userID, permissionType, permissionName, givenBy) VALUES (?, ?, ?, ?)', [$userID, $permissionGroup, $permissionName, $givenBy]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function revokePermission($userID, $permissionGroup, $permissionName) {
|
public function revokePermission($userID, $permissionGroup, $permissionName)
|
||||||
|
{
|
||||||
$this->db->query('DELETE FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permissionGroup, $permissionName]);
|
$this->db->query('DELETE FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permissionGroup, $permissionName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
application/views/admin/blog/templates/post_reference.php
Normal file
10
application/views/admin/blog/templates/post_reference.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Titel</h5>
|
||||||
|
<p class="card-text"></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -125,9 +125,8 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
<input type="hidden" value="<?= $postID ?>" id="postID">
|
<input type="hidden" value="<?= $postID ?>" id="postID">
|
||||||
<input type="hidden" value="<?= isset($contents[$postLanguage]) ? $contents[$postLanguage] : $contents['de'] ?>" id="contentID">
|
<input type="hidden" value="<?= isset($versions[$lang]) ? $versions[$lang] : $versions['de'] ?>" id="versionID">
|
||||||
<input type="hidden" value="<?= $translations[$postLanguage] ?>" id="translationID">
|
<input type="hidden" value="<?= $lang ?>" id="postLanguage">
|
||||||
<input type="hidden" value="<?= $postLanguage ?>" id="postLanguage">
|
|
||||||
<input type="hidden" value="" id="uploadedImage">
|
<input type="hidden" value="" id="uploadedImage">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="blog">
|
<div class="blog">
|
||||||
|
@ -157,11 +156,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
<div>
|
<div>
|
||||||
<i class="fa fa-folder-open"></i>
|
<i class="fa fa-folder-open"></i>
|
||||||
<div class="category-select" style="display: inline-block;">
|
<div class="category-select" style="display: inline-block;">
|
||||||
<select class="form-control" id="postCategory">
|
<select class="form-control" id="postCategory" multiple>
|
||||||
<option value="new-category">-- Neue Kategorie --</option>
|
<option value="new-category">-- Neue Kategorie --</option>
|
||||||
<?php foreach ($categories as $category) { ?>
|
<?php foreach ($categories as $category) { ?>
|
||||||
<option value="<?= $category['ID'] ?>">
|
<option value="<?= $category['ID'] ?>">
|
||||||
<?= $category['display_name'] ?>
|
<?= $category['displayname'] ?>
|
||||||
</option>
|
</option>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</select>
|
</select>
|
||||||
|
@ -244,13 +243,13 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
</div>
|
</div>
|
||||||
<div class="x_content">
|
<div class="x_content">
|
||||||
<ul class="nav nav-pills nav-stacked" id="switchLanguages">
|
<ul class="nav nav-pills nav-stacked" id="switchLanguages">
|
||||||
<li role="presentation" class="<?= $postLanguage == 'de' ? 'active' : '' ?>" data-lang="de" data-translationID="<?= $translations['de'] ?>" data-contentID="<?= $contents['de'] ?>">
|
<li role="presentation" class="<?= $lang == 'de' ? 'active' : '' ?>" data-lang="de" data-versionID="<?= $versions['de'] ?>">
|
||||||
<span class="flag-icon flag-icon-de"></span> Deutsch
|
<span class="flag-icon flag-icon-de"></span> Deutsch
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation" class="<?= $postLanguage == 'en' ? 'active' : '' ?>" data-lang="en" data-translationID="<?= isset($translations['en']) ? $translations['en'] : -1 ?>" data-contentID="<?= isset($contents['en']) ? $contents['en'] : -1 ?>">
|
<li role="presentation" class="<?= $lang == 'en' ? 'active' : '' ?>" data-lang="en" data-versionID="<?= isset($versions['en']) ? $versions['en'] : -1 ?>">
|
||||||
<span class="flag-icon flag-icon-us"></span> Englisch
|
<span class="flag-icon flag-icon-us"></span> Englisch
|
||||||
</li>
|
</li>
|
||||||
<li role="presentation" class="<?= $postLanguage == 'fr' ? 'active' : '' ?>" data-lang="fr" data-translationID="<?= isset($translations['fr']) ? $translations['fr'] : -1 ?>" data-contentID="<?= isset($contents['fr']) ? $contents['fr'] : -1 ?>">
|
<li role="presentation" class="<?= $lang == 'fr' ? 'active' : '' ?>" data-lang="fr" data-versionID="<?= isset($versions['fr']) ? $versions['fr'] : -1 ?>">
|
||||||
<span class="flag-icon flag-icon-fr"></span> Französisch
|
<span class="flag-icon flag-icon-fr"></span> Französisch
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
require_once './vendor/Diff/htmLawed.php';
|
||||||
|
require_once './vendor/Diff/class.Diff.php';
|
||||||
?>
|
?>
|
||||||
<div class="right_col" role="main">
|
<div class="right_col" role="main">
|
||||||
<div class="">
|
<div class="">
|
||||||
|
@ -12,37 +15,64 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="x_content">
|
<div class="x_content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="compare-items-container">
|
||||||
|
<div class="compare-items row">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<a href="#" class="btn btn-sm btn-primary compare-btn" disabled="">Vergleichen</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row" style="width: auto; overflow-x:scroll;">
|
||||||
<?php foreach ($content as $language => $items): ?>
|
<?php foreach ($content as $language => $items): ?>
|
||||||
<div class="col-sm-3">
|
<div class="col-12">
|
||||||
<h3><?= $language ?></h3>
|
<h3><?= $language ?></h3>
|
||||||
|
|
||||||
|
<!-- --><?php //echo Diff::toHTML(Diff::compare("Hallo!\n Peter Enis\nFotze", "Hallo.\n Peter Penis\nFotze")) ?>
|
||||||
|
|
||||||
<ul class="list-unstyled timeline">
|
<ul class="list-unstyled timeline">
|
||||||
<?php foreach ($items as $item): ?>
|
<?php foreach ($items as $i => $item): ?>
|
||||||
<li>
|
<li>
|
||||||
<div class="block">
|
<div class="block">
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<?php if ($item['isActive'] == 1): ?>
|
<?php if ($item['active'] == 1): ?>
|
||||||
<a class="tag">
|
<a class="tag">
|
||||||
<span>Aktiv</span>
|
<span>Aktiv</span>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($item['isNativePost'] == 1): ?>
|
|
||||||
<a class="tag">
|
|
||||||
<span>Original-Version</span>
|
|
||||||
</a>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="block_content">
|
<div class="block_content">
|
||||||
<h2 class="title">
|
<h2 class="title">
|
||||||
<?= $item['versionMessage'] ?>
|
<span class="badge badge-default"><?= substr($item['hashID'], 0, 8) ?></span>
|
||||||
|
<?= $item['changes'] ?>
|
||||||
</h2>
|
</h2>
|
||||||
<div class="byline">
|
<div class="byline">
|
||||||
<span><?= date("d.m.Y \u\m H:i", strtotime($item['contentDate'])) ?> Uhr</span>
|
<span><?= date("d.m.Y \u\m H:i", strtotime($item['edited'])) ?> Uhr</span>
|
||||||
von
|
von
|
||||||
<?php $author = $this->BlogModel->getAuthorData($item['contentAuthorID']) ?>
|
<?php $author = $this->BlogModel->getAuthorData($item['authorID']) ?>
|
||||||
<a href="/user/<?= $author['username'] ?>"><?= $author['displayname'] ?></a>
|
<a href="/user/<?= $author['username'] ?>"><?= $author['displayname'] ?></a>
|
||||||
</div>
|
</div>
|
||||||
<p class="excerpt"><?= $item['content'] ?>
|
<p class="excerpt">
|
||||||
|
Titel:
|
||||||
|
<i><?= $item['title'] ?></i>
|
||||||
|
<br>
|
||||||
|
Beschreibung:
|
||||||
|
<i><?= $item['description'] ?></i>
|
||||||
</p>
|
</p>
|
||||||
|
<div class="actions">
|
||||||
|
<button class="btn btn-sm btn-primary">
|
||||||
|
Ansehen
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-sm btn-default history-compare" data-hashID="<?= $item['hashID'] ?>">
|
||||||
|
Vergleichen mit...
|
||||||
|
</button>
|
||||||
|
<?php if (!$item['active']): ?>
|
||||||
|
<button class="btn btn-sm btn-default">
|
||||||
|
Aktivieren
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -36,33 +36,33 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($posts as $post) { ?>
|
<?php foreach ($posts as $post) { ?>
|
||||||
<tr id="post-<?= $post['postID'] ?>">
|
<tr id="post-<?= $post['ID'] ?>">
|
||||||
<td>
|
<td>
|
||||||
<?= $post['postID'] ?>
|
<?= $post['ID'] ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= base_url('blog/post/' . $post['postUrl']) ?>" target="_blank"><?= $post['postTitle'] ?></a>
|
<a href="<?= base_url('blog/post/' . $post['url']) ?>" target="_blank"><?= $post['title'] ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $post['postDesc'] ?>
|
<?= substr($post['description'], 0, 40) ?>...
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $post['postStateDisplay'] ?>
|
<?= $post['stateName'] ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= date('d.m.Y H:i', strtotime($post['postPublishDate'])) ?>
|
<?= date('d.m.Y H:i', strtotime($post['initialRelease'])) ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= date('d.m.Y H:i', strtotime($post['postLastEdit'])) ?>
|
<?= date('d.m.Y H:i', strtotime($post['lastEdit'])) ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= base_url('user/' . $post['postAuthorUsername']) ?>" target="_blank"><?= $post['postAuthorDisplayname'] ?></a>
|
<a href="<?= base_url('user/' . $post['author']['displayname']) ?>" target="_blank"><?= $post['author']['displayname'] ?></a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= base_url('blog/category/' . $post['categoryName']) ?>" target="_blank"><?= $post['categoryDisplayName'] ?></a>
|
<!-- <a href="--><?//= base_url('blog/category/' . $post['categoryName']) ?><!--" target="_blank">--><?//= $post['categoryDisplayName'] ?><!--</a>-->
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $post['postViews'] ?>
|
<?= $post['views'] ?>
|
||||||
<i class="fa fa-eye"></i>
|
<i class="fa fa-eye"></i>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -75,30 +75,30 @@
|
||||||
</td>
|
</td>
|
||||||
<?php if (isset($trashbin) && $trashbin): ?>
|
<?php if (isset($trashbin) && $trashbin): ?>
|
||||||
<td>
|
<td>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Bearbeiten" href="<?= base_url('admin/blog/edit/' . $post['postID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Bearbeiten" href="<?= base_url('admin/blog/edit/' . $post['ID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="History" href="<?= base_url('admin/blog/history/' . $post['postID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="History" href="<?= base_url('admin/blog/history/' . $post['ID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
||||||
<i class="fa fa-history"></i>
|
<i class="fa fa-history"></i>
|
||||||
</a>
|
</a>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Wiederherstellen" onclick="restorePost(<?= $post['postID'] ?>)" class="btn btn-xs btn-green">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Wiederherstellen" onclick="restorePost(<?= $post['ID'] ?>)" class="btn btn-xs btn-green">
|
||||||
<i class="fa fa-undo"></i>
|
<i class="fa fa-undo"></i>
|
||||||
</a>
|
</a>
|
||||||
<a href="" data-toggle="tooltip" data-placement="top" title="Endgültig löschen">
|
<a href="" data-toggle="tooltip" data-placement="top" title="Endgültig löschen">
|
||||||
<button type="button" class="btn btn-xs btn-red" data-toggle="modal" data-target="#deleteModal" data-type="Blog-Post" data-title="<?= $post['postTitle'] ?>" data-id="<?= $post['postID'] ?>">
|
<button type="button" class="btn btn-xs btn-red" data-toggle="modal" data-target="#deleteModal" data-type="Blog-Post" data-title="<?= $post['title'] ?>" data-id="<?= $post['ID'] ?>">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<td>
|
<td>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Bearbeiten" href="<?= base_url('admin/blog/edit/' . $post['postID'] . '/') ?>" target="_blank" class="btn btn-xs btn-default">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Bearbeiten" href="<?= base_url('admin/blog/edit/' . $post['ID'] . '/') ?>" target="_blank" class="btn btn-xs btn-default">
|
||||||
<i class="fa fa-edit"></i>
|
<i class="fa fa-edit"></i>
|
||||||
</a>
|
</a>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="History" href="<?= base_url('admin/blog/history/' . $post['postID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="History" href="<?= base_url('admin/blog/history/' . $post['ID']) ?>" target="_blank" class="btn btn-xs btn-default">
|
||||||
<i class="fa fa-history"></i>
|
<i class="fa fa-history"></i>
|
||||||
</a>
|
</a>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Löschen" onclick="deletePost(<?= $post['postID'] ?>)" class="btn btn-xs btn-red">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Löschen" onclick="deletePost(<?= $post['ID'] ?>)" class="btn btn-xs btn-red">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -90,23 +90,37 @@
|
||||||
<table id="datatable-fixed-header" class="table table-striped table-bordered">
|
<table id="datatable-fixed-header" class="table table-striped table-bordered">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>ID</th>
|
<th rowspan="2">ID</th>
|
||||||
<th>Name</th>
|
<th colspan="3">Name</th>
|
||||||
<th>Titel - Deutsch</th>
|
<th colspan="3">Titel</th>
|
||||||
<th>Titel - English</th>
|
<th rowspan="2">Anzahl Einträge</th>
|
||||||
<th>Titel - Französisch</th>
|
<th rowspan="2">Tools</th>
|
||||||
<th>Anzahl Einträge</th>
|
</tr>
|
||||||
<th>Tools</th>
|
<tr>
|
||||||
|
<th>Deutsch</th>
|
||||||
|
<th>Englisch</th>
|
||||||
|
<th>Französisch</th>
|
||||||
|
<th>Deutsch</th>
|
||||||
|
<th>Englisch</th>
|
||||||
|
<th>Französisch</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($categories as $c) { ?>
|
<?php foreach ($categories as $c) {
|
||||||
|
$names = explode(',', $c['name']);
|
||||||
|
$displaynames = explode(',', $c['displayname']);
|
||||||
|
?>
|
||||||
<tr id="category-<?= $c['ID'] ?>">
|
<tr id="category-<?= $c['ID'] ?>">
|
||||||
<td><?= $c['ID'] ?></td>
|
<td><?= $c['ID'] ?></td>
|
||||||
<td><?= $c['collection'] ?></td>
|
|
||||||
<td><?= $c['displayname'] ?></td>
|
<td><?= isset($names[0]) ? $names[0] : '' ?></td>
|
||||||
<td><?= $c['displaynameEnglish'] ?></td>
|
<td><?= isset($names[1]) ? $names[1] : '' ?></td>
|
||||||
<td><?= $c['displaynameFrench'] ?></td>
|
<td><?= isset($names[2]) ? $names[2] : '' ?></td>
|
||||||
|
|
||||||
|
<td><?= isset($displaynames[0]) ? $displaynames[0] : '' ?></td>
|
||||||
|
<td><?= isset($displaynames[1]) ? $displaynames[1] : '' ?></td>
|
||||||
|
<td><?= isset($displaynames[2]) ? $displaynames[2] : '' ?></td>
|
||||||
|
|
||||||
<td><?= $c['count'] ?></td>
|
<td><?= $c['count'] ?></td>
|
||||||
<td>
|
<td>
|
||||||
<button type="button" class="btn btn-xs btn-red" data-toggle="modal" data-target="#deleteModal" data-type="Projekt-Kategorie" data-title="<?= $c['displayname'] ?>" data-id="<?= $c['ID'] ?>">
|
<button type="button" class="btn btn-xs btn-red" data-toggle="modal" data-target="#deleteModal" data-type="Projekt-Kategorie" data-title="<?= $c['displayname'] ?>" data-id="<?= $c['ID'] ?>">
|
||||||
|
|
|
@ -16,18 +16,18 @@ use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||||
<div class="x_content">
|
<div class="x_content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-2">
|
<div class="col-sm-2">
|
||||||
<img src="<?= $user['profile_picture'] ?>" class="img-fluid">
|
<img src="<?= $user['profilePicture'] ?>" class="img-fluid">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<h3><a href="<?= base_url('user/' . $user['username']) ?>"
|
<h3><a href="<?= base_url('user/' . $user['username']) ?>"
|
||||||
target="_blank"><?= $user['displayname'] ?></a></h3>
|
target="_blank"><?= $user['displayname'] ?></a></h3>
|
||||||
<?php $created_at = strtotime($user['date_created']); ?>
|
<?php $created_at = strtotime($user['dateCreated']); ?>
|
||||||
<p>
|
<p>
|
||||||
<b>Account erstellt: </b>
|
<b>Account erstellt: </b>
|
||||||
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$created_at"), "de_DE") ?>
|
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$created_at"), "de_DE") ?>
|
||||||
<i>(<?= date("d.m.Y H:i", $created_at) ?>)</i>
|
<i>(<?= date("d.m.Y H:i", $created_at) ?>)</i>
|
||||||
</p>
|
</p>
|
||||||
<p><b>Originaler Name:</b> <?= $user['original_name'] ?></p>
|
<p><b>Originaler Name:</b> <?= $user['originalName'] ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row col-sm-12">
|
<div class="row col-sm-12">
|
||||||
|
@ -55,7 +55,7 @@ use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<b>Aktiviert?</b>
|
<b>Aktiviert?</b>
|
||||||
<?= $user['is_activated'] ? '<i class="fa fa-check-circle-o"></i> Ja' : '<i class="fa fa-times-circle-o"></i>Nein' ?>
|
<?= $user['activated'] ? '<i class="fa fa-check-circle-o"></i> Ja' : '<i class="fa fa-times-circle-o"></i>Nein' ?>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<b>Zeige Werbung?</b>
|
<b>Zeige Werbung?</b>
|
||||||
|
|
|
@ -53,9 +53,9 @@
|
||||||
2 => "Twitter",
|
2 => "Twitter",
|
||||||
3 => "GitHub"
|
3 => "GitHub"
|
||||||
];
|
];
|
||||||
$loginMethod = $loginMethods[$user['login_method']];
|
$loginMethod = $loginMethods[$user['loginMethod']];
|
||||||
|
|
||||||
$dateCreated = strtotime($user['date_created']);
|
$dateCreated = strtotime($user['dateCreated']);
|
||||||
$lastLogin = strtotime($user['lastLogin']);
|
$lastLogin = strtotime($user['lastLogin']);
|
||||||
$dateCreatedStr = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), "de_DE");
|
$dateCreatedStr = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), "de_DE");
|
||||||
if($lastLogin)
|
if($lastLogin)
|
||||||
|
@ -82,12 +82,12 @@
|
||||||
(<?= date("d.m.Y H:i", $dateCreated) ?>)
|
(<?= date("d.m.Y H:i", $dateCreated) ?>)
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<img src="<?= $user['profile_picture'] ?>?w=50" class="img-fluid rounded"
|
<img src="<?= $user['profilePicture'] ?>?w=50" class="img-fluid rounded"
|
||||||
alt="Profilbild"
|
alt="Profilbild"
|
||||||
style="max-height: 50px;">
|
style="max-height: 50px;">
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $user['is_activated'] ? "<i class='fa fa-check-circle'></i> Ja" : "<i class='fa fa-times-circle'></i> Nein" ?>
|
<?= $user['activated'] ? "<i class='fa fa-check-circle'></i> Ja" : "<i class='fa fa-times-circle'></i> Nein" ?>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?= $user['showAds'] ? '<i class="fa fa-check-circle"></i> Ja' : '<i class="fa fa-times-circle"></i> Nein' ?>
|
<?= $user['showAds'] ? '<i class="fa fa-check-circle"></i> Ja' : '<i class="fa fa-times-circle"></i> Nein' ?>
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if(get_instance()->hasPermission('user.ban')): ?>
|
<?php if(get_instance()->hasPermission('user.ban')): ?>
|
||||||
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Account löschen" onclick="showDeleteModal(<?= $user['ID'] ?>. <?= $user['username'] ?>)" target="_blank" class="btn btn-xs btn-red">
|
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Account löschen" onclick="showDeleteModal(<?= $user['ID'] ?>.; <?= $user['username'] ?>)" target="_blank" class="btn btn-xs btn-red">
|
||||||
<i class="fas fa-user-slash"></i>
|
<i class="fas fa-user-slash"></i>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<div class="well comment-well">
|
<div class="well comment-well">
|
||||||
<div class="d-inline-block mr-2">
|
<div class="d-inline-block mr-2">
|
||||||
<a href="<?= base_url('user/' . $author['username']) ?>" target="_blank">
|
<a href="<?= base_url('user/' . $author['username']) ?>" target="_blank">
|
||||||
<img src="<?= $author['profile_picture'] ?>" alt="">
|
<img src="<?= $author['profilePicture'] ?>" alt="">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-inline-block mr-2">
|
<div class="d-inline-block mr-2">
|
||||||
|
@ -16,7 +16,7 @@
|
||||||
<?= $author['displayname'] ?>
|
<?= $author['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
/
|
/
|
||||||
<?= date('d.m.Y H:i \\U\\h\\r', strtotime($date_created)) ?></small>
|
<?= date('d.m.Y H:i \\U\\h\\r', strtotime($date)) ?></small>
|
||||||
</h3>
|
</h3>
|
||||||
<p class="comment">
|
<p class="comment">
|
||||||
<?= $comment ?>
|
<?= $comment ?>
|
||||||
|
|
25
application/views/blog/delete_modal.php
Normal file
25
application/views/blog/delete_modal.php
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form id="postDeleteForm">
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<p>
|
||||||
|
<b>Bist du dir wirklich sicher, dass du deinen Kommentar löschen willst?</b>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<i>Diese Aktion kann nicht rückgängig gemacht werden!</i>
|
||||||
|
</p>
|
||||||
|
<ul class="comment-list" style="pointer-events: none">
|
||||||
|
<?php
|
||||||
|
$this->load->view('network/blog/comment_item', ['data' => $author, 'c' => $comment, 'hideActionBtns' => true]) ?>
|
||||||
|
</ul>
|
||||||
|
<!-- --><?php //var_dump($post) ?>
|
||||||
|
</div>
|
||||||
|
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
|
||||||
|
Nein, Kommentar behalten
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deleteComment(<?= $comment['ID'] ?>)">
|
||||||
|
Ja, endgültig löschen
|
||||||
|
</button>
|
||||||
|
</form>
|
|
@ -5,7 +5,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="notice-container navbar-fixed-bottom"></div>
|
<div class="notice-container navbar-fixed-bottom"></div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<aside class="col-sm-4 col-sm-push-8">
|
<aside class="col-lg-4 order-lg-last">
|
||||||
<div class="widget search">
|
<div class="widget search">
|
||||||
<form role="form" action="/blog/search">
|
<form role="form" action="/blog/search">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
|
@ -35,15 +35,15 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
<?php foreach ($categoryPosts as $post) { ?>
|
<?php foreach ($categoryPosts as $post) { ?>
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<?php if (!empty($post['postImage'])): ?>
|
<?php if (!empty($post['image'])): ?>
|
||||||
<a href="<?= base_url('blog/post/' . $post['postUrl']); ?>">
|
<a href="<?= base_url('blog/post/' . $post['url']); ?>">
|
||||||
<img src="<?= $post['postImage']; ?>?w=300" class="img-fluid rounded post-image">
|
<img src="<?= $post['image']; ?>?w=300" class="img-fluid rounded post-image">
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<div class="media-heading">
|
<div class="media-heading">
|
||||||
<a href="<?= base_url('blog/post/' . $post['postUrl']); ?>">
|
<a href="<?= base_url('blog/post/' . $post['url']); ?>">
|
||||||
<strong><?= $post['postTitle']; ?></strong>
|
<strong><?= $post['title']; ?></strong>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -58,7 +58,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
<?php foreach ($categories as $category) { ?>
|
<?php foreach ($categories as $category) { ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url('blog/category/' . $category['name']) ?>">
|
<a href="<?= base_url('blog/category/' . $category['name']) ?>">
|
||||||
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['display_name'] ?>
|
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
|
@ -5,41 +5,44 @@
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="col-sm-8 col-sm-pull-4">
|
<div class="col-lg-8 order-lg-first">
|
||||||
<div class="like-toggle-icon-container floating">
|
<div class="like-toggle-icon-container floating">
|
||||||
<button class="like-toggle-icon <?= $hasLiked ? '-checked' : '' ?>" title="❤ Toggle Like!" onclick="likeDislike(<?= $postID ?>)"></button>
|
<button class="like-toggle-icon <?= $hasLiked ? '-checked' : '' ?>" title="❤ Toggle Like!" onclick="likeDislike(<?= $ID ?>)"></button>
|
||||||
<span class="like-count"><?= $likeCount ?></span>
|
<span class="like-count"><?= $likeCount ?></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="blog">
|
<div class="blog">
|
||||||
<div class="blog-item">
|
<div class="blog-item">
|
||||||
<?php if ($postIsDeleted): ?>
|
<?php // TODO: Add notice if post was deleted
|
||||||
|
if (false): ?>
|
||||||
<h2 class="text-error">
|
<h2 class="text-error">
|
||||||
<i class="fa fa-warning"></i>
|
<i class="fa fa-warning"></i>
|
||||||
</h2>
|
</h2>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<?php if ($postImage != '') { ?>
|
<?php if ($image != '') { ?>
|
||||||
<img class="img-fluid img-blog" src="<?= $postImage; ?>?w=800" width="100%" alt="" />
|
<img class="img-fluid img-blog" src="<?= $image; ?>?w=800" width="100%" alt="" />
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<div class="blog-content">
|
<div class="blog-content">
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<span>
|
<span>
|
||||||
<a href="<?= base_url('user/' . $postAuthorUsername) ?>">
|
<a href="<?= base_url('user/' . $author['username']) ?>">
|
||||||
<i class="far fa-user"></i>
|
<i class="far fa-user"></i>
|
||||||
<?= $postAuthorDisplayname ?>
|
<?= $author['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
<?php
|
<?php
|
||||||
$publishDate = strtotime($postPublishDate);
|
$initialRelease = strtotime($initialRelease);
|
||||||
$lastEdit = strtotime($postLastEdit);
|
if (isset($lastEdit)) {
|
||||||
|
$lastEdit = strtotime($lastEdit);
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
||||||
title="<?= strftime("%d. %B %Y", $publishDate) ?>">
|
title="<?= strftime("%d. %B %Y", $initialRelease) ?>">
|
||||||
<i class="far fa-calendar"></i>
|
<i class="far fa-calendar"></i>
|
||||||
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$publishDate"), $_SESSION['site_lang']) ?>
|
<?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$initialRelease"), $_SESSION['site_lang']) ?>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<?php if (isset($postLastEdit) && $postLastEdit !== null): ?>
|
<?php if (isset($lastEdit) && $lastEdit !== null): ?>
|
||||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom"
|
||||||
title="<?= strftime("%d. %B %Y", $lastEdit) ?>">
|
title="<?= strftime("%d. %B %Y", $lastEdit) ?>">
|
||||||
<i class="far fa-edit"></i>
|
<i class="far fa-edit"></i>
|
||||||
|
@ -47,16 +50,9 @@
|
||||||
</span>
|
</span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<span>
|
|
||||||
<a href="<?= base_url('blog/category/' . $categoryName) ?>">
|
|
||||||
<i class="far fa-folder-open"></i>
|
|
||||||
<?= lang('blog_category_' . $categoryName) != '' ? lang('blog_category_' . $categoryName) : $categoryDisplayName ?>
|
|
||||||
</a>
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom" title="<?= lang('blog_approximate_reading_time') ?>">
|
<span style="cursor:pointer" data-toggle="tooltip" data-placement="bottom" title="<?= lang('blog_approximate_reading_time') ?>">
|
||||||
<i class="far fa-clock"></i>
|
<i class="far fa-clock"></i>
|
||||||
<?= $this->BlogModel->getReadingTime($postID) ?> min
|
<?= $this->BlogModel->getReadingTime($wordCount) ?> min
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
|
@ -67,40 +63,60 @@
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span>
|
<span>
|
||||||
<a href="#" style="cursor:pointer" onclick="likeDislike(<?= $postID ?>)">
|
<a href="#" style="cursor:pointer" onclick="likeDislike(<?= $ID ?>)">
|
||||||
<i class="far fa-heart"></i>
|
<i class="far fa-heart"></i>
|
||||||
<span class="like-count"><?= $likeCount ?></span>
|
<span class="like-count"><?= $likeCount ?></span>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="post-title"><?= $postTitle ?></h1>
|
<h1 class="post-title"><?= $title ?></h1>
|
||||||
<h2 class="post-subtitle"><?= $postDesc ?></h2>
|
<h2 class="post-subtitle"><?= $description ?></h2>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blog-item">
|
<div class="blog-item">
|
||||||
<div class="blog-content">
|
<div class="blog-content">
|
||||||
<div class="blog-post">
|
<div class="blog-post">
|
||||||
<?= isset($postContent) ? $postContent : "" ?>
|
<?= isset($content) ? $content : "" ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="blog-item">
|
|
||||||
<div class="blog-content">
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
<div class="blog-item">
|
||||||
|
<div class="blog-content">
|
||||||
|
<h3>
|
||||||
|
<i class="far fa-folder-open"></i>
|
||||||
|
Kategorien
|
||||||
|
</h3>
|
||||||
|
<?php foreach ($categories as $category): ?>
|
||||||
|
<a href="<?= base_url('blog/category/' . $category['name']) ?>">
|
||||||
|
<span class="badge badge-primary">
|
||||||
|
<?= lang('blog_category_' . $category['name']) != '' ? lang('blog_category_' . $category['name']) : $category['displayname'] ?>
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="blog-item">
|
||||||
|
<div class="blog-content">
|
||||||
<h3>
|
<h3>
|
||||||
<i class="fa fa-tags"></i>
|
<i class="fa fa-tags"></i>
|
||||||
Tags
|
Tags
|
||||||
</h3>
|
</h3>
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<?php foreach ($tags as $tag) { ?>
|
<?php foreach ($tags as $tag) { ?>
|
||||||
<a href="<?= base_url('blog/tag/' . $tag['name']) ?>"><span
|
<a href="<?= base_url('blog/tag/' . $tag['name']) ?>">
|
||||||
class="label label-primary"><?= $tag['display_name'] ?></span>
|
<span class="badge badge-primary"><?= $tag['displayname'] ?></span>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
|
<div class="blog-item">
|
||||||
|
<div class="blog-content">
|
||||||
<h3>
|
<h3>
|
||||||
<i class="far fa-user"></i> <?= lang('blog_about') ?>
|
<i class="far fa-user"></i> <?= lang('blog_about') ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
@ -108,11 +124,11 @@
|
||||||
<?php
|
<?php
|
||||||
$this->load->view('network/user/user_overview_card', [
|
$this->load->view('network/user/user_overview_card', [
|
||||||
'noContainer' => true,
|
'noContainer' => true,
|
||||||
'username' => $postAuthorUsername,
|
'username' => $author['username'],
|
||||||
'displayname' => $postAuthorDisplayname,
|
'displayname' => $author['displayname'],
|
||||||
'profile_picture' => $postAuthorProfilePicture,
|
'profilePicture' => $author['profilePicture'],
|
||||||
'header_image' => $postAuthorHeaderImage,
|
'headerImage' => $author['headerImage'],
|
||||||
'about' => $postAuthorAbout])
|
'about' => $author['about']])
|
||||||
?>
|
?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -128,19 +144,19 @@
|
||||||
<?php foreach ($randomPosts as $item) { ?>
|
<?php foreach ($randomPosts as $item) { ?>
|
||||||
<div class="col-sm-4">
|
<div class="col-sm-4">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<?php if ($item['postImage'] != ''): ?>
|
<?php if ($item['image'] != ''): ?>
|
||||||
<a href="<?= base_url('blog/post/' . $item['postUrl']) ?>">
|
<a href="<?= base_url('blog/post/' . $item['url']) ?>">
|
||||||
<img src="<?= $item['postImage'] ?>?w=200" alt="<?= $item['postTitle'] ?>" class="card-img-top">
|
<img src="<?= $item['image'] ?>?w=200" alt="<?= $item['title'] ?>" class="card-img-top">
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a href="<?= base_url('blog/post/' . $item['postUrl']) ?>">
|
<a href="<?= base_url('blog/post/' . $item['url']) ?>">
|
||||||
<h5 class="card-title"><?= $item['postTitle'] ?></h5>
|
<h5 class="card-title"><?= $item['title'] ?></h5>
|
||||||
</a>
|
</a>
|
||||||
<small class="card-text">
|
<small class="card-text">
|
||||||
<i class="far fa-user"></i>
|
<i class="far fa-user"></i>
|
||||||
<a href="<?= base_url('user/' . $item['postAuthorUsername']) ?>">
|
<a href="<?= base_url('user/' . $item['author']['username']) ?>">
|
||||||
<?= $item['postAuthorDisplayname'] ?>
|
<?= $item['author']['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
|
@ -152,20 +168,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="blog-item">
|
|
||||||
<div class="blog-content">
|
|
||||||
<div class="container">
|
|
||||||
<div id="comments">
|
|
||||||
<h3>
|
|
||||||
<i class="far fa-comments"></i> <?= lang('blog_comments') ?> (<span class="comment-count"><?= $commentCount; ?></span>)
|
|
||||||
</h3>
|
|
||||||
<ul class="comment-list" id="comment-list">
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="blog-item">
|
<div class="blog-item">
|
||||||
<div class="blog-content">
|
<div class="blog-content">
|
||||||
<div id="comment-form">
|
<div id="comment-form">
|
||||||
|
@ -196,35 +198,57 @@
|
||||||
</div>
|
</div>
|
||||||
<!--/#comments-->
|
<!--/#comments-->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="blog-item">
|
||||||
|
<div class="blog-content">
|
||||||
|
<div class="container">
|
||||||
|
<div id="comments">
|
||||||
|
<h3>
|
||||||
|
<i class="far fa-comments"></i> <?= lang('blog_comments') ?> (
|
||||||
|
<span class="comment-count"><?= $commentCount; ?></span>
|
||||||
|
)
|
||||||
|
</h3>
|
||||||
|
<ul class="comment-list" id="comment-list">
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
<?php if (!empty($prevPost)):
|
<?php if (!empty($prevPost)):
|
||||||
$prevPost = $prevPost[0]; ?>
|
$prevPost = $prevPost[0]; ?>
|
||||||
<div class="blog-item col-xs-6" style="width:calc(50% - 5px);">
|
<div class="col-6">
|
||||||
<a href="<?= base_url('blog/post/' . $prevPost['postUrl']) ?>">
|
<div class="blog-item following-post left">
|
||||||
<div class="pull-left"
|
<a href="<?= base_url('blog/post/' . $prevPost['url']) ?>">
|
||||||
style="background: url(<?= $prevPost['postImage'] ?>?w=150) center;background-size:cover;width:100px;height:100px;border-radius: 4px;margin:10px 0;"></div>
|
<div class="following-post-image"
|
||||||
<div class="float-right" style="width: calc(100% - 110px)">
|
style="background-image: url(<?= $prevPost['image'] ?>?w=150)"></div>
|
||||||
|
<div style="width: calc(100% - 110px);display: inline-block;margin:10px 0;">
|
||||||
<h5>
|
<h5>
|
||||||
<i class="fa fa-arrow-left"></i> <?= lang('blog_previous_article') ?></h5>
|
<i class="fa fa-arrow-left"></i> <?= lang('blog_previous_article') ?></h5>
|
||||||
<h4 style="font-size:20px"><?= $prevPost['postTitle'] ?></h4>
|
<h4 style="font-size:20px"><?= $prevPost['title'] ?></h4>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if (!empty($nextPost)):
|
<?php if (!empty($nextPost)):
|
||||||
$nextPost = $nextPost[0]; ?>
|
$nextPost = $nextPost[0]; ?>
|
||||||
<div class="blog-item col-xs-6 float-right" style="width:calc(50% - 5px);">
|
<div class="col-6">
|
||||||
<a href="<?= base_url('blog/post/' . $nextPost['postUrl']) ?>">
|
<div class="blog-item following-post right">
|
||||||
<div class="float-right"
|
<a href="<?= base_url('blog/post/' . $nextPost['url']) ?>">
|
||||||
style="background: url(<?= $nextPost['postImage'] ?>?w=150) center;background-size:cover;width:100px;height:100px;border-radius: 4px;margin:10px 0;"></div>
|
<div class="following-post-image" style="background-image: url(<?= $nextPost['image'] ?>?w=150)"></div>
|
||||||
<div class="pull-left" style="width: calc(100% - 110px);text-align:right;">
|
<div style="width: calc(100% - 110px);text-align:right;display: inline-block;margin:10px 0;">
|
||||||
<h5><?= lang('blog_next_article') ?>
|
<h5><?= lang('blog_next_article') ?>
|
||||||
<i class="fa fa-arrow-right"></i>
|
<i class="fa fa-arrow-right"></i>
|
||||||
</h5>
|
</h5>
|
||||||
<h4 style="font-size:20px"><?= $nextPost['postTitle'] ?></h4>
|
<h4 style="font-size:20px"><?= $nextPost['title'] ?></h4>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
<!--/.blog-item-->
|
<!--/.blog-item-->
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -3,35 +3,40 @@
|
||||||
|
|
||||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||||
|
|
||||||
$postPublishDate = strtotime($postPublishDate);
|
$initialRelease = strtotime($initialRelease);
|
||||||
?>
|
?>
|
||||||
<div class="blog-item">
|
<div class="blog-item">
|
||||||
<?php if ($postImage != NULL && $postImage != ''): ?>
|
<?php if ($image != NULL && $image != ''): ?>
|
||||||
<a href="<?= base_url('blog/post/' . $postUrl) ?>">
|
<a href="<?= base_url('blog/post/' . $url) ?>">
|
||||||
<div class="img-blog-entry" style="background-image: url('<?= $postImage ?>?w=750');"></div>
|
<div class="img-blog-entry" style="background-image: url('<?= $image ?>?w=750');"></div>
|
||||||
</a>
|
</a>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="blog-content">
|
<div class="blog-content">
|
||||||
<div class="entry-meta">
|
<div class="entry-meta">
|
||||||
<span><a target="_blank" href="<?= base_url('user/' . $postAuthorUsername) ?>"><i class="fa fa-user"></i> <?= $postAuthorDisplayname ?></a></span>
|
<span><a target="_blank" href="<?= base_url('user/' . $author['username']) ?>"><i class="fa fa-user"></i> <?= $author['displayname'] ?></a></span>
|
||||||
<span><i class="fa fa-calendar"></i> <?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$postPublishDate"), $_SESSION['site_lang']) ?></span>
|
<span><i class="fa fa-calendar"></i> <?= DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$initialRelease"), $_SESSION['site_lang']) ?></span>
|
||||||
<span><a href="<?= base_url("blog/category/" . $categoryName) ?>"><i class="fa fa-folder-open"></i> <?= $categoryDisplayName ?></a></span>
|
<span>
|
||||||
|
<i class="fa fa-folder-open"></i>
|
||||||
|
<?php foreach ($categories as $category) { ?>
|
||||||
|
<a href="<?= base_url('blog/category/' . $category['name']) ?>"><?= $category['displayname'] ?></a>
|
||||||
|
<?php } ?>
|
||||||
|
</span>
|
||||||
<span style="cursor: pointer;" data-toggle="tooltip" data-placement="left" title="Geschätzte Lesedauer">
|
<span style="cursor: pointer;" data-toggle="tooltip" data-placement="left" title="Geschätzte Lesedauer">
|
||||||
<i class="fa fa-clock"></i>
|
<i class="fa fa-clock"></i>
|
||||||
<?= $this->BlogModel->getReadingTime($postID) ?> min
|
<?= $this->BlogModel->getReadingTime($wordCount) ?> min
|
||||||
</span>
|
</span>
|
||||||
<span><a href="<?= base_url('blog/post/' . $postUrl . '#comments') ?>"><i class="fa fa-comment"></i> <?= $commentCount ?></a></span>
|
<span><a href="<?= base_url('blog/post/' . $url . '#comments') ?>"><i class="fa fa-comment"></i> <?= $commentCount ?></a></span>
|
||||||
<span><i class="fa fa-heart"></i> <?= $likeCount ?></span>
|
<span><i class="fa fa-heart"></i> <?= $likeCount ?></span>
|
||||||
</div>
|
</div>
|
||||||
<a href="<?= base_url('blog/post/' . $postUrl) ?>">
|
<a href="<?= base_url('blog/post/' . $url) ?>">
|
||||||
<h3><?= $postTitle ?></h3>
|
<h3><?= $title ?></h3>
|
||||||
</a>
|
</a>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
<p><?= $postDesc ?></p>
|
<p><?= $description ?></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3" style="padding:0">
|
<div class="col-md-3" style="padding:0">
|
||||||
<a class="btn btn-primary outline" href="<?= base_url('blog/post/' . $postUrl) ?>"><?= lang('blog_read') ?>
|
<a class="btn btn-primary outline" href="<?= base_url('blog/post/' . $url) ?>"><?= lang('blog_read') ?>
|
||||||
<i class="fa fa-angle-right"></i>
|
<i class="fa fa-angle-right"></i>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="col-sm-8 col-sm-pull-4">
|
<div class="col-lg-8 order-lg-first">
|
||||||
<div class="blog">
|
<div class="blog">
|
||||||
<ul class="page-selection pagination-lg blog-pagination"></ul>
|
<ul class="page-selection pagination-lg blog-pagination"></ul>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
|
|
28
application/views/blog/report_modal.php
Normal file
28
application/views/blog/report_modal.php
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<form id="commentReportForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="commentReportReason">Grund für deine Meldung</label>
|
||||||
|
<select name="reason" id="commentReportReason" class="form-control" required>
|
||||||
|
<option value="">Bitte auswählen</option>
|
||||||
|
<option value="hatespeech">Hasserfüllte Inhalte</option>
|
||||||
|
<option value="racism">Rassistische, diskriminierende oder bewusst ausgrenzende Inhalte</option>
|
||||||
|
<option value="terrorism">Unterstützung von Terrorismus</option>
|
||||||
|
<option value="abuse">(Kindes-)Missbrauch</option>
|
||||||
|
<option value="violence">Gewaltverherrlichende Inhalte</option>
|
||||||
|
<option value="copyright">Verletzung meiner (Urheber-)Rechte</option>
|
||||||
|
<option value="spam">Spam oder irreführende Inhalte</option>
|
||||||
|
<option value="technical-issue">Technische Fehler</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="commentReportText">Weitere Anmerkungen (optional)</label>
|
||||||
|
<textarea name="reportText" id="commentReportText" class="form-control"></textarea>
|
||||||
|
</div>
|
||||||
|
<button type="submit" class="btn btn-primary float-right">
|
||||||
|
Absenden
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
|
@ -119,7 +119,7 @@
|
||||||
<?= lang('header_edit_profile') ?>
|
<?= lang('header_edit_profile') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php if (get_instance()->hasPermission('dashboard.view')): ?>
|
<?php if (get_instance()->hasPermission('dashboard.view')): ?>
|
||||||
<a href="<? //= base_url('admin') ?>" class="dropdown-item">
|
<a href="<?= base_url('admin') ?>" class="dropdown-item">
|
||||||
<i class="fa fa-tachometer-alt"></i>
|
<i class="fa fa-tachometer-alt"></i>
|
||||||
<?= lang('header_admin_panel') ?>
|
<?= lang('header_admin_panel') ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -221,7 +221,7 @@
|
||||||
<?php foreach ($currentlyActiveUsers as $activeUser):
|
<?php foreach ($currentlyActiveUsers as $activeUser):
|
||||||
$loginTime = strtotime($activeUser['lastLogin']); ?>
|
$loginTime = strtotime($activeUser['lastLogin']); ?>
|
||||||
<div class="user-item">
|
<div class="user-item">
|
||||||
<img src="<?= $activeUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
<img src="<?= $activeUser['profilePicture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<a href="<?= base_url('user/' . $activeUser['username']) ?>">
|
<a href="<?= base_url('user/' . $activeUser['username']) ?>">
|
||||||
<h2><?= $activeUser['displayname'] ?></h2>
|
<h2><?= $activeUser['displayname'] ?></h2>
|
||||||
|
@ -236,9 +236,9 @@
|
||||||
<h2><?= lang('home_newest_users') ?></h2>
|
<h2><?= lang('home_newest_users') ?></h2>
|
||||||
<?php
|
<?php
|
||||||
foreach ($newestUsers as $newestUser):
|
foreach ($newestUsers as $newestUser):
|
||||||
$registeredDate = strtotime($newestUser['date_created']); ?>
|
$registeredDate = strtotime($newestUser['dateCreated']); ?>
|
||||||
<div class="user-item">
|
<div class="user-item">
|
||||||
<img src="<?= $newestUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
<img src="<?= $newestUser['profilePicture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||||
<div class="user-info">
|
<div class="user-info">
|
||||||
<a href="<?= base_url('user/' . $newestUser['username']) ?>">
|
<a href="<?= base_url('user/' . $newestUser['username']) ?>">
|
||||||
<h2><?= $newestUser['displayname'] ?></h2>
|
<h2><?= $newestUser['displayname'] ?></h2>
|
||||||
|
|
|
@ -18,7 +18,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="loading-msg">
|
<div class="loading-msg">
|
||||||
<i class="fa fa-cog fa-spin"></i>
|
.loadingSpinner
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="success-msg">
|
<div class="success-msg">
|
||||||
|
|
|
@ -3,22 +3,22 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
?>
|
?>
|
||||||
<li class="blog-post-item">
|
<li class="blog-post-item">
|
||||||
<div class="well comment-well">
|
<div class="well comment-well">
|
||||||
<a href="<?= base_url('blog/post/' . $post['postUrl']) ?>" target="_blank">
|
<a href="<?= base_url('blog/post/' . $post['url']) ?>" target="_blank">
|
||||||
<div class="entry-image" style="background-image:url(<?= $post['postImage'] ?>?w=150"></div>
|
<div class="entry-image" style="background-image:url(<?= $post['image'] ?>?w=150"></div>
|
||||||
</a>
|
</a>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h3>
|
<h3>
|
||||||
<a href="<?= base_url('blog/post/' . $post['postUrl']) ?>" target="_blank">
|
<a href="<?= base_url('blog/post/' . $post['url']) ?>" target="_blank">
|
||||||
<?= $post['postTitle'] ?>
|
<?= $post['title'] ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<small><?= lang('person_by') ?> <a
|
<small><?= lang('person_by') ?> <a
|
||||||
href="<?= base_url('user/' . $data['username']) ?>"
|
href="<?= base_url('user/' . $data['username']) ?>"
|
||||||
target="_blank"><?= $data['displayname'] ?></a>
|
target="_blank"><?= $data['displayname'] ?></a>
|
||||||
/ <?= date(lang('date'), strtotime($post['postPublishDate'])) ?>
|
/ <?= date(lang('date'), strtotime($post['initialRelease'])) ?>
|
||||||
</small>
|
</small>
|
||||||
</h3>
|
</h3>
|
||||||
<p class="comment"><?= $post['postDesc'] ?></p>
|
<p class="comment"><?= $post['description'] ?></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
|
@ -1,47 +1,64 @@
|
||||||
<?php
|
<?php
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
|
||||||
|
|
||||||
|
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||||
?>
|
?>
|
||||||
<li>
|
<li id="comment-<?= $c['ID'] ?>">
|
||||||
<div class="well comment-well">
|
<div class="user-post-item">
|
||||||
<div class="post-non-content">
|
<a href="<?= base_url('user/' . $data['username']) ?>" class="item-avatar-container">
|
||||||
<a href="<?= base_url('user/' . $data['username']) ?>" target="_blank">
|
<img src="<?= $data['profilePicture'] ?>?w=100" alt="<?= $data['username'] ?>" class="item-avatar">
|
||||||
<img src="<?= $data['profile_picture'] ?>?w=100" class="img-fluid">
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
<h3 class="item-user">
|
||||||
<div class="content-container">
|
<a href="<?= base_url('user/' . $data['username']) ?>">
|
||||||
<div class="content">
|
|
||||||
<h3>
|
|
||||||
<a href="<?= base_url('user/' . $data['username']) ?>" target="_blank">
|
|
||||||
<?= $data['displayname'] ?>
|
<?= $data['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
<small>
|
</h3>
|
||||||
|
<h4 class="item-meta">
|
||||||
<?php
|
<?php
|
||||||
$locale = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'en';
|
$locale = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'en';
|
||||||
$date_created = strtotime($c['date_created']);
|
$dateCreated = strtotime($c['date']);
|
||||||
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $locale);
|
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $locale);
|
||||||
?>
|
?>
|
||||||
|
<?php if (isset($c['url'])): ?>
|
||||||
unter
|
unter
|
||||||
<a href="<?= base_url('blog/post/' . $c['postUrl']) ?>">
|
<a href="<?= base_url('blog/post/' . $c['url']) ?>">
|
||||||
<?= $c['postTitle'] ?>
|
<?= $c['title'] ?>
|
||||||
</a>
|
</a>
|
||||||
</small>
|
<?php endif; ?>
|
||||||
</h3>
|
</h4>
|
||||||
<p class="comment"><?= $c['comment'] ?></p>
|
<p class="item-content">
|
||||||
</div>
|
<?= $c['comment'] ?>
|
||||||
</div>
|
</p>
|
||||||
<div class="action-btns">
|
<?php if(!isset($hideActionBtns) || $hideActionBtns == false): ?>
|
||||||
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Antworten">
|
<div class="item-actions">
|
||||||
|
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Antworten">
|
||||||
<i class="far fa-comment"></i>
|
<i class="far fa-comment"></i>
|
||||||
|
<span>0</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
|
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
|
||||||
<i class="far fa-heart"></i>
|
<i class="far fa-heart"></i>
|
||||||
|
<span>0</span>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" class="action-btn" data-toggle="tooltip" data-placement="top" title="Mehr Optionen">
|
<div class="item-btn dropdown">
|
||||||
|
<a href="#" class="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="fa fa-ellipsis-h"></i>
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<a onclick="openCommentReportModal(<?= $c['ID'] ?>)" class="dropdown-item">
|
||||||
|
<i class="fa fa-flag"></i>
|
||||||
|
Kommentar melden
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<?php if(isset($_SESSION['user']) && $_SESSION['user']['username'] == $data['username']): ?>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<a onclick="openCommentDeleteModal(<?= $c['ID'] ?>)" class="dropdown-item text-danger">
|
||||||
|
<i class="fa fa-trash"></i>
|
||||||
|
Kommentar löschen
|
||||||
|
</a>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
|
@ -15,7 +15,7 @@
|
||||||
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
|
<button type="reset" class="btn btn-sm btn-primary round float-right" data-dismiss="modal">
|
||||||
Nein, Post behalten
|
Nein, Post behalten
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deletePost('<?= $post['uuid'] ?>')">
|
<button type="submit" class="btn btn-sm btn-red outline round float-right" onclick="deletePost('<?= $post['hashID'] ?>')">
|
||||||
Ja, endgültig löschen
|
Ja, endgültig löschen
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<li class="post-item is-reply% my-2" data-uuid="<?= $uuid ?>" data-username="<?= $username ?>">
|
<li class="post-item is-reply% my-2" data-uuid="<?= $hashID ?>" data-username="<?= $username ?>">
|
||||||
<div class="comment-well" <?= isset($hideShadows) && $hideShadows ? 'style="box-shadow: none;padding:0"' : '' ?>>
|
<div class="comment-well" <?= isset($hideShadows) && $hideShadows ? 'style="box-shadow: none;padding:0"' : '' ?>>
|
||||||
<div class="post-non-content">
|
<div class="post-non-content">
|
||||||
<a href="<?= base_url('user/' . $username) ?>" target="_blank">
|
<a href="<?= base_url('user/' . $username) ?>" target="_blank">
|
||||||
<img src="<?= $profile_picture ?>?w=100" class="img-fluid">
|
<img src="<?= $profilePicture ?>?w=100" class="img-fluid">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="content-container">
|
<div class="content-container">
|
||||||
|
@ -18,13 +18,13 @@
|
||||||
<?= $displayname ?>
|
<?= $displayname ?>
|
||||||
</a>
|
</a>
|
||||||
<small><?php
|
<small><?php
|
||||||
$date_created = strtotime($date);
|
$dateCreated = strtotime($date);
|
||||||
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']); ?></small>
|
echo DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']); ?></small>
|
||||||
<?php if ($reply_to != NULL): ?>
|
<?php if ($replyToPostID != NULL): ?>
|
||||||
<small>
|
<small>
|
||||||
<i class="fa fa-reply"></i>
|
<i class="fa fa-reply"></i>
|
||||||
<?= lang('post_reply_to') ?>
|
<?= lang('post_reply_to') ?>
|
||||||
<a href="#" onclick="showFullPost('<?= $replyToPost['uuid'] ?>', '<?= $replyToPost['username'] ?>')">@<?= $replyToPost['displayname'] ?></a>
|
<a href="#" onclick="showFullPost('<?= $replyToPost['hashID'] ?>', '<?= $replyToPost['username'] ?>')">@<?= $replyToPost['displayname'] ?></a>
|
||||||
</small>
|
</small>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</h3>
|
</h3>
|
||||||
|
@ -80,31 +80,31 @@
|
||||||
</div>
|
</div>
|
||||||
<?php if (!isset($hideActionBtns) || !$hideActionBtns): ?>
|
<?php if (!isset($hideActionBtns) || !$hideActionBtns): ?>
|
||||||
<div class="action-btns">
|
<div class="action-btns">
|
||||||
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="<?= lang('post_reply') ?>">
|
<a href="#" data-uuid="<?= $hashID ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="<?= lang('post_reply') ?>">
|
||||||
<i class="far fa-comment"></i>
|
<i class="far fa-comment"></i>
|
||||||
<span><?= $replyCount ?></span>
|
<span><?= $replyCount ?></span>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" data-uuid="<?= $uuid ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= lang('post_like') ?>">
|
<a href="#" data-uuid="<?= $hashID ?>" class="action-btn like-button <?= isset($userHasLiked) && $userHasLiked ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="<?= lang('post_like') ?>">
|
||||||
<i class="<?= isset($userHasLiked) && $userHasLiked ? 'fas' : 'far' ?> fa-heart"></i>
|
<i class="<?= isset($userHasLiked) && $userHasLiked ? 'fas' : 'far' ?> fa-heart"></i>
|
||||||
<span><?= $likeCount ?></span>
|
<span><?= $likeCount ?></span>
|
||||||
</a>
|
</a>
|
||||||
<div class="action-btn dropdown">
|
<div class="action-btn dropdown">
|
||||||
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $uuid ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $hashID ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="fa fa-ellipsis-h"></i>
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $uuid ?>">
|
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $hashID ?>">
|
||||||
<a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $uuid) ?>')" class="dropdown-item">
|
<a href="#" onclick="copyToClipboard('<?= base_url('user/' . $username . '/post/' . $hashID) ?>')" class="dropdown-item">
|
||||||
<i class="fa fa-copy"></i>
|
<i class="fa fa-copy"></i>
|
||||||
<?= lang('post_copy_link') ?>
|
<?= lang('post_copy_link') ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" onclick="openPostReportModal('<?= $uuid ?>')" class="dropdown-item">
|
<a href="#" onclick="openPostReportModal('<?= $hashID ?>')" class="dropdown-item">
|
||||||
<i class="fa fa-flag"></i>
|
<i class="fa fa-flag"></i>
|
||||||
<?= lang('post_report') ?>
|
<?= lang('post_report') ?>
|
||||||
</a>
|
</a>
|
||||||
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $username): ?>
|
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $username): ?>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a href="#" onclick="openDeletePostModal('<?= $uuid ?>')" class="dropdown-item text-danger">
|
<a href="#" onclick="openDeletePostModal('<?= $hashID ?>')" class="dropdown-item text-danger">
|
||||||
<i class="fa fa-trash"></i>
|
<i class="fa fa-trash"></i>
|
||||||
<?= lang('post_delete') ?>
|
<?= lang('post_delete') ?>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -5,21 +5,21 @@
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?= $message; ?>
|
<?php if (isset($post['replyToPost'])): ?>
|
||||||
|
<div class="row justify-content-center">
|
||||||
<div class="row justify-content-center">
|
|
||||||
<ul class="comment-list">
|
<ul class="comment-list">
|
||||||
<?php
|
<?php
|
||||||
$post['replyToPost']['hideShadows'] = true;
|
$post['replyToPost']['hideShadows'] = true;
|
||||||
$this->load->view('network/posts/post_item', $post['replyToPost'])
|
$this->load->view('network/posts/post_item', $post['replyToPost'])
|
||||||
?>
|
?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="post-non-content">
|
<div class="post-non-content">
|
||||||
<a href="<?= base_url('user/' . $post['username']) ?>">
|
<a href="<?= base_url('user/' . $post['username']) ?>">
|
||||||
<img src="<?= $post['profile_picture'] ?>?w=75" alt="" class="img-fluid rounded-circle">
|
<img src="<?= $post['profilePicture'] ?>?w=75" alt="" class="img-fluid rounded-circle">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@
|
||||||
<?= $post['displayname'] ?>
|
<?= $post['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
<?php
|
<?php
|
||||||
$date_created = strtotime($post['date']);
|
$dateCreated = strtotime($post['date']);
|
||||||
$time_passed = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
|
$time_passed = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||||
?>
|
?>
|
||||||
<small>
|
<small>
|
||||||
<?= $time_passed ?>
|
<?= $time_passed ?>
|
||||||
|
@ -51,20 +51,20 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<div class="action-btns">
|
<div class="action-btns">
|
||||||
<a href="#" data-uuid="<?= $post['uuid'] ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten">
|
<a href="#" data-uuid="<?= $post['hashID'] ?>" class="action-btn reply-button" data-toggle="tooltip" data-placement="top" title="Antworten">
|
||||||
<span><i class="far fa-comment"></i></span>
|
<span><i class="far fa-comment"></i></span>
|
||||||
<?= $post['replyCount'] ?>
|
<?= $post['replyCount'] ?>
|
||||||
</a>
|
</a>
|
||||||
<a href="#" data-uuid="<?= $post['uuid'] ?>" class="action-btn like-button <?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
|
<a href="#" data-uuid="<?= $post['hashID'] ?>" class="action-btn like-button <?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'active' : '' ?>" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
|
||||||
<i class="<?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'fas' : 'far' ?> fa-heart"></i>
|
<i class="<?= isset($post['userHasLiked']) && $post['userHasLiked'] ? 'fas' : 'far' ?> fa-heart"></i>
|
||||||
<span><?= $post['likeCount'] ?></span>
|
<span><?= $post['likeCount'] ?></span>
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown d-inline-block">
|
<div class="dropdown d-inline-block">
|
||||||
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $post['uuid'] ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a href="#" class="action-btn more-options-button" id="postMoreOptionsButton<?= $post['hashID'] ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
<i class="fa fa-ellipsis-h"></i>
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $post['uuid'] ?>">
|
<div class="dropdown-menu" aria-labelledby="postMoreOptionsButton<?= $post['hashID'] ?>">
|
||||||
<a href="#" class="dropdown-item">
|
<a href="#" class="dropdown-item">
|
||||||
<i class="fa fa-copy"></i>
|
<i class="fa fa-copy"></i>
|
||||||
Link zum Post kopieren
|
Link zum Post kopieren
|
||||||
|
|
|
@ -49,8 +49,8 @@
|
||||||
<form method="post" enctype="multipart/form-data">
|
<form method="post" enctype="multipart/form-data">
|
||||||
<!-- Username -->
|
<!-- Username -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">Nutzername</label>
|
<label for="displayname">Nutzername</label>
|
||||||
<input name="username" id="username" class="form-control"
|
<input name="displayname" id="displayname" class="form-control"
|
||||||
value="<?= isset($data['displayname']) ? $data['displayname'] : '' ?>">
|
value="<?= isset($data['displayname']) ? $data['displayname'] : '' ?>">
|
||||||
<span class="error-message" id="usernameErrorLength">
|
<span class="error-message" id="usernameErrorLength">
|
||||||
<b>Dein Nutzername ist zu kurz!</b> Er muss mindestens 4 Zeichen lang sein
|
<b>Dein Nutzername ist zu kurz!</b> Er muss mindestens 4 Zeichen lang sein
|
||||||
|
@ -1093,26 +1093,24 @@
|
||||||
</div>
|
</div>
|
||||||
<!-- Bio -->
|
<!-- Bio -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="biography">Profilbeschreibung/Biographie</label>
|
<label for="about">Profilbeschreibung/Biographie</label>
|
||||||
<textarea class="form-control" name="biography" id="biography">
|
<textarea class="form-control" name="about" id="about"><?= isset($data['about']) ? $data['about'] : "" ?></textarea>
|
||||||
<?= isset($data['about']) ? $data['about'] : "" ?>
|
|
||||||
</textarea>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Avatar -->
|
<!-- Avatar -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="avatar">Avatar</label>
|
<label for="avatar">Avatar</label>
|
||||||
<?php if (isset($data['profile_picture']) || $data['profile_picture'] != ""): ?>
|
<?php if (isset($data['profilePicture']) || $data['profilePicture'] != ""): ?>
|
||||||
<img class="img-fluid img-thumbnail picture-preview d-block"
|
<img class="img-fluid img-thumbnail picture-preview d-block"
|
||||||
src="<?= $data['profile_picture'] ?>">
|
src="<?= $data['profilePicture'] ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<input type="file" name="avatar" id="avatar">
|
<input type="file" name="avatar" id="avatar">
|
||||||
</div>
|
</div>
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="header">Header</label>
|
<label for="header">Header</label>
|
||||||
<?php if (isset($data['header_image']) || $data['header_image'] != ""): ?>
|
<?php if (isset($data['headerImage']) || $data['headerImage'] != ""): ?>
|
||||||
<img class="img-fluid img-thumbnail picture-preview d-block"
|
<img class="img-fluid img-thumbnail picture-preview d-block"
|
||||||
src="<?= $data['header_image'] ?>">
|
src="<?= $data['headerImage'] ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<input type="file" name="header" id="header">
|
<input type="file" name="header" id="header">
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,14 +2,14 @@
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
?>
|
?>
|
||||||
<section id="profile-header" class="container-fluid" data-type="background" data-speed="2.14"
|
<section id="profile-header" class="container-fluid" data-type="background" data-speed="2.14"
|
||||||
style="background-image: url('<?= $data['header_image'] ?>?w=1920')">
|
style="background-image: url('<?= $data['headerImage'] ?>?w=1920')">
|
||||||
</section>
|
</section>
|
||||||
<div id="scroll-trigger"></div>
|
<div id="scroll-trigger"></div>
|
||||||
<section id="profile-sub-header" data-type="foreground" data-speed="10">
|
<section id="profile-sub-header" data-type="foreground" data-speed="10">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-xs-3 col-sm-2 col-md-4 col-lg-4 profile-card profile-picture-container">
|
<div class="col-xs-3 col-sm-2 col-md-4 col-lg-4 profile-card profile-picture-container">
|
||||||
<img src="<?= $data['profile_picture'] ?>?w=300" class="img-fluid rounded-circle profile-picture">
|
<img src="<?= $data['profilePicture'] ?>?w=300" class="img-fluid rounded-circle profile-picture">
|
||||||
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $data['username']): ?>
|
<?php if (isset($_SESSION['user']) && $_SESSION['user']['username'] == $data['username']): ?>
|
||||||
<div class="avatar-upload-overlay">
|
<div class="avatar-upload-overlay">
|
||||||
<i class="fa fa-upload"></i>
|
<i class="fa fa-upload"></i>
|
||||||
|
|
|
@ -7,8 +7,8 @@ $dateFollowing = strtotime($data['followedSince']);
|
||||||
?>
|
?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?= base_url('user/' . $data['username']) ?>">
|
<a href="<?= base_url('user/' . $data['username']) ?>">
|
||||||
<div style="background-image: url(<?= $data['header_image'] ?>)" class="header-image"></div>
|
<div style="background-image: url(<?= $data['headerImage'] ?>)" class="header-image"></div>
|
||||||
<img src="<?= $data['profile_picture'] ?>" alt="" class="img-fluid rounded-circle profile-picture">
|
<img src="<?= $data['profilePicture'] ?>" alt="" class="img-fluid rounded-circle profile-picture">
|
||||||
<div class="user-card-content">
|
<div class="user-card-content">
|
||||||
<h3><?= $data['displayname'] ?></h3>
|
<h3><?= $data['displayname'] ?></h3>
|
||||||
<small><?= $data['followerCount'] ?> Follower | folgt
|
<small><?= $data['followerCount'] ?> Follower | folgt
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<a href="<?= base_url('user/' . $username) ?>">
|
<a href="<?= base_url('user/' . $username) ?>">
|
||||||
<img src="<?= $header_image ?>?w=350" class="card-img-top" alt="Header Image">
|
<img src="<?= $headerImage ?>?w=350" class="card-img-top" alt="Header Image">
|
||||||
</a>
|
</a>
|
||||||
<a href="<?= base_url('user/' . $username) ?>">
|
<a href="<?= base_url('user/' . $username) ?>">
|
||||||
<img src="<?= $profile_picture ?>?w=100" class="img-fluid rounded-circle card-profile-picture" alt="Profile Picture">
|
<img src="<?= $profilePicture ?>?w=100" class="img-fluid rounded-circle card-profile-picture" alt="Profile Picture">
|
||||||
</a>
|
</a>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a href="<?= base_url('user/' . $username) ?>">
|
<a href="<?= base_url('user/' . $username) ?>">
|
||||||
|
|
|
@ -2,33 +2,33 @@
|
||||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<li class="col-4 p-2 <?= strtolower($post_plattform) ?>">
|
<li class="col-4 p-2 <?= strtolower($origin) ?>">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<a href="<?= $post_url ?>">
|
<a href="<?= $url ?>">
|
||||||
<div class="card-header bg-<?= strtolower($post_plattform) ?> text-white">
|
<div class="card-header bg-<?= strtolower($origin) ?> text-white">
|
||||||
<i class="fab fa-<?= strtolower($post_plattform) ?>"></i>
|
<i class="fab fa-<?= strtolower($origin) ?>"></i>
|
||||||
<?= $post_plattform ?>
|
<?= $origin ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if (!empty($post_img_source)): ?>
|
<?php if (!empty($imageSource)): ?>
|
||||||
<div style="height: 200px; background: url(<?= $post_img_source ?>) center; background-size: cover;">
|
<div style="height: 200px; background: url(<?= $imageSource ?>) center; background-size: cover;">
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</a>
|
</a>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<a href="<?= $post_url ?>">
|
<a href="<?= $url ?>">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<?= $post_content ?>
|
<?= $content ?>
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
<i class="far fa-clock"></i>
|
<i class="far fa-clock"></i>
|
||||||
<?= $post_date ?>
|
<?= $date ?>
|
||||||
<br>
|
<br>
|
||||||
<i class="far fa-user"></i>
|
<i class="far fa-user"></i>
|
||||||
<?= lang('person_by') ?>
|
<?= lang('person_by') ?>
|
||||||
<a href="<?= $post_author_url ?>" target="_blank">
|
<a href="<?= $authorUrl ?>" target="_blank">
|
||||||
<?= $post_author ?>
|
<?= $authorName ?>
|
||||||
</a>
|
</a>
|
||||||
</small>
|
</small>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -39,30 +39,11 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
<?= lang('projects_all'); ?>
|
<?= lang('projects_all'); ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php
|
|
||||||
$categoryList = [];
|
|
||||||
$categoryNames = [];
|
|
||||||
$siteLang = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'en';
|
|
||||||
$languageName = 'displayname';
|
|
||||||
if($siteLang == 'en') {
|
|
||||||
$languageName = 'displaynameEnglish';
|
|
||||||
} elseif($siteLang == 'fr') {
|
|
||||||
$languageName = 'displaynameFrench';
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($collections as $item) {
|
<?php foreach($categories as $category): ?>
|
||||||
$categoryName = $item[$languageName];
|
|
||||||
$categoryList[] = $categoryName;
|
|
||||||
$categoryNames[$categoryName] = $item['collection'];
|
|
||||||
}
|
|
||||||
|
|
||||||
sort($categoryList);
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php foreach($categoryList as $category): ?>
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#" class="btn btn-default btn-sm <?= $album == $categoryNames[$category] ? 'active' : '' ?>" data-filter=".<?= $categoryNames[$category] ?>">
|
<a href="#" class="btn btn-default btn-sm <?= $album == $category['name'] ? 'active' : '' ?>" data-filter=".<?= $category['name'] ?>">
|
||||||
<?= $category ?>
|
<?= $category['displayname'] ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
|
@ -5,26 +5,26 @@
|
||||||
$categoryUrls = [];
|
$categoryUrls = [];
|
||||||
$lang = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'de';
|
$lang = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'de';
|
||||||
|
|
||||||
foreach ($pCategories as $pCategory) {
|
// foreach ($pCategories as $pCategory) {
|
||||||
if ($lang == 'fr' && $pCategory['displaynameFrench'] != NULL) {
|
// if ($lang == 'fr' && $pCategory['displaynameFrench'] != NULL) {
|
||||||
$pCategoriesList[] = $pCategory['displaynameFrench'];
|
// $pCategoriesList[] = $pCategory['displaynameFrench'];
|
||||||
$categoryUrls[$pCategory['displaynameFrench']] = $pCategory['collection'];
|
// $categoryUrls[$pCategory['displaynameFrench']] = $pCategory['collection'];
|
||||||
} else if ($lang == 'en' && $pCategory['displaynameEnglish'] != NULL) {
|
// } else if ($lang == 'en' && $pCategory['displaynameEnglish'] != NULL) {
|
||||||
$pCategoriesList[] = $pCategory['displaynameEnglish'];
|
// $pCategoriesList[] = $pCategory['displaynameEnglish'];
|
||||||
$categoryUrls[$pCategory['displaynameEnglish']] = $pCategory['collection'];
|
// $categoryUrls[$pCategory['displaynameEnglish']] = $pCategory['collection'];
|
||||||
} else {
|
// } else {
|
||||||
$pCategoriesList[] = $pCategory['displayname'];
|
// $pCategoriesList[] = $pCategory['displayname'];
|
||||||
$categoryUrls[$pCategory['displayname']] = $pCategory['collection'];
|
// $categoryUrls[$pCategory['displayname']] = $pCategory['collection'];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
sort($pCategoriesList);
|
// sort($pCategoriesList);
|
||||||
|
//
|
||||||
$pCategoriesListUrls = [];
|
// $pCategoriesListUrls = [];
|
||||||
foreach ($pCategoriesList as $pCategory) {
|
// foreach ($pCategoriesList as $pCategory) {
|
||||||
$pCategoriesListUrls[] = '<a href="' . base_url('projects/' . $categoryUrls[$pCategory]) . '">' . $pCategory . '</a>';
|
// $pCategoriesListUrls[] = '<a href="' . base_url('projects/' . $categoryUrls[$pCategory]) . '">' . $pCategory . '</a>';
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
$pCategoriesListUrls = implode(', ', $pCategoriesListUrls);
|
// $pCategoriesListUrls = implode(', ', $pCategoriesListUrls);
|
||||||
?>
|
?>
|
||||||
<section class="container">
|
<section class="container">
|
||||||
<div class="vote-container" data-id="<?= $data['ID'] ?>">
|
<div class="vote-container" data-id="<?= $data['ID'] ?>">
|
||||||
|
@ -89,7 +89,13 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
<div class="col-lg-8 col-md-8 col-sm-12 col-xs-12">
|
||||||
<span data-toggle="tooltip" data-placement="top" title="Kategorien">
|
<span data-toggle="tooltip" data-placement="top" title="Kategorien">
|
||||||
<i class="fa fa-folder-open"></i> <?= $pCategoriesListUrls ?>
|
<i class="fa fa-folder-open"></i>
|
||||||
|
<?php foreach ($pCategories as $i => $category): ?>
|
||||||
|
<?= $i != 0 ? ' | ' : '' ?>
|
||||||
|
<a href="<?= base_url('projects/' . $category['name']) ?>">
|
||||||
|
<?= $category['displayname'] ?>
|
||||||
|
</a>
|
||||||
|
<?php endforeach; ?>
|
||||||
</span>
|
</span>
|
||||||
<span data-toggle="tooltip" data-placement="top"
|
<span data-toggle="tooltip" data-placement="top"
|
||||||
title="Datum: <?= strftime("%d. %B %Y", strtotime($data['datetime'])) ?>"
|
title="Datum: <?= strftime("%d. %B %Y", strtotime($data['datetime'])) ?>"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
$categories = $this->projectsModel->getEntryCategories($ID);
|
$categories = $this->projectsModel->getEntryCategories($ID);
|
||||||
$categoriesClasses = "";
|
$categoriesClasses = "";
|
||||||
foreach ($categories as $category) {
|
foreach ($categories as $category) {
|
||||||
$categoriesClasses .= $category['collection'] . " ";
|
$categoriesClasses .= $category['name'] . " ";
|
||||||
}
|
}
|
||||||
if ($isDownloadable) {
|
if ($isDownloadable) {
|
||||||
$categoriesClasses .= 'downloadable ';
|
$categoriesClasses .= 'downloadable ';
|
||||||
|
|
|
@ -169,7 +169,7 @@
|
||||||
.widget.filled-background .media {
|
.widget.filled-background .media {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
padding: 10px 0;
|
padding: 10px 0;
|
||||||
border-bottom: 1px solid rgba(0,0,0,.3);
|
border-bottom: 1px solid rgba(0, 0, 0, .3);
|
||||||
transition: transform .2s;
|
transition: transform .2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,3 +195,31 @@
|
||||||
right: 30%;
|
right: 30%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.following-post {
|
||||||
|
display: block;
|
||||||
|
height: 108px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.following-post .following-post-image {
|
||||||
|
float: left;
|
||||||
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
|
width: 100px;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.following-post.right .following-post-image {
|
||||||
|
float: right;
|
||||||
|
margin-right: 0;
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.following-post h4 {
|
||||||
|
max-height: 48px;
|
||||||
|
overflow: hidden;
|
||||||
|
-ms-text-overflow: ellipsis;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
|
@ -8,6 +8,15 @@ body {
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
font-family: Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-family: "Roboto Black", Helvetica, "Arial Black", Arial, sans-serif;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
.left_col {
|
.left_col {
|
||||||
background: #444;
|
background: #444;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1407,6 +1407,87 @@ ul#downloadSlider a.active .overlay {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-post-item {
|
||||||
|
display: grid;
|
||||||
|
grid-template-areas: "logo username metadata" "logo content content" "logo actions actions";
|
||||||
|
grid-template-rows: 25px auto 35px;
|
||||||
|
grid-template-columns: 90px auto 1fr;
|
||||||
|
grid-gap: 10px 5px;
|
||||||
|
|
||||||
|
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
|
||||||
|
background-color: rgb(255, 255, 255);
|
||||||
|
padding: 3px 10px;
|
||||||
|
border-radius: 10px;
|
||||||
|
/*min-height: 100px;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item:hover {
|
||||||
|
background-color: rgb(245, 245, 245)
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-avatar-container {
|
||||||
|
grid-area: logo;
|
||||||
|
padding: 10px 0 10px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-avatar {
|
||||||
|
max-width: 100%;
|
||||||
|
height: 75px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-avatar-container .fa {
|
||||||
|
margin-top: 5px;
|
||||||
|
padding: 15px;
|
||||||
|
font-size: 35px;
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-avatar-container .fa.fa-check {
|
||||||
|
background-color: #08DD73;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-user {
|
||||||
|
grid-area: username;
|
||||||
|
margin: 5px 0 0 !important;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-meta {
|
||||||
|
grid-area: metadata;
|
||||||
|
margin: 9px 10px 0 0;
|
||||||
|
color: rgb(97, 97, 97);
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-content {
|
||||||
|
grid-area: content;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #777;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-actions {
|
||||||
|
grid-area: actions;
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-actions .item-btn {
|
||||||
|
display: inline-block;
|
||||||
|
margin: 0 5px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-post-item .item-actions .item-btn:first-child {
|
||||||
|
margin-left: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
.like-button-floating {
|
.like-button-floating {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
-webkit-transform: translateX(-100%);
|
-webkit-transform: translateX(-100%);
|
||||||
|
|
|
@ -63,19 +63,18 @@ $(document).on("keydown", function (e) {
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
|
|
||||||
$('#postTitle').bind('click', function () {
|
$('#postTitle')
|
||||||
|
.bind('click', function () {
|
||||||
$(this).attr('contentEditable', true);
|
$(this).attr('contentEditable', true);
|
||||||
}).blur(
|
}).blur(
|
||||||
function () {
|
function () {
|
||||||
$(this).attr('contentEditable', false);
|
$(this).attr('contentEditable', false);
|
||||||
});
|
}).on('keyup', function () {
|
||||||
|
|
||||||
$('#postTitle').on('keyup', function () {
|
|
||||||
if (changeUrl) {
|
if (changeUrl) {
|
||||||
var title = prepareString($('#postTitle').text());
|
var title = prepareString($('#postTitle').text());
|
||||||
$('#postUrl').val(encodeURI(title));
|
$('#postUrl').val(encodeURI(title));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#postDescription').bind('click', function () {
|
$('#postDescription').bind('click', function () {
|
||||||
$(this).attr('contentEditable', true);
|
$(this).attr('contentEditable', true);
|
||||||
|
@ -89,7 +88,7 @@ $('#postCategory').bind('change', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
function switchCategory() {
|
function switchCategory() {
|
||||||
if ($('#postCategory').val() === 'new-category') {
|
if ($('#postCategory').val().includes('new-category')) {
|
||||||
$('#new-category').fadeIn(250);
|
$('#new-category').fadeIn(250);
|
||||||
} else {
|
} else {
|
||||||
$('#new-category').fadeOut(250);
|
$('#new-category').fadeOut(250);
|
||||||
|
@ -236,13 +235,8 @@ $(function () {
|
||||||
getPostTags();
|
getPostTags();
|
||||||
// getTranslations();
|
// getTranslations();
|
||||||
|
|
||||||
if ($('#contentID').val() !== '-1') {
|
if ($('#versionID').val() !== '-1')
|
||||||
getContentData();
|
getVersionData();
|
||||||
}
|
|
||||||
|
|
||||||
if ($('#translationID').val() !== '-1') {
|
|
||||||
getTranslationData();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#postPublishDate').datetimepicker({
|
$('#postPublishDate').datetimepicker({
|
||||||
|
@ -291,66 +285,56 @@ function getPostData() {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
$('#postUrl').val(result.postData.postUrl);
|
const categoryIDs = result.postData.categories.map(item => item.ID);
|
||||||
$('#postCategory').val(result.postData.postCategoryID);
|
$('#postCategory').val(categoryIDs);
|
||||||
switchCategory();
|
switchCategory();
|
||||||
|
|
||||||
$('#postPublishDate').data('DateTimePicker').setValue(convertDate(result.postData.postPublishDate));
|
$('#uploadedImage').val(result.postData.image);
|
||||||
// $('#postPublishDate').val(convertDate(result.postData.postPublishDate));
|
$('.img-container').css('background-image', 'url(' + result.postData.image + ')');
|
||||||
$('#uploadedImage').val(result.postData.postImage);
|
$('#postPublishDate').data('DateTimePicker').setValue(convertDate(result.postData.initialRelease));
|
||||||
$('.img-container').css('background-image', 'url(' + result.postData.postImage + ')');
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (result.postData.postState === "1") {
|
|
||||||
$('#postUrl').attr('disabled', '');
|
function getVersionData() {
|
||||||
changeUrl = false;
|
const postID = $('#postID').val();
|
||||||
$('#postUrl').keydown((e) => {
|
const versionID = $('#versionID').val();
|
||||||
e.preventDefault();
|
const lang = $('#postLanguage').val();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/admin/blog/getVersion',
|
||||||
|
method: 'post',
|
||||||
|
data: {
|
||||||
|
postID, versionID, lang,
|
||||||
|
},
|
||||||
|
success: (result) => {
|
||||||
|
console.log(result);
|
||||||
|
if (result.status === 'success') {
|
||||||
|
$('#postTitle').text(result.title);
|
||||||
|
$('#postDescription').text(result.description);
|
||||||
|
|
||||||
|
console.log(tinyMCE.get('postContent'));
|
||||||
|
if (typeof (tinymce.activeEditor.contentDocument) !== 'undefined') {
|
||||||
|
tinyMCE.on('addeditor', (e) => {
|
||||||
|
const editor = e.editor;
|
||||||
|
if (editor.id === 'postContent') {
|
||||||
|
editor.setContent(result.content);
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
// tinyMCE.activeEditor.setContent(result.content);
|
||||||
|
$('#postContent').val(result.content);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function getContentData() {
|
$('#postUrl').val(result.url);
|
||||||
const postID = $('#postID').val();
|
$('#versionID').val('-1');
|
||||||
const contentID = $('#contentID').val();
|
}
|
||||||
const lang = $('#postLanguage').val();
|
|
||||||
$.ajax({
|
|
||||||
url: '/admin/blog/getContent',
|
|
||||||
method: 'post',
|
|
||||||
data: {
|
|
||||||
postID, contentID, lang
|
|
||||||
},
|
},
|
||||||
success: (result) => {
|
error: console.log
|
||||||
console.log(result);
|
});
|
||||||
if (result.status === 'success') {
|
|
||||||
quill.clipboard.dangerouslyPasteHTML(result.contentData.content);
|
|
||||||
// $('#contentID').val('-1');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function getTranslationData() {
|
|
||||||
const postID = $('#postID').val();
|
|
||||||
const translationID = $('#translationID').val();
|
|
||||||
const lang = $('#postLanguage').val();
|
|
||||||
$.ajax({
|
|
||||||
url: '/admin/blog/getTranslationData',
|
|
||||||
method: 'post',
|
|
||||||
data: {
|
|
||||||
postID, translationID, lang
|
|
||||||
},
|
|
||||||
success: (result) => {
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
if (result.status === 'success') {
|
|
||||||
$('#postTitle').text(result.translationData.postTitle);
|
|
||||||
$('#postDescription').text(result.translationData.postDesc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPostTags() {
|
function getPostTags() {
|
||||||
|
@ -377,54 +361,57 @@ $(function () {
|
||||||
$('#switchLanguages > li').click(function () {
|
$('#switchLanguages > li').click(function () {
|
||||||
const currentPostTitle = $('#postTitle').text();
|
const currentPostTitle = $('#postTitle').text();
|
||||||
const currentPostDescription = $('#postDescription').text();
|
const currentPostDescription = $('#postDescription').text();
|
||||||
const currentPostContent = quill.getContents();
|
// const currentPostContent = quill.getContents();
|
||||||
const currentContentID = $('#contentID').val();
|
const currentPostContent = tinymce.get('postContent').getContent();
|
||||||
const currentTranslationID = $('#translationID').val();
|
const currentPostUrl = $('#postUrl').val();
|
||||||
|
const currentVersionID = $('#versionID').val();
|
||||||
|
|
||||||
$('#switchLanguages > li.active').data('title', currentPostTitle)
|
$('#switchLanguages > li.active')
|
||||||
|
.data('title', currentPostTitle)
|
||||||
.data('description', currentPostDescription)
|
.data('description', currentPostDescription)
|
||||||
.data('content', currentPostContent)
|
.data('content', currentPostContent)
|
||||||
.data('contentid', currentContentID)
|
.data('url', currentPostUrl)
|
||||||
.data('translationid', currentTranslationID)
|
.data('versionid', currentVersionID)
|
||||||
.removeClass('active');
|
.removeClass('active');
|
||||||
|
|
||||||
console.log($(this));
|
console.log($(this));
|
||||||
|
|
||||||
|
const versionID = $(this).data('versionid');
|
||||||
|
|
||||||
|
$('#versionID').val(versionID);
|
||||||
|
$('#postLanguage').val($(this).data('lang'));
|
||||||
|
|
||||||
if ($(this).data('title')) {
|
if ($(this).data('title')) {
|
||||||
const postTitle = $(this).data('title');
|
const postTitle = $(this).data('title');
|
||||||
const postDescription = $(this).data('description');
|
const postDescription = $(this).data('description');
|
||||||
const postContent = $(this).data('content');
|
const postContent = $(this).data('content');
|
||||||
|
const postUrl = $(this).data('url');
|
||||||
|
|
||||||
$('#postTitle').text(postTitle);
|
$('#postTitle').text(postTitle);
|
||||||
$('#postDescription').text(postDescription);
|
$('#postDescription').text(postDescription);
|
||||||
quill.setContents(postContent);
|
// quill.setContents(postContent);
|
||||||
|
tinymce.get('postContent').setContent(postContent);
|
||||||
|
$('#postUrl').val(postUrl);
|
||||||
|
} else {
|
||||||
|
getVersionData();
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentID = $(this).data('contentid');
|
|
||||||
const translationID = $(this).data('translationid');
|
|
||||||
|
|
||||||
$('#contentID').val(contentID);
|
|
||||||
$('#translationID').val(translationID);
|
|
||||||
$('#postLanguage').val($(this).data('lang'));
|
|
||||||
|
|
||||||
getTranslationData();
|
|
||||||
getContentData();
|
|
||||||
|
|
||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function sendPost(executionFinished) {
|
function sendPost(executionFinished) {
|
||||||
const postID = $('#postID').val(),
|
const postID = $('#postID').val(),
|
||||||
contentID = $('#contentID').val(),
|
versionID = $('#versionID').val(),
|
||||||
translationID = $('#translationID').val(),
|
|
||||||
postImage = $('#uploadedImage').val(),
|
postImage = $('#uploadedImage').val(),
|
||||||
postTitle = $('#postTitle').text(),
|
postTitle = $('#postTitle').text(),
|
||||||
postDescription = $('#postDescription').text(),
|
postDescription = $('#postDescription').text(),
|
||||||
postContent = $('.ql-editor').html(),
|
postContent = tinyMCE.activeEditor.getContent(),
|
||||||
postPublishDate = $('#postPublishDate').val(),
|
postPublishDate = $('#postPublishDate').val(),
|
||||||
postUrl = $('#postUrl').val(),
|
postUrl = $('#postUrl').val(),
|
||||||
postCategory = $('#postCategory').val(),
|
postCategories = $('#postCategory').val(),
|
||||||
|
newCategoryName = $('#cat-name').val(),
|
||||||
|
newCategoryDisplayName = $('#cat-dname').val(),
|
||||||
postLanguage = $('#postLanguage').val(),
|
postLanguage = $('#postLanguage').val(),
|
||||||
postTags = $('#postTags').tagsinput('items');
|
postTags = $('#postTags').tagsinput('items');
|
||||||
|
|
||||||
|
@ -433,29 +420,47 @@ function sendPost(executionFinished) {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
postID,
|
postID,
|
||||||
contentID,
|
versionID,
|
||||||
translationID,
|
|
||||||
postImage,
|
postImage,
|
||||||
postTitle,
|
postTitle,
|
||||||
postDescription,
|
postDescription,
|
||||||
postContent,
|
postContent,
|
||||||
postPublishDate,
|
postPublishDate,
|
||||||
postUrl,
|
postUrl,
|
||||||
postCategory,
|
postCategories,
|
||||||
|
newCategoryName,
|
||||||
|
newCategoryDisplayName,
|
||||||
postLanguage,
|
postLanguage,
|
||||||
postTags
|
postTags
|
||||||
},
|
},
|
||||||
success: (result) => {
|
success: (result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
||||||
|
const newCategory = postCategories.includes('new-category');
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
$('#postID').val(result.postID);
|
$('#postID').val(result.postID);
|
||||||
$('#contentID').val(result.contentID);
|
$('#versionID').val(result.versionID);
|
||||||
$('#switchLanguages > li.active').data('contentid', result.contentID);
|
$('#switchLanguages > li.active').data('versionid', result.versionID);
|
||||||
$('#translationID').val(result.translationID);
|
|
||||||
$('#switchLanguages > li.active').data('translationid', result.translationID);
|
|
||||||
|
|
||||||
$('.snackbar-container').append(`<div class="alert alert-success snackbar" role="alert">${result.message}</div>`);
|
$('.snackbar-container').append(`<div class="alert alert-success snackbar" role="alert">${result.message}</div>`);
|
||||||
|
|
||||||
|
if(newCategory) {
|
||||||
|
if(!!result.newCategoryID) {
|
||||||
|
let categories = postCategories;
|
||||||
|
categories.splice(categories.indexOf('new-category'), 1);
|
||||||
|
categories.push(result.newCategoryID.toString());
|
||||||
|
|
||||||
|
$('#postCategory').append(`<option value="${result.newCategoryID}">${newCategoryDisplayName}</option>`);
|
||||||
|
setTimeout(() => {
|
||||||
|
$('#postCategory').val(categories);
|
||||||
|
}, 250);
|
||||||
|
$('#cat-name').val('');
|
||||||
|
$('#cat-dname').val('');
|
||||||
|
} else {
|
||||||
|
$('.snackbar-container').append('<div class="alert alert-warning snackbar" role="alert">Die neue Kategorie konnte nicht erstellt werden.</div>');
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$('.snackbar-container').append(`<div class="alert alert-danger snackbar" role="alert">${result.message}</div>`);
|
$('.snackbar-container').append(`<div class="alert alert-danger snackbar" role="alert">${result.message}</div>`);
|
||||||
}
|
}
|
||||||
|
@ -469,17 +474,17 @@ function sendPost(executionFinished) {
|
||||||
|
|
||||||
function publishPost() {
|
function publishPost() {
|
||||||
const postID = $('#postID').val(),
|
const postID = $('#postID').val(),
|
||||||
contentID = $('#contentID').val(),
|
versionID = $('#versionID').val(),
|
||||||
contentDE = $('#switchLanguages').find('> li[data-lang=de]').data('contentid'),
|
versionDE = $('#switchLanguages').find('> li[data-lang=de]').data('versionid'),
|
||||||
contentEN = $('#switchLanguages').find('> li[data-lang=en]').data('contentid'),
|
versionEN = $('#switchLanguages').find('> li[data-lang=en]').data('versionid'),
|
||||||
contentFR = $('#switchLanguages').find('> li[data-lang=fr]').data('contentid');
|
versionFR = $('#switchLanguages').find('> li[data-lang=fr]').data('versionid');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/admin/blog/publishPost',
|
url: '/admin/blog/publishPost',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: {
|
data: {
|
||||||
postID, contentID,
|
postID, versionID,
|
||||||
contentIDs: {'de': contentDE, 'en': contentEN, 'fr': contentFR}
|
versionIDs: {'de': versionDE, 'en': versionEN, 'fr': versionFR}
|
||||||
},
|
},
|
||||||
success: (result) => {
|
success: (result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
|
39
assets/js/blog-history.js
Normal file
39
assets/js/blog-history.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
let compareItems = [];
|
||||||
|
|
||||||
|
$('.history-compare').on('click', function () {
|
||||||
|
const hashID = $(this).data('hashid');
|
||||||
|
if(compareItems.includes(this)) {
|
||||||
|
compareItems.splice(compareItems.indexOf(this));
|
||||||
|
|
||||||
|
if(compareItems.length === 0) {
|
||||||
|
$('.history-compare').text('Vergleichen mit ...');
|
||||||
|
} else {
|
||||||
|
$(this).text('Zum Vergleich hinzufügen');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(compareItems.length === 0) {
|
||||||
|
$('.history-compare').text('Zum Vergleich hinzufügen');
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
compareItems.push(this);
|
||||||
|
$(this).text('Vom Vergleich entfernen');
|
||||||
|
}
|
||||||
|
updateCompareItemsView();
|
||||||
|
});
|
||||||
|
|
||||||
|
function updateCompareItemsView() {
|
||||||
|
$('.compare-items').empty();
|
||||||
|
compareItems.forEach(item => {
|
||||||
|
$('.compare-items').append(`<span class="badge badge-primary">${item.dataset.hashid.substring(0, 6)}</span>`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if(compareItems.length >= 2) {
|
||||||
|
const url = window.location.pathname + '/compare/' + compareItems[0].dataset.hashid + '/' + compareItems[1].dataset.hashid;
|
||||||
|
$('.compare-btn').attr('disabled', false)
|
||||||
|
.attr('href', url);
|
||||||
|
} else {
|
||||||
|
$('.compare-btn').attr('disabled', true)
|
||||||
|
.attr('href', '#');
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,25 +38,38 @@ var addComment = function () {
|
||||||
comment: comment
|
comment: comment
|
||||||
},
|
},
|
||||||
beforeSend: function () {
|
beforeSend: function () {
|
||||||
var date = new Date();
|
|
||||||
date = date.getDate() + '.' + date.getMonth() + '.' + date.getYear() + ' ' + date.getHours() + ':' + date.getMinutes() + ' Uhr';
|
|
||||||
item = $(`
|
item = $(`
|
||||||
<li>
|
<li>
|
||||||
<div class="well comment-well">
|
<div class="user-post-item">
|
||||||
<div class="d-inline-block mr-2">
|
<div class="item-avatar-container">
|
||||||
<div class="image-placeholder">
|
<div class="loadingSpinner"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<h3 class="item-user">
|
||||||
<div class="d-inline-block mr-2">
|
<a href="#">
|
||||||
<h3>
|
Du
|
||||||
<small>
|
</a>
|
||||||
von Dir / ${date}
|
|
||||||
</small>
|
|
||||||
</h3>
|
</h3>
|
||||||
<p class="comment">${comment}</p>
|
<h4 class="item-meta">
|
||||||
|
jetzt gerade
|
||||||
|
</h4>
|
||||||
|
<p class="item-content">
|
||||||
|
${comment}
|
||||||
|
</p>
|
||||||
|
<div class="item-actions">
|
||||||
|
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Antworten">
|
||||||
|
<i class="far fa-comment"></i>
|
||||||
|
<span>0</span>
|
||||||
|
</a>
|
||||||
|
<a href="#" class="item-btn" data-toggle="tooltip" data-placement="top" title="Gefällt mir">
|
||||||
|
<i class="far fa-heart"></i>
|
||||||
|
<span>0</span>
|
||||||
|
</a>
|
||||||
|
<div class="item-btn dropdown">
|
||||||
|
<a href="#" class="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="loading-container d-inline-block">
|
|
||||||
<i class="fa fa-cog fa-spin"></i>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -67,27 +80,57 @@ var addComment = function () {
|
||||||
$('#addComment').attr('disabled', '');
|
$('#addComment').attr('disabled', '');
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (data.type === 'success') {
|
console.log(data);
|
||||||
|
if (data.success) {
|
||||||
$('#commentField').val('');
|
$('#commentField').val('');
|
||||||
$('#notice-container').html('<div class="alert alert-success" role="alert">Dein Kommentar wurde <b>erfolgreich</b> gesendet!</div>');
|
|
||||||
$('.loading-container', item).css('background-color', '#28b62c');
|
|
||||||
$('.loading-container i', item)
|
|
||||||
.removeClass('fa-cog').removeClass('fa-spin')
|
|
||||||
.addClass('fa-check').css('color', '#fff');
|
|
||||||
$('.content h3 small', item).hide()
|
|
||||||
.html(`von <a href="/user/${data.content.username}" target="_blank">${data.content.displayname}</a> / ${data.content.date}`).fadeIn();
|
|
||||||
$('.loading-container', item).delay(2000).fadeOut(2000);
|
|
||||||
$('.comment-well', item).prepend(`<img src="${data.content.profilePic}" style="display:none">`);
|
|
||||||
$('.comment-well img', item).fadeIn(2000);
|
|
||||||
$('.image-placeholder', item).remove();
|
|
||||||
wait(8000);
|
|
||||||
$('.content', item).removeClass('small');
|
|
||||||
$('.comment-count').text(parseInt($('.comment-count').text()) + 1);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
|
addSnackbar('success', 'Dein Kommentar wurde erfolgreich veröffentlicht!');
|
||||||
|
|
||||||
|
item
|
||||||
|
.find('.item-avatar').attr('src', data.content.profilePicture).attr('alt', data.content.username)
|
||||||
|
.find('.item-user a').attr('href', data.content.profileUrl).text(data.content.displayname);
|
||||||
|
|
||||||
|
item.find('.item-avatar-container .loadingSpinner').fadeOut();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
item.find('.item-avatar-container .loadingSpinner').remove();
|
||||||
|
item.find('.item-avatar-container')
|
||||||
|
.addClass('text-center')
|
||||||
|
.append('<i class="fa fa-check" style="display:none"></i>')
|
||||||
|
.find('.fa').fadeIn();
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
item.find('.item-avatar-container .fa').fadeOut();
|
||||||
|
}, 1500);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
item.find('.item-avatar-container')
|
||||||
|
.empty()
|
||||||
|
.removeClass('text-center')
|
||||||
|
.append(`<img src="${data.content.profilePicture}" class="item-avatar" style="display:none">`)
|
||||||
|
.find('img').fadeIn();
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
// $('.loading-container', item).css('background-color', '#28b62c');
|
||||||
|
// $('.loading-container i', item)
|
||||||
|
// .removeClass('fa-cog').removeClass('fa-spin')
|
||||||
|
// .addClass('fa-check').css('color', '#fff');
|
||||||
|
// $('.content h3 small', item).hide()
|
||||||
|
// .html(`von <a href="/user/${data.content.username}" target="_blank">${data.content.displayname}</a> / ${data.content.date}`).fadeIn();
|
||||||
|
// $('.loading-container', item).delay(2000).fadeOut(2000);
|
||||||
|
// $('.comment-well', item).prepend(`<img src="${data.content.profilePic}" style="display:none">`);
|
||||||
|
// $('.comment-well img', item).fadeIn(2000);
|
||||||
|
// $('.image-placeholder', item).remove();
|
||||||
|
// wait(8000);
|
||||||
|
// $('.content', item).removeClass('small');
|
||||||
|
// $('.comment-count').text(parseInt($('.comment-count').text()) + 1);
|
||||||
|
} else {
|
||||||
|
addSnackbar('danger', data.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
|
console.log(data);
|
||||||
$('#notice-container').html('<div class="alert alert-danger" role="alert"><b>Error:</b> Comment couldn\'t be sent caused by an unkown error! Please try again later or contact the admin to get help!</div>');
|
$('#notice-container').html('<div class="alert alert-danger" role="alert"><b>Error:</b> Comment couldn\'t be sent caused by an unkown error! Please try again later or contact the admin to get help!</div>');
|
||||||
$('div.loading-container', item).css('background-color', '#ff4136');
|
$('div.loading-container', item).css('background-color', '#ff4136');
|
||||||
$('div.loading-container i', item).removeClass('fa-cog').removeClass('fa-spin').addClass('fa-exclamation').css("color", '#fff');
|
$('div.loading-container i', item).removeClass('fa-cog').removeClass('fa-spin').addClass('fa-exclamation').css("color", '#fff');
|
||||||
|
|
92
assets/js/comment-item.js
Normal file
92
assets/js/comment-item.js
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
function openCommentReportModal(ID) {
|
||||||
|
openAsyncModal(
|
||||||
|
'/blog/getReportModal',
|
||||||
|
'Kommentar melden',
|
||||||
|
{ID},
|
||||||
|
() => {
|
||||||
|
$('#commentReportForm').on('submit', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
const reason = $('#commentReportReason').val();
|
||||||
|
const text = $('#commentReportText').val();
|
||||||
|
|
||||||
|
reportComment(ID, reason, text);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'commentReportModal'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reportComment(ID, reason, text) {
|
||||||
|
const modal = $('#commentReportModal');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/blog/reportComment',
|
||||||
|
data: {
|
||||||
|
ID, reason, text
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
success: (result) => {
|
||||||
|
console.log(result);
|
||||||
|
|
||||||
|
modal.modal('hide');
|
||||||
|
|
||||||
|
if(result.success) {
|
||||||
|
addSnackbar('success', result.message);
|
||||||
|
} else {
|
||||||
|
addSnackbar('danger', result.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (result) => {
|
||||||
|
console.log(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCommentDeleteModal(ID) {
|
||||||
|
openAsyncModal(
|
||||||
|
'/blog/getDeleteModal',
|
||||||
|
'Kommentar löschen',
|
||||||
|
{ID},
|
||||||
|
() => {
|
||||||
|
console.log('tetst');
|
||||||
|
},
|
||||||
|
'commentDeleteModal',
|
||||||
|
'lg'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function deleteComment(ID) {
|
||||||
|
const modal = $('#commentDeleteModal');
|
||||||
|
|
||||||
|
modal.find('.modal-body').empty().append('<div class="loadingSpinner"></div>');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/blog/deleteComment',
|
||||||
|
data: {
|
||||||
|
ID
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
success: (result) => {
|
||||||
|
modal.modal('hide');
|
||||||
|
console.log(result);
|
||||||
|
if(result.success) {
|
||||||
|
addSnackbar('success', result.message);
|
||||||
|
$('#comment-' + ID).slideUp();
|
||||||
|
|
||||||
|
let commentCount = $('.comment-count').text();
|
||||||
|
if(commentCount !== '') {
|
||||||
|
commentCount = parseInt(commentCount) - 1;
|
||||||
|
$('.comment-count').text(commentCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
$('#comment-' + ID).remove();
|
||||||
|
}, 500)
|
||||||
|
} else {
|
||||||
|
addSnackbar('danger', result.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: console.log
|
||||||
|
});
|
||||||
|
}
|
|
@ -230,7 +230,7 @@ function closeSearch() {
|
||||||
function executeSearch() {
|
function executeSearch() {
|
||||||
const search = $('.navbar-search input').val().trim();
|
const search = $('.navbar-search input').val().trim();
|
||||||
|
|
||||||
if(search.length < 3) {
|
if (search.length < 3) {
|
||||||
addSnackbar('warning', 'Bitte gib mindestens 3 Buchstaben als Suchbegriff an.');
|
addSnackbar('warning', 'Bitte gib mindestens 3 Buchstaben als Suchbegriff an.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -456,3 +456,54 @@ function addSnackbar(type, text) {
|
||||||
snackbar.remove();
|
snackbar.remove();
|
||||||
}, 5500);
|
}, 5500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openAsyncModal(url, title, data, finished, id, size = 'default') {
|
||||||
|
const modal = $(`
|
||||||
|
<div class="modal fade" id="${id}" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog ${size !== 'default' ? 'modal-' + size : ''} modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h4 class="modal-title">${title}</h4>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Schließen">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="loadingSpinner"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
$('body').append(modal);
|
||||||
|
modal.modal('show');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url,
|
||||||
|
data,
|
||||||
|
method: 'POST',
|
||||||
|
success: (result) => {
|
||||||
|
console.log(result);
|
||||||
|
modal.find('.modal-body').empty();
|
||||||
|
if(result.success) {
|
||||||
|
modal.find('.modal-title').text(result.title);
|
||||||
|
modal.find('.modal-body').append(result.body);
|
||||||
|
finished();
|
||||||
|
} else {
|
||||||
|
modal.modal('hide');
|
||||||
|
addSnackbar('danger', result.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: (data) => {
|
||||||
|
console.log(data);
|
||||||
|
modal.modal('hide');
|
||||||
|
addSnackbar('danger', '<b>Ein unbekannter Fehler ist aufgetreten.</b> Versuche, die Seite erneut zu laden, oder kontaktiere das Support-Team sollte der Fehler bestehen bleiben.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.on('hidden.bs.modal', function() {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
|
||||||
|
return modal;
|
||||||
|
}
|
|
@ -372,10 +372,31 @@ function submitPost(content, replyTo) {
|
||||||
resetPostForm();
|
resetPostForm();
|
||||||
},
|
},
|
||||||
success: function (data) {
|
success: function (data) {
|
||||||
|
console.log(data);
|
||||||
$('.loadingSpinner', body).remove();
|
$('.loadingSpinner', body).remove();
|
||||||
body.append(data);
|
body.append(`
|
||||||
|
<div class="alert alert-${data.success ? 'success' : 'danger'}" role="alert">
|
||||||
|
<b>${data.title}</b>
|
||||||
|
${data.message.join('<br>')}
|
||||||
|
</div>
|
||||||
|
`);
|
||||||
|
if(data.buttons) {
|
||||||
|
const footer = $('<div class="modal-footer"></div>');
|
||||||
|
body.parent().append(footer);
|
||||||
|
data.buttons.forEach(button => {
|
||||||
|
let btn;
|
||||||
|
if(button.action) {
|
||||||
|
btn = `<a href="${button.action}" class="btn btn-${button.type}">${button.text}</a>`;
|
||||||
|
} else {
|
||||||
|
btn = `<button role="button" class="btn btn-${button.type}">${button.text}</button>`;
|
||||||
|
}
|
||||||
|
footer.append(btn);
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error: function (data) {
|
error: function (data) {
|
||||||
|
console.log(data);
|
||||||
|
addSnackbar('warning', '<b>Ein unbekannter Fehler ist beim Veröffentlichen deines Posts aufgetreten.</b> Bitte versuche es später erneut oder kontaktiere uns.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -81,7 +81,8 @@ function registerPostEvents() {
|
||||||
$('.post-item').click(function (e) {
|
$('.post-item').click(function (e) {
|
||||||
const target = e.target;
|
const target = e.target;
|
||||||
|
|
||||||
if(target.tagName !== 'BUTTON' && target.tagName !== 'INPUT' && target.tagName !== 'A' && target.tagName !== 'IMG' && target.tagName !== 'I' && !target.classList.contains('post-media')) {
|
const forbiddenElements = ['BUTTON', 'A', 'INPUT', 'IMG', 'I', 'SPAN'];
|
||||||
|
if(!forbiddenElements.includes(target.tagName) && !target.classList.contains('post-media')) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const uuid = $(this).data('uuid');
|
const uuid = $(this).data('uuid');
|
||||||
const username = $(this).data('username');
|
const username = $(this).data('username');
|
||||||
|
@ -141,16 +142,9 @@ function addPostLike(el) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
text.text(likeCount);
|
text.text(likeCount);
|
||||||
$('body').append(`
|
addSnackbar('warning', result.message);
|
||||||
<div class="alert alert-warning snackbar" id="message-uuid-${uuid}" role="alert">
|
|
||||||
${result.message}
|
|
||||||
</div>
|
|
||||||
`);
|
|
||||||
icon.toggleClass('far').toggleClass('fas');
|
icon.toggleClass('far').toggleClass('fas');
|
||||||
icon.parent().toggleClass('active');
|
icon.parent().toggleClass('active');
|
||||||
setTimeout(() => {
|
|
||||||
$('#message-uuid-' + uuid).remove();
|
|
||||||
}, 6000);
|
|
||||||
}
|
}
|
||||||
pendingRequests.splice(pendingRequests.indexOf(uuid), 1);
|
pendingRequests.splice(pendingRequests.indexOf(uuid), 1);
|
||||||
},
|
},
|
||||||
|
@ -215,7 +209,7 @@ function loadPostReportModal(uuid) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$('#postReportForm').slideUp();
|
$('#postReportForm').slideUp();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$('#postReportBody').append('<i class="fa fa-cog fa-4x fa-spin text-center"></i>');
|
$('#postReportBody').addClass('text-center').append('<i class="fa fa-cog fa-4x fa-spin"></i>');
|
||||||
}, 200);
|
}, 200);
|
||||||
submitReportForm(uuid, $('#postReportReason').val(), $('#postReportText').val());
|
submitReportForm(uuid, $('#postReportReason').val(), $('#postReportText').val());
|
||||||
});
|
});
|
||||||
|
@ -225,11 +219,11 @@ function loadPostReportModal(uuid) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function submitReportForm(postUuid, reportReason, reportText) {
|
function submitReportForm(hashID, reportReason, reportText) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/posts/reportPost',
|
url: '/posts/reportPost',
|
||||||
data: {
|
data: {
|
||||||
uuid: postUuid,
|
hashID,
|
||||||
reason: reportReason,
|
reason: reportReason,
|
||||||
explanation: reportText
|
explanation: reportText
|
||||||
},
|
},
|
||||||
|
@ -253,8 +247,8 @@ function submitReportForm(postUuid, reportReason, reportText) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$('#postReportBody').find('.alert').slideDown();
|
$('#postReportBody').find('.alert').slideDown();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openDeletePostModal(uuid) {
|
function openDeletePostModal(uuid) {
|
||||||
|
@ -278,52 +272,52 @@ function openDeletePostModal(uuid) {
|
||||||
|
|
||||||
$('#postDeleteModal').modal('show');
|
$('#postDeleteModal').modal('show');
|
||||||
$('#postDeleteModal').on('hidden.bs.modal', function () {
|
$('#postDeleteModal').on('hidden.bs.modal', function () {
|
||||||
$('#postDeleteModal').remove();
|
$(this).remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
loadDeletePostModal(uuid);
|
loadDeletePostModal(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadDeletePostModal(uuid) {
|
function loadDeletePostModal(hashID) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/posts/getDeleteModal',
|
url: '/posts/getDeleteModal',
|
||||||
data: {
|
data: {
|
||||||
uuid
|
hashID
|
||||||
},
|
},
|
||||||
method: 'post',
|
method: 'post',
|
||||||
success: data => {
|
success: data => {
|
||||||
$('#postReportTitle').text(data.title);
|
$('#postReportTitle').text(data.title);
|
||||||
$('#postDeleteBody').removeClass('text-center').html(data.body);
|
$('#postDeleteBody').removeClass('text-center').html(data.body);
|
||||||
}
|
},
|
||||||
|
error: console.log
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function deletePost(uuid) {
|
function deletePost(hashID) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/posts/deletePost',
|
url: '/posts/deletePost',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: { uuid },
|
data: { hashID },
|
||||||
beforeSend: () => {
|
beforeSend: () => {
|
||||||
$('#postDeleteBody').addClass('text-center').html('<i class="fa fa-cog fa-spin fa-4x"></i>');
|
$('#postDeleteBody').addClass('text-center').html('<i class="fa fa-cog fa-spin fa-4x"></i>');
|
||||||
},
|
},
|
||||||
success: data => {
|
success: data => {
|
||||||
|
let timeout = 2000;
|
||||||
if(data.success) {
|
if(data.success) {
|
||||||
$('#postDeleteBody').html('<div class="alert alert-success" role="alert"></div>');
|
addSnackbar('success', data.message);
|
||||||
|
timeout = 0;
|
||||||
} else {
|
} else {
|
||||||
$('#postDeleteBody').html('<div class="alert alert-danger" role="alert"></div>');
|
$('#postDeleteBody').html(`<div class="alert alert-danger" role="alert">${data.message}</div>`);
|
||||||
}
|
}
|
||||||
$('#postDeleteBody').removeClass('text-center').find('.alert').text(data.message);
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$('#postDeleteModal').modal('hide');
|
$('#postDeleteModal').modal('hide');
|
||||||
$(`.post-item[data-uuid=${uuid}]`).slideUp();
|
$(`.post-item[data-uuid=${hashID}]`).slideUp();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
$('#postDeleteModal').modal('dispose').remove();
|
$('#postDeleteModal').modal('dispose').remove();
|
||||||
$(`.post-item[data-uuid=${uuid}]`).remove();
|
$(`.post-item[data-uuid=${hashID}]`).remove();
|
||||||
}, 500);
|
}, 500);
|
||||||
}, 2000);
|
}, timeout);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function addScrollListener() {
|
|
||||||
}
|
|
|
@ -6,7 +6,7 @@ $("input").blur(function () {
|
||||||
passwordError = false,
|
passwordError = false,
|
||||||
passwordRepeatError = false;
|
passwordRepeatError = false;
|
||||||
// Username
|
// Username
|
||||||
if ($(this).attr('name') === "username") {
|
if ($(this).attr('name') === "displayname") {
|
||||||
if ($(this).val().length < 4) {
|
if ($(this).val().length < 4) {
|
||||||
$('#usernameErrorLength').addClass('active');
|
$('#usernameErrorLength').addClass('active');
|
||||||
usernameError = true;
|
usernameError = true;
|
||||||
|
|
386
vendor/Diff/class.Diff.php
vendored
Normal file
386
vendor/Diff/class.Diff.php
vendored
Normal file
|
@ -0,0 +1,386 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
class.Diff.php
|
||||||
|
|
||||||
|
A class containing a diff implementation
|
||||||
|
|
||||||
|
Created by Kate Morley - http://iamkate.com/ - and released under the terms of
|
||||||
|
the CC0 1.0 Universal legal code:
|
||||||
|
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/legalcode
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// A class containing functions for computing diffs and formatting the output.
|
||||||
|
class Diff{
|
||||||
|
|
||||||
|
// define the constants
|
||||||
|
const UNMODIFIED = 0;
|
||||||
|
const DELETED = 1;
|
||||||
|
const INSERTED = 2;
|
||||||
|
|
||||||
|
/* Returns the diff for two strings. The return value is an array, each of
|
||||||
|
* whose values is an array containing two values: a line (or character, if
|
||||||
|
* $compareCharacters is true), and one of the constants DIFF::UNMODIFIED (the
|
||||||
|
* line or character is in both strings), DIFF::DELETED (the line or character
|
||||||
|
* is only in the first string), and DIFF::INSERTED (the line or character is
|
||||||
|
* only in the second string). The parameters are:
|
||||||
|
*
|
||||||
|
* $string1 - the first string
|
||||||
|
* $string2 - the second string
|
||||||
|
* $compareCharacters - true to compare characters, and false to compare
|
||||||
|
* lines; this optional parameter defaults to false
|
||||||
|
*/
|
||||||
|
public static function compare(
|
||||||
|
$string1, $string2, $compareCharacters = false){
|
||||||
|
|
||||||
|
// initialise the sequences and comparison start and end positions
|
||||||
|
$start = 0;
|
||||||
|
if ($compareCharacters){
|
||||||
|
$sequence1 = $string1;
|
||||||
|
$sequence2 = $string2;
|
||||||
|
$end1 = strlen($string1) - 1;
|
||||||
|
$end2 = strlen($string2) - 1;
|
||||||
|
}else{
|
||||||
|
$sequence1 = preg_split('/\R/', $string1);
|
||||||
|
$sequence2 = preg_split('/\R/', $string2);
|
||||||
|
$end1 = count($sequence1) - 1;
|
||||||
|
$end2 = count($sequence2) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip any common prefix
|
||||||
|
while ($start <= $end1 && $start <= $end2
|
||||||
|
&& $sequence1[$start] == $sequence2[$start]){
|
||||||
|
$start ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip any common suffix
|
||||||
|
while ($end1 >= $start && $end2 >= $start
|
||||||
|
&& $sequence1[$end1] == $sequence2[$end2]){
|
||||||
|
$end1 --;
|
||||||
|
$end2 --;
|
||||||
|
}
|
||||||
|
|
||||||
|
// compute the table of longest common subsequence lengths
|
||||||
|
$table = self::computeTable($sequence1, $sequence2, $start, $end1, $end2);
|
||||||
|
|
||||||
|
// generate the partial diff
|
||||||
|
$partialDiff =
|
||||||
|
self::generatePartialDiff($table, $sequence1, $sequence2, $start);
|
||||||
|
|
||||||
|
// generate the full diff
|
||||||
|
$diff = array();
|
||||||
|
for ($index = 0; $index < $start; $index ++){
|
||||||
|
$diff[] = array($sequence1[$index], self::UNMODIFIED);
|
||||||
|
}
|
||||||
|
while (count($partialDiff) > 0) $diff[] = array_pop($partialDiff);
|
||||||
|
for ($index = $end1 + 1;
|
||||||
|
$index < ($compareCharacters ? strlen($sequence1) : count($sequence1));
|
||||||
|
$index ++){
|
||||||
|
$diff[] = array($sequence1[$index], self::UNMODIFIED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the diff
|
||||||
|
return $diff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the diff for two files. The parameters are:
|
||||||
|
*
|
||||||
|
* $file1 - the path to the first file
|
||||||
|
* $file2 - the path to the second file
|
||||||
|
* $compareCharacters - true to compare characters, and false to compare
|
||||||
|
* lines; this optional parameter defaults to false
|
||||||
|
*/
|
||||||
|
public static function compareFiles(
|
||||||
|
$file1, $file2, $compareCharacters = false){
|
||||||
|
|
||||||
|
// return the diff of the files
|
||||||
|
return self::compare(
|
||||||
|
file_get_contents($file1),
|
||||||
|
file_get_contents($file2),
|
||||||
|
$compareCharacters);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the table of longest common subsequence lengths for the specified
|
||||||
|
* sequences. The parameters are:
|
||||||
|
*
|
||||||
|
* $sequence1 - the first sequence
|
||||||
|
* $sequence2 - the second sequence
|
||||||
|
* $start - the starting index
|
||||||
|
* $end1 - the ending index for the first sequence
|
||||||
|
* $end2 - the ending index for the second sequence
|
||||||
|
*/
|
||||||
|
private static function computeTable(
|
||||||
|
$sequence1, $sequence2, $start, $end1, $end2){
|
||||||
|
|
||||||
|
// determine the lengths to be compared
|
||||||
|
$length1 = $end1 - $start + 1;
|
||||||
|
$length2 = $end2 - $start + 1;
|
||||||
|
|
||||||
|
// initialise the table
|
||||||
|
$table = array(array_fill(0, $length2 + 1, 0));
|
||||||
|
|
||||||
|
// loop over the rows
|
||||||
|
for ($index1 = 1; $index1 <= $length1; $index1 ++){
|
||||||
|
|
||||||
|
// create the new row
|
||||||
|
$table[$index1] = array(0);
|
||||||
|
|
||||||
|
// loop over the columns
|
||||||
|
for ($index2 = 1; $index2 <= $length2; $index2 ++){
|
||||||
|
|
||||||
|
// store the longest common subsequence length
|
||||||
|
if ($sequence1[$index1 + $start - 1]
|
||||||
|
== $sequence2[$index2 + $start - 1]){
|
||||||
|
$table[$index1][$index2] = $table[$index1 - 1][$index2 - 1] + 1;
|
||||||
|
}else{
|
||||||
|
$table[$index1][$index2] =
|
||||||
|
max($table[$index1 - 1][$index2], $table[$index1][$index2 - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the table
|
||||||
|
return $table;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the partial diff for the specificed sequences, in reverse order.
|
||||||
|
* The parameters are:
|
||||||
|
*
|
||||||
|
* $table - the table returned by the computeTable function
|
||||||
|
* $sequence1 - the first sequence
|
||||||
|
* $sequence2 - the second sequence
|
||||||
|
* $start - the starting index
|
||||||
|
*/
|
||||||
|
private static function generatePartialDiff(
|
||||||
|
$table, $sequence1, $sequence2, $start){
|
||||||
|
|
||||||
|
// initialise the diff
|
||||||
|
$diff = array();
|
||||||
|
|
||||||
|
// initialise the indices
|
||||||
|
$index1 = count($table) - 1;
|
||||||
|
$index2 = count($table[0]) - 1;
|
||||||
|
|
||||||
|
// loop until there are no items remaining in either sequence
|
||||||
|
while ($index1 > 0 || $index2 > 0){
|
||||||
|
|
||||||
|
// check what has happened to the items at these indices
|
||||||
|
if ($index1 > 0 && $index2 > 0
|
||||||
|
&& $sequence1[$index1 + $start - 1]
|
||||||
|
== $sequence2[$index2 + $start - 1]){
|
||||||
|
|
||||||
|
// update the diff and the indices
|
||||||
|
$diff[] = array($sequence1[$index1 + $start - 1], self::UNMODIFIED);
|
||||||
|
$index1 --;
|
||||||
|
$index2 --;
|
||||||
|
|
||||||
|
}elseif ($index2 > 0
|
||||||
|
&& $table[$index1][$index2] == $table[$index1][$index2 - 1]){
|
||||||
|
|
||||||
|
// update the diff and the indices
|
||||||
|
$diff[] = array($sequence2[$index2 + $start - 1], self::INSERTED);
|
||||||
|
$index2 --;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// update the diff and the indices
|
||||||
|
$diff[] = array($sequence1[$index1 + $start - 1], self::DELETED);
|
||||||
|
$index1 --;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the diff
|
||||||
|
return $diff;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns a diff as a string, where unmodified lines are prefixed by ' ',
|
||||||
|
* deletions are prefixed by '- ', and insertions are prefixed by '+ '. The
|
||||||
|
* parameters are:
|
||||||
|
*
|
||||||
|
* $diff - the diff array
|
||||||
|
* $separator - the separator between lines; this optional parameter defaults
|
||||||
|
* to "\n"
|
||||||
|
*/
|
||||||
|
public static function toString($diff, $separator = "\n"){
|
||||||
|
|
||||||
|
// initialise the string
|
||||||
|
$string = '';
|
||||||
|
|
||||||
|
// loop over the lines in the diff
|
||||||
|
foreach ($diff as $line){
|
||||||
|
|
||||||
|
// extend the string with the line
|
||||||
|
switch ($line[1]){
|
||||||
|
case self::UNMODIFIED : $string .= ' ' . $line[0];break;
|
||||||
|
case self::DELETED : $string .= '- ' . $line[0];break;
|
||||||
|
case self::INSERTED : $string .= '+ ' . $line[0];break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// extend the string with the separator
|
||||||
|
$string .= $separator;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the string
|
||||||
|
return $string;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns a diff as an HTML string, where unmodified lines are contained
|
||||||
|
* within 'span' elements, deletions are contained within 'del' elements, and
|
||||||
|
* insertions are contained within 'ins' elements. The parameters are:
|
||||||
|
*
|
||||||
|
* $diff - the diff array
|
||||||
|
* $separator - the separator between lines; this optional parameter defaults
|
||||||
|
* to '<br>'
|
||||||
|
*/
|
||||||
|
public static function toHTML($diff, $separator = '<br>'){
|
||||||
|
|
||||||
|
// initialise the HTML
|
||||||
|
$html = '';
|
||||||
|
|
||||||
|
// loop over the lines in the diff
|
||||||
|
foreach ($diff as $line){
|
||||||
|
|
||||||
|
// extend the HTML with the line
|
||||||
|
switch ($line[1]){
|
||||||
|
case self::UNMODIFIED : $element = 'span'; break;
|
||||||
|
case self::DELETED : $element = 'del'; break;
|
||||||
|
case self::INSERTED : $element = 'ins'; break;
|
||||||
|
}
|
||||||
|
$html .=
|
||||||
|
'<' . $element . '>'
|
||||||
|
. htmlspecialchars($line[0])
|
||||||
|
. '</' . $element . '>';
|
||||||
|
|
||||||
|
// extend the HTML with the separator
|
||||||
|
$html .= $separator;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the HTML
|
||||||
|
return $html;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns a diff as an HTML table. The parameters are:
|
||||||
|
*
|
||||||
|
* $diff - the diff array
|
||||||
|
* $indentation - indentation to add to every line of the generated HTML; this
|
||||||
|
* optional parameter defaults to ''
|
||||||
|
* $separator - the separator between lines; this optional parameter
|
||||||
|
* defaults to '<br>'
|
||||||
|
*/
|
||||||
|
public static function toTable($diff, $indentation = '', $separator = '<br>'){
|
||||||
|
|
||||||
|
// initialise the HTML
|
||||||
|
$html = $indentation . "<table class=\"diff\">\n";
|
||||||
|
|
||||||
|
// loop over the lines in the diff
|
||||||
|
$index = 0;
|
||||||
|
while ($index < count($diff)){
|
||||||
|
|
||||||
|
// determine the line type
|
||||||
|
switch ($diff[$index][1]){
|
||||||
|
|
||||||
|
// display the content on the left and right
|
||||||
|
case self::UNMODIFIED:
|
||||||
|
$leftCell =
|
||||||
|
self::getCellContent(
|
||||||
|
$diff, $indentation, $separator, $index, self::UNMODIFIED);
|
||||||
|
$rightCell = $leftCell;
|
||||||
|
break;
|
||||||
|
|
||||||
|
// display the deleted on the left and inserted content on the right
|
||||||
|
case self::DELETED:
|
||||||
|
$leftCell =
|
||||||
|
self::getCellContent(
|
||||||
|
$diff, $indentation, $separator, $index, self::DELETED);
|
||||||
|
$rightCell =
|
||||||
|
self::getCellContent(
|
||||||
|
$diff, $indentation, $separator, $index, self::INSERTED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
// display the inserted content on the right
|
||||||
|
case self::INSERTED:
|
||||||
|
$leftCell = '';
|
||||||
|
$rightCell =
|
||||||
|
self::getCellContent(
|
||||||
|
$diff, $indentation, $separator, $index, self::INSERTED);
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// extend the HTML with the new row
|
||||||
|
$html .=
|
||||||
|
$indentation
|
||||||
|
. " <tr>\n"
|
||||||
|
. $indentation
|
||||||
|
. ' <td class="diff'
|
||||||
|
. ($leftCell == $rightCell
|
||||||
|
? 'Unmodified'
|
||||||
|
: ($leftCell == '' ? 'Blank' : 'Deleted'))
|
||||||
|
. '">'
|
||||||
|
. $leftCell
|
||||||
|
. "</td>\n"
|
||||||
|
. $indentation
|
||||||
|
. ' <td class="diff'
|
||||||
|
. ($leftCell == $rightCell
|
||||||
|
? 'Unmodified'
|
||||||
|
: ($rightCell == '' ? 'Blank' : 'Inserted'))
|
||||||
|
. '">'
|
||||||
|
. $rightCell
|
||||||
|
. "</td>\n"
|
||||||
|
. $indentation
|
||||||
|
. " </tr>\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the HTML
|
||||||
|
return $html . $indentation . "</table>\n";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Returns the content of the cell, for use in the toTable function. The
|
||||||
|
* parameters are:
|
||||||
|
*
|
||||||
|
* $diff - the diff array
|
||||||
|
* $indentation - indentation to add to every line of the generated HTML
|
||||||
|
* $separator - the separator between lines
|
||||||
|
* $index - the current index, passes by reference
|
||||||
|
* $type - the type of line
|
||||||
|
*/
|
||||||
|
private static function getCellContent(
|
||||||
|
$diff, $indentation, $separator, &$index, $type){
|
||||||
|
|
||||||
|
// initialise the HTML
|
||||||
|
$html = '';
|
||||||
|
|
||||||
|
// loop over the matching lines, adding them to the HTML
|
||||||
|
while ($index < count($diff) && $diff[$index][1] == $type){
|
||||||
|
$html .=
|
||||||
|
'<span>'
|
||||||
|
. htmlspecialchars($diff[$index][0])
|
||||||
|
. '</span>'
|
||||||
|
. $separator;
|
||||||
|
$index ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the HTML
|
||||||
|
return $html;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Reference in New Issue
Block a user