Commits

Christoffer Niska committed cf64e99

Fix issue with publishing assets in the Bootstrap component

  • Participants
  • Parent commits dd71572
  • Branches stable

Comments (0)

Files changed (2)

components/Bootstrap.php

 	/**
 	 * @var boolean indicates whether assets should be republished on every request.
 	 */
-	public $publishAssets = YII_DEBUG;
+	public $forceCopyAssets = false;
 
 	protected $_assetsUrl;
 
 	/**
 	 * Registers the Bootstrap JavaScript.
 	 * @param int $position the position of the JavaScript code.
-	 * @see CClientScript::registerScriptFile
 	 */
 	protected function registerJS($position = CClientScript::POS_HEAD)
 	{
 	}
 
 	/**
+	 * 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
 	 * @param string $defaultSelector the default CSS selector
 	 * @since 0.9.8
 	 */
-	protected function registerPlugin($name, $selector = null, $options = array(), $defaultSelector = null)
+	protected function registerPlugin($name, $selector = null, $options = array())
 	{
-		if (!isset($selector) && empty($options))
+		// Initialization from extension configuration.
+		$config = isset($this->plugins[$name]) ? $this->plugins[$name] : array();
+
+		if ($selector === null && isset($config['selector']))
+			$selector = $config['selector'];
+
+		if (isset($config['options']))
+			$options = !empty($options) ? CMap::mergeArray($options, $config['options']) : $config['options'];
+
+		if ($selector !== null)
 		{
-			// Initialization from extension configuration.
-			$config = isset($this->plugins[$name]) ? $this->plugins[$name] : array();
-
-			if (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;
-		}
-
-		if (isset($selector))
-		{
-			$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});");
 		}
 		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;
 		}
 	}
      */
     public function getVersion()
     {
-        return '2.0.0';
+        return '2.1.0';
     }
 }

theme/views/layouts/main.php

     <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>