Minor - format code - refs BT#12441

pull/2487/head
Angel Fernando Quiroz Campos 8 years ago
parent 157754fd77
commit d9a0fae005
  1. 88
      main/course_progress/thematic.php

@ -2,11 +2,11 @@
/* For licensing terms, see /license.txt */
/**
* View (MVC patter) for thematic control
* @author Christian Fasanando <christian1827@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> Bug fixing
* @package chamilo.course_progress
*/
* View (MVC patter) for thematic control
* @author Christian Fasanando <christian1827@gmail.com>
* @author Julio Montoya <gugli100@gmail.com> Bug fixing
* @package chamilo.course_progress
*/
// protect a course script
api_protect_course_script(true);
@ -23,25 +23,25 @@ if (api_is_allowed_to_edit(null, true)) {
case 'thematic_add':
case 'thematic_import_select':
echo '<a href="index.php?'.api_get_cidreq().'">'.
Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('ThematicDetails'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('ThematicDetails'), '', ICON_SIZE_MEDIUM).'</a>';
break;
case 'thematic_list':
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
break;
case 'thematic_details':
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_import_select'.$url_token.'">'.
Display::return_icon('import_csv.png',get_lang('ImportThematic'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('import_csv.png', get_lang('ImportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export'.$url_token.'">'.
Display::return_icon('export_csv.png',get_lang('ExportThematic'),'', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('export_csv.png', get_lang('ExportThematic'), '', ICON_SIZE_MEDIUM).'</a>';
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_export_pdf'.$url_token.'">'.
Display::return_icon('pdf.png',get_lang('ExportToPDF'),'', ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('pdf.png', get_lang('ExportToPDF'), '', ICON_SIZE_MEDIUM).'</a>';
break;
default:
echo '<a href="index.php?'.api_get_cidreq().'&action=thematic_add'.$url_token.'">'.
Display::return_icon('new_course_progress.png',get_lang('NewThematicSection'),'',ICON_SIZE_MEDIUM).'</a>';
Display::return_icon('new_course_progress.png', get_lang('NewThematicSection'), '', ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
}
@ -55,7 +55,7 @@ if ($action == 'thematic_list') {
$parameters['action'] = $action;
$table->set_additional_parameters($parameters);
$table->set_header(0, '', false, array('style'=>'width:20px;'));
$table->set_header(0, '', false, array('style' => 'width:20px;'));
$table->set_header(1, get_lang('Title'), false);
if (api_is_allowed_to_edit(null, true)) {
$table->set_header(
@ -64,7 +64,7 @@ if ($action == 'thematic_list') {
false,
array('style' => 'text-align:center;width:40%;')
);
$table->set_form_actions(array ('thematic_delete_select' => get_lang('DeleteAllThematics')));
$table->set_form_actions(array('thematic_delete_select' => get_lang('DeleteAllThematics')));
}
$table->display();
@ -75,11 +75,11 @@ if ($action == 'thematic_list') {
if (isset($last_id) && $last_id) {
$link_to_thematic_plan = '<a href="index.php?'.api_get_cidreq().'&action=thematic_plan_list&thematic_id='.$last_id.'">'.
Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
Display::return_icon('lesson_plan.png', get_lang('ThematicPlan'), array('style' => 'vertical-align:middle;float:none;'), ICON_SIZE_SMALL).'</a>';
$link_to_thematic_advance = '<a href="index.php?'.api_get_cidreq().'&action=thematic_advance_list&thematic_id='.$last_id.'">'.
Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style'=>'vertical-align:middle;float:none;'),ICON_SIZE_SMALL).'</a>';
Display::return_icon('lesson_plan_calendar.png', get_lang('ThematicAdvance'), array('style' => 'vertical-align:middle;float:none;'), ICON_SIZE_SMALL).'</a>';
Display::display_confirmation_message(
get_lang('ThematicSectionHasBeenCreatedSuccessfull').'<br />'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'),$link_to_thematic_plan, $link_to_thematic_advance),
get_lang('ThematicSectionHasBeenCreatedSuccessfull').'<br />'.sprintf(get_lang('NowYouShouldAddThematicPlanXAndThematicAdvanceX'), $link_to_thematic_plan, $link_to_thematic_advance),
false
);
}
@ -119,35 +119,41 @@ if ($action == 'thematic_list') {
Display::return_icon('cd.gif', get_lang('Copy')),
'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token
);
if (api_get_session_id() == 0 ) {
if (api_get_session_id() == 0) {
if ($thematic['display_order'] > 1) {
$actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'),'',ICON_SIZE_SMALL).'</a>';
$actions_first_col .= ' <a href="'.api_get_self().'?action=moveup&'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('up.png', get_lang('Up'), '', ICON_SIZE_SMALL).'</a>';
} else {
$actions_first_col .= ' '.Display::return_icon('up_na.png','&nbsp;','',ICON_SIZE_SMALL);
$actions_first_col .= ' '.Display::return_icon('up_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
if (isset($thematic['max_thematic_item']) && $thematic['display_order'] < $thematic['max_thematic_item']) {
$actions_first_col .= ' <a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('down.png',get_lang('Down'),'',ICON_SIZE_SMALL).'</a>';
$actions_first_col .= ' <a href="'.api_get_self().'?action=movedown&a'.api_get_cidreq().'&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('down.png', get_lang('Down'), '', ICON_SIZE_SMALL).'</a>';
} else {
$actions_first_col .= ' '.Display::return_icon('down_na.png','&nbsp;','',ICON_SIZE_SMALL);
$actions_first_col .= ' '.Display::return_icon('down_na.png', '&nbsp;', '', ICON_SIZE_SMALL);
}
}
if (api_get_session_id() == $thematic['session_id']) {
$actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('edit.png',get_lang('Edit'),'',ICON_SIZE_SMALL).'</a>';
$actions_first_col .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='.$my_thematic_id.$params.$url_token.'">'.Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a>';
$actions_first_col .= '<a href="index.php?'.api_get_cidreq().'&action=thematic_edit&thematic_id='
.$my_thematic_id.$params.$url_token.'">'
.Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL).'</a>';
$actions_first_col .= '<a onclick="javascript:if(!confirm(\''
.get_lang('AreYouSureToDelete')
.'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_delete&thematic_id='
.$my_thematic_id.$params.$url_token.'">'
.Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a>';
}
$actions_first_col = Display::div($actions_first_col, array('id'=>'thematic_id_content_'.$thematic['id'], 'class'=>'thematic_tools'));
$actions_first_col = Display::div($actions_first_col, array('style'=>'height:20px'));
$actions_first_col = Display::div($actions_first_col, array('id' => 'thematic_id_content_'.$thematic['id'], 'class' => 'thematic_tools'));
$actions_first_col = Display::div($actions_first_col, array('style' => 'height:20px'));
}
echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id'=>'thematic_td_content_'.$thematic['id'], 'class'=>'thematic_content'));
echo Display::tag('td', Display::tag('h3', Security::remove_XSS($thematic['title'], STUDENT).$session_star).Security::remove_XSS($thematic['content'], STUDENT).$actions_first_col, array('id' => 'thematic_td_content_'.$thematic['id'], 'class' => 'thematic_content'));
// Display 2nd column - thematic plan data
echo '<td>';
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&origin=thematic_details&action=thematic_plan_list&thematic_id='.$thematic['id'].'&width=700&height=500">'.
Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style'=>'vertical-align:middle'),ICON_SIZE_MEDIUM).'</a></div><br />';
Display::return_icon('edit.png', get_lang('EditThematicPlan'), array('style' => 'vertical-align:middle'), ICON_SIZE_MEDIUM).'</a></div><br />';
}
if (empty($thematic_plan_div[$thematic['id']])) {
@ -163,7 +169,7 @@ if ($action == 'thematic_list') {
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
if (api_is_allowed_to_edit(null, true)) {
echo '<div style="text-align:right"><a href="index.php?'.api_get_cidreq().'&action=thematic_advance_add&thematic_id='.$thematic['id'].'">'.
Display::return_icon('add.png',get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a></div>';
Display::return_icon('add.png', get_lang('NewThematicAdvance'), '', ICON_SIZE_MEDIUM).'</a></div>';
}
//if (api_is_allowed_to_edit(null, true) && api_get_session_id() == $thematic['session_id']) {
@ -184,24 +190,24 @@ if ($action == 'thematic_list') {
[],
ICON_SIZE_SMALL
),
'index.php?' . api_get_cidreq() . '&' . http_build_query([
'index.php?'.api_get_cidreq().'&'.http_build_query([
'action' => 'thematic_advance_edit',
'thematic_id' => $thematic['id'],
'thematic_advance_id' => $thematic_advance['id']
])
);
$edit_link .= '<a onclick="javascript:if(!confirm(\''.get_lang('AreYouSureToDelete').'\')) return false;" href="index.php?'.api_get_cidreq().'&action=thematic_advance_delete&thematic_id='.$thematic['id'].'&thematic_advance_id='.$thematic_advance['id'].'">'.
Display::return_icon('delete.png',get_lang('Delete'),'',ICON_SIZE_SMALL).'</a></center>';
Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL).'</a></center>';
// Links
$edit_link = Display::div(
Display::div($edit_link, array('id'=>'thematic_advance_tools_'.$thematic_advance['id'], 'class'=>'thematic_advance_actions')),
array('style'=>'height:20px;')
Display::div($edit_link, array('id' => 'thematic_advance_tools_'.$thematic_advance['id'], 'class' => 'thematic_advance_actions')),
array('style' => 'height:20px;')
);
}
$thematic_advance_item = isset($thematic_advance_div[$thematic['id']][$thematic_advance['id']]) ? $thematic_advance_div[$thematic['id']][$thematic_advance['id']] : null;
echo Display::div($thematic_advance_item, array('id'=>'thematic_advance_'.$thematic_advance['id']));
echo Display::div($thematic_advance_item, array('id' => 'thematic_advance_'.$thematic_advance['id']));
echo $edit_link;
echo '</td>';
@ -244,7 +250,7 @@ if ($action == 'thematic_list') {
}
} elseif ($action == 'thematic_add' || $action == 'thematic_edit') {
// Display form
$form = new FormValidator('thematic_add','POST','index.php?action=thematic_add&'.api_get_cidreq());
$form = new FormValidator('thematic_add', 'POST', 'index.php?action=thematic_add&'.api_get_cidreq());
if ($action == 'thematic_edit') {
$form->addElement('header', '', get_lang('EditThematicSection'));
}
@ -253,10 +259,10 @@ if ($action == 'thematic_list') {
$form->addElement('hidden', 'action', $action);
if (!empty($thematic_id)) {
$form->addElement('hidden', 'thematic_id',$thematic_id);
$form->addElement('hidden', 'thematic_id', $thematic_id);
}
$form->addText('title', get_lang('Title'), true, array('size'=>'50'));
$form->addText('title', get_lang('Title'), true, array('size' => '50'));
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
$form->addButtonSave(get_lang('Save'));
@ -265,8 +271,8 @@ if ($action == 'thematic_list') {
if (!empty($thematic_data)) {
if (api_get_session_id()) {
if ($thematic_data['session_id'] != api_get_session_id()) {
$show_form = false;
Display::display_error_message(get_lang('NotAllowedClickBack'),false);
$show_form = false;
Display::display_error_message(get_lang('NotAllowedClickBack'), false);
}
}
// set default values
@ -277,14 +283,14 @@ if ($action == 'thematic_list') {
// error messages
if (isset($error)) {
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'),false);
Display::display_error_message(get_lang('FormHasErrorsPleaseComplete'), false);
}
if ($show_form) {
$form->display();
}
} elseif ($action == 'thematic_import_select') {
// Create form to upload csv file.
$form = new FormValidator('thematic_import','POST','index.php?action=thematic_import&'.api_get_cidreq().$url_token);
$form = new FormValidator('thematic_import', 'POST', 'index.php?action=thematic_import&'.api_get_cidreq().$url_token);
$form->addElement('header', get_lang('ImportThematic'));
$form->addElement('file', 'file');
$form->addElement('checkbox', 'replace', null, get_lang('DeleteAllThematic'));

Loading…
Cancel
Save