Skip to content

Commit bb90bcd

Browse files
committed
Minor - format code
1 parent 0e992bf commit bb90bcd

File tree

1 file changed

+15
-38
lines changed

1 file changed

+15
-38
lines changed

main/lp/learnpath.class.php

Lines changed: 15 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder;
77
use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer;
88
use Gedmo\Sortable\Entity\Repository\SortableRepository;
9+
use Symfony\Component\Filesystem\Filesystem;
910

1011
/**
1112
* Class learnpath
@@ -237,7 +238,6 @@ public function __construct($course, $lp_id, $user_id)
237238

238239
$sql = "UPDATE $lp_table SET id = iid WHERE iid = ".$this->lp_view_id;
239240
Database::query($sql);
240-
241241
}
242242

243243
// Initialise items.
@@ -484,7 +484,7 @@ private static function get_level_for_item($in_tab_items, $in_current_item_id)
484484
* @param int $parent
485485
* @param int $previous
486486
* @param string $type
487-
* @param int resource ID (ref)
487+
* @param int $id resource ID (ref)
488488
* @param string $title
489489
* @param string $description
490490
* @param int $prerequisites
@@ -770,9 +770,7 @@ public static function add_lp(
770770

771771
// Session id.
772772
$session_id = api_get_session_id();
773-
774773
$userId = empty($userId) ? api_get_user_id() : $userId;
775-
776774
$check_name = "SELECT * FROM $tbl_lp
777775
WHERE c_id = $course_id AND name = '$name'";
778776

@@ -1090,7 +1088,8 @@ public function delete($courseInfo = null, $id = null, $delete = 'keep')
10901088
$sql = "SELECT id FROM $lp
10911089
WHERE c_id = ".$course_id." AND path = '$path' AND id != " . $this->lp_id;
10921090
$res = Database::query($sql);
1093-
if (Database :: num_rows($res) > 0) { // Another learning path uses this directory, so don't delete it.
1091+
if (Database :: num_rows($res) > 0) {
1092+
// Another learning path uses this directory, so don't delete it.
10941093
if ($this->debug > 2) {
10951094
error_log('New LP - In learnpath::delete(), found other LP using path ' . $path . ', keeping directory', 0);
10961095
}
@@ -9640,8 +9639,6 @@ public function scorm_export()
96409639
}
96419640
}
96429641
}*/
9643-
9644-
96459642
$possible_parent = $this->get_scorm_xml_node($children, 'ITEM_'.$item->parent);
96469643
if ($possible_parent) {
96479644
if ($possible_parent->getAttribute('identifier') == 'ITEM_'.$item->parent) {
@@ -9857,7 +9854,6 @@ public function scorm_export()
98579854
// TODO: Add a readme file here, with a short description and a link to the Reload player
98589855
// then add the file to the zip, then destroy the file (this is done automatically).
98599856
// http://www.reload.ac.uk/scormplayer.html - once done, don't forget to close FS#138
9860-
98619857
foreach ($zip_files as $file_path) {
98629858
if (empty($file_path)) {
98639859
continue;
@@ -9988,7 +9984,7 @@ public function scorm_export()
99889984
// Add the extra files that go along with a SCORM package.
99899985
$main_code_path = api_get_path(SYS_CODE_PATH) . 'lp/packaging/';
99909986

9991-
$fs = new \Symfony\Component\Filesystem\Filesystem;
9987+
$fs = new Filesystem();
99929988
$fs->mirror($main_code_path, $archive_path.$temp_dir_short);
99939989

99949990
// Finalize the imsmanifest structure, add to the zip, then return the zip.
@@ -10118,12 +10114,9 @@ public function delete_lp_image()
1011810114
*/
1011910115
public function upload_image($image_array)
1012010116
{
10121-
$image_moved = false;
1012210117
if (!empty ($image_array['name'])) {
1012310118
$upload_ok = process_uploaded_file($image_array);
1012410119
$has_attachment = true;
10125-
} else {
10126-
$image_moved = true;
1012710120
}
1012810121

1012910122
if ($upload_ok) {
@@ -10135,8 +10128,7 @@ public function upload_image($image_array)
1013510128
$new_file_name = add_ext_on_mime(stripslashes($image_array['name']), $image_array['type']);
1013610129

1013710130
if (!filter_extension($new_file_name)) {
10138-
//Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
10139-
$image_moved = false;
10131+
1014010132
} else {
1014110133
$file_extension = explode('.', $image_array['name']);
1014210134
$file_extension = strtolower($file_extension[sizeof($file_extension) - 1]);
@@ -10151,7 +10143,6 @@ public function upload_image($image_array)
1015110143

1015210144
// Storing the image filename.
1015310145
if ($result) {
10154-
$image_moved = true;
1015510146
$this->set_preview_image($new_file_name);
1015610147

1015710148
//Resize to 64px to use on course homepage
@@ -10203,9 +10194,9 @@ public function select_previous_item_id()
1020310194
$table_lp_item = Database::get_course_table(TABLE_LP_ITEM);
1020410195

1020510196
// Get the max order of the items
10206-
$sql_max_order = "SELECT max(display_order) AS display_order FROM $table_lp_item
10207-
WHERE c_id = $course_id AND lp_id = '" . $this->lp_id . "'";
10208-
$rs_max_order = Database::query($sql_max_order);
10197+
$sql = "SELECT max(display_order) AS display_order FROM $table_lp_item
10198+
WHERE c_id = $course_id AND lp_id = '" . $this->lp_id . "'";
10199+
$rs_max_order = Database::query($sql);
1020910200
$row_max_order = Database::fetch_object($rs_max_order);
1021010201
$max_order = $row_max_order->display_order;
1021110202
// Get the previous item ID
@@ -10223,9 +10214,7 @@ public function select_previous_item_id()
1022310214
*/
1022410215
public function copy()
1022510216
{
10226-
$main_path = api_get_path(SYS_CODE_PATH);
10227-
10228-
//Course builder
10217+
// Course builder
1022910218
$cb = new CourseBuilder();
1023010219

1023110220
//Setting tools that will be copied
@@ -10460,7 +10449,9 @@ public static function getCategory($id)
1046010449
public static function getCategoryByCourse($courseId)
1046110450
{
1046210451
$em = Database::getManager();
10463-
$items = $em->getRepository('ChamiloCourseBundle:CLpCategory')->findBy(array('cId' => $courseId));
10452+
$items = $em->getRepository('ChamiloCourseBundle:CLpCategory')->findBy(
10453+
array('cId' => $courseId)
10454+
);
1046410455

1046510456
return $items;
1046610457
}
@@ -10475,7 +10466,6 @@ public static function deleteCategory($id)
1047510466
$em = Database::getManager();
1047610467
$item = $em->find('ChamiloCourseBundle:CLpCategory', $id);
1047710468
if ($item) {
10478-
1047910469
$courseId = $item->getCId();
1048010470
$query = $em->createQuery('SELECT u FROM ChamiloCourseBundle:CLp u WHERE u.cId = :id AND u.categoryId = :catId');
1048110471
$query->setParameter('id', $courseId);
@@ -10501,7 +10491,7 @@ public static function deleteCategory($id)
1050110491
*
1050210492
* @return mixed
1050310493
*/
10504-
static function getCategoryFromCourseIntoSelect($courseId, $addSelectOption = false)
10494+
public static function getCategoryFromCourseIntoSelect($courseId, $addSelectOption = false)
1050510495
{
1050610496
$items = self::getCategoryByCourse($courseId);
1050710497
$cats = array();
@@ -10737,7 +10727,6 @@ public function getExercisesItems()
1073710727
public function getFinalEvaluationItem()
1073810728
{
1073910729
$exercises = [];
10740-
1074110730
foreach ($this->items as $item) {
1074210731
if ($item->type != 'quiz') {
1074310732
continue;
@@ -11123,10 +11112,9 @@ public function isFirstOrLastItem($currentItemId)
1112311112
}
1112411113

1112511114
$lpItemId = [];
11126-
1112711115
$typeListNotToVerify = self::getChapterTypes();
1112811116

11129-
// Using get_toc() function instead $this->items because returns the correct order of the items
11117+
// Using get_toc() function instead $this->items because returns the correct order of the items
1113011118
foreach ($this->get_toc() as $item) {
1113111119
if (!in_array($item['type'], $typeListNotToVerify)) {
1113211120
$lpItemId[] = $item['id'];
@@ -11184,7 +11172,6 @@ public function setAccumulateScormTime($value)
1118411172
return true;
1118511173
}
1118611174

11187-
1118811175
/**
1118911176
* Returns an HTML-formatted link to a resource, to incorporate directly into
1119011177
* the new learning path tool.
@@ -11299,14 +11286,6 @@ public static function rl_get_resource_link_for_learnpath($course_id, $learningP
1129911286
$tbl_post = Database::get_course_table(TABLE_FORUM_POST);
1130011287
$result = Database::query("SELECT * FROM $tbl_post WHERE c_id = $course_id AND post_id=$id");
1130111288
$myrow = Database::fetch_array($result);
11302-
$title = $myrow['post_title'];
11303-
//$desc = $row_item['description'];
11304-
$posternom = $myrow['poster_name'];
11305-
$posttime = $myrow['post_date'];
11306-
$posttext = $myrow['post_text'];
11307-
$posttitle = $title;
11308-
$posttext = str_replace('"', "'", $posttext);
11309-
1131011289
$link .= $main_dir_path.'forum/viewthread.php?post='.$id.'' .
1131111290
'&thread='.$myrow['thread_id'].'&forum='.$myrow['forum_id'].'' .
1131211291
'&lp=true';
@@ -11468,11 +11447,9 @@ public static function rl_get_resource_name($course_code, $learningPathId, $id_i
1146811447
$pathname = explode('/', $myrow['path']); // Making a correct name for the link.
1146911448
$last = count($pathname) - 1; // Making a correct name for the link.
1147011449
$filename = $pathname[$last]; // Making a correct name for the link.
11471-
$image = choose_image($filename);
1147211450
$ext = explode('.', $filename);
1147311451
$ext = strtolower($ext[sizeof($ext) - 1]);
1147411452
$myrow['path'] = rawurlencode($myrow['path']);
11475-
$in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
1147611453
$output = $filename;
1147711454
break;
1147811455
}

0 commit comments

Comments
 (0)