-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
40 lines (36 loc) · 1.1 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once('frontend/posts.php');
include_once('includes/Markdown.php');
require_once('frontend/comments.php');
class Posts extends Blog{
public function __construct(){
parent::__construct();
$this->comments = new Comments();
if(!empty($_GET['id'])){
$this->viewpost($_GET['id']);
}else{
$this->getposts();
}
}
public function getposts(){
$id = 0;
$posts = array();
$template = '';
$posts = $this->ksdb->dbselect('posts', array('*'));
foreach($posts as $key => $post){
$posts[$key]['comments'] = $this->comments->commentnumber($post['id']);
}
$template = 'list-posts.php';
include_once('frontend/templates/'.$template);
}
public function viewpost($postid){
$id = $postid;
$posts = $this->ksdb->dbselect('posts', array('*'),array('id' => $id));
$markdown = new Michelf\Markdown();
$posts[0]['content'] = $markdown->defaultTransform($posts[0]['content']);
$postcomments = $this->comments->getcomments($posts[0]['id']);
$template = 'view-post.php';
include_once('frontend/templates/'.$template);
}
}
$blog = new Posts;