-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
132 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: Lesha | ||
* Date: 08.11.2017 | ||
* Time: 0:29 | ||
*/ | ||
|
||
namespace lesha724\documentviewer; | ||
|
||
|
||
use yii\web\AssetBundle; | ||
|
||
/** | ||
* Class ViewerJsAssets | ||
* @package lesha724\documentviewer | ||
*/ | ||
class ViewerJsAssets extends AssetBundle | ||
{ | ||
/** | ||
* @var string the directory that contains the source asset files for this asset bundle. | ||
*/ | ||
public $sourcePath = '@vendor/bower/viewerjs/ViewerJs'; | ||
/** | ||
* @var array list of JavaScript files that this bundle contains. | ||
*/ | ||
public $js = [ | ||
/*'compatibility.js', | ||
'pdf.js', | ||
'pdf.worker.js', | ||
'pdfjsversion.js', | ||
'text_layer_builder.js', | ||
'ui_utils.js', | ||
'webodf.js',*/ | ||
]; | ||
/** | ||
* @var array list of CSS files that this bundle contains. | ||
*/ | ||
public $css = [ | ||
|
||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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('@vendor/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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters