From ba794c24c59ceba5c89a55f52f7b192104fc6cba Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Jul 2018 15:05:50 +0200 Subject: [PATCH 01/12] Minor - fix breadcrumb + format code --- main/inc/lib/link.lib.php | 6 +++--- main/link/link.php | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index 7b2c326206..5aa940e689 100755 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -1722,9 +1722,9 @@ class Link extends Model } /** - * @param int $linkId - * @param $action - * @param null $token + * @param int $linkId + * @param string $action + * @param null $token * * @return FormValidator */ diff --git a/main/link/link.php b/main/link/link.php index efcf3adf56..9b6e31f387 100755 --- a/main/link/link.php +++ b/main/link/link.php @@ -82,17 +82,14 @@ if ($action === 'addcategory') { } if ($action === 'editlink') { - $nameTools = ''; + $nameTools = get_lang('EditLink'); $interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')]; - $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('EditLink')]; } // Statistics Event::event_access_tool(TOOL_LINK); /* Action Handling */ -$nameTools = get_lang('Links'); - $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; $scope = isset($_REQUEST['scope']) ? $_REQUEST['scope'] : null; $show = isset($_REQUEST['show']) && in_array(trim($_REQUEST['show']), ['all', 'none']) ? $_REQUEST['show'] : ''; @@ -224,10 +221,6 @@ switch ($action) { } Display::display_header($nameTools, 'Links'); - -/* Introduction section */ Display::display_introduction_section(TOOL_LINK); - echo $content; - Display::display_footer(); From 46c821c34c04fc743c333b4330d1dc4c01a579ac Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 19 Jul 2018 15:17:17 +0200 Subject: [PATCH 02/12] Minor - format code --- main/announcements/announcements.php | 20 ++++++--------- .../pear/HTML/QuickForm/advmultiselect.php | 25 ++++++++----------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/main/announcements/announcements.php b/main/announcements/announcements.php index a48c9954a8..8841378bf4 100755 --- a/main/announcements/announcements.php +++ b/main/announcements/announcements.php @@ -378,7 +378,7 @@ switch ($action) { } // DISPLAY ADD ANNOUNCEMENT COMMAND - $id = isset($_GET['id']) ? intval($_GET['id']) : 0; + $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; $url = api_get_self().'?action='.$action.'&id='.$id.'&'.api_get_cidreq(); $form = new FormValidator( @@ -389,15 +389,13 @@ switch ($action) { ['enctype' => 'multipart/form-data'] ); + $form_name = get_lang('ModifyAnnouncement'); if (empty($id)) { $form_name = get_lang('AddAnnouncement'); - } else { - $form_name = get_lang('ModifyAnnouncement'); } - $interbreadcrumb[] = [ - "url" => api_get_path(WEB_CODE_PATH)."announcements/announcements.php?".api_get_cidreq(), - "name" => $nameTools, + 'url' => api_get_path(WEB_CODE_PATH).'announcements/announcements.php?'.api_get_cidreq(), + 'name'=> $nameTools, ]; $nameTools = $form_name; @@ -424,7 +422,7 @@ switch ($action) { } elseif (isset($_GET['remindallinactives']) && $_GET['remindallinactives'] === 'true') { // we want to remind inactive users. The $_GET['since'] parameter // determines which users have to be warned (i.e the users who have been inactive for x days or more - $since = isset($_GET['since']) ? intval($_GET['since']) : 6; + $since = isset($_GET['since']) ? (int) $_GET['since'] : 6; // Getting the users who have to be reminded $to = Tracking::getInactiveStudentsInCourse( @@ -477,7 +475,6 @@ switch ($action) { $announcementInfo = AnnouncementManager::get_by_id($courseId, $id); if (isset($announcementInfo) && !empty($announcementInfo)) { $to = AnnouncementManager::load_edit_users('announcement', $id); - $defaults = [ 'title' => $announcementInfo['title'], 'content' => $announcementInfo['content'], @@ -498,7 +495,6 @@ switch ($action) { if (!isset($parts[1]) || empty($parts[1])) { continue; } - $form->addHtml(" diff --git a/main/template/default/layout/head.tpl b/main/template/default/layout/head.tpl index a99e580783..4e4469d768 100755 --- a/main/template/default/layout/head.tpl +++ b/main/template/default/layout/head.tpl @@ -19,42 +19,8 @@ {{ css_static_file_to_string }} {{ js_file_to_string }} {{ extra_headers }} - - -{% include 'layout/header.js.tpl'|get_template %} + {{ css_custom_file_to_string }} {{ css_style_print }} diff --git a/main/template/default/layout/header.js.tpl b/main/template/default/layout/header.js.tpl index 603227b215..943d1ef764 100644 --- a/main/template/default/layout/header.js.tpl +++ b/main/template/default/layout/header.js.tpl @@ -1,5 +1,37 @@ - diff --git a/main/template/default/layout/page.tpl b/main/template/default/layout/page.tpl index d1e5b406da..815ac0b0e2 100755 --- a/main/template/default/layout/page.tpl +++ b/main/template/default/layout/page.tpl @@ -58,8 +58,6 @@ {% if show_footer == true %} {% include 'layout/page_footer.tpl'|get_template %} {% endif %} - - {% include 'layout/footer.js.tpl'|get_template %} \ No newline at end of file diff --git a/main/template/default/layout/show_footer.tpl b/main/template/default/layout/show_footer.tpl index 7d4ae221be..6b60cca721 100755 --- a/main/template/default/layout/show_footer.tpl +++ b/main/template/default/layout/show_footer.tpl @@ -4,6 +4,5 @@ {% include 'layout/page_footer.tpl'|get_template %} {% endif %} - {% include 'layout/footer.js.tpl'|get_template %} From de60f7ed3b16574896702a9df279ee6c4bd9022f Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 20 Jul 2018 13:30:32 +0200 Subject: [PATCH 10/12] Improve delete popup #2584 --- main/inc/lib/document.lib.php | 10 ++- main/template/default/layout/header.js.tpl | 83 ++++---------------- main/template/default/layout/page_footer.tpl | 37 +++++++-- 3 files changed, 53 insertions(+), 77 deletions(-) diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 0da32c82c9..e23e1ad6ee 100644 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -6778,10 +6778,16 @@ class DocumentManager 'id' => $parentId, 'deleteid' => $documentData['id'], ]); + $btn = Display::url( $iconEn, - api_get_self()."?$courseParams&$urlDeleteParams", - ['onclick' => "return confirmation('$titleToShow');"] + '#', + [ + 'data-item-title' => $titleToShow, + 'data-href' => api_get_self()."?$courseParams&$urlDeleteParams", + 'data-toggle' => 'modal', + 'data-target' => '#confirm-delete', + ] ); if ( diff --git a/main/template/default/layout/header.js.tpl b/main/template/default/layout/header.js.tpl index 943d1ef764..23462226d9 100644 --- a/main/template/default/layout/header.js.tpl +++ b/main/template/default/layout/header.js.tpl @@ -1,8 +1,8 @@ /* Global chat variables */ var ajax_url = '{{ _p.web_rel_code }}inc/ajax/chat.ajax.php'; -var online_button = '{{ 'statusonline.png' |icon(8) }}'; -var offline_button = '{{ 'statusoffline.png' |icon(8) }}'; +var online_button = '{{ 'statusonline.png' |img(8) }}'; +var offline_button = '{{ 'statusoffline.png' |img(8) }}'; var connect_lang = '{{ "ChatConnected"|get_lang }}'; var disconnect_lang = '{{ "ChatDisconnected"|get_lang }}'; var logOutUrl = '{{ _p.web_rel_code }}inc/ajax/course.ajax.php?a=course_logout&{{ _p.web_cid_query }}'; @@ -157,7 +157,8 @@ $(document).ready(function() { header: ".accordion-heading" }); - // Global popup + // Start modals + // class='ajax' loads a page in a modal $('body').on('click', 'a.ajax', function(e) { e.preventDefault(); @@ -192,6 +193,7 @@ $(document).ready(function() { }); }); + // Expands an image modal $('a.expand-image').on('click', function(e) { e.preventDefault(); var title = $(this).attr('title'); @@ -211,11 +213,14 @@ $(document).ready(function() { image.src = this.href; }); - // Global confirmation - $('.popup-confirmation').on('click', function() { - showConfirmationPopup(this); - return false; + // Delete modal + $('#confirm-delete').on('show.bs.modal', function(e) { + $(this).find('.btn-ok').attr('href', $(e.relatedTarget).data('href')); + $('.debug-url').html( + '{{ 'AreYouSureToDeleteJS' | get_lang }}: ' + $(e.relatedTarget).data('item-title') + '' + ); }); + // End modals // old jquery.menu.js $('#navigation a').stop().animate({ @@ -263,6 +268,7 @@ $(document).ready(function() { }); }); }; + $(".black-shadow").mouseenter(function() { $(this).addClass('hovered-course'); }).mouseleave(function() { @@ -480,7 +486,8 @@ function get_url_params(q, attribute) { } } -function check_brand() { +function check_brand() +{ if ($('.subnav').length) { if ($(window).width() >= 969) { $('.subnav .brand').hide(); @@ -490,66 +497,6 @@ function check_brand() { } } -function showConfirmationPopup(obj, urlParam) { - if (urlParam) { - url = urlParam - } else { - url = obj.href; - } - - var dialog = $("#dialog"); - if ($("#dialog").length == 0) { - dialog = $('').appendTo('body'); - } - - var width_value = 350; - var height_value = 150; - var resizable_value = true; - - var new_param = get_url_params(url, 'width'); - if (new_param) { - width_value = new_param; - } - - var new_param = get_url_params(url, 'height') - if (new_param) { - height_value = new_param; - } - - var new_param = get_url_params(url, 'resizable'); - if (new_param) { - resizable_value = new_param; - } - - // Show dialog - dialog.dialog({ - modal : true, - width : width_value, - height : height_value, - resizable : resizable_value, - buttons: [ - { - text: '{{ 'Yes' | get_lang }}', - click: function() { - window.location = url; - }, - icons:{ - primary:'ui-icon-locked' - } - }, - { - text: '{{ 'No' | get_lang }}', - click: function() { $(this).dialog("close"); }, - icons:{ - primary:'ui-icon-locked' - } - } - ] - }); - // prevent the browser to follow the link - return false; -} - function setCheckbox(value, table_id) { checkboxes = $("#"+table_id+" input:checkbox"); $.each(checkboxes, function(index, checkbox) { diff --git a/main/template/default/layout/page_footer.tpl b/main/template/default/layout/page_footer.tpl index a0d6fb97ed..79c73b9a28 100755 --- a/main/template/default/layout/page_footer.tpl +++ b/main/template/default/layout/page_footer.tpl @@ -62,6 +62,23 @@ +{# Global modal, load content by AJAX call to href attribute on anchor tag with 'ajax' class #} + + +{# Expands an image modal #} -{# Global modal, load content by AJAX call to href attribute on anchor tag with 'ajax' class #} -