Add changes
This commit is contained in:
parent
62803f0e13
commit
7ecc711e8a
|
@ -76,7 +76,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var url = OC.generateUrl('/apps/printer/printfile'),
|
var url = OC.generateUrl('/apps/printer/printfile'),
|
||||||
data = {source: fileInfo.getFullPath(), type: orientation},
|
data = {source: fileInfo.getFullPath(), orientation: orientation},
|
||||||
_self = this;
|
_self = this;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -104,10 +104,10 @@
|
||||||
msg = data.msg;
|
msg = data.msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg += '<br><br><a id="reload-checksum" class="icon icon-history" style="display:block" href=""></a>';
|
msg += '<br><br><a id="reload-print" class="icon icon-history" style="display:block" href=""></a>';
|
||||||
|
|
||||||
this.delegateEvents({
|
this.delegateEvents({
|
||||||
'click #reload-checksum': '_onReloadEvent'
|
'click #reload-print': '_onReloadEvent'
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$el.find('.get-print').html(msg);
|
this.$el.find('.get-print').html(msg);
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
this._renderSelectList(this.$el);
|
this._renderSelectList(this.$el);
|
||||||
this.delegateEvents({
|
this.delegateEvents({
|
||||||
'change #choose-algorithm': '_onChangeEvent'
|
'change #choose-orientation': '_onChangeEvent'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,16 +27,18 @@ class PrinterController extends Controller {
|
||||||
* @param (string) $orientation - Orientation of printed file
|
* @param (string) $orientation - Orientation of printed file
|
||||||
*/
|
*/
|
||||||
public function printfile($source, $orientation) {
|
public function printfile($source, $orientation) {
|
||||||
if(!$this->checkAlgorithmType($type)) {
|
if($orientation == "landscape") {
|
||||||
|
shell_exec('lpr ' . $source);
|
||||||
return new JSONResponse(
|
return new JSONResponse(
|
||||||
array(
|
array(
|
||||||
'response' => 'error',
|
'response' => 'success',
|
||||||
'msg' => $this->language->t('Print failed!')
|
'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(
|
return new JSONResponse(
|
||||||
array(
|
array(
|
||||||
'response' => 'success',
|
'response' => 'success',
|
||||||
|
@ -47,35 +49,9 @@ class PrinterController extends Controller {
|
||||||
return new JSONResponse(
|
return new JSONResponse(
|
||||||
array(
|
array(
|
||||||
'response' => 'error',
|
'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'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue