Minor - removing white spaces, formatting code.

1.9.x
Julio Montoya 12 years ago
parent 4cd1a376f7
commit 920d02de65
  1. 12
      main/admin/settings.lib.php
  2. 58
      main/inc/lib/event_email_template.class.php
  3. 239
      main/inc/lib/grade_model.lib.php
  4. 3
      main/inc/lib/model.lib.php

@ -841,7 +841,7 @@ function add_edit_template() {
// Initialize the object.
$form = new FormValidator('template', 'post', 'settings.php?category=Templates&action='.Security::remove_XSS($_GET['action']).'&id='.Security::remove_XSS($_GET['id']));
// Settting the form elements: the header.
// Setting the form elements: the header.
if ($_GET['action'] == 'add') {
$title = get_lang('AddTemplate');
} else {
@ -849,16 +849,16 @@ function add_edit_template() {
}
$form->addElement('header', '', $title);
// Settting the form elements: the title of the template.
// Setting the form elements: the title of the template.
$form->add_textfield('title', get_lang('Title'), false);
// Settting the form elements: the content of the template (wysiwyg editor).
// Setting the form elements: the content of the template (wysiwyg editor).
$form->addElement('html_editor', 'template_text', get_lang('Text'), null, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400'));
// Settting the form elements: the form to upload an image to be used with the template.
// Setting the form elements: the form to upload an image to be used with the template.
$form->addElement('file','template_image',get_lang('Image'),'');
// Settting the form elements: a little bit information about the template image.
// Setting the form elements: a little bit information about the template image.
$form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70'));
// Getting all the information of the template when editing a template.
@ -887,7 +887,7 @@ function add_edit_template() {
// Setting the information of the template that we are editing.
$form->setDefaults($defaults);
}
// Settting the form elements: the submit button.
// Setting the form elements: the submit button.
$form->addElement('style_submit_button' , 'submit', get_lang('Ok') ,'class="save"');
// Setting the rules: the required fields.

@ -15,19 +15,19 @@ define ('EVENT_EMAIL_TEMPLATE_INACTIVE',0);
* @package chamilo.library
*/
class EventEmailTemplate extends Model {
var $table;
var $columns = array('id', 'message','subject','event_type_name','activated');
public function __construct() {
$this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
}
}
public function get_all($where_conditions = array()) {
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
}
/**
* Displays the title + grid
*/
@ -35,64 +35,64 @@ class EventEmailTemplate extends Model {
// action links
$content = Display::actions(array(
array(
'url' => 'event_type.php' ,
'url' => 'event_type.php' ,
'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
)
)
);
$content .= Display::grid_html('event_email_template');
$content .= Display::grid_html('event_email_template');
return $content;
}
public function get_status_list() {
return array(EVENT_EMAIL_TEMPLATE_ACTIVE => get_lang('Enabled'), EVENT_EMAIL_TEMPLATE_INACTIVE=> get_lang('Disabled'));
}
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return obj form validator obj
*/
public function return_form($url, $action) {
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'careers';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
$form = new FormValidator('career', 'post', $url);
// Settting the form elements
$header = get_lang('Add');
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list();
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$status_list = $this->get_status_list();
$form->addElement('select', 'status', get_lang('Status'), $status_list);
if ($action == 'edit') {
$form->addElement('text', 'created_at', get_lang('CreatedAt'));
$form->freeze('created_at');
}
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
// Setting the defaults
$defaults = $this->get($id);
if (!empty($defaults['created_at'])) {
$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
}
@ -100,17 +100,17 @@ class EventEmailTemplate extends Model {
$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
return $form;
}
public function get_count() {
public function get_count() {
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
/*
public function save($params) {
$id = parent::save($params);
@ -119,9 +119,9 @@ class EventEmailTemplate extends Model {
}
return $id;
}
public function delete($id) {
parent::delete($id);
event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
} */
} */
}

@ -8,117 +8,129 @@
/**
* Code
*/
/**
* @package chamilo.library
*/
require_once 'fckeditor/fckeditor.php';
/**
* Class GradeModel
*/
class GradeModel extends Model
{
public $table;
public $columns = array('id', 'name', 'description');
class GradeModel extends Model {
var $table;
var $columns = array('id', 'name', 'description');
public function __construct() {
public function __construct()
{
$this->table = Database::get_main_table(TABLE_GRADE_MODEL);
}
public function get_all($where_conditions = array()) {
}
/**
* @param array $where_conditions
* @return array
*/
public function get_all($where_conditions = array())
{
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
}
public function get_count() {
/**
* @return mixed
*/
public function get_count()
{
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
}
/**
* Displays the title + grid
*/
public function display() {
public function display()
{
// action links
echo '<div class="actions" style="margin-bottom:20px">';
echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
echo '</div>';
echo Display::grid_html('grade_model');
echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
echo '</div>';
echo Display::grid_html('grade_model');
}
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return obj form validator obj
*/
public function return_form($url, $action) {
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'grade_model';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
public function return_form($url, $action)
{
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'grade_model';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
$form = new FormValidator('grades', 'post', $url);
// Settting the form elements
// Setting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$form->addElement('label', get_lang('Components'));
//Get components
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
$defaults = $this->get($id);
$components = $this->get_components($defaults['id']);
if ($action == 'edit') {
if (!empty($components)) {
if (!empty($components)) {
$nr_items = count($components) -1;
}
}
}
$form->addElement('hidden', 'maxvalue', '100');
$form->addElement('hidden', 'minvalue', '0');
$renderer = & $form->defaultRenderer();
$component_array = array();
for ($i = 0; $i <= $max; $i++) {
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][acronym]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span3'));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span3'));
$form->addElement('hidden', 'components['.$i.'][id]', null, array('class' => 'span3'));
$template_percentage =
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
<p>
<label class="control-label">{label}</label>
<div class="controls">
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
{element} <!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --> % = ';
$template_acronym = '
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
{element} {label} <!-- BEGIN error --><span class="form_error">{error}</span> <!-- END error -->';
$template_title =
@ -128,31 +140,31 @@ class GradeModel extends Model {
</a>
<a href="javascript:minItem(' . ($counter) . ')">
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="min-' . $counter . '" src="../img/delete.png" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></img>
</a>
</a>
</div></p></div>';
$renderer->setElementTemplate($template_title, 'components['.$i.'][title]');
$renderer->setElementTemplate($template_percentage , 'components['.$i.'][percentage]');
$renderer->setElementTemplate($template_acronym , 'components['.$i.'][acronym]');
if ($i == 0) {
$form->addRule('components['.$i.'][percentage]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addRule('components['.$i.'][percentage]', get_lang('OnlyNumbers'), 'numeric');
$form->addRule(array('components['.$i.'][percentage]', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
$form->addRule(array('components['.$i.'][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$form->addRule(array('components['.$i.'][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$component_array[] = 'components['.$i.'][percentage]';
}
//New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addElement('advanced_settings', get_lang('AllMustWeight100'));
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
@ -167,43 +179,46 @@ class GradeModel extends Model {
}
$counter++;
}
}
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
public function get_components($id) {
public function get_components($id)
{
$obj = new GradeModelComponents();
if (!empty($id)) {
return $obj->get_all(array('where'=> array('grade_model_id = ?' => $id)));
}
return $obj->get_all(array('where'=> array('grade_model_id = ?' => $id)));
}
return null;
}
public function save($params, $show_query = false) {
public function save($params, $show_query = false)
{
$id = parent::save($params, $show_query);
if (!empty($id)) {
foreach ($params['components'] as $component) {
if (!empty($id)) {
foreach ($params['components'] as $component) {
if (!empty($component['title']) && !empty($component['percentage']) && !empty($component['acronym'])) {
$obj = new GradeModelComponents();
$component['grade_model_id'] = $id;
$obj->save($component);
}
}
}
}
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
return $id;
}
public function update($params) {
public function update($params)
{
parent::update($params);
if (!empty($params['id'])) {
foreach ($params['components'] as $component) {
foreach ($params['components'] as $component) {
$obj = new GradeModelComponents();
$component['grade_model_id'] = $params['id'];
if (empty($component['title']) && empty($component['percentage']) && empty($component['acronym'])) {
@ -212,41 +227,43 @@ class GradeModel extends Model {
$obj->update($component);
}
}
}
}
//$params['components']
}
public function delete($id) {
public function delete($id)
{
parent::delete($id);
//event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
}
public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null) {
public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null)
{
if (api_get_setting('gradebook_enable_grade_model') == 'false') {
return false;
}
}
if (api_get_setting('teachers_can_change_grade_model_settings') == 'true' || api_is_platform_admin()) {
$grade_models = $this->get_all();
$grade_model_options = array('-1' => get_lang('None'));
$grade_models = $this->get_all();
$grade_model_options = array('-1' => get_lang('None'));
if (!empty($grade_models)) {
foreach ($grade_models as $item) {
$grade_model_options[$item['id']] = $item['name'];
}
}
}
$form->addElement('select', $name, get_lang('GradeModel'), $grade_model_options);
$default_platform_setting = api_get_setting('gradebook_default_grade_model_id');
$default = -1;
if ($default_platform_setting == -1) {
if (!empty($default_value)) {
$default = $default_value;
}
}
} else {
$default = $default_platform_setting;
}
if (!empty($default) && $default != '-1') {
$form->setDefaults(array($name => $default));
}
@ -254,16 +271,22 @@ class GradeModel extends Model {
}
}
class GradeModelComponents extends Model {
var $table;
var $columns = array('id', 'title', 'percentage', 'acronym', 'grade_model_id');
public function __construct() {
/**
* Class GradeModelComponents
*/
class GradeModelComponents extends Model
{
public $table;
public $columns = array('id', 'title', 'percentage', 'acronym', 'grade_model_id');
public function __construct()
{
$this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
}
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
}
public function save($params, $show_query = false)
{
$id = parent::save($params, $show_query);
return $id;
}
}

@ -137,7 +137,8 @@ class Model {
* @return bool
*
*/
public function save($params, $show_query = false) {
public function save($params, $show_query = false)
{
$params = $this->clean_parameters($params);
if ($this->is_course_model) {

Loading…
Cancel
Save