Skip to content

Commit

Permalink
PSR-0 compliance
Browse files Browse the repository at this point in the history
* Renamed class files
* closed #8
  • Loading branch information
David Kobia committed Jan 7, 2013
1 parent 57b79a7 commit b5f68cb
Show file tree
Hide file tree
Showing 25 changed files with 45 additions and 35 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
*.DS_Store
application/logs/*
application/cache/*
application/config/*.php
application/config/*.php

core.ignorecase=true
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/

class Controller_API_Forms extends Ushahidi_API {
class Controller_Api_Forms extends Ushahidi_Api {

/**
* Create A Form
Expand All @@ -27,7 +27,7 @@ public function action_post_index_collection()
{
$post = $this->_request_payload;

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

// Are form attributes defined?
Expand All @@ -51,7 +51,7 @@ public function action_post_index_collection()
// Yes, loop through and validate each form attribute
foreach ($group['attributes'] as $attribute)
{
$_attribute = ORM::factory('form_attribute')->values($attribute);
$_attribute = ORM::factory('Form_Attribute')->values($attribute);
$_attribute->check();
}
}
Expand All @@ -68,7 +68,7 @@ public function action_post_index_collection()
{
foreach ($post['groups'] as $group)
{
$_group = ORM::factory('form_group');
$_group = ORM::factory('Form_Group');
if ( isset($group['label']) )
{
$_group->label = $group['label'];
Expand All @@ -85,7 +85,7 @@ public function action_post_index_collection()
{
foreach ($group['attributes'] as $attribute)
{
$_attribute = ORM::factory('form_attribute');
$_attribute = ORM::factory('Form_Attribute');
$_attribute->values($attribute, array(
'key', 'label', 'input', 'type'
));
Expand Down Expand Up @@ -121,7 +121,7 @@ public function action_get_index_collection()
{
$results = array();

$forms = ORM::factory('form')
$forms = ORM::factory('Form')
->order_by('created', 'ASC')
->find_all();

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

// Respond with form
$form = ORM::factory('form', $form_id);
$form = ORM::factory('Form', $form_id);
$this->_response_payload = $this->form($form);
}

Expand All @@ -178,7 +178,7 @@ public function action_put_index()
public function action_delete_index()
{
$form_id = $this->request->param('id', 0);
$form = ORM::factory('form', $form_id);
$form = ORM::factory('Form', $form_id);
if ( $form->loaded() )
{
$form->delete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/

class Controller_API_Forms_Attributes extends Ushahidi_API {
class Controller_Api_Forms_Attributes extends Ushahidi_Api {

/**
* Retrieve An attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/

class Controller_API_Posts extends Ushahidi_API {
class Controller_Api_Posts extends Ushahidi_Api {

/**
* @var int Post Parent ID
Expand All @@ -37,7 +37,7 @@ public function action_post_index_collection()
{
$post = $this->_request_payload;

$_post = ORM::factory('post')->values($post);
$_post = ORM::factory('Post')->values($post);
// Validation - cycle through nested models
// and perform in-model validation before
// saving
Expand All @@ -53,12 +53,12 @@ public function action_post_index_collection()
// to the form_attribute
foreach ($post['values'] as $key => $value)
{
$attribute = ORM::factory('form_attribute')
$attribute = ORM::factory('Form_Attribute')
->where('form_id', '=', $post['form_id'])
->where('key', '=', $key)
->find();

$_value = ORM::factory('post_'.$attribute->type)->values(array(
$_value = ORM::factory('Post_'.ucfirst($attribute->type))->values(array(
'value' => $value
));
$_value->check();
Expand All @@ -78,14 +78,14 @@ public function action_post_index_collection()
{
foreach ($post['values'] as $key => $value)
{
$attribute = ORM::factory('form_attribute')
$attribute = ORM::factory('Form_Attribute')
->where('form_id', '=', $post['form_id'])
->where('key', '=', $key)
->find();

if ( $attribute->loaded() )
{
$_value = ORM::factory('post_'.$attribute->type);
$_value = ORM::factory('Post_'.ucfirst($attribute->type));
$_value->post_id = $_post->id;
$_value->form_attribute_id = $attribute->id;
$_value->value = $value;
Expand Down Expand Up @@ -117,7 +117,7 @@ public function action_get_index_collection()
{
$results = array();

$posts = ORM::factory('post')
$posts = ORM::factory('Post')
->order_by('created', 'ASC')
->find_all();

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

// Respond with post
$post = ORM::factory('post', $post_id);
$post = ORM::factory('Post', $post_id);
$this->_response_payload = $this->post($post);
}

Expand All @@ -173,7 +173,7 @@ public function action_put_index()
public function action_delete_index()
{
$post_id = $this->request->param('id', 0);
$post = ORM::factory('post', $post_id);
$post = ORM::factory('Post', $post_id);
if ( $post->loaded() )
{
$post->delete();
Expand Down Expand Up @@ -259,6 +259,14 @@ public function post($post = NULL)
$response['values'][$result['key']] = $result['value'];
}
}
else
{
$response = array(
'errors' => array(
'Post does not exist'
)
);
}

return $response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/

class Controller_API_Posts_Streams extends Controller_API_Posts {
class Controller_Api_Posts_Streams extends Controller_Api_Posts {


public function before()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Model_Form extends ORM {
'form_groups' => array(),

'children' => array(
'model' => 'form',
'model' => 'Form',
'foreign_key' => 'parent_id',
),
);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Model_Post extends ORM {
'tags' => array('through' => 'posts_tags'),

'children' => array(
'model' => 'post',
'model' => 'Post',
'foreign_key' => 'parent_id',
),
);
Expand Down Expand Up @@ -109,7 +109,7 @@ public function rules()
*/
public function form_exists($validation, $field, $value)
{
$form = ORM::factory('form')
$form = ORM::factory('Form')
->where('id', '=', $value)
->find();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Model_Post_Comment extends ORM {
*/
protected $_has_many = array(
'children' => array(
'model' => 'post_comment',
'model' => 'Post_Comment',
'foreign_key' => 'parent_id',
),
);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Model_Tags extends ORM {
'posts' => array('through' => 'posts_tags'),

'children' => array(
'model' => 'tag',
'model' => 'Tag',
'foreign_key' => 'parent_id'
)
);
Expand All @@ -37,7 +37,7 @@ class Model_Tags extends ORM {
*/
protected $_belongs_to = array(
'parent' => array(
'model' => 'tag',
'model' => 'Tag',
'foreign_key' => 'parent_id',
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Model_Task extends ORM {
*/
protected $_has_many = array(
'children' => array(
'model' => 'task',
'model' => 'Task',
'foreign_key' => 'parent_id',
),
);
Expand All @@ -36,15 +36,15 @@ class Model_Task extends ORM {
protected $_belongs_to = array(
'post' => array(),
'parent' => array(
'model' => 'task',
'model' => 'Task',
'foreign_key' => 'parent_id',
),
'assignor' => array(
'model' => 'user',
'model' => 'User',
'foreign_key' => 'assignor',
),
'assignee' => array(
'model' => 'user',
'model' => 'User',
'foreign_key' => 'assignee',
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class Model_User extends Model_Auth_User {

// Task Assignor / Assignee relationship
'assignors' => array(
'model' => 'task',
'model' => 'Task',
'foreign_key' => 'assignor',
),
'assignees' => array(
'model' => 'task',
'model' => 'Task',
'foreign_key' => 'assignee'
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License Version 3 (GPLv3)
*/

class Ushahidi_API extends Controller {
class Ushahidi_Api extends Controller {

protected $version = '2.0.0';

Expand Down
2 changes: 1 addition & 1 deletion application/config/database.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ return array
(
'default' => array
(
'type' => 'mysql',
'type' => 'MySQL',
'connection' => array(
'hostname' => 'localhost',
'database' => 'database',
Expand Down

0 comments on commit b5f68cb

Please sign in to comment.