-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlog.php
More file actions
185 lines (166 loc) · 3.31 KB
/
Copy pathBlog.php
File metadata and controls
185 lines (166 loc) · 3.31 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?php
include_once 'system/database.php';
/**
* @todo revisit images
* @author ThaKidd
*
*/
class Blog
{
private $id;
private $title;
private $createdDate;
private $editDate;
private $bodyText;
private $images;//array of blog images
private $keywords;//array of describing keywords
//contructor
function __construct($_blogData)
{
$this->setID((isset($_blogData['id'])?$_blogData['id']:''));
$this->setTitle($_blogData['title']);
$this->setBodyText($_blogData['bodyText']);
//$this->setImages($_blogData['images']);
$this->setKeywords($_blogData['keywords']);
$this->createdDate = date('Y-m-d H:i:s');
}
private function Blog()
{
//construct a specified blog object
/*use a default ctor? with no arguments?
then use the setX functions to build up that object
add that blog to the array and return...
this is an attempt to return objects not some shit mysql array
*/
}
//add to db
public function createBlog(/*TODO*/)
{
//TODO make connection to db
//TODO verify contents
//TODO add to db
//TODO return mysql insert id to this.id
}
public function editBlog($param)
{
$this->editDate = date('Y-m-d H:i:s');//update db with new verified info associated with blog id
}
//GETS
/**
* Returns id of this entry
* @return int $id
*/
public function getID()
{
return $this->id;
}
/**
* Returns title of this entry
* @return string $title
*/
public function getTitle()
{
return $this->title;
}
/**
* Returns body of this entry
* @return string $body
*/
public function getBodyText()
{
return $this->bodyText;
}
/**
* Returns the array of keywords associated with this blog entry
* @return array $keywords
*/
public function getKeywords()
{
return $this->keywords;
}
public function getKeywordsStr($array)
{
$kStr = '';
if(!empty($array))
{
$kStr = implode(',', $array);
}
}
/**
* Returns the array of images associated with this blog entry
* @return array $images
*/
public function getImages()
{
return $this->images;
}
//SETS
/**
* Set the id of the blog in the object
* @param int $id
*/
public function setID($id)
{
$this->id = $id;
}
/**
* Set title of blog entry
* @param string $str
*/
public function setTitle($str)
{
//TODO some validation is needed
$this->title = $str;
}
/**
* Set text for body of blog entry
* @param string $str
*/
public function setBodyText($str)
{
$this->bodyText = $str;
}
/**
* Set the array of keywords that describe the blog entry
* @param array $array
*/
public function setKeywords($array)
{
if(!empty($array))
{
$this->keywords = $array;
}
}
/**
* Set array of image to be included in blog entry
* @param array $array
*/
public function setImages($array)
{
$this->images = $array;
}
/**
* Get all blogs and create an array of blogs
* @return array $blogs
*/
public static function getBlogList()
{
$dbCon = Database::getInstance();
$blogs = array();
$blogList = $dbCon->query("select * from blog");
while($aBlog = $blogList->fetch_assoc())
{
$blogs[] = new Blog($aBlog);
}
return $blogs;
}
/**
* Returns the html body of the blog entry formatted and including images
* @return string
*/
//HTML functions
private function formBody($imgArr,$bodyStr)
{
;//TODO add images and form html code accordingly
}
}