diff --git a/public/articles/admin.php b/public/articles/admin.php index a83b349..9c4ca3c 100644 --- a/public/articles/admin.php +++ b/public/articles/admin.php @@ -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"); } diff --git a/public/articles/list.php b/public/articles/list.php index 8f88505..2f014b8 100644 --- a/public/articles/list.php +++ b/public/articles/list.php @@ -1,23 +1,53 @@ -

All Articles

- -
- -
- - - - - - - - - - - - -
Publication DateArticle
publication_date)?> - title?> -
-

New article

-

Return to Homepage

+ + + + + + + + + Articles | Chiro - Canto + + + + + + +
+

All Articles

+ +
+ +
+ + + + + + + + + + + + +
Publication DateArticle
publication_date)?> + title?> +
+

New article

+

Return to Homepage

+ +
+ + + + \ No newline at end of file diff --git a/public/database/articles.sql b/public/database/articles.sql new file mode 100644 index 0000000..6355c5f --- /dev/null +++ b/public/database/articles.sql @@ -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 */; diff --git a/public/forum/topics/scripts/editor.js b/public/forum/topics/scripts/editor.js index 277df8a..264facf 100644 --- a/public/forum/topics/scripts/editor.js +++ b/public/forum/topics/scripts/editor.js @@ -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); + } } + } @@ -57,4 +67,15 @@ url_button.addEventListener('click', function() { // sel.removeAllRanges(); // sel.addRange(range); -// } \ No newline at end of file +// } +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); + } + } +} \ No newline at end of file diff --git a/public/forum/topics/sendreply.php b/public/forum/topics/sendreply.php index 9a894da..cd26983 100644 --- a/public/forum/topics/sendreply.php +++ b/public/forum/topics/sendreply.php @@ -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"); ?> \ No newline at end of file diff --git a/public/forum/topics/topics.php b/public/forum/topics/topics.php index c0562c0..87cc6c2 100644 --- a/public/forum/topics/topics.php +++ b/public/forum/topics/topics.php @@ -34,6 +34,8 @@ if (isset($_GET['topic'])){ try { $rows = $req->fetchAll(PDO::FETCH_ASSOC); ?> + +

@@ -59,9 +61,9 @@ if (isset($_GET['topic'])){ } ?> - - - + + +

Your Reply

- + + @@ -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 { diff --git a/public/styles/style.css b/public/styles/style.css index 3bcfc7e..f89c75e 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -318,4 +318,8 @@ form#url-form { padding: 1em; border-radius: 5px; border: 1px solid #ccc; -} \ No newline at end of file +} + +table#replies td { + background-color: white; +}
($username)"?>text($row['reply_content'])?>$firstname $lastname
($username)"?>
text($row['reply_content'])?>