forked from echo511/Plupload
/
Libs.php
51 lines (40 loc) · 1.33 KB
/
Libs.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
namespace Echo511\Plupload\Components\Libs;
/**
* This file is a part of Plupload component for Nette Framework.
*
* @author Nikolas Tsiongas
* @package Plupload component
* @license New BSD License
*/
class Libs extends \Nette\Application\UI\Control
{
// Where js etc. will be stored for browser to load (WWW_DIR)
private $tempLibsDir;
// Array of already loaded Js (uses paths relative to tempLibsDir)
public $loadedJs = array();
// Array of already loaded Css (uses paths relative to tempLibsDir)
public $loadedCss = array();
/*********** Setters ***********/
public function setTempLibsDir($tempLibsDir)
{
$this->tempLibsDir = $tempLibsDir;
return $this;
}
/*********** Magic loading ***********/
public function registerJs($shortPath)
{
if(!in_array($shortPath, $this->loadedJs)) {
$this->loadedJs[] = $shortPath;
$string = '<script type="text/javascript" src="'.$this->tempLibsDir.$shortPath.'"></script>';
return $string;
}
}
public function registerCss($shortPath)
{
if(!in_array($shortPath, $this->loadedJs)) {
$this->loadedJs[] = $shortPath;
return '<link rel="stylesheet" type="text/css" href="'.$this->tempLibsDir.$shortPath.'" />';
}
}
}