Skip to content

Commit d0b7699

Browse files
committed
Post created
1 parent 9ade49f commit d0b7699

File tree

8 files changed

+959
-19
lines changed

8 files changed

+959
-19
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ $RECYCLE.BIN/
4141
Network Trash Folder
4242
Temporary Items
4343
.apdisk
44+
/nbproject/

application/configuration/database.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ database.default.host = localhost
33
database.default.username = root
44
database.default.password =
55
database.default.port = 3306
6-
database.default.schema = mvc
6+
database.default.schema = test

application/controllers/home.php

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,35 @@
55
*
66
* @author Faizan Ayubi
77
*/
8-
use Framework\Controller as Controller;
8+
use Shared\Controller as Controller;
9+
use Framework\Registry as Registry;
10+
use Framework\RequestMethods as RequestMethods;
911

1012
class Home extends Controller {
1113

1214
public function index() {
13-
15+
//$model = new Post();
16+
//$db = Registry::get("database");
17+
//$db->sync($model);
1418
}
19+
20+
public function post() {
21+
$view = $this->getActionView();
22+
$view->set("errors", array());
23+
24+
if(RequestMethods::post("action") == "blogpost"){
25+
$post = new Post(array(
26+
"title" => RequestMethods::post("title"),
27+
"content" => RequestMethods::post("content")
28+
));
1529

30+
if ($post->validate()) {
31+
$post->save();
32+
$view->set("success", true);
33+
}
34+
35+
$view->set("errors", $post->getErrors());
36+
}
37+
}
38+
1639
}

application/models/post.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/**
4+
* Description of post
5+
*
6+
* @author Faizan Ayubi
7+
*/
8+
class Post extends Shared\Model {
9+
10+
/**
11+
* @column
12+
* @readwrite
13+
* @type text
14+
* @length 100
15+
*
16+
* @validate required, min(3), max(100)
17+
* @label title
18+
*/
19+
protected $_title;
20+
21+
/**
22+
* @column
23+
* @readwrite
24+
* @type text
25+
*
26+
* @validate required, min(3)
27+
* @label content
28+
*/
29+
protected $_content;
30+
}

application/models/user.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77
*/
88
class User extends Shared\Model {
99

10-
/**
11-
* @column
12-
* @readwrite
13-
* @primary
14-
* @type autonumber
15-
*/
16-
protected $_id;
17-
1810
/**
1911
* @column
2012
* @readwrite
@@ -60,12 +52,5 @@ class User extends Shared\Model {
6052
* @label password
6153
*/
6254
protected $_password;
63-
64-
/**
65-
* @column
66-
* @readwrite
67-
* @type boolean
68-
*/
69-
protected $_admin = false;
7055

7156
}

application/views/home/post.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<div class="container">
2+
<div class="row">
3+
{if(isset($success))}
4+
<p>Posted Successfully</p>
5+
{/if}
6+
<form method="post" action="/SwiftBlog/home/post">
7+
<div class="form-group">
8+
<label>Title</label>
9+
<input type="text" name="title" class="form-control" placeholder="title of post">
10+
{echo Shared\Markup::errors($errors, "title")}
11+
</div>
12+
<div class="form-group">
13+
<label>Content</label>
14+
<input type="text" name="content" class="form-control" placeholder="Content">
15+
{echo Shared\Markup::errors($errors, "content")}
16+
</div>
17+
<input type="hidden" name="action" value="blogpost">
18+
<button type="submit" class="btn btn-default">Submit</button>
19+
</form>
20+
21+
</div>
22+
23+
<div class="row">
24+
25+
</div>
26+
</div>

framework/model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ protected function _validateMin($value, $number) {
396396
* We then split the @validate metadata into a list of validation conditions. If a condition has arguments, we extract the arguments.
397397
* We then run each validation method on the column data and generate error messages for those validation conditions that failed.
398398
*
399-
* @return type
399+
* @return array
400400
* @throws Exception\Validation
401401
*/
402402
public function validate() {

logs/2015-07-01.txt

Lines changed: 875 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)