Archived
1
0

Database refactoring and improving blog comments, blog post history and more

This commit is contained in:
Marcel
2019-01-08 22:42:54 +01:00
parent 56aed78b00
commit 7f887a99b0
67 changed files with 3076 additions and 1755 deletions

View File

@@ -1,188 +1,336 @@
<?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() {
parent::__construct('blog');
$this->load->model('BlogModel', '', TRUE);
$this->load->helper('url');
}
function index() {
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getAllPosts('', 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if(!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount('', 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => '']);
function __construct()
{
parent::__construct('blog');
$this->load->model('BlogModel', '', TRUE);
$this->load->helper('url');
}
$this->load->view('footer', ['additionalScripts' => ['lib/jquery.twbsPagination.min.js']]);
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
function search($query = null) {
if(isset($_GET['q'])) {
redirect(base_url('blog/search/' . urlencode($this->input->get('q'))));
} elseif($query == null) {
redirect(base_url('blog'));
} else {
$query = $this->security->xss_clean(urldecode($query));
function index()
{
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getAllPosts($query, 5, $offset);
$data = $this->BlogModel->getAllPosts('', 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if(!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount($query, 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $query]);
}
$this->load->view('footer');
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
}
function category($category = null) {
if($category == null) {
redirect(base_url('blog'));
} else {
$category = urldecode($category);
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getCategoryPosts($category, 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if(!empty($data)) {
if (!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount('', 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $category]);
$this->load->view('blog/postListError', ['search' => '']);
}
$this->load->view('footer', ['additionalScripts' => ['lib/jquery.twbsPagination.min.js']]);
$this->load->view('blog/pagination', ['pageCount' => $pageCount, 'page' => $offset]);
}
function search($query = null)
{
if (isset($_GET['q'])) {
redirect(base_url('blog/search/' . urlencode($this->input->get('q'))));
} elseif ($query == null) {
redirect(base_url('blog'));
} else {
$query = $this->security->xss_clean(urldecode($query));
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getAllPosts($query, 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if (!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount($query, 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $query]);
}
$this->load->view('footer');
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
}
function category($category = null)
{
if ($category == null) {
redirect(base_url('blog'));
} else {
$category = urldecode($category);
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getCategoryPosts($category, 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if (!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount('', 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $category]);
}
$this->load->view('footer');
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
}
public function tag($tag = null)
{
if ($tag == null) {
redirect(base_url('blog'));
}
$tag = urldecode($tag);
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
$data = $this->BlogModel->getTagPosts($tag, 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if (!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount('', 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $tag]);
}
$this->load->view('footer');
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
}
public function tag($tag = null) {
if($tag == null) {
redirect(base_url('blog'));
}
$tag = urldecode($tag);
$offset = isset($_GET['page']) ? intval($_GET['page']) -1 : 0;
$data = $this->BlogModel->getTagPosts($tag, 5, $offset);
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
if(!empty($data)) {
$pageCount = $this->BlogModel->getPostPageCount('', 5);
$this->load->view('blog/postList', ['pageContent' => $data]);
} else {
$pageCount = 1;
$this->load->view('blog/postListError', ['search' => $tag]);
}
$this->load->view('footer');
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
}
function add() {
if(isset($_SESSION['user']) && $this->hasPermission('blog.create')) {
redirect('/admin/blog/add');
} else {
redirect('/blog');
}
}
function post($postTitle = null) {
if($postTitle == null) {
redirect("/blog");
} elseif(isset($_GET['q'])) {
redirect('/blog?q=' . $_GET['q']);
} else {
$post = $this->BlogModel->getPost($postTitle);
if(empty($post)) {
function add()
{
if (isset($_SESSION['user']) && $this->hasPermission('blog.create')) {
redirect('/admin/blog/add');
} else {
redirect('/blog');
} else {
$post['randomPosts'] = $this->BlogModel->getRandomPosts($post['postID']);
$post['comments'] = $this->BlogModel->getComments($post['postID']);
$post['tags'] = $this->BlogModel->getTags($post['postID']);
$post['hasLiked'] = isset($_SESSION['user']) && !empty($_SESSION['user']) ? $this->BlogModel->hasAlreadyLiked($post['postID'], $_SESSION['user']['ID']) : false;
$sameCategoryPosts = $this->BlogModel->getCategoryPostsByID($post['postCategoryID'], 3, $post['postID']);
$post['prevPost'] = $this->BlogModel->getPrevPost($post['postID']);
$post['nextPost'] = $this->BlogModel->getNextPost($post['postID']);
$this->BlogModel->incrementViews($post['postID']);
$this->load->view('header', ['active' => 'blog', 'title' => $post['postTitle'], 'additionalStyles' => ['posts_list.css', 'blog.css']]);
$this->load->view('blog/first', ['categoryPosts' => $sameCategoryPosts, 'categories' => $this->BlogModel->getCategories()]);
$this->load->view('blog/post', $post);
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
}
}
}
function like() {
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
echo "no-user";
} else {
if(!$this->BlogModel->hasAlreadyLiked($_POST['postID'], $_SESSION['user']['ID'])) {
echo 'true:';
echo $this->BlogModel->addLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
function post($postTitle = null)
{
if ($postTitle == null) {
redirect("/blog");
} elseif (isset($_GET['q'])) {
redirect('/blog?q=' . $_GET['q']);
} else {
echo 'false:';
echo $this->BlogModel->removeLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
$post = $this->BlogModel->getPost($postTitle);
if (empty($post)) {
redirect('/blog');
} else {
$post['randomPosts'] = $this->BlogModel->getRandomPosts($post['ID']);
$post['comments'] = $this->BlogModel->getComments($post['ID']);
$post['tags'] = $this->BlogModel->getTags($post['ID']);
$post['hasLiked'] = isset($_SESSION['user']) && !empty($_SESSION['user']) ? $this->BlogModel->hasAlreadyLiked($post['ID'], $_SESSION['user']['ID']) : false;
$sameCategoryPosts = $this->BlogModel->getCategoryPostsByID($post['categories'], 3, $post['ID']);
$post['prevPost'] = $this->BlogModel->getPrevPost($post['initialRelease']);
$post['nextPost'] = $this->BlogModel->getNextPost($post['initialRelease']);
$this->BlogModel->incrementViews($post['ID']);
$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/post', $post);
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js', 'comment-item.js']]);
}
}
}
}
function comment() {
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
$result = ['type' => 'error', 'message' => 'Nicht eingeloggt'];
} else {
$url = $this->input->post('url');
function like()
{
if (!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
echo "no-user";
} else {
if (!$this->BlogModel->hasAlreadyLiked($_POST['postID'], $_SESSION['user']['ID'])) {
echo 'true:';
echo $this->BlogModel->addLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
} else {
echo 'false:';
echo $this->BlogModel->removeLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
}
}
}
function comment()
{
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 {
$url = $this->input->post('url');
$url = str_replace('/blog/post/', '', $url);
$comment = $this->BlogModel->addCommentByUrl($url, $_SESSION['user']['ID'], $this->input->post('comment'), NULL);
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'],
'displayname' => $_SESSION['user']['displayname'],
'profilePicture' => $_SESSION['user']['profilePic'],
]
];
}
}
header("Content-Type: application/json");
echo json_encode($result);
}
function getComments()
{
$url = $this->input->get('url');
$url = str_replace('/blog/post/', '', $url);
$comment = $this->BlogModel->addCommentByUrl($url, $_SESSION['user']['ID'], $this->input->post('comment'), false, NULL);
$result = ['type' => 'success', 'content' => [
'username' => $_SESSION['user']['username'],
'displayname' => $_SESSION['user']['displayname'],
'profilePic' => $_SESSION['user']['profilePic'],
'date' => date('d.m.Y H: i \\U\\h\\r', strtotime($comment['date_created']))
]];
$authorCache = [];
$comments = $this->BlogModel->getCommentsByUrl($url);
foreach ($comments as $comment) {
$userID = $comment['userID'];
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]);
}
}
header("Content-Type: application/json");
echo json_encode($result);
}
public function getReportModal()
{
header('Content-Type: application/json');
function getComments() {
$url = $this->input->get('url');
$url = str_replace('/blog/post/', '', $url);
$comments = $this->BlogModel->getCommentsByUrl($url);
foreach($comments as $comment) {
$comment['author'] = $this->BlogModel->getAuthorData($comment['user_id']);
$this->load->view('blog/comment', $comment);
$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.']);
}
}

View File

@@ -14,7 +14,7 @@ class File extends MY_Controller
if ($title == null) {
redirect(base_url());
} 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)) {
$file = $file[0];

View File

@@ -26,7 +26,7 @@
$rememberMe = isset($_POST['rememberMe']) ? $_POST['rememberMe'] : 'off';
$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'] : '';

View File

@@ -20,7 +20,7 @@
{
// 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);
$newestUsers = $this->UserModel->getNewestUsers(5);
@@ -43,8 +43,8 @@
}
$font_sizes = [27, 27, 24, 24, 24, 20, 16, 16, 14, 14, 12, 11, 10];
foreach ($items as $item) {
$post_date = $item['post_date'];
$item['post_date'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$post_date"), $_SESSION['site_lang']);
$date = strtotime($item['date']);
$item['date'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date"), $_SESSION['site_lang']);
$item['font_sizes'] = $font_sizes;
$this->load->view('post_list_entry', $item);
}

View File

@@ -71,10 +71,10 @@
exit;
}
$postUUID = $this->input->post('postUUID');
$hashID = $this->input->post('postUUID');
$isLiked = $this->PostsModel->addPostLikeByUUID($postUUID, $_SESSION['user']['ID']);
$likeCount = $this->PostsModel->getPostLikeCountByUUID($postUUID);
$isLiked = $this->PostsModel->addPostLikeByHashID($hashID, $_SESSION['user']['ID']);
$likeCount = $this->PostsModel->getPostLikeCountByHashID($hashID);
echo json_encode([
'success' => true,
@@ -115,7 +115,7 @@
$users = $this->UserModel->searchUsers($query, $rank, $country, $lang, $userAmount, $userOffset);
if (!empty($users)) {
if($offset == 0) {
if ($offset == 0) {
echo '<h2>Nutzer (' . sizeof($users) . ')</h2>';
}
@@ -142,7 +142,8 @@
}
}
public function getAvailableCountries() {
public function getAvailableCountries()
{
$countries = $this->UserModel->getAvailableCountries();
foreach ($countries as $i => $country) {
@@ -153,7 +154,8 @@
echo json_encode(['countries' => $countries]);
}
public function getAvailableLanguages() {
public function getAvailableLanguages()
{
$languages = $this->UserModel->getAvailableLanguages();
foreach ($languages as $i => $language) {
@@ -164,54 +166,69 @@
echo json_encode(['languages' => $languages]);
}
public function getReportModal() {
public function getReportModal()
{
$this->load->view('network/posts/report_modal');
}
public function reportPost() {
public function reportPost()
{
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');
$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.']);
exit;
}
$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.']);
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.']);
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.']);
}
public function getDeleteModal() {
public function getDeleteModal()
{
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']);
exit;
}
$uuid = $this->input->post('uuid');
$post = $this->PostsModel->getPostByUUID($uuid);
$hashID = $this->input->post('hashID');
if(empty($post)) {
if ($hashID == NULL) {
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
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.']);
exit;
}
@@ -222,27 +239,34 @@
echo json_encode(['success' => true, 'title' => 'Post löschen', 'body' => $body]);
}
public function deletePost() {
public function deletePost()
{
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']);
exit;
}
$uuid = $this->input->post('uuid');
$post = $this->PostsModel->getPostByUUID($uuid);
$hashID = $this->input->post('hashID');
if(empty($post)) {
if ($hashID == NULL) {
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
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.']);
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.']);
}

View File

@@ -14,11 +14,11 @@ class Projects extends MY_Controller
public function index($album = 'all')
{
$collections = $this->ProjectsModel->getCategories($album);
$categories = $this->ProjectsModel->getCategories($album);
$content = $this->ProjectsModel->getEntries('all');
$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']]);
}

View File

@@ -20,24 +20,24 @@
$title = "Error - Profile";
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
} else {
$user_data = $this->UserModel->getUser($user);
$user_exists = !empty($user_data);
if ($user_exists) {
$user_data = $user_data[0];
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
$userData = $this->UserModel->getUser($user);
$userExists = !empty($userData);
if ($userExists) {
$userData = $userData[0];
$userStats = $this->UserModel->getUserStats($userData['ID']);
$user_posts = $this->PostsModel->getUserPosts($user_data['ID'], 3, 0, 192);
$user_comments = $this->UserModel->getUserComments($user_data['ID'], 3, 0);
$user_blog_posts = $this->UserModel->getUserBlogPosts($user_data['ID'], 3, 0);
$userPosts = $this->PostsModel->getUserPosts($userData['ID'], 3, 0, 192);
$userComments = $this->UserModel->getUserComments($userData['ID'], 3, 0);
$userBlogPosts = $this->UserModel->getUserBlogPosts($userData['ID'], 3, 0);
$date_created = strtotime($user_data['date_created']);
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
$title = $user_data['displayname'] . " - Profile";
$dateCreated = strtotime($userData['dateCreated']);
$userData['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
$title = $userData['displayname'] . " - Profile";
$isCurrentUserFollowing = false;
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 {
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
$title = "Error - Profile";
@@ -48,10 +48,10 @@
if (isset($message)) {
$this->load->view('network/message', $message);
}
if (isset($user_data) && isset($user_stats) && isset($user_posts) && isset($user_comments) && isset($user_blog_posts)) {
$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]);
if (isset($userData) && isset($userStats) && isset($userPosts) && isset($userComments) && isset($userBlogPosts)) {
$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 = "")
@@ -65,7 +65,7 @@
$user_exists = !empty($user_data);
if ($user_exists) {
$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_stats = $this->UserModel->getUserStats($user_data['ID']);
$title = $user_data['displayname'] . " - Blog-Kommentare";
@@ -87,7 +87,7 @@
if ($user_exists) {
$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]);
}
@@ -114,7 +114,7 @@
$user_exists = !empty($user_data);
if ($user_exists) {
$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_stats = $this->UserModel->getUserStats($user_data['ID']);
$title = $user_data['displayname'] . " - Posts";
@@ -161,7 +161,7 @@
$user_exists = !empty($user_data);
if ($user_exists) {
$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_stats = $this->UserModel->getUserStats($user_data['ID']);
$title = $user_data['displayname'] . " - Posts";
@@ -204,7 +204,7 @@
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
redirect(base_url());
if(empty($_FILES) || !isset($_FILES['postMedia']))
if (empty($_FILES) || !isset($_FILES['postMedia']))
redirect(base_url());
header('Content-Type: application/json');
@@ -229,60 +229,65 @@
echo json_encode(['success' => true, 'type' => $mediaType, 'path' => $path]);
}
public function deletePostMedia() {
public function deletePostMedia()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
redirect(base_url());
if(empty($_POST) || !isset($_POST['path']))
if (empty($_POST) || !isset($_POST['path']))
redirect(base_url());
$url = $_POST['path'];
$filePath = $this->FileModel->getFilePath(substr($url, 3), $_SESSION['user']['ID']);
if($filePath != null)
if ($filePath != null)
unlink($filePath);
}
public function publishPost()
{
header('Content-Type: application/json');
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
echo json_encode(['success' => false,
'title' => lang('post_error_login_title'),
'title' => lang('post_error_login_title'),
'message' => lang('post_error_login_lines')
]);
exit;
}
$content = $this->input->post('content');
if (strlen($content) >= 10000) {
?>
<div class="alert alert-warning" role="alert">
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Dein Post ist leider zu lang. Er darf maximal 10.000
Zeichen umfassen.
</div>
<?php
exit;
}
$content = $this->input->post('content');
$content = trim($content);
if (strlen($content) >= 10000) {
echo json_encode(['success' => false,
'title' => lang('post_error_too_long_title'),
'message' => lang('post_error_too_long_lines')
]);
exit;
}
$replyTo = $this->input->post('replyTo');
if ($replyTo !== "-1" && !$this->PostsModel->isUUIDValid($replyTo)) {
?>
<div class="alert alert-warning" role="alert">
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Der Post, an den du deine Antwort richten willst,
existiert nicht (mehr).<br>
Solltest du dies für einen Fehler halten, versuche es später erneut oder kontaktiere uns.
</div>
<?php
exit;
}
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;
}
$postID = -1;
if ($replyTo !== "-1") {
$postID = $this->PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
} else {
$postID = $this->PostsModel->addPost($_SESSION['user']['ID'], $content);
}
$replyTo = $this->input->post('replyTo');
if ($replyTo !== "-1" && !$this->PostsModel->isHashIDValid($replyTo)) {
echo json_encode(['success' => false,
'title' => lang('post_error_reply_title'),
'message' => lang('post_error_reply_lines')
]);
exit;
}
if ($replyTo !== "-1") {
$postID = $this->PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
} else {
$postID = $this->PostsModel->addPost($_SESSION['user']['ID'], $content);
}
$media = $this->input->post('postMedia');
if (!empty($media)) {
@@ -321,15 +326,21 @@
}
}
?>
<div class="alert alert-success" role="alert">
<b>Dein Post wurde erfolgreich veröffentlicht!</b> Möchtest du nun deine Posts ansehen? <br>
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Nein</button>
<a href='<?= base_url('user/' . $_SESSION['user']['username'] . '/posts') ?>'
class='btn btn-sm btn-primary'>Ja
</a>
</div>
<?php
echo json_encode(['success' => true,
'title' => lang('post_success_title'),
'message' => lang('post_success_lines'),
'buttons' => [
[
'type' => 'default',
'text' => lang('post_success_no')
],
[
'type' => 'primary',
'action' => base_url('user/' . $_SESSION['user']['username'] . '/posts'),
'text' => lang('post_success_yes')
]
]
]);
}
public function followers($user = "")
@@ -343,7 +354,7 @@
$user_exists = !empty($user_data);
if ($user_exists) {
$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_stats = $this->UserModel->getUserStats($user_data['ID']);
$followers = $this->UserModel->getFollowers($user_data['ID']);
@@ -379,7 +390,7 @@
$user_exists = !empty($user_data);
if ($user_exists) {
$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_stats = $this->UserModel->getUserStats($user_data['ID']);
$following = $this->UserModel->getFollowing($user_data['ID']);
@@ -460,6 +471,13 @@
// Update Settings
$newData = [];
// TODO: Error messages
foreach ($_POST as $key => $item) {
if (isset($user_data[$key]) && $user_data[$key] == $item) {
unset($_POST[$key]);
}
}
// Username
if (isset($_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>";
}
} 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
@@ -506,25 +524,25 @@
$newData['country'] = $_POST['country'];
}
// Biography/About
if (isset($_POST['biography'])) {
$newData['about'] = $_POST['biography'];
if (isset($_POST['about'])) {
$newData['about'] = trim($_POST['about']);
}
// Avatar
if (isset($_FILES['avatar'])) {
$image = $this->FileModel->uploadCroppedImage('avatar', 4096, $_FILES['avatar']['name'], 500, 500);
if ($image != null)
$newData['profile_picture'] = $image;
$newData['profilePicture'] = $image;
unset($_FILES['avatar']);
}
// Header
if (isset($_FILES['header'])) {
$image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
if ($image != null)
$newData['header_image'] = $image;
$newData['headerImage'] = $image;
unset($_FILES['header']);
}
// Social Networks
if (isset($_POST['social-networks'])) {
if (isset($_POST['sociaNetworks'])) {
}
// Profile color
@@ -611,7 +629,7 @@
// Add entry to history
unset($user_data['rankName']);
unset($_SESSION['user']);
$this->UserModel->insertIntoHistory($user_data);
$this->UserModel->insertIntoHistory($newData);
// Update profile
$this->UserModel->updateProfile($newData, $user_data['ID']);
$this->db->cache_delete('user', $user_data['username']);
@@ -651,38 +669,36 @@
$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) {
$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>';
goto display;
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>';
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>';
goto display;
if ($hashID == null) {
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);
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>';
goto display;
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>';
exit;
}
$user = $user[0];
$post = $this->PostsModel->getPostDetails($user['ID'], $uuid);
$post = $this->PostsModel->getPostDetails($user['ID'], $hashID);
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>';
goto display;
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>';
exit;
}
$post = $post[0];
$replies = $this->PostsModel->getPostReplies($post['ID']);
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]);
}
}

View File

@@ -1,452 +1,460 @@
<?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;
public function __construct()
class Blog extends MY_Controller
{
parent::__construct();
$this->load->model('BlogModel', '', TRUE);
$this->load->model('FileModel', '', TRUE);
}
public function index()
{
$this->neededPermission('blog.view');
$posts = $this->BlogModel->getPostList(false);
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
$this->load->view('admin/blog_posts', ['posts' => $posts]);
$this->load->view('admin/footer');
}
public function tags() {
$this->neededPermission('blog.view');
$tags = $this->BlogModel->getAllTags();
$tags = $this->BlogModel->mergeTagInfo($tags);
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Tags']);
$this->load->view('admin/blog_tags', ['tags' => $tags]);
$this->load->view('admin/footer', ['additionalScripts' => 'all-blog-tags.js']);
}
public function sendEdit()
{
header('Content-Type: application/json');
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']);
exit;
public function __construct()
{
parent::__construct();
$this->load->model('BlogModel', '', TRUE);
$this->load->model('FileModel', '', TRUE);
}
$postID = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
public function index()
{
$this->neededPermission('blog.view');
$posts = $this->BlogModel->getPostList(false);
if ($postID == -2) {
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
$this->load->view('admin/blog_posts', ['posts' => $posts]);
$this->load->view('admin/footer');
}
$contentID = $this->input->post('contentID');
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
public function tags()
{
$this->neededPermission('blog.view');
$translationID = $this->input->post('translationID');
$translationID = is_numeric($translationID) && is_int(intval($translationID)) ? intval($translationID) : -2;
$tags = $this->BlogModel->getAllTags();
$tags = $this->BlogModel->mergeTagInfo($tags);
$postImage = $this->input->post('postImage');
$postTitle = $this->input->post('postTitle');
$postDescription = $this->input->post('postDescription');
$postContent = $this->input->post('postContent');
$postPublishDate = $this->input->post('postPublishDate');
$postPublishDate = date("Y-m-d H:i:s", strtotime($postPublishDate));
$postUrl = $this->input->post('postUrl');
$postCategory = $this->input->post('postCategory');
$postTags = $this->input->post('postTags');
$postLang = $this->input->post('postLanguage');
$postLang = $postLang !== NULL ? $postLang : 'de';
if(strlen($postUrl) == 0) {
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
exit;
}
if(strlen($postUrl) < 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.']);
exit;
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Tags']);
$this->load->view('admin/blog_tags', ['tags' => $tags]);
$this->load->view('admin/footer', ['additionalScripts' => 'all-blog-tags.js']);
}
if ($postID == -1 || $translationID == -1) { // Create new blog post
if ($postID == -1) {
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
public function sendEdit()
{
header('Content-Type: application/json');
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']);
exit;
}
if($this->BlogModel->postUrlExisting($postUrl)) {
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
exit;
$postID = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
if ($postID == -2) {
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
}
$versionID = $this->input->post('versionID');
$versionID = is_numeric($versionID) && is_int(intval($versionID)) ? intval($versionID) : -2;
$image = $this->input->post('postImage');
$title = $this->input->post('postTitle');
$description = $this->input->post('postDescription');
$content = $this->input->post('postContent');
$initialRelease = $this->input->post('postPublishDate');
$initialRelease = date("Y-m-d H:i:s", strtotime($initialRelease));
$url = $this->input->post('postUrl');
$categories = $this->input->post('postCategories');
$tags = $this->input->post('postTags');
$lang = $this->input->post('postLanguage');
$lang = $lang !== NULL ? $lang : 'de';
if (strlen($url) == 0) {
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
exit;
}
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.']);
exit;
}
if ($postID == -1) { // Create new blog post
if ($postID == -1) {
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
if ($this->BlogModel->postUrlExisting($url)) {
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
exit;
}
}
}
$translationID = $this->BlogModel->createNewTranslation($postID, $postLang);
}
if ($contentID < 0) {
$contentID = $this->BlogModel->createNewContentDraft($postID);
}
$this->BlogModel->updatePostDraft($postID, $postUrl, $postCategory, $postPublishDate, $postImage);
$this->BlogModel->updateContentDraft($contentID, $postContent, $postLang);
$this->BlogModel->updateTranslation($translationID, $postTitle, $postDescription);
if(!empty($postTags)) {
$this->BlogModel->deleteAllPostTags($postID);
foreach ($postTags as $postTag) {
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
$this->BlogModel->addPostTagByID($postID, $tagID);
}
}
echo json_encode(['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'contentID' => $contentID, 'translationID' => $translationID]);
}
public function publishPost()
{
header('Content-Type: application/json');
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']);
exit;
}
$postID = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
if ($postID < 0) {
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
}
$contentIDs = $this->input->post('contentIDs');
$contentPublished = FALSE;
foreach ($contentIDs as $lang => $contentID) {
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
if($contentID < 0) {
continue;
if ($versionID < 0) {
$versionID = $this->BlogModel->createNewTranslationDraft($postID, $_SESSION['user']['ID'], $lang);
}
$this->BlogModel->publishContentDraft($_SESSION['user']['ID'], $contentID, $postID, $lang);
$contentPublished = TRUE;
}
$this->BlogModel->updatePostDraft($postID, $initialRelease, $image);
$this->BlogModel->updateTranslationDraft($versionID, $url, $title, $description, $content, $lang);
if (!$contentPublished) {
echo json_encode(['success' => false, 'message' => 'Ungültige Content-ID angegeben. Bitte versuche es später erneut']);
exit;
}
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');
$this->BlogModel->publishPostDraft($postID);
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich veröffentlicht.']);
}
public function getTranslations()
{
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 = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
if ($postID < 0) {
echo json_encode(['status' => 'error', 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
}
$translations = $this->BlogModel->getPostTranslations($postID);
echo json_encode(['status' => 'success', 'translations' => $translations]);
}
public function getPost() {
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'));
if(!is_numeric($postID)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
exit;
}
$postData = $this->BlogModel->getPostDataByID($postID);
if(empty($postData)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
exit;
}
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
}
public function getContent() {
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'));
$contentID = intval($this->input->post('contentID'));
$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($contentID)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
exit;
}
$contentData = $this->BlogModel->getContentDataByID($postID, $contentID, $language);
if(empty($contentData)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
exit;
}
echo json_encode(['status' => 'success', 'contentData' => $contentData[0]]);
}
public function getTranslationData() {
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');
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.']);
exit;
}
$postID = intval($this->input->post('postID'));
if(!is_numeric($postID)) {
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
exit;
}
$postTags = $this->BlogModel->getTags($postID);
echo json_encode(['success' => true, 'tags' => $postTags]);
}
public function edit($postID = -1, $lang = "de")
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$translations = ['de' => -1];
$contents = ['de' => -1];
if(!$postID != -1) {
if($this->BlogModel->postIDExisting($postID)) {
$postTranslations = $this->BlogModel->getPostTranslationIDs($postID);
foreach ($postTranslations as $postTranslation) {
$translations[$postTranslation['language']] = $postTranslation['postTranslationID'];
}
$postContents = $this->BlogModel->getPostContentIDs($postID);
foreach ($postContents as $postContent) {
$contents[$postContent['language']] = $postContent['contentID'];
$category = $this->BlogModel->createCategory($name, $displayname, 'de');
$newCategoryID = $category;
}
$this->BlogModel->addPostCategoryByID($postID, $category);
}
}
if (!empty($tags)) {
$this->BlogModel->deleteAllPostTags($postID);
foreach ($tags as $postTag) {
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
$this->BlogModel->addPostTagByID($postID, $tagID);
}
}
$result = ['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'versionID' => $versionID];
if(isset($newCategoryID))
$result['newCategoryID'] = $newCategoryID;
echo json_encode($result);
}
$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/blog_edit', ['categories' => $categories, 'postID' => $postID, 'contents' => $contents, 'translations' => $translations, 'postLanguage' => $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']]);
public function publishPost()
{
header('Content-Type: application/json');
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']);
exit;
}
}
$postID = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
public function history($postID = 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 ($postID < 0) {
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
}
$content['de'] = $this->BlogModel->getAllContentVersions($postID, 'de');
$content['en'] = $this->BlogModel->getAllContentVersions($postID, 'en');
$content['fr'] = $this->BlogModel->getAllContentVersions($postID, 'fr');
$versionIDs = $this->input->post('versionIDs');
$contentPublished = FALSE;
foreach ($versionIDs as $lang => $versionID) {
$versionID = is_numeric($versionID) && is_int(intval($versionID)) ? intval($versionID) : -2;
$this->load->view('admin/sidebar', ['title' => 'Geschichte']);
$this->load->view('admin/blog_history', ['content' => $content]);
$this->load->view('admin/footer');
}
if ($versionID < 0) {
continue;
}
public function new_category()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] !== 'admin') redirect(base_url('login'));
$name = filter_input(INPUT_POST, "name");
$display_name = filter_input(INPUT_POST, "display_name");
if ($name !== NULL && $display_name !== NULL) {
$category = $this->BlogModel->getCategoryIDAfterInsert($name, $display_name);
echo $category;
$this->BlogModel->publishTranslationDraft($postID, $versionID, $_SESSION['user']['ID'], $lang);
$contentPublished = TRUE;
}
if (!$contentPublished) {
echo json_encode(['success' => false, 'message' => 'Ungültige Content-ID angegeben. Bitte versuche es später erneut']);
exit;
}
$this->BlogModel->publishPostDraft($postID);
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich veröffentlicht.']);
}
}
public function delete()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
echo $this->BlogModel->deletePost($id);
}
public function getTranslations()
{
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;
}
public function deleteFinally()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
$this->BlogModel->deletePostFinally($id);
}
$postID = $this->input->post('postID');
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
public function restore()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
echo $this->BlogModel->restorePost($id);
}
if ($postID < 0) {
echo json_encode(['status' => 'error', 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
exit;
}
public function trashbin()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$posts = $this->BlogModel->getPostList(true);
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
$this->load->view('admin/blog_posts', ['posts' => $posts, 'trashbin' => true]);
$this->load->view('admin/footer');
}
public function tagsList()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
echo '{"type":"error", "message":"<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden <i>Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontakformular.</i>"}';
header("Content-Type: application/json");
exit;
$translations = $this->BlogModel->getPostTranslations($postID);
echo json_encode(['status' => 'success', 'translations' => $translations]);
}
$result = array_map(function($value) {
return $value['display_name'];
}, $this->BlogModel->getAllTags());
echo json_encode($result);
public function getPost()
{
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'));
if (!is_numeric($postID)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
exit;
}
$postData = $this->BlogModel->getPostDataByID($postID);
if (empty($postData)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
exit;
}
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
}
public function getVersion() {
header('Content-Type: application/json');
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.']);
exit;
}
$postID = intval($this->input->post('postID'));
$versionID = intval($this->input->post('versionID'));
$language = $this->input->post('lang');
if ($postID == 0) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
exit;
}
if ($versionID == 0) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde keine Version mit der angegebenen Versions-ID gefunden.']);
exit;
}
$versionData = $this->BlogModel->getPostTranslationByID($postID, $versionID, $language);
if (empty($versionData)) {
echo json_encode(['status' => 'error', 'message' => 'Es wurde keine Version mit der angegebenen Versions-ID gefunden.']);
exit;
}
echo json_encode(array_merge(['status' => 'success'], $versionData[0]));
}
public function getPostTags()
{
header('Content-Type: application/json');
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.']);
exit;
}
$postID = intval($this->input->post('postID'));
if (!is_numeric($postID)) {
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
exit;
}
$postTags = $this->BlogModel->getTags($postID);
echo json_encode(['success' => true, 'tags' => $postTags]);
}
public function edit($postID = -1, $lang = "de")
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$versions = ['de' => -1];
if (!$postID != -1) {
if ($this->BlogModel->postIDExisting($postID)) {
$postVersions = $this->BlogModel->getPostVersionIDs($postID);
foreach ($postVersions as $postVersion) {
$versions[$postVersion['lang']] = $postVersion['ID'];
}
}
}
$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/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']]);
}
public function history($postID = NULL)
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
if ($postID === NULL) redirect(base_url('admin/blog'));
$content['de'] = $this->BlogModel->getAllPostVersions($postID, 'de');
$content['en'] = $this->BlogModel->getAllPostVersions($postID, 'en');
$content['fr'] = $this->BlogModel->getAllPostVersions($postID, 'fr');
$this->load->view('admin/sidebar', ['title' => 'Änderungen']);
$this->load->view('admin/blog_history', ['content' => $content]);
$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()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] !== 'admin') redirect(base_url('login'));
$name = filter_input(INPUT_POST, "name");
$display_name = filter_input(INPUT_POST, "display_name");
if ($name !== NULL && $display_name !== NULL) {
$category = $this->BlogModel->getCategoryIDAfterInsert($name, $display_name);
echo $category;
}
}
public function delete()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
echo $this->BlogModel->deletePost($id);
}
public function deleteFinally()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
$this->BlogModel->deletePostFinally($id);
}
public function restore()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$id = filter_input(INPUT_POST, "id");
echo $this->BlogModel->restorePost($id);
}
public function trashbin()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
$posts = $this->BlogModel->getPostList(true);
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
$this->load->view('admin/blog_posts', ['posts' => $posts, 'trashbin' => true]);
$this->load->view('admin/footer');
}
public function tagsList()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
echo '{"type":"error", "message":"<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden <i>Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontakformular.</i>"}';
header("Content-Type: application/json");
exit;
}
$result = array_map(function ($value) {
return $value['displayname'];
}, $this->BlogModel->getAllTags());
echo json_encode($result);
// echo json_encode($this->BlogModel->getAllTags());
header("Content-Type: application/json");
header("Content-Type: application/json");
}
public function updatePreview()
{
header('Content-Type: application/json');
if (!$this->hasPermission('blog.create')) {
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um die Vorschau anzusehen.']);
exit;
}
if (!isset($_POST['postTitle']) || !isset($_POST['postDesc']) || !isset($_POST['postContent'])) {
exit;
}
if (!isset($_POST['previewID'])) {
$previewID = substr(md5(uniqid() . date(time())), 0, 16);
} else {
$previewID = $_POST['previewID'];
}
$_SESSION['preview_' . $previewID] = [
'title' => $_POST['postTitle'],
'desc' => $_POST['postDesc'],
'content' => $_POST['postContent'],
];
echo json_encode(['success' => true, 'previewID' => $previewID, 'session' => $_SESSION['preview_' . $previewID]]);
}
public function getTemplates()
{
header('Content-Type: application/json');
if (!$this->hasPermission('blog.create')) {
echo json_encode([]);
exit;
}
$templates = [
new Template('Verweis auf anderen Post', 'Verlinkungs-Karte für weiteren Blog-Post', 'post_reference'),
];
foreach ($templates as $template) {
$template->content = $this->load->view('admin/blog/templates/' . $template->content, '', true);
}
echo json_encode($templates);
}
public function preview()
{
$this->neededPermission('blog.create');
$previewID = $_GET['id'];
if (!isset($_SESSION['preview_' . $previewID])) {
redirect('admin/blog');
}
$this->load->view('header', ['active' => 'blog', 'title' => 'Vorschau', 'additionalStyles' => ['posts_list.css', 'blog.css']]);
$this->load->view('blog/first', ['categoryPosts' => [], 'categories' => $this->BlogModel->getCategories()]);
$this->load->view('admin/blog_post_preview', $_SESSION['preview_' . $previewID]);
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
}
}
public function updatePreview() {
header('Content-Type: application/json');
if(!$this->hasPermission('blog.create')) {
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um die Vorschau anzusehen.']);
exit;
}
if(!isset($_POST['postTitle']) || !isset($_POST['postDesc']) || !isset($_POST['postContent'])) {
exit;
}
if(!isset($_POST['previewID'])) {
$previewID = substr(md5(uniqid() . date(time())), 0, 16);
} else {
$previewID = $_POST['previewID'];
}
$_SESSION['preview_' . $previewID] = [
'title' => $_POST['postTitle'],
'desc' => $_POST['postDesc'],
'content' => $_POST['postContent'],
];
echo json_encode(['success' => true, 'previewID' => $previewID, 'session' => $_SESSION['preview_' . $previewID]]);
}
public function getTemplates() {
header('Content-Type: application/json');
if(!$this->hasPermission('blog.create')) {
echo json_encode([]);
exit;
}
$templates = [
new Template('Verweis auf anderen Post', 'Verlinkungs-Karte für weiteren Blog-Post', 'post_reference'),
];
foreach ($templates as $template) {
$template->content = $this->load->view('admin/blog/templates/' . $template->content, '', true);
}
echo json_encode($templates);
}
public function preview() {
$this->neededPermission('blog.create');
$previewID = $_GET['id'];
if(!isset($_SESSION['preview_' . $previewID])) {
redirect('admin/blog');
}
$this->load->view('header', ['active' => 'blog', 'title' => 'Vorschau', 'additionalStyles' => ['posts_list.css', 'blog.css']]);
$this->load->view('blog/first', ['categoryPosts' => [], 'categories' => $this->BlogModel->getCategories()]);
$this->load->view('admin/blog_post_preview', $_SESSION['preview_' . $previewID]);
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
}
}
class Template {
public $title;
public $desc;
public $content;
/**
* Template constructor.
* @param $title
* @param $desc
* @param $content
*/
public function __construct($title, $desc, $content)
class Template
{
$this->title = $title;
$this->desc = $desc;
$this->content = $content;
public $title;
public $desc;
public $content;
/**
* Template constructor.
* @param $title
* @param $desc
* @param $content
*/
public function __construct($title, $desc, $content)
{
$this->title = $title;
$this->desc = $desc;
$this->content = $content;
}
}
}

View File

@@ -16,7 +16,7 @@
$this->neededPermission('projects.view');
$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/projects', ['entries' => $entries, 'categories' => $categories]);

View File

@@ -127,8 +127,8 @@ class Users extends MY_Controller
'displayname' => $userData['displayname'],
'email' => $userData['email'],
'rank' => $userData['rank'],
'profile_picture' => $userData['profile_picture'],
'header_image' => $userData['header_image'],
'profilePicture' => $userData['profilePicture'],
'headerImage' => $userData['headerImage'],
'social_networks' => $userData['social_networks'],
'showAds' => $userData['showAds'],
'about' => $userData['about'],