Applied fixes from FlintCI and Codacy

pull/2525/head
Nosolored 8 years ago
parent e5be241d98
commit 76a6b96ccd
  1. 2
      main/gradebook/lib/fe/displaygradebook.php
  2. 6
      plugin/customcertificate/resources/css/certificate.css
  3. 4
      plugin/customcertificate/resources/js/certificate.js
  4. 6
      plugin/customcertificate/src/CustomCertificatePlugin.php
  5. 12
      plugin/customcertificate/src/index.php
  6. 144
      plugin/customcertificate/src/print_certificate.php

@ -475,7 +475,7 @@ class DisplayGradebook
$my_api_cidreq.'&origin=gradebook&selectcat='.$catobj->get_id().'">'.
Display::return_icon('certificate.png', get_lang('AttachCertificate'), '', ICON_SIZE_MEDIUM).'</a>';
}
if (empty($categories)) {
$actionsRight .= '<a href="gradebook_edit_all.php?id_session='.api_get_session_id().'&'.$my_api_cidreq.'&selectcat='.$catobj->get_id().'">'.
Display::return_icon('percentage.png', get_lang('EditAllWeights'), '', ICON_SIZE_MEDIUM).'</a>';

@ -1,7 +1,7 @@
body {background-repeat:no-repeat; margin:0; padding: 0;}
td { font-family:arial, sans-serif; font-size:18px; }
.logo { height: 150px; vertical-align: middle; }
.content-table { height: 480px; padding: 10px 25px; vertical-align:middle;}
.logo {height: 150px; vertical-align: middle; }
.content-table {height: 480px; vertical-align:middle;}
.content-student { text-align:center;}
.course { padding-top: 10px; text-align:center; vertical-align: middle;}
.modality { text-align:center; }
@ -13,5 +13,5 @@ td { font-family:arial, sans-serif; font-size:18px; }
.caraA {box-decoration-break: slice; page: caraA}
@page caraB { background:#FFFFFF; }
.caraB {box-decoration-break: slice; page: caraB}
.contents-learnpath td {background: #FFFFFF; font-size: 12px; height: 160mm; padding: 10px; vertical-align: top;}
.contents-learnpath td {background: #FFFFFF; font-size: 12px; height: 160mm; vertical-align: top;}
ol {margin: 0; padding:0;}

@ -27,7 +27,7 @@ function typeDateExpedictionSwitchRadioButton(){
var inputType = document.getElementsByName("type_date_expediction");
var type;
for (var i=0;i<inputType.length;i++){
if ( inputType[i].checked == true) {
if ( inputType[i].checked === true) {
type = parseInt(inputType[i].value);
}
}
@ -49,7 +49,7 @@ function contentsTypeSwitchRadioButton(){
var inputType = document.getElementsByName("contents_type");
var type;
for (var i=0;i<inputType.length;i++){
if ( inputType[i].checked ) {
if ( inputType[i].checked === true) {
type = parseInt(inputType[i].value);
}
}

@ -24,7 +24,7 @@ class CustomCertificatePlugin extends Plugin
'type' => 'checkbox',
],
];
protected function __construct()
{
parent::__construct(
@ -198,7 +198,7 @@ class CustomCertificatePlugin extends Plugin
echo get_lang('MessageUpdate');
}
}
/**
* Get certificate data.
*
@ -233,7 +233,7 @@ class CustomCertificatePlugin extends Plugin
];
}
}
return [];
}
}

@ -1176,16 +1176,16 @@ function uploadImageCertificate(
if (empty($certId)) {
return false;
}
$delete = empty($file);
if (empty($sourceFile)) {
$sourceFile = $file;
}
$base = api_get_path(SYS_UPLOAD_PATH);
$path = $base.'certificates/'.$certId.'/';
if ($default) {
$path = $base.'certificates/default/';
}
@ -1194,17 +1194,17 @@ function uploadImageCertificate(
if (!file_exists($path)) {
mkdir($path, api_get_permissions_for_new_directories(), true);
}
// Exit if only deletion has been requested. Return an empty picture name.
if ($delete) {
return '';
}
$allowedTypes = api_get_supported_image_extensions();
$file = str_replace('\\', '/', $file);
$filename = (($pos = strrpos($file, '/')) !== false) ? substr($file, $pos + 1) : $file;
$extension = strtolower(substr(strrchr($filename, '.'), 1));
if (!in_array($extension, $allowedTypes)) {
return false;
}

@ -6,7 +6,7 @@ use Chamilo\CourseBundle\Entity\CLpCategory;
if (intval($_GET['default']) == 1) {
$cidReset = true;
}
$course_plugin = 'customcertificate';
require_once __DIR__.'/../config.php';
@ -105,14 +105,14 @@ if (empty($infoCertificate)) {
$workSpace = intval(297 - $infoCertificate['margin_left'] - $infoCertificate['margin_right']);
$widthCell = intval($workSpace / 6);
$htmlText = '';
$htmlText .= '<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css"
>';
$htmlText .= '<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'editor.css"
>';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_PLUGIN_PATH).'customcertificate/resources/css/certificate.css">';
$htmlText .= '
<link rel="stylesheet"
type="text/css"
href="'.api_get_path(WEB_CSS_PATH).'editor.css">';
$htmlText .= '<body>';
foreach ($userList as $userInfo) {
$studentId = $userInfo['user_id'];
@ -121,48 +121,47 @@ foreach ($userList as $userInfo) {
$htmlText .= '<div class="caraA" style="padding:0; page-break-before:always;" margin:0; padding:0;>';
} else {
$urlBackground = $path.$infoCertificate['background'];
$htmlText .= '<div class="caraA"
style="background-image:url('.$urlBackground.') no-repeat; background-image-resize:6;"
margin:0;
padding:0;
>';
$htmlText .= '
<div class="caraA"
style="background-image:url('.$urlBackground.') no-repeat; background-image-resize:6;"
margin:0;
padding:0;>';
}
if (!empty($infoCertificate['logo_left'])) {
$logoLeft = '<img
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['logo_left'].'"
/>';
$logoLeft = '
<img
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['logo_left'].'" />';
} else {
$logoLeft = '';
}
if (!empty($infoCertificate['logo_center'])) {
$logoCenter = '<img
style="max-height: 150px; max-width: '.intval($workSpace - (2 * $widthCell)).'mm;"
src="'.$path.$infoCertificate['logo_center'].'"
/>';
$logoCenter = '
<img
style="max-height: 150px; max-width: '.intval($workSpace - (2 * $widthCell)).'mm;"
src="'.$path.$infoCertificate['logo_center'].'" />';
} else {
$logoCenter = '';
}
if (!empty($infoCertificate['logo_right'])) {
$logoRight = '<img
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['logo_right'].'"
/>';
$logoRight = '
<img
style="max-height: 150px; max-width: '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['logo_right'].'" />';
} else {
$logoRight = '';
}
$htmlText .= '<table
width="'.$workSpace.'mm"
style="
margin-left:'.$infoCertificate['margin_left'].'mm;
margin-right:'.$infoCertificate['margin_right'].'mm;
"
border="0"
>';
width="'.$workSpace.'mm"
style="
margin-left:'.$infoCertificate['margin_left'].'mm;
margin-right:'.$infoCertificate['margin_right'].'mm;
"
border="0">';
$htmlText .= '<tr>';
$htmlText .= '<td colspan="4" class="logo">'.$logoLeft.'</td>';
$htmlText .= '<td colspan="4" class="logo" style="text-align:center;">'.$logoCenter.'</td>';
@ -268,57 +267,52 @@ foreach ($userList as $userInfo) {
$htmlText .= '</tr>';
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
$htmlText .= '<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text1'])) ? $infoCertificate['signature_text1'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : '').
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text2'])) ? $infoCertificate['signature_text2'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : '').
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text3'])) ? $infoCertificate['signature_text3'] : '').
'</td>
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : '').
<td colspan="2" class="seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature_text4'])) ? $infoCertificate['signature_text4'] : '').
'</td>
<td colspan="4" class="seals" style="width:'.(2 * $widthCell).'mm">
'.((!empty($infoCertificate['seal'])) ? $plugin->get_lang('Seal') : '').
'</td>';
$htmlText .= '</tr>';
$htmlText .= '<tr>';
$htmlText .= '<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature1']))
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature1'].'"
/>'
: '').
$htmlText .= '<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature1']))
? '<img style="max-height: 100px; max-width: '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature1'].'" />'
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature2'].'"
/>'
: '').
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature2']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature2'].'" />'
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature3'].'"
/>'
: '').
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature3']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature3'].'" />'
: '').
'</td>
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">
'.((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature4'].'"
/>'
: '').
<td colspan="2" class="logo-seals" style="width:'.$widthCell.'mm">'.
((!empty($infoCertificate['signature4']))
? '<img style="max-height: 100px; '.$widthCell.'mm;"
src="'.$path.$infoCertificate['signature4'].'" />'
: '').
'</td>
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm">
'.((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['seal'].'"
/>'
: '').
<td colspan="4" class="logo-seals" style="width:'.(2 * $widthCell).'mm">'.
((!empty($infoCertificate['seal']))
? '<img style="max-height: 100px; '.(2 * $widthCell).'mm;"
src="'.$path.$infoCertificate['seal'].'" />'
: '').
'</td>';
$htmlText .= '</tr>';
$htmlText .= '</table>';
@ -329,12 +323,10 @@ foreach ($userList as $userInfo) {
if ($infoCertificate['contents_type'] == 0) {
$contentsDescription = CourseDescription::get_data_by_description_type(3, $courseId, 0);
$domd = new DOMDocument();
libxml_use_internal_errors(true);
$domd->loadHTML($contentsDescription['description_content']);
libxml_use_internal_errors(false);
$domx = new DOMXPath($domd);
$items = $domx->query("//li[@style]");
foreach ($items as $item) {
@ -347,7 +339,6 @@ foreach ($userList as $userInfo) {
}
$output = $domd->saveHTML();
$htmlText .= getIndexFiltered($output);
}
@ -358,9 +349,8 @@ foreach ($userList as $userInfo) {
$categoryTest->setId(0);
$categoryTest->setName($plugin->get_lang('WithOutCategory'));
$categoryTest->setPosition(0);
$categories = [
$categoryTest
];
$categories = [$categoryTest];
if (!empty($categoriesTempList)) {
$categories = array_merge($categories, $categoriesTempList);
}

Loading…
Cancel
Save