Minor - flint fixes

pull/2789/head
Julio Montoya 7 years ago
parent 5759607643
commit dc0c50303b
  1. 2
      main/inc/lib/MoodleImport.php
  2. 214
      main/inc/lib/course_home.lib.php
  3. 134
      main/inc/lib/formvalidator/Element/DateTimeRangePicker.php
  4. 1
      main/inc/lib/zombie/zombie_report.class.php
  5. 2
      plugin/notebookteacher/src/NotebookTeacherPlugin.php
  6. 2
      plugin/test2pdf/src/test2pdf_plugin.class.php

@ -478,7 +478,7 @@ class MoodleImport
/**
* Search the current file resource in main Files XML.
*
* @param resource $filesXml XML file
* @param resource $filesXml XML file
* @param int $contextId
*
* @return mixed | array if is a valid xml file, false otherwise

@ -1563,113 +1563,6 @@ class CourseHome
}
}
/**
* Filter tool icons. Only show if $patronKey is = :teacher
* Example dataIcons[i]['name']: parameter titleIcons1:teacher || titleIcons2 || titleIcons3:teacher.
*
* @param array $dataIcons array Reference to icons
* @param string $courseToolCategory Current tools category
*
* @return array
*/
private static function filterPluginTools($dataIcons, $courseToolCategory)
{
$patronKey = ':teacher';
if ($courseToolCategory == TOOL_STUDENT_VIEW) {
//Fix only coach can see external pages - see #8236 - icpna
if (api_is_coach()) {
foreach ($dataIcons as $index => $array) {
if (isset($array['name'])) {
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']);
}
}
return $dataIcons;
}
$flagOrder = false;
foreach ($dataIcons as $index => $array) {
if (!isset($array['name'])) {
continue;
}
$pos = strpos($array['name'], $patronKey);
if ($pos !== false) {
unset($dataIcons[$index]);
$flagOrder = true;
}
}
if ($flagOrder) {
return array_values($dataIcons);
}
return $dataIcons;
}
// clean patronKey of name icons
foreach ($dataIcons as $index => $array) {
if (isset($array['name'])) {
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']);
}
}
return $dataIcons;
}
/**
* Find the tool icon when homepage_view is activity_big.
*
* @param array $item
* @param int $iconSize
* @param bool $generateId
*
* @return string
*/
private static function getToolIcon(array $item, $iconSize, $generateId = true)
{
$image = str_replace('.gif', '.png', $item['tool']['image']);
$toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null;
if (isset($item['tool']['custom_image'])) {
return Display::img(
$item['tool']['custom_image'],
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
if (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) {
$customIcon = $item['tool']['custom_icon'];
if ($item['tool']['visibility'] == '0') {
$customIcon = self::getDisableIcon($item['tool']['custom_icon']);
}
return Display::img(
self::getCustomWebIconPath().$customIcon,
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
$id = '';
if ($generateId) {
$id = 'toolimage_'.$toolIid;
}
return Display::return_icon(
$image,
$item['name'],
['id' => $id],
$iconSize,
false
);
}
/**
* @return array
*/
@ -1808,4 +1701,111 @@ class CourseHome
return $blocks;
}
/**
* Filter tool icons. Only show if $patronKey is = :teacher
* Example dataIcons[i]['name']: parameter titleIcons1:teacher || titleIcons2 || titleIcons3:teacher.
*
* @param array $dataIcons array Reference to icons
* @param string $courseToolCategory Current tools category
*
* @return array
*/
private static function filterPluginTools($dataIcons, $courseToolCategory)
{
$patronKey = ':teacher';
if ($courseToolCategory == TOOL_STUDENT_VIEW) {
//Fix only coach can see external pages - see #8236 - icpna
if (api_is_coach()) {
foreach ($dataIcons as $index => $array) {
if (isset($array['name'])) {
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']);
}
}
return $dataIcons;
}
$flagOrder = false;
foreach ($dataIcons as $index => $array) {
if (!isset($array['name'])) {
continue;
}
$pos = strpos($array['name'], $patronKey);
if ($pos !== false) {
unset($dataIcons[$index]);
$flagOrder = true;
}
}
if ($flagOrder) {
return array_values($dataIcons);
}
return $dataIcons;
}
// clean patronKey of name icons
foreach ($dataIcons as $index => $array) {
if (isset($array['name'])) {
$dataIcons[$index]['name'] = str_replace($patronKey, '', $array['name']);
}
}
return $dataIcons;
}
/**
* Find the tool icon when homepage_view is activity_big.
*
* @param array $item
* @param int $iconSize
* @param bool $generateId
*
* @return string
*/
private static function getToolIcon(array $item, $iconSize, $generateId = true)
{
$image = str_replace('.gif', '.png', $item['tool']['image']);
$toolIid = isset($item['tool']['iid']) ? $item['tool']['iid'] : null;
if (isset($item['tool']['custom_image'])) {
return Display::img(
$item['tool']['custom_image'],
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
if (isset($item['tool']['custom_icon']) && !empty($item['tool']['custom_icon'])) {
$customIcon = $item['tool']['custom_icon'];
if ($item['tool']['visibility'] == '0') {
$customIcon = self::getDisableIcon($item['tool']['custom_icon']);
}
return Display::img(
self::getCustomWebIconPath().$customIcon,
$item['name'],
['id' => 'toolimage_'.$toolIid]
);
}
$id = '';
if ($generateId) {
$id = 'toolimage_'.$toolIid;
}
return Display::return_icon(
$image,
$item['name'],
['id' => $id],
$iconSize,
false
);
}
}

@ -44,70 +44,6 @@ class DateTimeRangePicker extends DateRangePicker
'.$this->getElementJS();
}
/**
* Get the necessary javascript for this datepicker.
*
* @return string
*/
private function getElementJS()
{
$js = null;
$id = $this->getAttribute('id');
$js .= "<script>
$(function() {
var txtDate = $('#$id'),
inputGroup = txtDate.parents('.input-group'),
txtDateAlt = $('#{$id}_alt'),
txtDateAltText = $('#{$id}_alt_text');
txtDate
.hide()
.datepicker({
defaultDate: '".$this->getValue()."',
dateFormat: 'yy-mm-dd',
altField: '#{$id}_alt',
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
showOn: 'both',
buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."',
buttonImageOnly: true,
buttonText: '".get_lang('SelectDate')."',
changeMonth: true,
changeYear: true,
yearRange: 'c-60y:c+5y'
})
.on('change', function (e) {
txtDateAltText.text(txtDateAlt.val());
});
txtDateAltText.on('click', function () {
txtDate.datepicker('show');
});
inputGroup
.find('button')
.on('click', function (e) {
e.preventDefault();
$('#$id, #{$id}_alt').val('');
$('#{$id}_alt_text').html('');
});
$('#".$id."_time_range .time').timepicker({
'showDuration': true,
'timeFormat': 'H:i:s',
'scrollDefault': 'now',
});
var timeOnlyExampleEl = document.getElementById('".$id."_time_range');
var timeOnlyDatepair = new Datepair(timeOnlyExampleEl);
});
</script>";
return $js;
}
/**
* @param string $layout
*
@ -122,7 +58,7 @@ class DateTimeRangePicker extends DateRangePicker
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
$size = [2, $sizeTemp, 2];
} else {
if (is_array($size)) {
if (count($size) != 3) {
@ -130,11 +66,11 @@ class DateTimeRangePicker extends DateRangePicker
if (empty($size)) {
$sizeTemp = 8;
}
$size = array(2, $sizeTemp, 2);
$size = [2, $sizeTemp, 2];
}
// else just keep the $size array as received
} else {
$size = array(2, intval($size), 2);
$size = [2, intval($size), 2];
}
}
@ -206,4 +142,68 @@ class DateTimeRangePicker extends DateRangePicker
break;
}
}
/**
* Get the necessary javascript for this datepicker.
*
* @return string
*/
private function getElementJS()
{
$js = null;
$id = $this->getAttribute('id');
$js .= "<script>
$(function() {
var txtDate = $('#$id'),
inputGroup = txtDate.parents('.input-group'),
txtDateAlt = $('#{$id}_alt'),
txtDateAltText = $('#{$id}_alt_text');
txtDate
.hide()
.datepicker({
defaultDate: '".$this->getValue()."',
dateFormat: 'yy-mm-dd',
altField: '#{$id}_alt',
altFormat: \"".get_lang('DateFormatLongNoDayJS')."\",
showOn: 'both',
buttonImage: '".Display::return_icon('attendance.png', null, [], ICON_SIZE_TINY, true, true)."',
buttonImageOnly: true,
buttonText: '".get_lang('SelectDate')."',
changeMonth: true,
changeYear: true,
yearRange: 'c-60y:c+5y'
})
.on('change', function (e) {
txtDateAltText.text(txtDateAlt.val());
});
txtDateAltText.on('click', function () {
txtDate.datepicker('show');
});
inputGroup
.find('button')
.on('click', function (e) {
e.preventDefault();
$('#$id, #{$id}_alt').val('');
$('#{$id}_alt_text').html('');
});
$('#".$id."_time_range .time').timepicker({
'showDuration': true,
'timeFormat': 'H:i:s',
'scrollDefault': 'now',
});
var timeOnlyExampleEl = document.getElementById('".$id."_time_range');
var timeOnlyDatepair = new Datepair(timeOnlyExampleEl);
});
</script>";
return $js;
}
}

@ -62,7 +62,6 @@ class ZombieReport implements Countable
],
];
return $result;
}

@ -64,7 +64,7 @@ class NotebookTeacherPlugin extends Plugin
'/32/notebookteacher.png',
'/32/notebookteacher_na.png',
'/32/test2pdf_na.png',
'/22/notebookteacher.png'
'/22/notebookteacher.png',
];
foreach ($list as $file) {

@ -44,7 +44,7 @@ class Test2pdfPlugin extends Plugin
'/64/test2pdf_na.png',
'/32/test2pdf.png',
'/32/test2pdf_na.png',
'/22/test2pdf.png'
'/22/test2pdf.png',
];
$res = true;

Loading…
Cancel
Save