forked from ho96/yii2-extplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Extplorer.php
51 lines (42 loc) · 966 Bytes
/
Extplorer.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
<?php
/**
* Yii2 Extplorer
* @license New BSD License
*
*/
namespace sansusan\extplorer;
use Yii;
use yii\web\View;
use yii\base\Widget;
class Extplorer extends Widget
{
private $_assetsUrl;
public function run()
{
if($this->_assetsUrl === null)
{
$assets = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
$this -> _assetsUrl = Yii::$app->getAssetManager()->publish($assets, array('beforeCopy' =>
function($from, $to)
{
if(strpos($from, '.directory') < 1)
return $from;
}
));
}
$this->getView()->registerJs("
resizeIframe();
$(window).resize(function(){
resizeIframe();
});
function resizeIframe()
{
$('iframe').attr('width',$('#iframe-div').width());
$('iframe').attr('height','700');
}
", View::POS_END, 'iframe');
echo '<div id="iframe-div">';
echo '<iframe src="' . $this->_assetsUrl[1] . '/extplorer"></iframe>';
echo '</div>';
}
}