Commit 5d6589fd by Crisu83

Fix issue with publishing assets in the Bootstrap component

parent 2d732769
......@@ -37,7 +37,7 @@ class Bootstrap extends CApplicationComponent
/**
* @var boolean indicates whether assets should be republished on every request.
*/
public $publishAssets = YII_DEBUG;
public $forceCopyAssets = false;
protected $_assetsUrl;
......@@ -96,7 +96,6 @@ class Bootstrap extends CApplicationComponent
/**
* Registers the Bootstrap JavaScript.
* @param int $position the position of the JavaScript code.
* @see CClientScript::registerScriptFile
*/
protected function registerJS($position = CClientScript::POS_HEAD)
{
......@@ -108,6 +107,16 @@ class Bootstrap extends CApplicationComponent
}
/**
* Registers all Bootstrap CSS and JavaScript.
* @since 2.1.0
*/
public function register()
{
$this->registerAllCss();
$this->registerCoreScripts();
}
/**
* Registers the Bootstrap affix plugin.
* @param string $selector the CSS selector
* @param array $options the plugin options
......@@ -264,26 +273,20 @@ class Bootstrap extends CApplicationComponent
* @param string $defaultSelector the default CSS selector
* @since 0.9.8
*/
protected function registerPlugin($name, $selector = null, $options = array(), $defaultSelector = null)
{
if (!isset($selector) && empty($options))
protected function registerPlugin($name, $selector = null, $options = array())
{
// Initialization from extension configuration.
$config = isset($this->plugins[$name]) ? $this->plugins[$name] : array();
if (isset($config['selector']))
if ($selector === null && isset($config['selector']))
$selector = $config['selector'];
if (isset($config['options']))
$options = !empty($options) ? CMap::mergeArray($config['options'], $options) : $config['options'];
if (!isset($selector))
$selector = $defaultSelector;
}
$options = !empty($options) ? CMap::mergeArray($options, $config['options']) : $config['options'];
if (isset($selector))
if ($selector !== null)
{
$key = __CLASS__.'.'.md5($name.$selector.serialize($options).$defaultSelector);
$key = __CLASS__.'.'.md5($name.$selector.serialize($options));
$options = !empty($options) ? CJavaScript::encode($options) : '';
Yii::app()->clientScript->registerScript($key, "jQuery('{$selector}').{$name}({$options});");
}
......@@ -300,7 +303,7 @@ class Bootstrap extends CApplicationComponent
else
{
$assetsPath = Yii::getPathOfAlias('bootstrap.assets');
$assetsUrl = Yii::app()->assetManager->publish($assetsPath, true, -1, $this->publishAssets);
$assetsUrl = Yii::app()->assetManager->publish($assetsPath, true, -1, $this->forceCopyAssets);
return $this->_assetsUrl = $assetsUrl;
}
}
......@@ -311,6 +314,6 @@ class Bootstrap extends CApplicationComponent
*/
public function getVersion()
{
return '2.0.0';
return '2.1.0';
}
}
......@@ -8,6 +8,8 @@
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->theme->baseUrl; ?>/css/styles.css" />
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<?php Yii::app()->bootstrap->register(); ?>
</head>
<body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment