From d9b45b9471d4fb8db7c4d514e3e07296e498e72a Mon Sep 17 00:00:00 2001 From: Allendale Nato Date: Sat, 3 Dec 2016 03:17:49 +0800 Subject: [PATCH] Codify coding standard --- application/controllers/CSOcontroller.php | 2 -- contributing.md | 43 ++++++++++++++++++++++- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/application/controllers/CSOcontroller.php b/application/controllers/CSOcontroller.php index 8c76441..7ab6e6f 100644 --- a/application/controllers/CSOcontroller.php +++ b/application/controllers/CSOcontroller.php @@ -53,8 +53,6 @@ public function activity_page($orgInitials,$pageID) { // Show 404 :-( show_404(); } - - $this->load->view('cso_activity_page', $activity); } diff --git a/contributing.md b/contributing.md index a4fd1a9..8c66d8a 100644 --- a/contributing.md +++ b/contributing.md @@ -1 +1,42 @@ -# Coding Standards +## Coding Standards +Since the CSO Finance Dashboard is built on-top of CodeIgniter 3, the **PHP scripting language** will be utilized.
+As a result, standard PHP practices and conventions will be followed. + +### Function naming conventions +Considering CodeIgniter follows the MVC framework, the following functions naming conventions is followed for both contollers and models: +

+ +#### Loading view pages. + +For functions that loads html pages, all function names must be in lowercase and the spaces is delimited by an underscore.
+An example can be seen below. +``` +public function activity_page($orgInitials,$pageID) { + // Redirect to login if session does not exists. + $this->checkSession(); + // Load ActitivityModel.php + $this->load->model('CSOmodel'); + + ... + + $this->load->view('cso_activity_page', $activity); + } +``` + +#### CRUD Functions +For functions that performs CRUD (Create, Retrieve, Update, and Delete functions), function names should follow Camel Case naming convention. An example can be seen below. + +``` +public function checkSession(){ + if($this->session->has_userdata('email')){ + return; + } + redirect(site_url('login')); + } +``` + +#### Important Note +If a function both performs CURD and loading of html, **the loading of view naming convention is followed.** + + +## Creating Issues