42 class Booster extends CApplicationComponent {
222 return Yii::app() instanceof CConsoleApplication || PHP_SAPI ==
'cli';
228 return defined(
'IS_IN_TESTS') && IS_IN_TESTS;
236 if (Yii::getPathOfAlias(
'booster') ===
false) {
237 Yii::setPathOfAlias(
'booster', realpath(dirname(__FILE__) .
'/..'));
260 $bootstrapPackages = require(Yii::getPathOfAlias(
'booster.components') .
'/packages.php');
264 $this->packages = CMap::mergeArray(
275 foreach ($this->packages as $name => $definition) {
276 $this->cs->addPackage($name, $definition);
278 $this->cs->scriptMap[
'jquery-ui.min.js'] = $this->
getAssetsUrl() .
'/js/jquery-ui-no-conflict.min.js';
289 if (!$this->ajaxCssLoad && Yii::app()->request->isAjaxRequest)
292 if ($this->bootstrapCss)
295 if ($this->fontAwesomeCss)
298 if ($this->responsiveCss)
301 if ($this->yiiCss !==
false)
304 if ($this->jqueryCss !==
false)
324 ) .
'/css/jquery-ui-bootstrap.css';
332 if (!$this->enableJS)
335 if (!$this->ajaxJsLoad && Yii::app()->request->isAjaxRequest)
341 if ($this->enableBootboxJS)
344 if ($this->enableNotifierJS)
347 if($this->enablePopover)
350 if($this->enableTooltip)
375 return $this->cs->registerPackage($name);
388 $this->cs->registerCssFile($this->
getAssetsUrl() .
"/css/{$name}", $media);
401 $this->cs->registerScriptFile($this->
getAssetsUrl() .
"/js/{$name}", $position);
410 if (isset($this->_assetsUrl)) {
413 return $this->_assetsUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias(
'booster.assets'),
false, -1, $this->forceCopyAssets);
420 $this->cs = Yii::app()->getClientScript();
426 $this->cs->registerPackage(
'bootstrap.css');
437 return array(
'bootstrap.css' => array(
438 'baseUrl' => $this->enableCdn ?
'//netdna.bootstrapcdn.com/bootstrap/3.1.1/' : $this->
getAssetsUrl() .
'/bootstrap/',
439 'css' => array( ($this->minify || $this->enableCdn) ?
'css/bootstrap.min.css' :
'css/bootstrap.css' ),
449 $jsFiles = array($this->minify ?
'select2.min.js' :
'select2.js');
451 if (strpos(Yii::app()->language,
'en') !== 0) {
452 $locale =
'select2_locale_'. substr(Yii::app()->language, 0, 2).
'.js';
453 if (@file_exists(Yii::getPathOfAlias(
'booster.assets.select2') . DIRECTORY_SEPARATOR . $locale )) {
454 $jsFiles[] = $locale;
456 $locale =
'select2_locale_'. Yii::app()->language .
'.js';
457 if (@file_exists(Yii::getPathOfAlias(
'booster.assets.select2') . DIRECTORY_SEPARATOR . $locale )) {
458 $jsFiles[] = $locale;
460 $locale =
'select2_locale_'. substr(Yii::app()->language, 0, 2) .
'-' . strtoupper(substr(Yii::app()->language, 3, 2)) .
'.js';
461 if (@file_exists(Yii::getPathOfAlias(
'booster.assets.select2') . DIRECTORY_SEPARATOR . $locale )) {
462 $jsFiles[] = $locale;
468 return array(
'select2' => array(
471 'css' => array(
'select2.css',
'select2-bootstrap.css'),
472 'depends' => array(
'jquery'),
480 if($this->disableZooming)
481 $this->cs->registerMetaTag(
'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no',
'viewport');
483 $this->cs->registerMetaTag(
'width=device-width, initial-scale=1',
'viewport');
496 $this->cs->registerScript($this->
getUniqueScriptId(),
"jQuery('[data-toggle=popover]').popover();");
500 $this->cs->registerScript($this->
getUniqueScriptId(),
"jQuery('[data-toggle=tooltip]').tooltip();");
509 return uniqid(__CLASS__ .
'#',
true);
519 return $this->tryGetInfoForPlugin($name,
'selector');
528 return $this->tryGetInfoForPlugin($name,
'options');
537 if ($value instanceof
Booster) {
538 self::$_instance = $value;
548 if (null === self::$_instance) {
550 $module = Yii::app()->getController()->getModule();
552 if ($module->hasComponent(
'booster')) {
553 self::$_instance = $module->getComponent(
'booster');
557 if (null === self::$_instance) {
558 if (Yii::app()->hasComponent(
'booster')) {
559 self::$_instance = Yii::app()->getComponent(
'booster');