forked from sensorario/lyiightbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigWidget.php
executable file
·75 lines (64 loc) · 1.69 KB
/
ConfigWidget.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
73
74
75
<?php
/**
* ConfigWidget class file.
*
* @author Simone Gentili <[email protected]>
* @version 1.1
*/
/**
* This widget encapsulates the LightBox2 script for popup images.
*
* ({@link https://github.com/sensorario/lyiightbox}).
*
* @author Simone Gentili <[email protected]>
*/
class ConfigWidget extends CWidget
{
private $scripts = null;
private $css = null;
private $assetsFolder = null;
private $assetsFolderName = 'assets';
private $baseUrl = null;
/* @todo: user patter singleton */
public function __construct()
{
parent::__construct();
}
private function populateCssArrayFiles()
{
$this->css = array(
'/css/lightbox.css'
);
}
private function populateJsarrayScripts()
{
$this->scripts = array(
'/js/lightbox.js',
);
}
private function loadAllJsScript()
{
$this->populateJsarrayScripts();
foreach ($this->scripts as $filename) {
Yii::app()->getClientScript()->registerScriptFile($this->baseUrl . $filename, CClientScript::POS_END);
}
}
private function loadAllCssScripts()
{
$this->populateCssArrayFiles();
foreach ($this->css as $filename) {
Yii::app()->getClientScript()->registerCssFile($this->baseUrl . $filename);
}
}
private function setAssetsFolder()
{
$this->assetsFolder = dirname(__FILE__) . DIRECTORY_SEPARATOR . $this->assetsFolderName;
$this->baseUrl = CHtml::asset($this->assetsFolder);
}
protected function config()
{
$this->setAssetsFolder();
$this->loadAllJsScript();
$this->loadAllCssScripts();
}
}