Skip to content

Commit

Permalink
Minor - format code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Aug 10, 2017
1 parent 4c5ebe3 commit a43e0c9
Show file tree
Hide file tree
Showing 15 changed files with 225 additions and 120 deletions.
46 changes: 33 additions & 13 deletions main/course_progress/thematic.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

$toolbar = null;
if (api_is_allowed_to_edit(null, true)) {

switch ($action) {
case 'thematic_add':
case 'thematic_import_select':
Expand All @@ -47,13 +46,17 @@
break;
default:
$actionLeft = '<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>';
}

$toolbar = Display::toolbarAction('thematic-bar', array($actionLeft));
}


if ($action == 'thematic_list') {
$table = new SortableTable(
'thematic_list',
Expand All @@ -77,8 +80,16 @@
$table->display();

} elseif ($action == 'thematic_details') {
if (isset($_GET['thematic_plan_save_message']) && $_GET['thematic_plan_save_message'] == 'ok') {
Display::addFlash(Display::return_message(get_lang('ThematicSectionHasBeenCreatedSuccessfull'), 'confirmation', false));
if (isset($_GET['thematic_plan_save_message']) &&
$_GET['thematic_plan_save_message'] == 'ok'
) {
Display::addFlash(
Display::return_message(
get_lang('ThematicSectionHasBeenCreatedSuccessfull'),
'confirmation',
false
)
);
}

if (isset($last_id) && $last_id) {
Expand All @@ -99,20 +110,19 @@
$message = Display::return_message($text, 'info', false);
}
$list = [];
// Display thematic data

// Display thematic data
if (!empty($thematic_data)) {
// display progress
foreach ($thematic_data as $thematic) {

$list['id'] = $thematic['id'];
$list['id_course'] = $thematic['c_id'];
$list['id_session'] = $thematic['session_id'];
$list['title'] = Security::remove_XSS($thematic['title'], STUDENT);
$list['content'] = Security::remove_XSS($thematic['content'], STUDENT);
$list['display_orden'] = $thematic['display_order'];
$list['active'] = $thematic['active'];

$my_thematic_id = $thematic['id'];

$session_star = '';
Expand All @@ -129,9 +139,14 @@
if (api_is_allowed_to_edit(null, true)) {
// Thematic title
$toolbarThematic = Display::url(
Display::return_icon('cd.png', get_lang('Copy'), null, ICON_SIZE_TINY),
Display::return_icon(
'cd.png',
get_lang('Copy'),
null,
ICON_SIZE_TINY
),
'index.php?'.api_get_cidreq().'&action=thematic_copy&thematic_id='.$my_thematic_id.$params.$url_token,
array('class'=> 'btn btn-default')
array('class'=> 'btn btn-default')
);
if (api_get_session_id() == 0) {
if ($thematic['display_order'] > 1) {
Expand Down Expand Up @@ -211,7 +226,13 @@
} else {
$form->addText('title', get_lang('Title'), true, array('size' => '50'));
}
$form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Height' => '150'));
$form->addHtmlEditor(
'content',
get_lang('Content'),
false,
false,
array('ToolbarSet' => 'TrainingDescription', 'Height' => '150')
);
$form->addButtonSave(get_lang('Save'));

$show_form = true;
Expand All @@ -235,7 +256,6 @@
}
if ($show_form) {
$html = $form->returnForm();

}
} elseif ($action == 'thematic_import_select') {
// Create form to upload csv file.
Expand Down
38 changes: 25 additions & 13 deletions main/course_progress/thematic_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct()

/**
* This method is used for thematic control (update, insert or listing)
* @param string $action
* @param string $action
* render to thematic.php
*/
public function thematic($action)
Expand Down Expand Up @@ -202,7 +202,6 @@ public function thematic($action)
case 'export_documents':
//no break
case 'thematic_export_pdf':

$pdfOrientation = api_get_configuration_value('thematic_pdf_orientation');

$list = $thematic->get_thematic_list();
Expand Down Expand Up @@ -272,9 +271,12 @@ public function thematic($action)
case 'export_single_thematic':
$theme = $thematic->get_thematic_list($thematic_id);
$plans = $thematic->get_thematic_plan_data($theme['id']);
$plans = array_filter($plans, function($plan) {
return !empty($plan['description']);
});
$plans = array_filter(
$plans,
function ($plan) {
return !empty($plan['description']);
}
);
$advances = $thematic->get_thematic_advance_by_thematic_id($theme['id']);

$view = new Template('', false, false, false, true, false, false);
Expand All @@ -301,7 +303,11 @@ public function thematic($action)
'add_signatures' => $signatures
]
);
$pdf->exportFromHtmlToDocumentsArea($view->fetch($template), $fileName, $courseId);
$pdf->exportFromHtmlToDocumentsArea(
$view->fetch($template),
$fileName,
$courseId
);

header('Location: '.api_get_self().'?'.api_get_cidreq());
exit;
Expand Down Expand Up @@ -380,15 +386,17 @@ public function thematic($action)

/**
* This method is used for thematic plan control (update, insert or listing)
* @param string $action
* @param string $action
* render to thematic_plan.php
*/
public function thematic_plan($action)
{
$thematic = new Thematic();
$data = array();
if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") {
if (isset($_POST['action']) && ($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')) {
if (isset($_POST['action']) &&
($_POST['action'] == 'thematic_plan_add' || $_POST['action'] == 'thematic_plan_edit')
) {
if (isset($_POST['title'])) {
if ($_POST['thematic_plan_token'] == $_SESSION['thematic_plan_token']) {
if (api_is_allowed_to_edit(null, true)) {
Expand Down Expand Up @@ -437,7 +445,10 @@ public function thematic_plan($action)
$error = true;
$action = $_POST['action'];
$data['error'] = $error;
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($_POST['thematic_id'], $_POST['description_type']);
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data(
$_POST['thematic_id'],
$_POST['description_type']
);
$data['thematic_id'] = $_POST['thematic_id'];
$data['description_type'] = $_POST['description_type'];
$data['action'] = $action;
Expand All @@ -463,11 +474,13 @@ public function thematic_plan($action)
}

$description_type = isset($_GET['description_type']) ? intval($_GET['description_type']) : null;

if (!empty($thematic_id) && !empty($description_type)) {
if ($action === 'thematic_plan_delete') {
if (api_is_allowed_to_edit(null, true)) {
$thematic->thematic_plan_destroy($thematic_id, $description_type);
$thematic->thematic_plan_destroy(
$thematic_id,
$description_type
);
}
$data['thematic_plan_data'] = $thematic->get_thematic_plan_data($thematic_id);
$action = 'thematic_plan_list';
Expand All @@ -489,8 +502,7 @@ public function thematic_plan($action)
$data['default_thematic_plan_question'] = $thematic->get_default_question();
$data['thematic_data'] = $thematic->get_thematic_list($thematic_id);

//render to the view

// render to the view
$this->view->set_data($data);
$this->view->set_layout('layout');
$this->view->set_template('thematic_plan');
Expand Down
10 changes: 7 additions & 3 deletions main/course_progress/thematic_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
}
}

//$i = 1;

echo Display::tag('h2', $thematic_data['title']);
echo $thematic_data['content'];

Expand Down Expand Up @@ -161,7 +159,13 @@

// error messages
if ($error) {
Display::addFlash(Display::return_message(get_lang('FormHasErrorsPleaseComplete'), 'error', false));
Display::addFlash(
Display::return_message(
get_lang('FormHasErrorsPleaseComplete'),
'error',
false
)
);
}
$form->display();
}
15 changes: 9 additions & 6 deletions main/create_course/add_course.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
/* For licensing terms, see /license.txt */

use Chamilo\CoreBundle\Entity\Repository\CourseCategoryRepository;
use Chamilo\CoreBundle\Entity\CourseCategory;

/**
* This script allows professors and administrative staff to create course sites.
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
Expand All @@ -12,9 +15,6 @@
* @author Ivan Tcholakov <ivantcholakov@gmail.com>
*/

use Chamilo\CoreBundle\Entity\Repository\CourseCategoryRepository;
use Chamilo\CoreBundle\Entity\CourseCategory;

// Flag forcing the "current course" reset.
$cidReset = true;

Expand All @@ -39,7 +39,9 @@
// true - the new course is requested only and it is created after approval;
// false - the new course is created immediately, after filling this form.
$course_validation_feature = false;
if (api_get_setting('course_validation') === 'true' && !api_is_platform_admin()) {
if (api_get_setting('course_validation') === 'true' &&
!api_is_platform_admin()
) {
$course_validation_feature = true;
}

Expand Down Expand Up @@ -191,7 +193,6 @@ function setFocus(){
);

if ($course_validation_feature) {

// A special URL to terms and conditions that is set
// in the platform settings page.
$terms_and_conditions_url = trim(
Expand Down Expand Up @@ -291,7 +292,9 @@ function MM_openBrWindow(theURL, winName, features) { //v2.0
}

if ($wanted_code == '') {
$wanted_code = CourseManager::generate_course_code(api_substr($title, 0, CourseManager::MAX_COURSE_LENGTH_CODE));
$wanted_code = CourseManager::generate_course_code(
api_substr($title, 0, CourseManager::MAX_COURSE_LENGTH_CODE)
);
}

// Check whether the requested course code has already been occupied.
Expand Down

0 comments on commit a43e0c9

Please sign in to comment.