forked from lesha724/yii2-document-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewerJsDocumentViewer.php
72 lines (63 loc) · 1.41 KB
/
ViewerJsDocumentViewer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
/**
* Created by PhpStorm.
* User: Lesha
* Date: 07.11.2017
* Time: 23:00
*/
namespace lesha724\documentviewer;
use yii\helpers\Html;
/**
* Class ViewerJsDocumentViewer
* @package lesha724\documentviewer
* @property string $urlViewer
*/
class ViewerJsDocumentViewer extends ADocumentViewer
{
/**
* @var string|null
*/
protected $_urlViewer = null;
/**
* getter for urlViewer
* @return string|null
*/
/*public function getUrlViewer(){
return $this->_urlViewer;
}*/
/**
* setter for urlViewer
* @param $value
*/
/*public function setUrlViewer($value){
$this->_urlViewer = $value;
}*/
/**
* Get iframe url for doc
* @return mixed
*/
protected function _getIframeUrl()
{
return $this->_urlViewer.'#'.$this->url;
}
public function init()
{
ViewerJsAssets::register($this->view);
$this->_urlViewer = \Yii::$app->assetManager->getPublishedUrl('@bower/viewerjs/ViewerJS');
parent::init();
}
/**
* герерация iframe
* @return string
*/
protected function _run(){
$options = [
'src'=>$this->_getIframeUrl(),
'width'=>$this->width,
'height'=>$this->height,
'allowfullscreen',
'webkitallowfullscreen'
];
return Html::tag('iframe','',$options);
}
}