Minor - format code.

1.10.x
Julio Montoya 10 years ago
parent 91ae215487
commit 3f3dc24b02
  1. 22
      main/inc/lib/course.lib.php
  2. 77
      main/inc/lib/display.lib.php
  3. 12
      main/inc/lib/userportal.lib.php
  4. 12
      tests/phpunit/classes/DisplayTest.lib.php
  5. 4
      user_portal.php

@ -3545,7 +3545,7 @@ class CourseManager
/**
* Display courses (without special courses) as several HTML divs
* of course categories, as class userportal-catalog-item.
* @uses display_courses_in_category() to display the courses themselves
* @uses displayCoursesInCategory() to display the courses themselves
* @param int user id
* @param bool Whether to show the document quick-loader or not
* @return string
@ -3558,8 +3558,10 @@ class CourseManager
}
// Step 1: We get all the categories of the user
$tucc = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT id, title FROM $tucc WHERE user_id='" . $user_id . "' ORDER BY sort ASC";
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT id, title FROM $table
WHERE user_id = '" . $user_id . "'
ORDER BY sort ASC";
$result = Database::query($sql);
$html = null;
$courseCount = 0;
@ -3574,7 +3576,11 @@ class CourseManager
'class' => 'table_user_course_category'
);
$courseInCategory = self:: display_courses_in_category($row['id'], $load_dirs);
$courseInCategory = self:: displayCoursesInCategory(
$row['id'],
$load_dirs
);
$html .= self::course_item_parent(
self::course_item_html($params, true),
$courseInCategory['html']
@ -3583,7 +3589,7 @@ class CourseManager
}
// Step 2: We display the course without a user category.
$courseInCategory = self:: display_courses_in_category(0, $load_dirs);
$courseInCategory = self::displayCoursesInCategory(0, $load_dirs);
$html .= $courseInCategory['html'];
$courseCount += $courseInCategory['course_count'];
@ -3601,7 +3607,7 @@ class CourseManager
* @param bool Whether to show the document quick-loader or not
* @return string
*/
public static function display_courses_in_category($user_category_id, $load_dirs = false)
public static function displayCoursesInCategory($user_category_id, $load_dirs = false)
{
$user_id = api_get_user_id();
// Table definitions
@ -3628,8 +3634,8 @@ class CourseManager
course_rel_user.status status,
course_rel_user.sort sort,
course_rel_user.user_course_cat user_course_cat
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user,
FROM $TABLECOURS course,
$TABLECOURSUSER course_rel_user,
$TABLE_ACCESS_URL_REL_COURSE url
WHERE
course.id = course_rel_user.c_id AND

@ -1474,83 +1474,6 @@ class Display
return $retvalue;
}
/**
* Displays a digest e.g. short summary of new agenda and announcements items.
* This used to be displayed in the right hand menu, but is now
* disabled by default (see config settings in this file) because most people like
* the what's new icons better.
*
* @version 1.0
*/
public static function display_digest($toolsList, $digest, $orderKey, $courses)
{
$html = '';
if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both)) {
// // // LEVEL 1 // // //
reset($digest);
$html .= "<br /><br />\n";
while (list($key1) = each($digest)) {
if (is_array($digest[$key1])) {
// // // Title of LEVEL 1 // // //
$html .= "<strong>\n";
if ($orderKey[0] == 'keyTools') {
$tools = $key1;
$html .= $toolsList[$key1]['name'];
} elseif ($orderKey[0] == 'keyCourse') {
$courseSysCode = $key1;
$html .= "<a href=\"".api_get_path(WEB_COURSE_PATH). $courses[$key1]['coursePath']. "\">".$courses[$key1]['courseCode']. "</a>\n";
} elseif ($orderKey[0] == 'keyTime') {
$html .= api_convert_and_format_date($digest[$key1], DATE_FORMAT_LONG, date_default_timezone_get());
}
$html .= "</strong>\n";
// // // End Of Title of LEVEL 1 // // //
// // // LEVEL 2 // // //
reset($digest[$key1]);
while (list ($key2) = each($digest[$key1])) {
// // // Title of LEVEL 2 // // //
$html .= "<p>\n". "\n";
if ($orderKey[1] == 'keyTools') {
$tools = $key2;
$html .= $toolsList[$key2][name];
} elseif ($orderKey[1] == 'keyCourse') {
$courseSysCode = $key2;
$html .= "<a href=\"". api_get_path(WEB_COURSE_PATH). $courses[$key2]['coursePath']. "\">". $courses[$key2]['courseCode']. "</a>\n";
} elseif ($orderKey[1] == 'keyTime') {
$html .= api_convert_and_format_date($key2, DATE_FORMAT_LONG, date_default_timezone_get());
}
$html .= "\n";
$html .= "</p>";
// // // End Of Title of LEVEL 2 // // //
// // // LEVEL 3 // // //
reset($digest[$key1][$key2]);
while (list ($key3, $dataFromCourse) = each($digest[$key1][$key2])) {
// // // Title of LEVEL 3 // // //
if ($orderKey[2] == 'keyTools') {
$level3title = "<a href=\"".$toolsList[$key3]["path"].$courseSysCode."\">".$toolsList[$key3]['name']."</a>";
} elseif ($orderKey[2] == 'keyCourse') {
$level3title = "&#8226; <a href=\"".$toolsList[$tools]["path"].$key3."\">".$courses[$key3]['courseCode']."</a>\n";
} elseif ($orderKey[2] == 'keyTime') {
$level3title = "&#8226; <a href=\"".$toolsList[$tools]["path"].$courseSysCode."\">".api_convert_and_format_date($key3, DATE_FORMAT_LONG, date_default_timezone_get())."</a>";
}
// // // End Of Title of LEVEL 3 // // //
// // // LEVEL 4 (data) // // //
reset($digest[$key1][$key2][$key3]);
while (list ($key4, $dataFromCourse) = each($digest[$key1][$key2][$key3])) {
$html .= $level3title. ' &ndash; '. api_substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT);
//adding ... (three dots) if the texts are too large and they are shortened
if (api_strlen($dataFromCourse) >= CONFVAL_NB_CHAR_FROM_CONTENT) {
$html .= '...';
}
}
$html .= "<br />\n";
}
}
}
}
return $html;
}
} // End function display_digest
/**
* Get the session box details as an array
* @param int Session ID

@ -1085,7 +1085,7 @@ class IndexManager
* @param int $user_id
* @return string
*/
public function return_courses_and_sessions($user_id)
public function returnCoursesAndSessions($user_id)
{
global $_configuration;
@ -1123,10 +1123,16 @@ class IndexManager
// If we're not in the history view...
if (!isset($_GET['history'])) {
// Display special courses.
$specialCourses = CourseManager::display_special_courses($user_id, $this->load_directories_preview);
$specialCourses = CourseManager::display_special_courses(
$user_id,
$this->load_directories_preview
);
$special_courses = $specialCourses['html'];
// Display courses.
$courses = CourseManager::display_courses($user_id, $this->load_directories_preview);
$courses = CourseManager::display_courses(
$user_id,
$this->load_directories_preview
);
$courses_html .= $courses['html'];
$courseCount = $specialCourses['course_count'] + $courses['course_count'];
}

@ -530,18 +530,6 @@ class DisplayTest extends PHPUnit_Framework_TestCase
);
}
/**
* @covers Display::display_digest
* @todo Implement testDisplay_digest().
*/
public function testDisplay_digest()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers Display::get_session_title_box
* @todo Implement testGet_session_title_box().

@ -9,7 +9,7 @@
* - menu bar
* Search for CONFIGURATION parameters to modify settings
* @package chamilo.main
* @todo Shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for?
* @todo Shouldn't the CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for?
* If these are really configuration settings then we can add those to the dokeos config settings.
* @todo check for duplication of functions with index.php (user_portal.php is orginally a copy of index.php)
* @todo display_digest, shouldn't this be removed and be made into an extension?
@ -39,7 +39,7 @@ $load_dirs = api_get_setting('show_documents_preview');
$controller = new IndexManager(get_lang('MyCourses'));
// Main courses and session list
$courseAndSessions = $controller->return_courses_and_sessions($userId);
$courseAndSessions = $controller->returnCoursesAndSessions($userId);
// Check if a user is enrolled only in one course for going directly to the course after the login.
if (api_get_setting('go_to_course_after_login') == 'true') {

Loading…
Cancel
Save