Fix #5 - Project Edit Page isn't working and more
This commit is contained in:
@@ -32,7 +32,8 @@
|
||||
|
||||
if ($edit) {
|
||||
if ($this->ProjectsModel->checkIfExists($id)) {
|
||||
$content = $this->ProjectsModel->getEntry($id)[0];
|
||||
$content = $this->ProjectsModel->getEntry($id);
|
||||
$content = $this->ProjectsModel->mergeFullTranslationData($content)[0];
|
||||
$projectCategories = $this->ProjectsModel->getEntryCategories($id);
|
||||
} else {
|
||||
redirect(base_url('admin/projects/edit'));
|
||||
@@ -42,7 +43,7 @@
|
||||
$categories = $this->ProjectsModel->getCategories();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Projekt erstellen', 'additionalStyles' => ['lib/content-tools/content-tools.min.css', 'project-edit.css']]);
|
||||
$this->load->view('admin/project_edit', ['edit' => -1, 'categories' => $categories, 'content' => $content, 'pCategories' => $projectCategories]);
|
||||
$this->load->view('admin/project_edit', ['edit' => $id === NULL ? -1 : $id, 'categories' => $categories, 'content' => $content, 'pCategories' => $projectCategories]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/content-tools/content-tools.min.js', 'project-edit.js']]);
|
||||
}
|
||||
|
||||
@@ -58,6 +59,12 @@
|
||||
$translations['de']['title'] = $this->input->post('titleDE');
|
||||
$translations['de']['description'] = $this->input->post('headlineDE');
|
||||
$translations['de']['content'] = $this->input->post('contentDE');
|
||||
$translations['en']['title'] = $this->input->post('titleEN');
|
||||
$translations['en']['description'] = $this->input->post('headlineEN');
|
||||
$translations['en']['content'] = $this->input->post('contentEN');
|
||||
$translations['fr']['title'] = $this->input->post('titleFR');
|
||||
$translations['fr']['description'] = $this->input->post('headlineFR');
|
||||
$translations['fr']['content'] = $this->input->post('contentFR');
|
||||
|
||||
$url = $this->input->post('url');
|
||||
|
||||
|
@@ -229,10 +229,18 @@
|
||||
}
|
||||
|
||||
private function mergeReplyData($post) {
|
||||
$data = $this->db->query('SELECT uuid, username, displayname FROM user_posts LEFT JOIN users ON users.ID = user_posts.user_id WHERE user_posts.ID = ?', [$post['reply_to']])->result_array();
|
||||
$post['replyToUuid'] = $data[0]['uuid'];
|
||||
$post['replyToUsername'] = $data[0]['username'];
|
||||
$post['replyToDisplayname'] = $data[0]['displayname'];
|
||||
$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->preparePostList($data);
|
||||
if(!empty($data)) {
|
||||
$post['replyToPost'] = $data[0];
|
||||
} else {
|
||||
$post['replyToPost'] = [
|
||||
'username' => '',
|
||||
'displayname' => '',
|
||||
'content' => 'Nicht existent',
|
||||
'date' => '',
|
||||
];
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
@@ -1,207 +1,243 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class ProjectsModel extends CI_Model {
|
||||
class ProjectsModel extends CI_Model
|
||||
{
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('projectsModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function getEntries($category) {
|
||||
if($category !== 'all') {
|
||||
$content = $this->db->query('SELECT *, (SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = -1)) voteCount FROM projects p WHERE ID IN (SELECT projectID FROM projects_entry_categories WHERE categoryID = ?) ORDER BY datetime DESC', [$category])->result_array();
|
||||
} else {
|
||||
$content = $this->db->query('SELECT *, (SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = -1)) voteCount FROM projects p ORDER BY datetime DESC')->result_array();
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('projectsModel', '', TRUE);
|
||||
}
|
||||
|
||||
$content = $this->mergeTranslationData($content, $_SESSION['site_lang']);
|
||||
public function getEntries($category)
|
||||
{
|
||||
if ($category !== 'all') {
|
||||
$content = $this->db->query('SELECT *, (SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = -1)) voteCount FROM projects p WHERE ID IN (SELECT projectID FROM projects_entry_categories WHERE categoryID = ?) ORDER BY datetime DESC', [$category])->result_array();
|
||||
} else {
|
||||
$content = $this->db->query('SELECT *, (SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = p.ID AND type = -1)) voteCount FROM projects p ORDER BY datetime DESC')->result_array();
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
$content = $this->mergeTranslationData($content, $_SESSION['site_lang']);
|
||||
|
||||
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();
|
||||
return $collections;
|
||||
}
|
||||
|
||||
public function editEntry($data, $id) {
|
||||
$this->db->update('projects', $data, ['id' => $id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function addEntry($data) {
|
||||
$this->db->insert('projects', $data);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function delete($id) {
|
||||
$this->db->query('DELETE FROM projects WHERE ID = ? LIMIT 1', [$id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function deleteCategory($id) {
|
||||
$this->db->query('DELETE FROM projects_entry_categories WHERE categoryID = ?', [$id]);
|
||||
$this->db->query('DELETE FROM projects_categories WHERE ID = ? LIMIT 1', [$id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function checkIfExists($id) {
|
||||
$result = $this->db->query('SELECT ID FROM projects WHERE ID = ? LIMIT 1', [$id])->result_array();
|
||||
if(!empty($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
public function checkIfNameExists($name) {
|
||||
$result = $this->db->query('SELECT ID FROM projects WHERE name = ? LIMIT 1', [$name])->result_array();
|
||||
if(!empty($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
public function mergeTranslationData($postList, $lang = 'de')
|
||||
{
|
||||
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();
|
||||
if (sizeof($data) == 1) {
|
||||
$postList[$i] = array_merge($post, $data[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$merged = [];
|
||||
foreach ($data[0] as $key => $value) {
|
||||
if (($value == NULL && $data[1][$key] == NULL) || ($value != NULL && $data[1][$key] == NULL)) {
|
||||
$merged[$key] = $value;
|
||||
} else {
|
||||
$merged[$key] = $data[1][$key];
|
||||
}
|
||||
}
|
||||
|
||||
$postList[$i] = array_merge($post, $merged);
|
||||
}
|
||||
return $postList;
|
||||
}
|
||||
}
|
||||
|
||||
public function getEntry($id) {
|
||||
return $this->db->query('SELECT * FROM projects WHERE ID = ? LIMIT 1', [$id])->result_array();
|
||||
}
|
||||
|
||||
public function getEntryByName($name, $lang = 'de') {
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE name = ? LIMIT 1', [$name])->result_array();
|
||||
|
||||
$result = $this->mergeTranslationData($result, $lang);
|
||||
|
||||
return !empty($result) ? $result[0] : null;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public function resetEntryCategories($postID) {
|
||||
$this->db->query('DELETE FROM projects_entry_categories WHERE projectID = ?', $postID);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function addCategoryToEntryID($postID, $categoryID) {
|
||||
$this->db->query('INSERT INTO projects_entry_categories (projectID, categoryID) VALUES (?, ?)', [$postID, $categoryID]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function updateCategories($postID, $categories) {
|
||||
$this->resetEntryCategories($postID);
|
||||
foreach ($categories as $category) {
|
||||
$this->addCategoryToEntryID($postID, $category);
|
||||
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();
|
||||
return $collections;
|
||||
}
|
||||
}
|
||||
|
||||
public function addCategoryToEntryName($name, $categoryID) {
|
||||
$id = $this->db->query('SELECT ID FROM projects WHERE name = ? LIMIT 1', [$name])->result_array()[0];
|
||||
$this->addCategoryToEntryID(intval($id['ID']), $categoryID);
|
||||
}
|
||||
public function editEntry($data, $id)
|
||||
{
|
||||
$this->db->update('projects', $data, ['id' => $id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function getPrevProject($id) {
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE datetime < (SELECT datetime FROM projects WHERE ID = ?) ORDER BY datetime DESC LIMIT 1', [$id])->result_array();
|
||||
public function addEntry($data)
|
||||
{
|
||||
$this->db->insert('projects', $data);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
$result = $this->mergeTranslationData($result, $_SESSION['site_lang']);
|
||||
public function delete($id)
|
||||
{
|
||||
$this->db->query('DELETE FROM projects WHERE ID = ? LIMIT 1', [$id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function deleteCategory($id)
|
||||
{
|
||||
$this->db->query('DELETE FROM projects_entry_categories WHERE categoryID = ?', [$id]);
|
||||
$this->db->query('DELETE FROM projects_categories WHERE ID = ? LIMIT 1', [$id]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function getNextProject($id) {
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE datetime > (SELECT datetime FROM projects WHERE ID = ?) ORDER BY datetime ASC LIMIT 1', [$id])->result_array();
|
||||
public function checkIfExists($id)
|
||||
{
|
||||
$result = $this->db->query('SELECT ID FROM projects WHERE ID = ? LIMIT 1', [$id])->result_array();
|
||||
if (!empty($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->mergeTranslationData($result, $_SESSION['site_lang']);
|
||||
public function checkIfNameExists($name)
|
||||
{
|
||||
$result = $this->db->query('SELECT ID FROM projects WHERE name = ? LIMIT 1', [$name])->result_array();
|
||||
if (!empty($result)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
public function getEntry($id)
|
||||
{
|
||||
return $this->db->query('SELECT * FROM projects WHERE ID = ? LIMIT 1', [$id])->result_array();
|
||||
}
|
||||
|
||||
public function addVote($projectID, $userID, $voteType) {
|
||||
$this->db->query('DELETE FROM projects_entry_votes WHERE projectID = ? AND userID = ?', [$projectID, $userID]);
|
||||
$this->db->query('INSERT INTO projects_entry_votes (projectID, userID, type) VALUES (?, ?, ?)', [$projectID, $userID, $voteType]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('projects', 'addVote');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
public function getEntryByName($name, $lang = 'de')
|
||||
{
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE name = ? LIMIT 1', [$name])->result_array();
|
||||
|
||||
public function getVoteCount($projectID) {
|
||||
$result = $this->db->query('SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = ? AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = ? AND type = -1) voteCount', [$projectID, $projectID])->result_array();
|
||||
return $result[0]['voteCount'];
|
||||
}
|
||||
$result = $this->mergeTranslationData($result, $lang);
|
||||
|
||||
public function getUserVoteType($projectID, $userID) {
|
||||
$result = $this->db->query('SELECT type FROM projects_entry_votes WHERE projectID = ? AND userID = ?', [$projectID, $userID])->result_array();
|
||||
if(empty($result))
|
||||
return 0;
|
||||
return $result[0]['type'];
|
||||
}
|
||||
return !empty($result) ? $result[0] : null;
|
||||
}
|
||||
|
||||
public function createNewProjectDraft() {
|
||||
$this->db->query('INSERT INTO projects () VALUES ()');
|
||||
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();
|
||||
}
|
||||
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
public function updateCategories($postID, $categories)
|
||||
{
|
||||
$this->resetEntryCategories($postID);
|
||||
foreach ($categories as $category) {
|
||||
$this->addCategoryToEntryID($postID, $category);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $this->db->query('SELECT ID FROM projects ORDER BY ID DESC LIMIT 1')->result_array();
|
||||
return $data[0]['ID'];
|
||||
}
|
||||
public function resetEntryCategories($postID)
|
||||
{
|
||||
$this->db->query('DELETE FROM projects_entry_categories WHERE projectID = ?', $postID);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function updateProject($id, $translations, $url, $download, $openSource, $customLink, $date, $image) {
|
||||
$this->db->query('UPDATE projects SET name = ?, isDownloadable = ?, downloadLink = ?, isOpenSource = ?, openSourceLink = ?, customLink = ?, datetime = ?, source = ? WHERE ID = ?', [$url, $download['available'], $download['link'], $openSource['available'], $openSource['link'], $customLink['link'], $date, $image, $id]);
|
||||
public function addCategoryToEntryID($postID, $categoryID)
|
||||
{
|
||||
$this->db->query('INSERT INTO projects_entry_categories (projectID, categoryID) VALUES (?, ?)', [$postID, $categoryID]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
$this->db->cache_off();
|
||||
foreach($translations as $lang => $translation) {
|
||||
$data = $this->db->query('SELECT translationID FROM projects_translations WHERE projectID = ? AND lang = ?', [$id, $lang])->result_array();
|
||||
public function addCategoryToEntryName($name, $categoryID)
|
||||
{
|
||||
$id = $this->db->query('SELECT ID FROM projects WHERE name = ? LIMIT 1', [$name])->result_array()[0];
|
||||
$this->addCategoryToEntryID(intval($id['ID']), $categoryID);
|
||||
}
|
||||
|
||||
if(empty($data)) {
|
||||
$this->db->query('INSERT INTO projects_translations (projectID, lang) VALUES (?, ?)', [$id, $lang]);
|
||||
public function getPrevProject($id)
|
||||
{
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE datetime < (SELECT datetime FROM projects WHERE ID = ?) ORDER BY datetime DESC LIMIT 1', [$id])->result_array();
|
||||
|
||||
$result = $this->mergeTranslationData($result, $_SESSION['site_lang']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getNextProject($id)
|
||||
{
|
||||
$result = $this->db->query('SELECT * FROM projects WHERE datetime > (SELECT datetime FROM projects WHERE ID = ?) ORDER BY datetime ASC LIMIT 1', [$id])->result_array();
|
||||
|
||||
$result = $this->mergeTranslationData($result, $_SESSION['site_lang']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function addVote($projectID, $userID, $voteType)
|
||||
{
|
||||
$this->db->query('DELETE FROM projects_entry_votes WHERE projectID = ? AND userID = ?', [$projectID, $userID]);
|
||||
$this->db->query('INSERT INTO projects_entry_votes (projectID, userID, type) VALUES (?, ?, ?)', [$projectID, $userID, $voteType]);
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
$this->db->cache_delete('projects', 'addVote');
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
}
|
||||
|
||||
public function getVoteCount($projectID)
|
||||
{
|
||||
$result = $this->db->query('SELECT (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = ? AND type = 1) - (SELECT COUNT(*) FROM projects_entry_votes WHERE projectID = ? AND type = -1) voteCount', [$projectID, $projectID])->result_array();
|
||||
return $result[0]['voteCount'];
|
||||
}
|
||||
|
||||
public function getUserVoteType($projectID, $userID)
|
||||
{
|
||||
$result = $this->db->query('SELECT type FROM projects_entry_votes WHERE projectID = ? AND userID = ?', [$projectID, $userID])->result_array();
|
||||
if (empty($result))
|
||||
return 0;
|
||||
return $result[0]['type'];
|
||||
}
|
||||
|
||||
public function createNewProjectDraft()
|
||||
{
|
||||
$this->db->query('INSERT INTO projects () VALUES ()');
|
||||
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
|
||||
$data = $this->db->query('SELECT ID FROM projects ORDER BY ID DESC LIMIT 1')->result_array();
|
||||
return $data[0]['ID'];
|
||||
}
|
||||
|
||||
public function updateProject($id, $translations, $url, $download, $openSource, $customLink, $date, $image)
|
||||
{
|
||||
$this->db->query('UPDATE projects SET name = ?, isDownloadable = ?, downloadLink = ?, isOpenSource = ?, openSourceLink = ?, customLink = ?, datetime = ?, source = ? WHERE ID = ?', [$url, $download['available'], $download['link'], $openSource['available'], $openSource['link'], $customLink['link'], $date, $image, $id]);
|
||||
|
||||
$this->db->cache_off();
|
||||
foreach ($translations as $lang => $translation) {
|
||||
$data = $this->db->query('SELECT translationID FROM projects_translations WHERE projectID = ? AND lang = ?', [$id, $lang])->result_array();
|
||||
|
||||
if (empty($data)) {
|
||||
$this->db->query('INSERT INTO projects_translations (projectID, lang) VALUES (?, ?)', [$id, $lang]);
|
||||
|
||||
$data = $this->db->query('SELECT translationID FROM projects_translations WHERE projectID = ? AND lang = ?', [$id, $lang])->result_array();
|
||||
}
|
||||
|
||||
$translationID = $data[0]['translationID'];
|
||||
|
||||
$this->db->query('UPDATE projects_translations SET title = ?, description = ?, content = ?, downloadName = ?, openSourceName = ?, customLinkName = ? WHERE translationID = ?', array_merge($translation, [$download['name'], $openSource['name'], $customLink['name'], $translationID]));
|
||||
}
|
||||
$this->db->cache_on();
|
||||
|
||||
$translationID = $data[0]['translationID'];
|
||||
|
||||
$this->db->query('UPDATE projects_translations SET title = ?, description = ?, content = ?, downloadName = ?, openSourceName = ?, customLinkName = ? WHERE translationID = ?', array_merge($translation, [$download['name'], $openSource['name'], $customLink['name'], $translationID]));
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
}
|
||||
$this->db->cache_on();
|
||||
|
||||
$this->db->cache_delete('admin', 'projects');
|
||||
$this->db->cache_delete('projects', 'index');
|
||||
$this->db->cache_delete('projects', 'entry');
|
||||
}
|
||||
|
||||
public function mergeTranslationData($postList, $lang = 'de') {
|
||||
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();
|
||||
if(sizeof($data) == 1) {
|
||||
$postList[$i] = array_merge($post, $data[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
$merged = [];
|
||||
foreach ($data[0] as $key => $value) {
|
||||
if(($value == NULL && $data[1][$key] == NULL) || ($value != NULL && $data[1][$key] == NULL)) {
|
||||
$merged[$key] = $value;
|
||||
} else {
|
||||
$merged[$key] = $data[1][$key];
|
||||
public function mergeFullTranslationData($postList)
|
||||
{
|
||||
foreach ($postList as $i => $post) {
|
||||
$data = $this->db->query('SELECT * FROM projects_translations WHERE projectID = ? ORDER BY lang', [$post['ID']])->result_array();
|
||||
foreach ($data as $lang) {
|
||||
$postList[$i]['translations'][$lang['lang']] = $lang;
|
||||
}
|
||||
}
|
||||
|
||||
$postList[$i] = array_merge($post, $merged);
|
||||
return $postList;
|
||||
}
|
||||
return $postList;
|
||||
}
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
<?php
|
||||
$scripts = [
|
||||
'lib/jquery.min.js',
|
||||
'lib/popper.min.js',
|
||||
'lib/bootstrap.min.js',
|
||||
'lib/typeahead.bundle.min.js',
|
||||
'lib/datatables.js',
|
||||
@@ -28,7 +29,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
'custom.js'
|
||||
];
|
||||
if(isset($additionalScripts)) {
|
||||
// $scripts[] = $additionalScripts;
|
||||
foreach ($additionalScripts as $additionalScript) {
|
||||
$scripts[] = $additionalScript;
|
||||
}
|
||||
|
@@ -154,7 +154,7 @@
|
||||
<div class="form-group">
|
||||
<label for="title">Titel (Deutsch)</label>
|
||||
<input type="text" class="form-control" name="title" id="title" placeholder="Titel auf Deutsch"
|
||||
required value="<?= isset($content) ? $content['title'] : '' ?>">
|
||||
required value="<?= isset($content) && isset($content['translations']['de']) ? $content['translations']['de']['title'] : '' ?>">
|
||||
</div>
|
||||
<!-- Headline input -->
|
||||
<div class="form-group">
|
||||
@@ -162,13 +162,13 @@
|
||||
<textarea name="headline" id="headline" rows="2"
|
||||
placeholder="Headline auf Deutsch"
|
||||
class="form-control"
|
||||
required><?= isset($content) ? $content['headline'] : '' ?></textarea>
|
||||
required><?= isset($content) && isset($content['translations']['de']) ? $content['translations']['de']['description'] : '' ?></textarea>
|
||||
</div>
|
||||
<!-- Description input -->
|
||||
<div class="form-group">
|
||||
<label for="description">Beschreibung (Deutsch)</label>
|
||||
<div data-editable data-name="content-german" id="content">
|
||||
<?= isset($content) ? $content['description'] : '' ?>
|
||||
<?= isset($content) && isset($content['translations']['de']) ? $content['translations']['de']['content'] : '' ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -177,20 +177,20 @@
|
||||
<div class="form-group">
|
||||
<label for="titleEnglish">Titel (Englisch)</label>
|
||||
<input type="text" class="form-control" name="titleEnglish" id="titleEnglish" placeholder="Titel auf Englisch"
|
||||
value="<?= isset($content) ? $content['titleEnglish'] : '' ?>">
|
||||
value="<?= isset($content) && isset($content['translations']['en']) ? $content['translations']['en']['title'] : '' ?>">
|
||||
</div>
|
||||
<!-- Headline English input -->
|
||||
<div class="form-group">
|
||||
<label for="headlineEnglish">Headline (Englisch)</label>
|
||||
<textarea name="headlineEnglish" id="headlineEnglish" rows="2"
|
||||
placeholder="Headline auf Englisch"
|
||||
class="form-control"><?= isset($content) ? $content['headlineEnglish'] : '' ?></textarea>
|
||||
class="form-control"><?= isset($content) && isset($content['translations']['en']) ? $content['translations']['en']['description'] : '' ?></textarea>
|
||||
</div>
|
||||
<!-- Description English input -->
|
||||
<div class="form-group">
|
||||
<label for="descriptionEnglish">Beschreibung (Englisch)</label>
|
||||
<div data-editable data-name="content-english" id="contentEnglish">
|
||||
<?= isset($content) ? $content['descriptionEnglish'] : '' ?>
|
||||
<?= isset($content) && isset($content['translations']['en']) ? $content['translations']['en']['content'] : '' ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -199,20 +199,20 @@
|
||||
<div class="form-group">
|
||||
<label for="titleFrench">Titel (Französisch)</label>
|
||||
<input type="text" class="form-control" name="titleFrench" id="titleFrench" placeholder="Titel auf Französisch"
|
||||
value="<?= isset($content) ? $content['titleFrench'] : '' ?>">
|
||||
value="<?= isset($content) && isset($content['translations']['fr']) ? $content['translations']['fr']['title'] : '' ?>">
|
||||
</div>
|
||||
<!-- Headline French input -->
|
||||
<div class="form-group">
|
||||
<label for="headlineFrench">Headline (Französisch)</label>
|
||||
<textarea name="headlineFrench" id="headlineFrench" rows="2"
|
||||
placeholder="Headline auf Französisch"
|
||||
class="form-control"><?= isset($content) ? $content['headlineFrench'] : '' ?></textarea>
|
||||
class="form-control"><?= isset($content) && isset($content['translations']['fr']) ? $content['translations']['fr']['description'] : '' ?></textarea>
|
||||
</div>
|
||||
<!-- Description French input -->
|
||||
<div class="form-group">
|
||||
<label for="descriptionFrench">Beschreibung (Französisch)</label>
|
||||
<div data-editable data-name="content-french" id="contentFrench">
|
||||
<?= isset($content) ? $content['descriptionFrench'] : '' ?>
|
||||
<?= isset($content) && isset($content['translations']['fr']) ? $content['translations']['fr']['content'] : '' ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -117,8 +117,8 @@
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog"
|
||||
aria-labelledby="deleteModalTitle">
|
||||
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="deleteModalTitle">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
@@ -102,12 +102,10 @@
|
||||
</div>
|
||||
</footer>
|
||||
<!--/#footer-->
|
||||
<script src="/assets/js/lib/jquery.min.js"></script>
|
||||
<script src="/assets/js/lib/popper.min.js"></script>
|
||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>-->
|
||||
<!--<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>-->
|
||||
<?php
|
||||
$scripts = [
|
||||
'lib/jquery.min.js',
|
||||
'lib/popper.min.js',
|
||||
'lib/bootstrap.min.js',
|
||||
'lib/jquery.PageScroll2id.min.js',
|
||||
'lib/jquery.mobile.custom.min.js',
|
||||
|
@@ -302,6 +302,11 @@
|
||||
<div class="side-navigation-background"></div>
|
||||
<div class="btn-floating">
|
||||
<ul class="btn-floating-list">
|
||||
<li>
|
||||
<a href="#" data-title="Dark Theme" id="switchDarkmode">
|
||||
<i class="fa fa-moon"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-title="<?= lang('header_contact') ?>" href="#" data-toggle="modal" data-target="#contactModal">
|
||||
<i class="fa fa-envelope"></i>
|
||||
|
@@ -227,51 +227,49 @@
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dark">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_active_users') ?></h2>
|
||||
<?php foreach ($currentlyActiveUsers as $activeUser):
|
||||
$loginTime = strtotime($activeUser['lastLogin']); ?>
|
||||
<section class="container">
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_active_users') ?></h2>
|
||||
<?php foreach ($currentlyActiveUsers as $activeUser):
|
||||
$loginTime = strtotime($activeUser['lastLogin']); ?>
|
||||
<div class="user-item">
|
||||
<img src="<?= $activeUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||
<div class="user-info">
|
||||
<a href="<?= base_url('user/' . $activeUser['username']) ?>">
|
||||
<h2><?= $activeUser['displayname'] ?></h2>
|
||||
</a>
|
||||
<small><?= $activeUser['follower_count'] ?> Followers | online
|
||||
seit <?= str_replace(['vor ', ' ago', 'il y a '], ['', '', ''], DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$loginTime"), $_SESSION['site_lang'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_newest_users') ?></h2>
|
||||
<?php
|
||||
foreach ($newestUsers as $newestUser):
|
||||
$registeredDate = strtotime($newestUser['date_created']); ?>
|
||||
<div class="user-item">
|
||||
<img src="<?= $activeUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||
<img src="<?= $newestUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||
<div class="user-info">
|
||||
<a href="<?= base_url('user/' . $activeUser['username']) ?>">
|
||||
<h2><?= $activeUser['displayname'] ?></h2>
|
||||
<a href="<?= base_url('user/' . $newestUser['username']) ?>">
|
||||
<h2><?= $newestUser['displayname'] ?></h2>
|
||||
</a>
|
||||
<small><?= $activeUser['follower_count'] ?> Followers | online
|
||||
seit <?= str_replace(['vor ', ' ago', 'il y a '], ['', '', ''], DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$loginTime"), $_SESSION['site_lang'])) ?></small>
|
||||
<small><?= $newestUser['follower_count'] ?> Followers |
|
||||
registriert
|
||||
seit <?= str_replace(['vor ', ' ago', 'il y a '], ['', '', ''], DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$registeredDate"), $_SESSION['site_lang'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_newest_users') ?></h2>
|
||||
<?php
|
||||
foreach ($newestUsers as $newestUser):
|
||||
$registeredDate = strtotime($newestUser['date_created']); ?>
|
||||
<div class="user-item">
|
||||
<img src="<?= $newestUser['profile_picture'] ?>?w=50" alt="" class="img-fluid rounded-circle">
|
||||
<div class="user-info">
|
||||
<a href="<?= base_url('user/' . $newestUser['username']) ?>">
|
||||
<h2><?= $newestUser['displayname'] ?></h2>
|
||||
</a>
|
||||
<small><?= $newestUser['follower_count'] ?> Followers |
|
||||
registriert
|
||||
seit <?= str_replace(['vor ', ' ago', 'il y a '], ['', '', ''], DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$registeredDate"), $_SESSION['site_lang'])) ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_newest_posts') ?></h2>
|
||||
<ul class="comment-list">
|
||||
<?php foreach ($newestPosts as $newestPost):
|
||||
$this->load->view('network/posts/post_item', $newestPost);
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4">
|
||||
<h2><?= lang('home_newest_posts') ?></h2>
|
||||
<ul class="comment-list">
|
||||
<?php foreach ($newestPosts as $newestPost):
|
||||
$this->load->view('network/posts/post_item', $newestPost);
|
||||
endforeach; ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
@@ -282,7 +280,8 @@
|
||||
<div class="col-md-6">
|
||||
<h1>Portfolio</h1>
|
||||
<p class="lead">
|
||||
Seit ich angefangen habe YouTube-Videos hochzuladen, bin ich auch langsam in Richtung Design, Programmieren, Fotografie, Videoschnitt, Animation etc. hineingeraten. Mit der Zeit haben sich einige mehr oder weniger gute Projekte angehäuft, die ihr in meinem Portfolio betrachten könnt.
|
||||
Seit ich angefangen habe YouTube-Videos hochzuladen, bin ich auch langsam in Richtung Design, Programmieren, Fotografie, Videoschnitt, Animation etc. hineingeraten. Mit der Zeit haben sich einige mehr oder weniger gute Projekte angehäuft,
|
||||
die ihr in meinem Portfolio betrachten könnt.
|
||||
</p>
|
||||
<a href="<?= base_url('projects') ?>" class="btn btn-default round">Projekte ansehen</a>
|
||||
</div>
|
||||
@@ -413,7 +412,8 @@
|
||||
<div class="col-md-6">
|
||||
<h1>Blog</h1>
|
||||
<p class="lead">
|
||||
Seid ihr an Programmierung, Design, Technik, Internet, Aktuellem, Gaming, zufälligem Kram und mehr interessiert? Dann ist mein Blog zwar nicht die erste Anlaufstelle, dennoch könnte man ihn eventuell ein-zwei Mal berücksichtigen. Schaut doch einfach mal vorbei und lasst euch selbst überraschen.
|
||||
Seid ihr an Programmierung, Design, Technik, Internet, Aktuellem, Gaming, zufälligem Kram und mehr interessiert? Dann ist mein Blog zwar nicht die erste Anlaufstelle, dennoch könnte man ihn eventuell ein-zwei Mal berücksichtigen. Schaut
|
||||
doch einfach mal vorbei und lasst euch selbst überraschen.
|
||||
</p>
|
||||
<a href="<?= base_url('blog') ?>" class="btn btn-default round">Zum Blog</a>
|
||||
</div>
|
||||
|
@@ -4,8 +4,8 @@
|
||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||
|
||||
?>
|
||||
<li class="post-item my-2" data-uuid="<?= $uuid ?>" data-username="<?= $username ?>">
|
||||
<div class="comment-well">
|
||||
<li class="post-item is-reply% my-2" data-uuid="<?= $uuid ?>" data-username="<?= $username ?>">
|
||||
<div class="comment-well" <?= isset($hideShadows) && $hideShadows ? 'style="box-shadow: none;padding:0"' : '' ?>>
|
||||
<div class="post-non-content">
|
||||
<a href="<?= base_url('user/' . $username) ?>" target="_blank">
|
||||
<img src="<?= $profile_picture ?>?w=100" class="img-fluid">
|
||||
@@ -24,7 +24,7 @@
|
||||
<small>
|
||||
<i class="fa fa-reply"></i>
|
||||
als Antwort an
|
||||
<a href="#" onclick="showFullPost('<?= $replyToUuid ?>', '<?= $replyToUsername ?>')">@<?= $replyToDisplayname ?></a>
|
||||
<a href="#" onclick="showFullPost('<?= $replyToPost['uuid'] ?>', '<?= $replyToPost['username'] ?>')">@<?= $replyToPost['displayname'] ?></a>
|
||||
</small>
|
||||
<?php endif; ?>
|
||||
</h3>
|
||||
|
@@ -7,14 +7,23 @@
|
||||
|
||||
<?= $message; ?>
|
||||
|
||||
<div class="row justify-content-center">
|
||||
<ul class="comment-list">
|
||||
<?php
|
||||
$post['replyToPost']['hideShadows'] = true;
|
||||
$this->load->view('network/posts/post_item', $post['replyToPost'])
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-2">
|
||||
<div class="post-non-content">
|
||||
<a href="<?= base_url('user/' . $post['username']) ?>">
|
||||
<img src="<?= $post['profile_picture'] ?>?w=75" alt="" class="img-fluid rounded-circle">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-10">
|
||||
<div class="col">
|
||||
<h4>
|
||||
<a href="<?= base_url('user/' . $post['username']) ?>">
|
||||
<?= $post['displayname'] ?>
|
||||
|
Reference in New Issue
Block a user