diff --git a/main/dashboard/block.class.php b/main/dashboard/block.class.php index 17f2b7538d..9f0b6aece2 100755 --- a/main/dashboard/block.class.php +++ b/main/dashboard/block.class.php @@ -12,10 +12,52 @@ */ class Block { + protected $path; + /** * Constructor. */ public function __construct() { } + + /** + * @return string + */ + public function getDeleteLink(): string + { + global $charset; + $closeLink = ' + + '; + return $closeLink; + } + + /** + * @param string $title + * @param string $content + * + * @return string + */ + public function getBlockCard($title, $content): string + { + $html = Display::panel( + $title, + $content, + '', + 'default', + '', + '', + '', + $this->getDeleteLink() + ); + + return $html; + } } diff --git a/main/inc/lib/dashboard.lib.php b/main/inc/lib/dashboard.lib.php index 9e5eb0bcbb..1b3ea081ec 100755 --- a/main/inc/lib/dashboard.lib.php +++ b/main/inc/lib/dashboard.lib.php @@ -239,8 +239,8 @@ class DashboardManager $plugin_controller = Database::escape_string($plugin_info['controller']); } - $ins = "INSERT INTO $tbl_block(name, description, path, controller) - VALUES ('$plugin_name', '$plugin_description', '$plugin_path', '$plugin_controller')"; + $ins = "INSERT INTO $tbl_block(name, description, path, controller, active) + VALUES ('$plugin_name', '$plugin_description', '$plugin_path', '$plugin_controller', 1)"; $result = Database::query($ins); $affected_rows = Database::affected_rows($result); } diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 0ca03a21a6..241f6f827c 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -2442,6 +2442,7 @@ class Display * @param string $extra * @param string $id * @param string $customColor + * @param string $rightAction * * @return string */ @@ -2452,15 +2453,19 @@ class Display $type = 'default', $extra = '', $id = '', - $customColor = '' + $customColor = '', + $rightAction = '' ) { $headerStyle = ''; if (!empty($customColor)) { $headerStyle = 'style = "color: white; background-color: '.$customColor.'" '; } - //$title = !empty($title) ? '

'.$title.'

'.$extra.'
' : ''; - $title = !empty($title) ? '

'.$title.'

'.$extra : ''; + if (!empty($rightAction)) { + $rightAction = ''.$rightAction.''; + } + + $title = !empty($title) ? '

'.$title.' '.$rightAction.'

'.$extra : ''; $footer = !empty($footer) ? '' : ''; $typeList = ['primary', 'success', 'info', 'warning', 'danger']; $style = !in_array($type, $typeList) ? 'default' : $type; @@ -2469,7 +2474,6 @@ class Display $id = " id='$id'"; } - //
return '
'.$title.' diff --git a/main/template/default/dashboard/index.html.twig b/main/template/default/dashboard/index.html.twig index 14d4864417..a5ed67e45a 100644 --- a/main/template/default/dashboard/index.html.twig +++ b/main/template/default/dashboard/index.html.twig @@ -1,3 +1,4 @@ +{% autoescape false %} {% if blocklist == '' %}
@@ -18,4 +19,5 @@
{% else %} {{ blocklist }} -{% endif %} \ No newline at end of file +{% endif %} +{% endautoescape %} \ No newline at end of file diff --git a/plugin/dashboard/block_course/block_course.class.php b/plugin/dashboard/block_course/block_course.class.php index 46f1d3e7af..14307a67d0 100755 --- a/plugin/dashboard/block_course/block_course.class.php +++ b/plugin/dashboard/block_course/block_course.class.php @@ -18,7 +18,6 @@ class BlockCourse extends Block { private $user_id; private $courses; - private $path; private $permission = [DRH]; /** @@ -65,28 +64,12 @@ class BlockCourse extends Block */ public function get_block() { - global $charset; $column = 2; $data = []; - $content = $this->get_content_html(); - $html = ' -
-
'.get_lang('CoursesInformation').' - -
-
- '.$content.' -
-
- '; + $html = $this->getBlockCard( + get_lang('YourCourseList'), + $this->getContent() + ); $data['column'] = $column; $data['content_html'] = $html; @@ -98,10 +81,10 @@ class BlockCourse extends Block * * @return string content html */ - public function get_content_html() + public function getContent() { $course_data = $this->get_course_information_data(); - $content = '

'.get_lang('YourCourseList').'

'; + $content = ''; $data_table = null; if (!empty($course_data)) { $data_table .= ''; @@ -134,9 +117,9 @@ class BlockCourse extends Block } $content .= $data_table; if (!empty($course_data)) { - $content .= '
'.get_lang('SeeMore').'
'; + $content .= '
+ '.get_lang('SeeMore').'
'; } - //$content .= ''; return $content; } diff --git a/plugin/dashboard/block_daily/block_daily.class.php b/plugin/dashboard/block_daily/block_daily.class.php index 541d7e1d80..d38a8d469d 100755 --- a/plugin/dashboard/block_daily/block_daily.class.php +++ b/plugin/dashboard/block_daily/block_daily.class.php @@ -24,7 +24,6 @@ class BlockDaily extends Block { private $user_id; private $courses; - private $path; private $permission = [DRH]; /** @@ -72,27 +71,14 @@ class BlockDaily extends Block */ public function get_block() { - global $charset; $column = 2; $data = []; - $content = $this->get_content_html(); - $html = '
-
'.get_lang('GradebookAndAttendances').' - -
-
- '.$content.' -
-
- '; + + $html = $this->getBlockCard( + get_lang('GradebookAndAttendances'), + $this->getContent() + ); + $data['column'] = $column; $data['content_html'] = $html; @@ -104,7 +90,7 @@ class BlockDaily extends Block * * @return string content html */ - public function get_content_html() + public function getContent() { $course_data = $this->get_course_information_data(); $content = '

'.get_lang('YourCourseList').'

'; diff --git a/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php b/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php index d5fb8c17ec..793c51627b 100755 --- a/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php +++ b/plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php @@ -25,7 +25,6 @@ class BlockEvaluationGraph extends Block private $user_id; private $courses; private $sessions; - private $path; private $permission = [DRH, SESSIONADMIN]; /** @@ -73,20 +72,12 @@ class BlockEvaluationGraph extends Block */ public function get_block() { - global $charset; $column = 1; $data = []; $evaluations_base_courses_graph = $this->get_evaluations_base_courses_graph(); $evaluations_courses_in_sessions_graph = $this->get_evaluations_courses_in_sessions_graph(); - $html = '
-
- '.get_lang('EvaluationsGraph').' - -
-
'; + $html = ''; if (empty($evaluations_base_courses_graph) && empty($evaluations_courses_in_sessions_graph)) { $html .= '

'.api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8').'

'; } else { @@ -109,8 +100,11 @@ class BlockEvaluationGraph extends Block } } } - $html .= '
-
'; + + $html = $this->getBlockCard( + get_lang('EvaluationsGraph'), + $html + ); $data['column'] = $column; $data['content_html'] = $html; diff --git a/plugin/dashboard/block_global_info/block_global_info.class.php b/plugin/dashboard/block_global_info/block_global_info.class.php index da9da65777..064c7a45c7 100755 --- a/plugin/dashboard/block_global_info/block_global_info.class.php +++ b/plugin/dashboard/block_global_info/block_global_info.class.php @@ -23,7 +23,6 @@ class BlockGlobalInfo extends Block { private $user_id; private $courses; - private $path; private $permission = []; /** @@ -35,9 +34,6 @@ class BlockGlobalInfo extends Block { $this->user_id = $user_id; $this->path = 'block_global_info'; - if ($this->is_block_visible_for_user($user_id)) { - //$this->courses = CourseManager::get_courses_followed_by_drh($user_id); - } } /** @@ -68,21 +64,12 @@ class BlockGlobalInfo extends Block */ public function get_block() { - global $charset; $column = 2; $data = []; - $content = $this->get_content_html(); - $html = '
-
'.get_lang('GlobalPlatformInformation').' - -
-
- '.$content.' -
-
- '; + $html = $this->getBlockCard( + get_lang('GlobalPlatformInformation'), + $this->getContent() + ); $data['column'] = $column; $data['content_html'] = $html; @@ -94,10 +81,9 @@ class BlockGlobalInfo extends Block * * @return string content html */ - public function get_content_html() + public function getContent() { $global_data = $this->get_global_information_data(); - $content = '

'.get_lang('GlobalPlatformInformation').'

'; $data_table = null; if (!empty($global_data)) { $data_table = '
'; @@ -119,9 +105,8 @@ class BlockGlobalInfo extends Block } else { $data_table .= get_lang('ThereIsNoInformationAboutThePlatform'); } - $content .= $data_table; - return $content; + return $data_table; } /** diff --git a/plugin/dashboard/block_session/block_session.class.php b/plugin/dashboard/block_session/block_session.class.php index bab9639da2..24f88be312 100755 --- a/plugin/dashboard/block_session/block_session.class.php +++ b/plugin/dashboard/block_session/block_session.class.php @@ -19,7 +19,6 @@ class BlockSession extends Block { private $user_id; private $sessions; - private $path; private $permission = [DRH, SESSIONADMIN]; /** @@ -62,25 +61,15 @@ class BlockSession extends Block */ public function get_block() { - global $charset; $column = 2; $data = []; - $content = $this->get_content_html(); - $content_html = '
-
- '.get_lang('SessionsInformation').' - -
-
- '.$content.' -
-
- '; + $html = $this->getBlockCard( + get_lang('YourSessionsList'), + $this->getContent() + ); $data['column'] = $column; - $data['content_html'] = $content_html; + $data['content_html'] = $html; return $data; } @@ -90,11 +79,10 @@ class BlockSession extends Block * * @return string content html */ - public function get_content_html() + public function getContent() { $content = ''; $sessions = $this->sessions; - $content .= '

'.get_lang('YourSessionsList').'

'; if (count($sessions) > 0) { $sessions_table = '
'; $sessions_table .= ' diff --git a/plugin/dashboard/block_student/block_student.class.php b/plugin/dashboard/block_student/block_student.class.php index a82384fa22..f17d025eb9 100755 --- a/plugin/dashboard/block_student/block_student.class.php +++ b/plugin/dashboard/block_student/block_student.class.php @@ -19,7 +19,6 @@ class BlockStudent extends Block { private $user_id; private $students; - private $path; private $permission = [DRH]; /** @@ -62,22 +61,12 @@ class BlockStudent extends Block */ public function get_block() { - global $charset; $column = 1; $data = []; - $student_content_html = $this->get_students_content_html_for_drh(); - $html = '
-
- '.get_lang('StudentsInformationsList').' - -
-
- '.$student_content_html.' -
-
'; + $html = $this->getBlockCard( + get_lang('YourStudents'), + $this->getContent() + ); $data['column'] = $column; $data['content_html'] = $html; @@ -89,10 +78,9 @@ class BlockStudent extends Block * * @return string content html */ - public function get_students_content_html_for_platform_admin() + public function getContent() { $students = $this->students; - $content = '

'.get_lang('YourStudents').'

'; $students_table = null; if (count($students) > 0) { $students_table .= '
'; @@ -148,12 +136,11 @@ class BlockStudent extends Block $students_table .= get_lang('ThereIsNoInformationAboutYourStudents'); } - $content .= $students_table; + $content = $students_table; if (count($students) > 0) { $content .= '
'.get_lang('SeeMore').'
'; } - //$content .= ''; return $content; } diff --git a/plugin/dashboard/block_student_graph/block_student_graph.class.php b/plugin/dashboard/block_student_graph/block_student_graph.class.php index 560e9404ce..a2a1552238 100755 --- a/plugin/dashboard/block_student_graph/block_student_graph.class.php +++ b/plugin/dashboard/block_student_graph/block_student_graph.class.php @@ -25,7 +25,6 @@ class BlockStudentGraph extends Block { private $user_id; private $students; - private $path; private $permission = [DRH]; /** @@ -72,23 +71,13 @@ class BlockStudentGraph extends Block */ public function get_block() { - global $charset; $column = 1; $data = []; - $students_attendance_graph = $this->get_students_attendance_graph(); + $html = $this->getBlockCard( + get_lang('StudentsInformationsGraph'), + $this->getContent() + ); - $html = '
-
- '.get_lang('StudentsInformationsGraph').' - -
-
-
'.get_lang('AttendancesFaults').'
- '.$students_attendance_graph.' -
-
'; $data['column'] = $column; $data['content_html'] = $html; @@ -101,7 +90,7 @@ class BlockStudentGraph extends Block * * @return string img html */ - public function get_students_attendance_graph() + public function getContent() { $students = $this->students; $attendance = new Attendance(); diff --git a/plugin/dashboard/block_teacher/block_teacher.class.php b/plugin/dashboard/block_teacher/block_teacher.class.php index 0556936cd1..f74e56d3b9 100755 --- a/plugin/dashboard/block_teacher/block_teacher.class.php +++ b/plugin/dashboard/block_teacher/block_teacher.class.php @@ -21,7 +21,6 @@ class BlockTeacher extends Block { private $user_id; private $teachers; - private $path; private $permission = [DRH]; /** @@ -65,24 +64,12 @@ class BlockTeacher extends Block */ public function get_block() { - global $charset; $column = 1; $data = []; - $teacher_content_html = $this->get_teachers_content_html_for_drh(); - $html = ' -
-
- '.get_lang('TeachersInformationsList').' - -
-
- '.$teacher_content_html.' -
-
- '; - + $html = $this->getBlockCard( + get_lang('TeachersInformationsList'), + $this->getContent() + ); $data['column'] = $column; $data['content_html'] = $html; @@ -95,11 +82,9 @@ class BlockTeacher extends Block * * @return string content html */ - public function get_teachers_content_html_for_platform_admin() + public function getContent() { $teachers = $this->teachers; - $content = '

'.get_lang('YourTeachers').'

'; - $teachers_table = null; if (count($teachers) > 0) { $teachers_table .= '
'; @@ -139,7 +124,7 @@ class BlockTeacher extends Block $teachers_table .= get_lang('ThereIsNoInformationAboutYourTeachers'); } - $content .= $teachers_table; + $content = $teachers_table; if (count($teachers) > 0) { $content .= '
@@ -149,6 +134,9 @@ class BlockTeacher extends Block return $content; } + /** + * @return string + */ public function get_teachers_content_html_for_drh() { $teachers = $this->teachers; diff --git a/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php b/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php index 9dfbc629b5..efae75ef15 100755 --- a/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php +++ b/plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php @@ -1,4 +1,9 @@ get_teachers_information_graph(); - $html = ' -
-
'.get_lang('TeachersInformationsGraph').' - -
-
-
'.get_lang('TimeSpentOnThePlatformLastWeekByDay').'
- '.$teacher_information_graph.' -
-
- '; + $html = $this->getBlockCard( + get_lang('TeachersInformationsGraph'), + $this->getContent() + ); $data['column'] = $column; $data['content_html'] = $html; @@ -96,7 +88,7 @@ class BlockTeacherGraph extends Block * * @return string content html */ - public function get_teachers_information_graph() + public function getContent() { $teachers = $this->teachers; $graph = ''; diff --git a/src/CoreBundle/Resources/views/Admin/switcher_links.html.twig b/src/CoreBundle/Resources/views/Admin/switcher_links.html.twig index a27b125ae6..7f9e67f2c9 100644 --- a/src/CoreBundle/Resources/views/Admin/switcher_links.html.twig +++ b/src/CoreBundle/Resources/views/Admin/switcher_links.html.twig @@ -1,22 +1,26 @@ -
- - +