From 7ecc711e8a15d7d3c81180925ce60b735ebb097c Mon Sep 17 00:00:00 2001 From: Alfred Egger Date: Thu, 13 Jun 2019 18:05:32 +0200 Subject: [PATCH] Add changes --- js/printer.tabview.js | 8 +++--- lib/Controller/PrinterController.php | 40 ++++++---------------------- 2 files changed, 12 insertions(+), 36 deletions(-) diff --git a/js/printer.tabview.js b/js/printer.tabview.js index 32aeebb..0a40f66 100644 --- a/js/printer.tabview.js +++ b/js/printer.tabview.js @@ -76,7 +76,7 @@ } var url = OC.generateUrl('/apps/printer/printfile'), - data = {source: fileInfo.getFullPath(), type: orientation}, + data = {source: fileInfo.getFullPath(), orientation: orientation}, _self = this; $.ajax({ type: 'GET', @@ -104,10 +104,10 @@ msg = data.msg; } - msg += '

'; + msg += '

'; this.delegateEvents({ - 'click #reload-checksum': '_onReloadEvent' + 'click #reload-print': '_onReloadEvent' }); this.$el.find('.get-print').html(msg); @@ -133,7 +133,7 @@ ev.preventDefault(); this._renderSelectList(this.$el); this.delegateEvents({ - 'change #choose-algorithm': '_onChangeEvent' + 'change #choose-orientation': '_onChangeEvent' }); } diff --git a/lib/Controller/PrinterController.php b/lib/Controller/PrinterController.php index eff8762..7326583 100644 --- a/lib/Controller/PrinterController.php +++ b/lib/Controller/PrinterController.php @@ -27,16 +27,18 @@ class PrinterController extends Controller { * @param (string) $orientation - Orientation of printed file */ public function printfile($source, $orientation) { - if(!$this->checkAlgorithmType($type)) { + if($orientation == "landscape") { + shell_exec('lpr ' . $source); return new JSONResponse( array( - 'response' => 'error', - 'msg' => $this->language->t('Print failed!') + 'response' => 'success', + 'msg' => $this->language->t('Print succeeded!') ) ); } - if($hash = $this->getHash($source, $type)){ + if($orientation == "portrait"){ + shell_exec('lpr -o orientation-requested=4 ' . $source); return new JSONResponse( array( 'response' => 'success', @@ -47,35 +49,9 @@ class PrinterController extends Controller { return new JSONResponse( array( 'response' => 'error', - 'msg' => $this->language->t('File to print not found.') + 'msg' => $this->language->t('Print failed') ) ); }; - - } - - protected function getHash($source, $type) { - - if($info = Filesystem::getLocalFile($source)) { - return hash_file($type, $info); - } - - return false; - } - - protected function checkAlgorithmType($type) { - $list_algos = hash_algos(); - return in_array($type, $this->getAllowedAlgorithmTypes()) && in_array($type, $list_algos); - } - - protected function getAllowedAlgorithmTypes() { - return array( - 'md5', - 'sha1', - 'sha256', - 'sha384', - 'sha512', - 'crc32' - ); - } + } }