Minor - Format code, add docs, remove globals

1.10.x
Julio Montoya 10 years ago
parent 20dd96739d
commit e75574fb95
  1. 23
      main/inc/lib/app_view.php
  2. 17
      main/inc/lib/banner.lib.php
  3. 17
      main/inc/lib/career.lib.php
  4. 1
      main/inc/lib/course_description.lib.php
  5. 2
      main/inc/lib/course_home.lib.php

@ -8,8 +8,8 @@
*/
class ViewException extends Exception {}
class View {
class View
{
private $data;
private $template;
private $layout;
@ -19,7 +19,8 @@ class View {
* Constructor, init tool path for rendering
* @param string tool name (optional)
*/
public function __construct($toolname = '', $template_path=null) {
public function __construct($toolname = '', $template_path=null)
{
if (!empty($toolname)) {
if (isset($template_path)) {
$path = $template_path.$toolname.'/';
@ -38,7 +39,8 @@ class View {
* Set data sent from a controller
* @param array data
*/
public function set_data($data) {
public function set_data($data)
{
if (!is_array($data)) {
throw new ViewException('View::set_data() $data must to be an array, you have sent a' . gettype( $data ));
}
@ -49,7 +51,8 @@ class View {
* Set layout view sent from a controller
* @param string layout view
*/
public function set_layout( $layout ) {
public function set_layout( $layout )
{
$this->layout = $layout;
}
@ -57,14 +60,16 @@ class View {
* Set template view sent from a controller
* @param string template view
*/
public function set_template($template) {
public function set_template($template)
{
$this->template = $template;
}
/**
* Render data to the template and layout views
*/
public function render() {
public function render()
{
$content = $this->render_template();
$target = $this->tool_path.$this->layout.'.php';
if (file_exists($target)) {
@ -78,7 +83,8 @@ class View {
* It's used into render method for rendering data in the template and layout views
* @return String Rendered template (as HTML, most of the time)
*/
private function render_template() {
private function render_template()
{
$target = $this->tool_path.$this->template.'.php';
if (file_exists($target)) {
ob_start();
@ -91,4 +97,3 @@ class View {
}
}
}
?>

@ -16,7 +16,7 @@
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
*/
function get_tabs() {
global $_course;
$_course = api_get_course_info();
$navigation = array();
@ -27,7 +27,7 @@ function get_tabs() {
// My Courses
if(api_is_allowed_to_create_course()) {
if (api_is_allowed_to_create_course()) {
// Link to my courses for teachers
$navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true';
} else {
@ -121,6 +121,7 @@ function get_tabs() {
$navigation['platform_admin']['title'] = get_lang('PlatformAdmin');
$navigation['platform_admin']['key'] = 'admin';
}
return $navigation;
}
@ -129,7 +130,8 @@ function get_tabs() {
*
* @return array
*/
function getCustomTabs() {
function getCustomTabs()
{
$tableSettingsCurrent = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
$sql = "SELECT * FROM $tableSettingsCurrent
WHERE variable = 'show_tabs' AND
@ -144,7 +146,8 @@ function getCustomTabs() {
return $customTabs;
}
function return_logo($theme) {
function return_logo($theme)
{
$_course = api_get_course_info();
$html = '';
$logo = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/images/header-logo.png';
@ -369,7 +372,11 @@ function return_navigation_array()
}
}
return array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs);
return array(
'menu_navigation' => $menu_navigation,
'navigation' => $navigation,
'possible_tabs' => $possible_tabs,
);
}
function return_menu()

@ -30,7 +30,12 @@ class Career extends Model
*/
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array(),'first');
$row = Database::select(
'count(*) as count',
$this->table,
array(),
'first'
);
return $row['count'];
}
@ -40,7 +45,11 @@ class Career extends Model
*/
public function get_all($where_conditions = array())
{
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
return Database::select(
'*',
$this->table,
array('where' => $where_conditions, 'order' => 'name ASC')
);
}
/**
@ -85,8 +94,8 @@ class Career extends Model
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @param string $url
* @param string $action add, edit
* @return obj form validator obj
*/
public function return_form($url, $action)

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains a class used like library provides functions for
* course description tool. It's also used like model to

@ -14,7 +14,7 @@ class CourseHome
*/
public static function show_tool_3column($cat)
{
global $_user;
$_user = api_get_user_info();
$TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);

Loading…
Cancel
Save