From e1bf2da1fb5c7e9a17543fcf8c71364cefdd4477 Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Wed, 2 Aug 2017 08:25:01 +0200 Subject: [PATCH] Minor - format code --- main/document/document.php | 2 +- main/inc/lib/certificate.lib.php | 28 +++++++++++++++------------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/main/document/document.php b/main/document/document.php index 13b772223a..95c4f79cf9 100755 --- a/main/document/document.php +++ b/main/document/document.php @@ -689,7 +689,7 @@ if (isset($_GET['curdirpath']) && $_GET['curdirpath'] == '/certificates' && $certificate = new Certificate(); $text = $certificate->parse_certificate_variables($content_html['variables']); - $result = $certificate->generate_qr($text, $qr_code_filename); + $result = $certificate->generateQRImage($text, $qr_code_filename); $new_content_html = $content_html['content']; $path_image = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/images/gallery'; diff --git a/main/inc/lib/certificate.lib.php b/main/inc/lib/certificate.lib.php index 747517a82e..8dc898b552 100755 --- a/main/inc/lib/certificate.lib.php +++ b/main/inc/lib/certificate.lib.php @@ -120,7 +120,7 @@ class Certificate extends Model $delete_db = false; if (!empty($this->certificate_data)) { if (!is_null($this->html_file) || $this->html_file != '' || strlen($this->html_file)) { - //Deleting HTML file + // Deleting HTML file if (is_file($this->html_file)) { @unlink($this->html_file); if (is_file($this->html_file) === false) { @@ -129,7 +129,7 @@ class Certificate extends Model $delete_db = false; } } - //Deleting QR code PNG image file + // Deleting QR code PNG image file if (is_file($this->qr_file)) { @unlink($this->qr_file); } @@ -191,10 +191,10 @@ class Certificate extends Model if ($my_category[0]->get_id() == strval(intval($this->certificate_data['cat_id']))) { $name = $this->certificate_data['path_certificate']; - $my_path_certificate = $this->certification_user_path.basename($name); - if (file_exists($my_path_certificate) && + $myPathCertificate = $this->certification_user_path.basename($name); + if (file_exists($myPathCertificate) && !empty($name) && - !is_dir($my_path_certificate) && + !is_dir($myPathCertificate) && $this->force_certificate_generation == false ) { //Seems that the file was already generated @@ -202,14 +202,14 @@ class Certificate extends Model } else { // Creating new name $name = md5($this->user_id.$this->certificate_data['cat_id']).'.html'; - $my_path_certificate = $this->certification_user_path.$name; + $myPathCertificate = $this->certification_user_path.$name; $path_certificate = '/'.$name; // Getting QR filename $file_info = pathinfo($path_certificate); $qr_code_filename = $this->certification_user_path.$file_info['filename'].'_qr.png'; - $my_new_content_html = str_replace( + $newContent = str_replace( '((certificate_barcode))', Display::img( $this->certification_web_user_path.$file_info['filename'].'_qr.png', @@ -218,13 +218,13 @@ class Certificate extends Model $new_content_html['content'] ); - $my_new_content_html = api_convert_encoding( - $my_new_content_html, + $newContent = api_convert_encoding( + $newContent, 'UTF-8', api_get_system_encoding() ); - $result = @file_put_contents($my_path_certificate, $my_new_content_html); + $result = @file_put_contents($myPathCertificate, $newContent); if ($result) { // Updating the path self::update_user_info_about_certificate( @@ -236,8 +236,10 @@ class Certificate extends Model if ($this->html_file_is_generated()) { if (!empty($file_info)) { - $text = $this->parse_certificate_variables($new_content_html['variables']); - $this->generate_qr($text, $qr_code_filename); + $text = $this->parse_certificate_variables( + $new_content_html['variables'] + ); + $this->generateQRImage($text, $qr_code_filename); } } } @@ -301,7 +303,7 @@ class Certificate extends Model * @param string $path file path of the image * @return bool **/ - public function generate_qr($text, $path) + public function generateQRImage($text, $path) { //Make sure HTML certificate is generated if (!empty($text) && !empty($path)) {