Added md editor, corrected articles/admin.php
This commit is contained in:
parent
353db5a8cb
commit
6dbee3d585
@ -73,7 +73,7 @@ function listArticles() {
|
||||
$results = array();
|
||||
$data = Article::getList();
|
||||
// print_r($data);
|
||||
$results['articles'][] = $data[0];
|
||||
$results['articles'] = $data;
|
||||
// $results['totalRows'] = $data['totalRows'];
|
||||
$results['pageTitle'] = "All Articles";
|
||||
if (isset($_GET['error'])) {
|
||||
@ -81,9 +81,9 @@ function listArticles() {
|
||||
$results['error'] = "Error: Article not found.";
|
||||
}
|
||||
}
|
||||
if ( isset( $_GET['status'] ) ) {
|
||||
if ( $_GET['status'] == "saved" ) $results['status'] = "Your changes have been saved.";
|
||||
if ( $_GET['status'] == "deleted" ) $results['status'] = "Article deleted.";
|
||||
if (isset( $_GET['status'])) {
|
||||
if ($_GET['status'] == "saved") $results['status'] = "Your changes have been saved.";
|
||||
if ($_GET['status'] == "deleted") $results['status'] = "Article deleted.";
|
||||
}
|
||||
require("list.php");
|
||||
}
|
||||
|
@ -1,23 +1,53 @@
|
||||
<h2>All Articles</h2>
|
||||
<?php if (isset($results['error'])) { ?>
|
||||
<div class="error"><?php echo $results['error'] ?></div>
|
||||
<?php }
|
||||
if (isset($results['status'])) {?>
|
||||
<div class="status"><?php echo $results['status'] ?></div>
|
||||
<?php } ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Publication Date</th>
|
||||
<th>Article</th>
|
||||
</tr>
|
||||
<?php foreach($results as $article) { ?>
|
||||
<tr>
|
||||
<td><?php echo date('j M Y', $article->publication_date)?></td>
|
||||
<td>
|
||||
<?php echo $article->title?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<p><a href="admin.php?action=new">New article</a></p>
|
||||
<p><a href="./">Return to Homepage</a></p>
|
||||
<?php
|
||||
$root = realpath($_SERVER["DOCUMENT_ROOT"]);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Articles | Chiro - Canto</title>
|
||||
<link rel="stylesheet" type="text/css" href="/styles/style.css">
|
||||
</head>
|
||||
<?php
|
||||
include("$root/analytics/matomo.php");
|
||||
?>
|
||||
<body>
|
||||
<?php include("$root/menu.php");?>
|
||||
<?php include("$root/header.php");?>
|
||||
<section>
|
||||
<h2>All Articles</h2>
|
||||
<?php if (isset($results['error'])) { ?>
|
||||
<div class="error"><?php echo $results['error'] ?></div>
|
||||
<?php }
|
||||
if (isset($results['status'])) {?>
|
||||
<div class="status"><?php echo $results['status'] ?></div>
|
||||
<?php } ?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Publication Date</th>
|
||||
<th>Article</th>
|
||||
</tr>
|
||||
<?php foreach($results['articles'] as $article) { ?>
|
||||
<tr>
|
||||
<td><?php echo date('j M Y', $article->publication_date)?></td>
|
||||
<td>
|
||||
<?php echo $article->title?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<p><a href="admin.php?action=new">New article</a></p>
|
||||
<p><a href="./">Return to Homepage</a></p>
|
||||
|
||||
</section>
|
||||
<?php include("$root/footer.php");?>
|
||||
</body>
|
||||
<script src="/scripts/script.js"></script>
|
||||
</html>
|
70
public/database/articles.sql
Normal file
70
public/database/articles.sql
Normal file
@ -0,0 +1,70 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.1.0
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: localhost
|
||||
-- Generation Time: Apr 05, 2021 at 01:45 PM
|
||||
-- Server version: 10.5.9-MariaDB
|
||||
-- PHP Version: 7.4.17RC1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `chirocanto`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `articles`
|
||||
--
|
||||
|
||||
CREATE TABLE `articles` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_on` datetime NOT NULL,
|
||||
`modified_on` datetime NOT NULL,
|
||||
`article_by` int(8) NOT NULL,
|
||||
`title` varchar(125) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`summary` varchar(500) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||
`content` text COLLATE utf8mb4_unicode_ci NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
--
|
||||
-- Dumping data for table `articles`
|
||||
--
|
||||
|
||||
INSERT INTO `articles` (`id`, `created_on`, `modified_on`, `article_by`, `title`, `summary`, `content`) VALUES
|
||||
(3, '2021-04-05 02:00:00', '1970-01-01 01:33:41', 9, 'First article of Chiro - Canto', 'What is Chiro-Canto ? Here is an attempt to make this point clearer...', '## What is Chiro-Canto\r\n\r\nChiro-Canto is a new website that forms an alternative to [xeno-canto.org](xeno-canto.org), adapted for Chiroptera taxon.\r\n\r\n## Who is behind Chiro-Canto\r\n\r\nChiro-Canto is developped by Samuel ORTION, a juvenile *Geekus biologicus*.\r\nIf you want to participate to its development, do not hesitate to fork and edit the git repository.\r\n\r\n## Source code and license\r\n\r\nChiro-Canto is available under the GNU Affero GPL v3 license at [https://forge.ortion.xyz/Chiro-Canto/chiro-canto](https://forge.ortion.xyz/Chiro-Canto/chiro-canto)\r\n\r\n## Who can use Chiro-Canto\r\n\r\nChiro-Canto is open to every one.\r\n\r\n## What is the purpose of Chiro-Canto\r\n\r\nChiro-Canto, as an alternative of Xeno-Canto, aims to offer a set of tools that proposes a support on acoustic identification through its forum and sound sharing plateform.\r\n\r\n');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `articles`
|
||||
--
|
||||
ALTER TABLE `articles`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `articles`
|
||||
--
|
||||
ALTER TABLE `articles`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
@ -20,13 +20,23 @@ function select() {
|
||||
|
||||
// let bold_button = document.getElementById('bold').addEventListener('click', function() {
|
||||
function bold() {
|
||||
let selection = select();
|
||||
if (selection == "") {
|
||||
alert("Please select text to bold.");
|
||||
}
|
||||
else {
|
||||
document.getElementById('reply').innerHTML.replace(selection, `**${selection}**`);
|
||||
// let selection = select();
|
||||
// if (selection == "") {
|
||||
// alert("Please select text to bold.");
|
||||
// }
|
||||
// else {
|
||||
// document.getElementById('reply').innerHTML.replace(selection, `**${selection}**`);
|
||||
// }
|
||||
if (window.getSelection) {
|
||||
var sel = window.getSelection();
|
||||
if (sel.rangeCount) {
|
||||
var range = sel.getRangeAt(0).cloneRange();
|
||||
range.surroundContents(document.createTextNode('**'));
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -58,3 +68,14 @@ url_button.addEventListener('click', function() {
|
||||
// sel.removeAllRanges();
|
||||
// sel.addRange(range);
|
||||
// }
|
||||
function surroundSelection(element) {
|
||||
if (window.getSelection) {
|
||||
var sel = window.getSelection();
|
||||
if (sel.rangeCount) {
|
||||
var range = sel.getRangeAt(0).cloneRange();
|
||||
range.surroundContents(element);
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
}
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ if (isset($_POST['submit']))
|
||||
{
|
||||
$_SESSION['error_msg'] .= "You did not enter your reply. \n";
|
||||
}
|
||||
if (isset($_POST['reply']))
|
||||
if (isset($_POST['reply']) and $_POST['reply'] != "")
|
||||
{
|
||||
$reply_content = $_POST['reply'];
|
||||
} else
|
||||
@ -64,8 +64,6 @@ if (isset($_POST['submit']))
|
||||
if ($_SESSION['error_msg'] == "")
|
||||
{
|
||||
send_reply($reply_content, $topic_id, $_SESSION['username']);
|
||||
header('Location: '."/forum/topics/?topic$topic_id");
|
||||
} else {
|
||||
header('Location: '."/auth/login/");
|
||||
}
|
||||
header('Location: '."/forum/topics/?topic=$topic_id");
|
||||
?>
|
@ -34,6 +34,8 @@ if (isset($_GET['topic'])){
|
||||
try {
|
||||
$rows = $req->fetchAll(PDO::FETCH_ASSOC);
|
||||
?>
|
||||
<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css">
|
||||
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
|
||||
<h3><?=$subject?></h3>
|
||||
<table id="replies">
|
||||
<thead>
|
||||
@ -59,9 +61,9 @@ if (isset($_GET['topic'])){
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><?="$firstname $lastname<br> ($username)"?></td>
|
||||
<td><?=$Parsedown->text($row['reply_content'])?></td>
|
||||
<td><?=$row['reply_date']?></td>
|
||||
<td class="author"><?="<span class='name'>$firstname $lastname</span><br> <span class='username'>($username)</span>"?></td>
|
||||
<td class="reply"><?=$Parsedown->text($row['reply_content'])?></td>
|
||||
<td class="date"><?=$row['reply_date']?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
@ -70,10 +72,10 @@ if (isset($_GET['topic'])){
|
||||
</table>
|
||||
<br>
|
||||
<h2>Your Reply</h2>
|
||||
|
||||
<!--
|
||||
<div class="container column">
|
||||
<div class="container items row">
|
||||
<button id="bold" title="bold" onmousedown="bold()"><b>B</b></button>
|
||||
<button id="bold" title="bold" onclick="bold()"><b>B</b></button>
|
||||
<button id="italic" title="italic"><i>I</i></button>
|
||||
<button id="underline" title="underline"><u>U</u></button>
|
||||
<button id="crossed" title="crossed"><s>s</s></button>
|
||||
@ -85,10 +87,13 @@ if (isset($_GET['topic'])){
|
||||
<button id="cite" title="cite"><img src="/media/icons/cite.svg" alt="cite"></button>
|
||||
<button id="image" title="image"><img src="/media/icons/dslr.png" alt="image"></button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<form action="sendreply.php" method="post">
|
||||
<input type="hidden" name="topic_id" value="<?=$topic_id?>">
|
||||
<textarea name="reply" id="reply" cols="30" rows="10" placeholder="Enter your reply (support Markdown).."></textarea>
|
||||
<script>
|
||||
var easyMDE = new EasyMDE({showIcons: ['strikethrough', 'code', 'table', 'redo', 'heading', 'undo', 'heading-bigger', 'heading-smaller', 'heading-1', 'heading-2', 'heading-3', 'clean-block', 'horizontal-rule']});
|
||||
</script>
|
||||
<input type="submit" name="submit" value="submit">
|
||||
<input type="reset" name="reset" value="reset">
|
||||
</form>
|
||||
@ -105,7 +110,7 @@ if (isset($_GET['topic'])){
|
||||
} catch (Exception $e)
|
||||
{
|
||||
die("Error : ".$e->getMessage());
|
||||
echo "Can fetch topic data.\n";
|
||||
echo "Can't fetch topic data.\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -319,3 +319,7 @@ form#url-form {
|
||||
border-radius: 5px;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
table#replies td {
|
||||
background-color: white;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user