Skip to content

Commit b5f68cb

Browse files
author
David Kobia
committed
PSR-0 compliance
* Renamed class files * closed #8
1 parent 57b79a7 commit b5f68cb

25 files changed

+45
-35
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
*.DS_Store
44
application/logs/*
55
application/cache/*
6-
application/config/*.php
6+
application/config/*.php
7+
8+
core.ignorecase=true

application/classes/controller/api/forms.php application/classes/Controller/Api/Forms.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
1515
*/
1616

17-
class Controller_API_Forms extends Ushahidi_API {
17+
class Controller_Api_Forms extends Ushahidi_Api {
1818

1919
/**
2020
* Create A Form
@@ -27,7 +27,7 @@ public function action_post_index_collection()
2727
{
2828
$post = $this->_request_payload;
2929

30-
$form = ORM::factory('form')->values($post);
30+
$form = ORM::factory('Form')->values($post);
3131
// Validation - cycle through nested models
3232
// and perform in-model validation before
3333
// saving
@@ -42,7 +42,7 @@ public function action_post_index_collection()
4242
// Yes, loop through and validate each group
4343
foreach ($post['groups'] as $group)
4444
{
45-
$_group = ORM::factory('form_group')->values($group);
45+
$_group = ORM::factory('Form_Group')->values($group);
4646
$_group->check();
4747

4848
// Are form attributes defined?
@@ -51,7 +51,7 @@ public function action_post_index_collection()
5151
// Yes, loop through and validate each form attribute
5252
foreach ($group['attributes'] as $attribute)
5353
{
54-
$_attribute = ORM::factory('form_attribute')->values($attribute);
54+
$_attribute = ORM::factory('Form_Attribute')->values($attribute);
5555
$_attribute->check();
5656
}
5757
}
@@ -68,7 +68,7 @@ public function action_post_index_collection()
6868
{
6969
foreach ($post['groups'] as $group)
7070
{
71-
$_group = ORM::factory('form_group');
71+
$_group = ORM::factory('Form_Group');
7272
if ( isset($group['label']) )
7373
{
7474
$_group->label = $group['label'];
@@ -85,7 +85,7 @@ public function action_post_index_collection()
8585
{
8686
foreach ($group['attributes'] as $attribute)
8787
{
88-
$_attribute = ORM::factory('form_attribute');
88+
$_attribute = ORM::factory('Form_Attribute');
8989
$_attribute->values($attribute, array(
9090
'key', 'label', 'input', 'type'
9191
));
@@ -121,7 +121,7 @@ public function action_get_index_collection()
121121
{
122122
$results = array();
123123

124-
$forms = ORM::factory('form')
124+
$forms = ORM::factory('Form')
125125
->order_by('created', 'ASC')
126126
->find_all();
127127

@@ -151,7 +151,7 @@ public function action_get_index()
151151
$form_id = $this->request->param('id', 0);
152152

153153
// Respond with form
154-
$form = ORM::factory('form', $form_id);
154+
$form = ORM::factory('Form', $form_id);
155155
$this->_response_payload = $this->form($form);
156156
}
157157

@@ -178,7 +178,7 @@ public function action_put_index()
178178
public function action_delete_index()
179179
{
180180
$form_id = $this->request->param('id', 0);
181-
$form = ORM::factory('form', $form_id);
181+
$form = ORM::factory('Form', $form_id);
182182
if ( $form->loaded() )
183183
{
184184
$form->delete();

application/classes/controller/api/forms/attributes.php application/classes/Controller/Api/Forms/Attributes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
1515
*/
1616

17-
class Controller_API_Forms_Attributes extends Ushahidi_API {
17+
class Controller_Api_Forms_Attributes extends Ushahidi_Api {
1818

1919
/**
2020
* Retrieve An attribute

application/classes/controller/api/posts.php application/classes/Controller/Api/Posts.php

+17-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
1515
*/
1616

17-
class Controller_API_Posts extends Ushahidi_API {
17+
class Controller_Api_Posts extends Ushahidi_Api {
1818

1919
/**
2020
* @var int Post Parent ID
@@ -37,7 +37,7 @@ public function action_post_index_collection()
3737
{
3838
$post = $this->_request_payload;
3939

40-
$_post = ORM::factory('post')->values($post);
40+
$_post = ORM::factory('Post')->values($post);
4141
// Validation - cycle through nested models
4242
// and perform in-model validation before
4343
// saving
@@ -53,12 +53,12 @@ public function action_post_index_collection()
5353
// to the form_attribute
5454
foreach ($post['values'] as $key => $value)
5555
{
56-
$attribute = ORM::factory('form_attribute')
56+
$attribute = ORM::factory('Form_Attribute')
5757
->where('form_id', '=', $post['form_id'])
5858
->where('key', '=', $key)
5959
->find();
6060

61-
$_value = ORM::factory('post_'.$attribute->type)->values(array(
61+
$_value = ORM::factory('Post_'.ucfirst($attribute->type))->values(array(
6262
'value' => $value
6363
));
6464
$_value->check();
@@ -78,14 +78,14 @@ public function action_post_index_collection()
7878
{
7979
foreach ($post['values'] as $key => $value)
8080
{
81-
$attribute = ORM::factory('form_attribute')
81+
$attribute = ORM::factory('Form_Attribute')
8282
->where('form_id', '=', $post['form_id'])
8383
->where('key', '=', $key)
8484
->find();
8585

8686
if ( $attribute->loaded() )
8787
{
88-
$_value = ORM::factory('post_'.$attribute->type);
88+
$_value = ORM::factory('Post_'.ucfirst($attribute->type));
8989
$_value->post_id = $_post->id;
9090
$_value->form_attribute_id = $attribute->id;
9191
$_value->value = $value;
@@ -117,7 +117,7 @@ public function action_get_index_collection()
117117
{
118118
$results = array();
119119

120-
$posts = ORM::factory('post')
120+
$posts = ORM::factory('Post')
121121
->order_by('created', 'ASC')
122122
->find_all();
123123

@@ -147,7 +147,7 @@ public function action_get_index()
147147
$post_id = $this->request->param('id', 0);
148148

149149
// Respond with post
150-
$post = ORM::factory('post', $post_id);
150+
$post = ORM::factory('Post', $post_id);
151151
$this->_response_payload = $this->post($post);
152152
}
153153

@@ -173,7 +173,7 @@ public function action_put_index()
173173
public function action_delete_index()
174174
{
175175
$post_id = $this->request->param('id', 0);
176-
$post = ORM::factory('post', $post_id);
176+
$post = ORM::factory('Post', $post_id);
177177
if ( $post->loaded() )
178178
{
179179
$post->delete();
@@ -259,6 +259,14 @@ public function post($post = NULL)
259259
$response['values'][$result['key']] = $result['value'];
260260
}
261261
}
262+
else
263+
{
264+
$response = array(
265+
'errors' => array(
266+
'Post does not exist'
267+
)
268+
);
269+
}
262270

263271
return $response;
264272
}

application/classes/controller/api/posts/streams.php application/classes/Controller/Api/Posts/Streams.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
1515
*/
1616

17-
class Controller_API_Posts_Streams extends Controller_API_Posts {
17+
class Controller_Api_Posts_Streams extends Controller_Api_Posts {
1818

1919

2020
public function before()

application/classes/model/form.php application/classes/Model/Form.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Model_Form extends ORM {
2626
'form_groups' => array(),
2727

2828
'children' => array(
29-
'model' => 'form',
29+
'model' => 'Form',
3030
'foreign_key' => 'parent_id',
3131
),
3232
);

application/classes/model/post.php application/classes/Model/Post.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Model_Post extends ORM {
3939
'tags' => array('through' => 'posts_tags'),
4040

4141
'children' => array(
42-
'model' => 'post',
42+
'model' => 'Post',
4343
'foreign_key' => 'parent_id',
4444
),
4545
);
@@ -109,7 +109,7 @@ public function rules()
109109
*/
110110
public function form_exists($validation, $field, $value)
111111
{
112-
$form = ORM::factory('form')
112+
$form = ORM::factory('Form')
113113
->where('id', '=', $value)
114114
->find();
115115

application/classes/model/post/comment.php application/classes/Model/Post/Comment.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Model_Post_Comment extends ORM {
2222
*/
2323
protected $_has_many = array(
2424
'children' => array(
25-
'model' => 'post_comment',
25+
'model' => 'Post_Comment',
2626
'foreign_key' => 'parent_id',
2727
),
2828
);
File renamed without changes.
File renamed without changes.

application/classes/model/tag.php application/classes/Model/Tag.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Model_Tags extends ORM {
2525
'posts' => array('through' => 'posts_tags'),
2626

2727
'children' => array(
28-
'model' => 'tag',
28+
'model' => 'Tag',
2929
'foreign_key' => 'parent_id'
3030
)
3131
);
@@ -37,7 +37,7 @@ class Model_Tags extends ORM {
3737
*/
3838
protected $_belongs_to = array(
3939
'parent' => array(
40-
'model' => 'tag',
40+
'model' => 'Tag',
4141
'foreign_key' => 'parent_id',
4242
),
4343
);

application/classes/model/task.php application/classes/Model/Task.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Model_Task extends ORM {
2222
*/
2323
protected $_has_many = array(
2424
'children' => array(
25-
'model' => 'task',
25+
'model' => 'Task',
2626
'foreign_key' => 'parent_id',
2727
),
2828
);
@@ -36,15 +36,15 @@ class Model_Task extends ORM {
3636
protected $_belongs_to = array(
3737
'post' => array(),
3838
'parent' => array(
39-
'model' => 'task',
39+
'model' => 'Task',
4040
'foreign_key' => 'parent_id',
4141
),
4242
'assignor' => array(
43-
'model' => 'user',
43+
'model' => 'User',
4444
'foreign_key' => 'assignor',
4545
),
4646
'assignee' => array(
47-
'model' => 'user',
47+
'model' => 'User',
4848
'foreign_key' => 'assignee',
4949
),
5050
);

application/classes/model/user.php application/classes/Model/User.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class Model_User extends Model_Auth_User {
3131

3232
// Task Assignor / Assignee relationship
3333
'assignors' => array(
34-
'model' => 'task',
34+
'model' => 'Task',
3535
'foreign_key' => 'assignor',
3636
),
3737
'assignees' => array(
38-
'model' => 'task',
38+
'model' => 'Task',
3939
'foreign_key' => 'assignee'
4040
),
4141
);

application/classes/ushahidi/api.php application/classes/Ushahidi/Api.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
1515
*/
1616

17-
class Ushahidi_API extends Controller {
17+
class Ushahidi_Api extends Controller {
1818

1919
protected $version = '2.0.0';
2020

application/config/database.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ return array
1818
(
1919
'default' => array
2020
(
21-
'type' => 'mysql',
21+
'type' => 'MySQL',
2222
'connection' => array(
2323
'hostname' => 'localhost',
2424
'database' => 'database',

0 commit comments

Comments
 (0)