Browse Source

Merge branch 'upstream' into 313-Inflector-Helper

* upstream:
  Fixes issue #320: Module::createController() will fail with a route with trailing slash.
  Fixed test break about AssetController.
  requirements css.php twitter bootstrap update to 2.3.2
  Twitter bootstrap updated to 2.3.2
  Modified the IAssetConvert interface.
  hashing the key for registerCss and registerJs.
  Update AccessRule.php
  refactored code after feedback
  Fixed framework path.
  Added support for View::POS_READY.
  new proposed structure
  remove from master (update track)
  made some changes, fix some pitfalls, remove PHP_EOL
  #20 proposed architecture for bootstrap

Conflicts:
	yii/helpers/base/Inflector.php
tags/2.0.0-alpha
Antonio Ramirez 12 years ago
parent
commit
8101b5ed88
  1. 5
      apps/bootstrap/yii
  2. 2
      yii/assets/bootstrap/css/bootstrap-responsive.css
  3. 11
      yii/assets/bootstrap/css/bootstrap.css
  4. 32
      yii/assets/bootstrap/js/bootstrap.js
  5. 1
      yii/base/Module.php
  6. 37
      yii/base/View.php
  7. 286
      yii/bootstrap/Modal.php
  8. 123
      yii/bootstrap/Widget.php
  9. 10
      yii/console/controllers/AssetController.php
  10. 18
      yii/helpers/Inflector.php
  11. 5258
      yii/requirements/views/web/css.php
  12. 2
      yii/web/AccessRule.php
  13. 4
      yii/web/AssetBundle.php
  14. 11
      yii/web/AssetConverter.php
  15. 6
      yii/web/IAssetConverter.php

5
apps/bootstrap/yii

@ -13,9 +13,8 @@ defined('YII_DEBUG') or define('YII_DEBUG', true);
// fcgi doesn't have STDIN defined by default
defined('STDIN') or define('STDIN', fopen('php://stdin', 'r'));
$frameworkPath = __DIR__ . '/../../yii';
require($frameworkPath . '/Yii.php');
require(__DIR__ . '/vendor/yiisoft/yii2/yii.php');
require(__DIR__ . '/vendor/autoload.php');
$config = require(__DIR__ . '/config/console.php');

2
yii/assets/bootstrap/css/bootstrap-responsive.css vendored

@ -1,5 +1,5 @@
/*!
* Bootstrap Responsive v2.3.1
* Bootstrap Responsive v2.3.2
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0

11
yii/assets/bootstrap/css/bootstrap.css vendored

@ -1,5 +1,5 @@
/*!
* Bootstrap v2.3.1
* Bootstrap v2.3.2
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
@ -3009,6 +3009,15 @@ table th[class*="span"],
display: block;
}
.dropdown-backdrop {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 990;
}
.pull-right > .dropdown-menu {
right: 0;
left: auto;

32
yii/assets/bootstrap/js/bootstrap.js vendored

@ -1,5 +1,5 @@
/* ===================================================
* bootstrap-transition.js v2.3.1
* bootstrap-transition.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#transitions
* ===================================================
* Copyright 2012 Twitter, Inc.
@ -58,7 +58,7 @@
})
}(window.jQuery);/* ==========================================================
* bootstrap-alert.js v2.3.1
* bootstrap-alert.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#alerts
* ==========================================================
* Copyright 2012 Twitter, Inc.
@ -156,7 +156,7 @@
$(document).on('click.alert.data-api', dismiss, Alert.prototype.close)
}(window.jQuery);/* ============================================================
* bootstrap-button.js v2.3.1
* bootstrap-button.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#buttons
* ============================================================
* Copyright 2012 Twitter, Inc.
@ -260,7 +260,7 @@
})
}(window.jQuery);/* ==========================================================
* bootstrap-carousel.js v2.3.1
* bootstrap-carousel.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#carousel
* ==========================================================
* Copyright 2012 Twitter, Inc.
@ -466,7 +466,7 @@
})
}(window.jQuery);/* =============================================================
* bootstrap-collapse.js v2.3.1
* bootstrap-collapse.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#collapse
* =============================================================
* Copyright 2012 Twitter, Inc.
@ -632,7 +632,7 @@
})
}(window.jQuery);/* ============================================================
* bootstrap-dropdown.js v2.3.1
* bootstrap-dropdown.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================
* Copyright 2012 Twitter, Inc.
@ -685,6 +685,10 @@
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('<div class="dropdown-backdrop"/>').insertBefore($(this)).on('click', clearMenus)
}
$parent.toggleClass('open')
}
@ -737,6 +741,7 @@
}
function clearMenus() {
$('.dropdown-backdrop').remove()
$(toggle).each(function () {
getParent($(this)).removeClass('open')
})
@ -791,13 +796,12 @@
$(document)
.on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown-menu', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
}(window.jQuery);
/* =========================================================
* bootstrap-modal.js v2.3.1
* bootstrap-modal.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#modals
* =========================================================
* Copyright 2012 Twitter, Inc.
@ -1044,7 +1048,7 @@
}(window.jQuery);
/* ===========================================================
* bootstrap-tooltip.js v2.3.1
* bootstrap-tooltip.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#tooltips
* Inspired by the original jQuery.tipsy by Jason Frame
* ===========================================================
@ -1405,7 +1409,7 @@
}(window.jQuery);
/* ===========================================================
* bootstrap-popover.js v2.3.1
* bootstrap-popover.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#popovers
* ===========================================================
* Copyright 2012 Twitter, Inc.
@ -1519,7 +1523,7 @@
}(window.jQuery);
/* =============================================================
* bootstrap-scrollspy.js v2.3.1
* bootstrap-scrollspy.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
* =============================================================
* Copyright 2012 Twitter, Inc.
@ -1680,7 +1684,7 @@
})
}(window.jQuery);/* ========================================================
* bootstrap-tab.js v2.3.1
* bootstrap-tab.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#tabs
* ========================================================
* Copyright 2012 Twitter, Inc.
@ -1823,7 +1827,7 @@
})
}(window.jQuery);/* =============================================================
* bootstrap-typeahead.js v2.3.1
* bootstrap-typeahead.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#typeahead
* =============================================================
* Copyright 2012 Twitter, Inc.
@ -2158,7 +2162,7 @@
}(window.jQuery);
/* ==========================================================
* bootstrap-affix.js v2.3.1
* bootstrap-affix.js v2.3.2
* http://twitter.github.com/bootstrap/javascript.html#affix
* ==========================================================
* Copyright 2012 Twitter, Inc.

1
yii/base/Module.php

@ -592,6 +592,7 @@ abstract class Module extends Component
if ($route === '') {
$route = $this->defaultRoute;
}
$route = trim($route, '/');
if (($pos = strpos($route, '/')) !== false) {
$id = substr($route, 0, $pos);
$route = substr($route, $pos + 1);

37
yii/base/View.php

@ -58,6 +58,11 @@ class View extends Component
*/
const POS_END = 3;
/**
* The location of registered JavaScript code block.
* This means the JavaScript code block will be enclosed within `jQuery(document).ready()`.
*/
const POS_READY = 4;
/**
* This is internally used as the placeholder for receiving the content registered for the head section.
*/
const PL_HEAD = '<![CDATA[YII-BLOCK-HEAD]]>';
@ -609,7 +614,7 @@ class View extends Component
*/
public function registerCss($css, $options = array(), $key = null)
{
$key = $key ?: $css;
$key = $key ?: md5($css);
$this->css[$key] = Html::style($css, $options);
}
@ -630,24 +635,26 @@ class View extends Component
/**
* Registers a JS code block.
* @param string $js the JS code block to be registered
* @param array $options the HTML attributes for the script tag. A special option
* named "position" is supported which specifies where the JS script tag should be inserted
* in a page. The possible values of "position" are:
* @param integer $position the position at which the JS script tag should be inserted
* in a page. The possible values are:
*
* - [[POS_HEAD]]: in the head section
* - [[POS_BEGIN]]: at the beginning of the body section
* - [[POS_END]]: at the end of the body section
* - [[POS_READY]]: enclosed within jQuery(document).ready(). This is the default value.
* Note that by using this position, the method will automatically register the jquery js file.
*
* @param string $key the key that identifies the JS code block. If null, it will use
* $js as the key. If two JS code blocks are registered with the same key, the latter
* will overwrite the former.
*/
public function registerJs($js, $options = array(), $key = null)
public function registerJs($js, $position = self::POS_READY, $key = null)
{
$position = isset($options['position']) ? $options['position'] : self::POS_END;
unset($options['position']);
$key = $key ?: $js;
$this->js[$position][$key] = Html::script($js, $options);
$key = $key ?: md5($js);
$this->js[$position][$key] = $js;
if ($position === self::POS_READY) {
$this->registerAssetBundle('yii/jquery');
}
}
/**
@ -659,7 +666,7 @@ class View extends Component
*
* - [[POS_HEAD]]: in the head section
* - [[POS_BEGIN]]: at the beginning of the body section
* - [[POS_END]]: at the end of the body section
* - [[POS_END]]: at the end of the body section. This is the default value.
*
* @param string $key the key that identifies the JS script file. If null, it will use
* $url as the key. If two JS files are registered with the same key, the latter
@ -697,7 +704,7 @@ class View extends Component
$lines[] = implode("\n", $this->jsFiles[self::POS_HEAD]);
}
if (!empty($this->js[self::POS_HEAD])) {
$lines[] = implode("\n", $this->js[self::POS_HEAD]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_HEAD]), array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}
@ -714,7 +721,7 @@ class View extends Component
$lines[] = implode("\n", $this->jsFiles[self::POS_BEGIN]);
}
if (!empty($this->js[self::POS_BEGIN])) {
$lines[] = implode("\n", $this->js[self::POS_BEGIN]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_BEGIN]), array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}
@ -731,7 +738,11 @@ class View extends Component
$lines[] = implode("\n", $this->jsFiles[self::POS_END]);
}
if (!empty($this->js[self::POS_END])) {
$lines[] = implode("\n", $this->js[self::POS_END]);
$lines[] = Html::script(implode("\n", $this->js[self::POS_END]), array('type' => 'text/javascript'));
}
if (!empty($this->js[self::POS_READY])) {
$js = "jQuery(document).ready(function(){\n{" . implode("\n", $this->js[self::POS_READY]) . "}\n});";
$lines[] = Html::script($js, array('type' => 'text/javascript'));
}
return empty($lines) ? '' : implode("\n", $lines) . "\n";
}

286
yii/bootstrap/Modal.php

@ -0,0 +1,286 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\bootstrap;
use Yii;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
/**
* Modal renders a bootstrap modal on the page for its use on your application.
*
* Basic usage:
*
* ```php
* $this->widget(Modal::className(), array(
* 'id' => 'myModal',
* 'header' => 'Modal Heading',
* 'content' => '<p>One fine body...</p>',
* 'footer' => 'Modal Footer',
* // if we wish to display a modal button
* 'buttonOptions' => array(
* 'label' => 'Show Modal',
* 'class' => 'btn btn-primary'
* )
* ));
* ```
* @see http://twitter.github.io/bootstrap/javascript.html#modals
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class Modal extends Widget
{
/**
* @var array The additional HTML attributes of the button that will show the modal. If empty array, only
* the markup of the modal will be rendered on the page, so users can easily call the modal manually with their own
* scripts. The following special attributes are available:
* <ul>
* <li>label: string, the label of the button</li>
* </ul>
*
* For available options of the button trigger, see http://twitter.github.com/bootstrap/javascript.html#modals.
*/
public $buttonOptions = array();
/**
* @var boolean indicates whether the modal should use transitions. Defaults to 'true'.
*/
public $fade = true;
/**
* @var bool $keyboard, closes the modal when escape key is pressed.
*/
public $keyboard = true;
/**
* @var bool $show, shows the modal when initialized.
*/
public $show = false;
/**
* @var mixed includes a modal-backdrop element. Alternatively, specify `static` for a backdrop which doesn't close
* the modal on click.
*/
public $backdrop = true;
/**
* @var mixed the remote url. If a remote url is provided, content will be loaded via jQuery's load method and
* injected into the .modal-body of the modal.
*/
public $remote;
/**
* @var string a javascript function that will be invoked immediately when the `show` instance method is called.
*/
public $onShow;
/**
* @var string a javascript function that will be invoked when the modal has been made visible to the user
* (will wait for css transitions to complete).
*/
public $onShown;
/**
* @var string a javascript function that will be invoked immediately when the hide instance method has been called.
*/
public $onHide;
/**
* @var string a javascript function that will be invoked when the modal has finished being hidden from the user
* (will wait for css transitions to complete).
*/
public $onHidden;
/**
* @var string[] the Javascript event handlers.
*/
protected $events = array();
/**
* @var array $pluginOptions the plugin options.
*/
protected $pluginOptions = array();
/**
* @var string
*/
public $closeText = '&times;';
/**
* @var string header content. Header can also be a path to a view file.
*/
public $header;
/**
* @var string body of modal. Body can also be a path to a view file.
*/
public $content;
/**
* @var string footer content. Content can also be a path to a view file.
*/
public $footer;
/**
* Widget's init method
*/
public function init()
{
parent::init();
$this->name = 'modal';
$this->defaultOption('id', $this->getId());
$this->defaultOption('role', 'dialog');
$this->defaultOption('tabindex', '-1');
$this->addClassName('modal');
$this->addClassName('hide');
if ($this->fade)
$this->addClassName('fade');
$this->initPluginOptions();
$this->initPluginEvents();
}
/**
* Initialize plugin events if any
*/
public function initPluginEvents()
{
foreach (array('onShow', 'onShown', 'onHide', 'onHidden') as $event) {
if ($this->{$event} !== null) {
$modalEvent = strtolower(substr($event, 2));
if ($this->{$event} instanceof JsExpression)
$this->events[$modalEvent] = $this->$event;
else
$this->events[$modalEvent] = new JsExpression($this->{$event});
}
}
}
/**
* Initialize plugin options.
* ***Important***: The display of the button overrides the initialization of the modal bootstrap widget.
*/
public function initPluginOptions()
{
if (null !== $this->remote)
$this->pluginOptions['remote'] = Html::url($this->remote);
foreach (array('backdrop', 'keyboard', 'show') as $option) {
$this->pluginOptions[$option] = isset($this->pluginOptions[$option])
? $this->pluginOptions[$option]
: $this->{$option};
}
}
/**
* Widget's run method
*/
public function run()
{
$this->renderModal();
$this->renderButton();
$this->registerScript();
}
/**
* Renders the button that will open the modal if its options have been configured
*/
public function renderButton()
{
if (!empty($this->buttonOptions)) {
$this->buttonOptions['data-toggle'] = isset($this->buttonOptions['data-toggle'])
? $this->buttonOptions['data-toggle']
: 'modal';
if ($this->remote !== null && !isset($this->buttonOptions['data-remote']))
$this->buttonOptions['data-remote'] = Html::url($this->remote);
$label = ArrayHelper::remove($this->buttonOptions, 'label', 'Button');
$name = ArrayHelper::remove($this->buttonOptions, 'name');
$value = ArrayHelper::remove($this->buttonOptions, 'value');
$attr = isset($this->buttonOptions['data-remote'])
? 'data-target'
: 'href';
$this->buttonOptions[$attr] = isset($this->buttonOptions[$attr])
? $this->buttonOptions[$attr]
: '#' . ArrayHelper::getValue($this->options, 'id');
echo Html::button($label, $name, $value, $this->buttonOptions);
}
}
/**
* Renders the modal markup
*/
public function renderModal()
{
echo Html::beginTag('div', $this->options);
$this->renderModalHeader();
$this->renderModalBody();
$this->renderModalFooter();
echo Html::endTag('div');
}
/**
* Renders the header HTML markup of the modal
*/
public function renderModalHeader()
{
echo Html::beginTag('div', array('class'=>'modal-header'));
if ($this->closeText)
echo Html::button($this->closeText, null, null, array('data-dismiss' => 'modal', 'class'=>'close'));
echo $this->header;
echo Html::endTag('div');
}
/**
* Renders the HTML markup for the body of the modal
*/
public function renderModalBody()
{
echo Html::beginTag('div', array('class'=>'modal-body'));
echo $this->content;
echo Html::endTag('div');
}
/**
* Renders the HTML markup for the footer of the modal
*/
public function renderModalFooter()
{
echo Html::beginTag('div', array('class'=>'modal-footer'));
echo $this->footer;
echo Html::endTag('div');
}
/**
* Registers client scripts
*/
public function registerScript()
{
// do we render a button? If so, bootstrap will handle its behavior through its
// mark-up, otherwise, register the plugin.
if(empty($this->buttonOptions))
$this->registerPlugin('modal', $this->pluginOptions);
// register events
$this->registerEvents($this->events);
}
}

123
yii/bootstrap/Widget.php

@ -0,0 +1,123 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\bootstrap;
use Yii;
use yii\base\View;
/**
* Bootstrap is the base class for bootstrap widgets.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class Widget extends \yii\base\Widget
{
/**
* @var bool whether to register the asset
*/
public static $responsive = true;
/**
* @var array the HTML attributes for the widget container tag.
*/
public $options = array();
/**
* Initializes the widget.
*/
public function init()
{
// ensure bundle
$this->registerBundle(static::$responsive);
}
/**
* Registers plugin events with the API.
* @param string $selector the CSS selector.
* @param string[] $events the JavaScript event configuration (name=>handler).
* @return boolean whether the events were registered.
* @todo To be discussed
*/
protected function registerEvents($selector, $events = array())
{
if (empty($events))
return;
$script = '';
foreach ($events as $name => $handler) {
$handler = ($handler instanceof JsExpression)
? $handler
: new JsExpression($handler);
$script .= ";jQuery('{$selector}').on('{$name}', {$handler});";
}
if (!empty($script))
$this->view->registerJs($script);
}
/**
* Registers a specific Bootstrap plugin using the given selector and options.
*
* @param string $name the name of the javascript widget to initialize
* @param array $options the Javascript options for the plugin
*/
public function registerPlugin($name, $options = array())
{
$selector = '#' . ArrayHelper::getValue($this->options, 'id');
$options = !empty($options) ? Json::encode($options) : '';
$script = ";jQuery('{$selector}').{$name}({$options});";
$this->view->registerJs($script);
}
/**
* Registers bootstrap bundle
* @param bool $responsive
*/
public function registerBundle($responsive = false)
{
$bundle = $responsive ? 'yii/bootstrap-responsive' : 'yii/bootstrap';
$this->view->registerAssetBundle($bundle);
}
/**
* Adds a new class to options. If the class key does not exists, it will create one, if it exists it will append
* the value and also makes sure the uniqueness of them.
*
* @param string $class
* @return array
*/
protected function addClassName($class)
{
if (isset($this->options['class'])) {
if (!is_array($this->options['class']))
$this->options['class'] = explode(' ', $this->options['class']);
$this->options['class'][] = $class;
$this->options['class'] = array_unique($this->options['class']);
$this->options['class'] = implode(' ', $this->options['class']);
} else
$this->options['class'] = $class;
return $this->options;
}
/**
* Sets the default value for an item if not set.
* @param string $key the name of the item.
* @param mixed $value the default value.
* @return array
*/
protected function defaultOption($key, $value)
{
if (!isset($this->options[$key]))
$this->options[$key] = $value;
return $this->options;
}
}

10
yii/console/controllers/AssetController.php

@ -256,7 +256,7 @@ class AssetController extends Controller
foreach ($target->depends as $name) {
if (isset($bundles[$name])) {
foreach ($bundles[$name]->$type as $file) {
$inputFiles[] = $bundles[$name]->basePath . $file;
$inputFiles[] = $bundles[$name]->basePath . '/' . $file;
}
} else {
throw new Exception("Unknown bundle: $name");
@ -383,13 +383,13 @@ EOD
if (is_string($this->jsCompressor)) {
$tmpFile = $outputFile . '.tmp';
$this->combineJsFiles($inputFiles, $tmpFile);
$log = shell_exec(strtr($this->jsCompressor, array(
echo shell_exec(strtr($this->jsCompressor, array(
'{from}' => escapeshellarg($tmpFile),
'{to}' => escapeshellarg($outputFile),
)));
@unlink($tmpFile);
} else {
$log = call_user_func($this->jsCompressor, $this, $inputFiles, $outputFile);
call_user_func($this->jsCompressor, $this, $inputFiles, $outputFile);
}
if (!file_exists($outputFile)) {
throw new Exception("Unable to compress JavaScript files into '{$outputFile}'.");
@ -412,13 +412,13 @@ EOD
if (is_string($this->cssCompressor)) {
$tmpFile = $outputFile . '.tmp';
$this->combineCssFiles($inputFiles, $tmpFile);
$log = shell_exec(strtr($this->cssCompressor, array(
echo shell_exec(strtr($this->cssCompressor, array(
'{from}' => escapeshellarg($tmpFile),
'{to}' => escapeshellarg($outputFile),
)));
@unlink($tmpFile);
} else {
$log = call_user_func($this->cssCompressor, $this, $inputFiles, $outputFile);
call_user_func($this->cssCompressor, $this, $inputFiles, $outputFile);
}
if (!file_exists($outputFile)) {
throw new Exception("Unable to compress CSS files into '{$outputFile}'.");

18
yii/helpers/Inflector.php

@ -1,18 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2008 Yii Software LLC
* @link http://www.yiiframework.com/
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers;
/**
* Inflector pluralizes and singularizes English nouns. It also contains other useful methods.
*
* @author Antonio Ramirez <amigo.cobos@gmail.com>
* @since 2.0
*/
class Inflector extends base\Inflector
{
}

5258
yii/requirements/views/web/css.php

File diff suppressed because it is too large Load Diff

2
yii/web/AccessRule.php

@ -124,7 +124,7 @@ class AccessRule extends Component
*/
protected function matchController($controller)
{
return empty($this->controllers) || in_array($controller->id, $this->controllers, true);
return empty($this->controllers) || in_array($controller->uniqueId, $this->controllers, true);
}
/**

4
yii/web/AssetBundle.php

@ -135,10 +135,10 @@ class AssetBundle extends Object
$this->publish($view->getAssetManager());
foreach ($this->js as $js) {
$view->registerJsFile($js, $this->jsOptions);
$view->registerJsFile($this->baseUrl . '/' . $js, $this->jsOptions);
}
foreach ($this->css as $css) {
$view->registerCssFile($css, $this->cssOptions);
$view->registerCssFile($this->baseUrl . '/' . $css, $this->cssOptions);
}
}

11
yii/web/AssetConverter.php

@ -34,13 +34,12 @@ class AssetConverter extends Component implements IAssetConverter
* Converts a given asset file into a CSS or JS file.
* @param string $asset the asset file path, relative to $basePath
* @param string $basePath the directory the $asset is relative to.
* @param string $baseUrl the URL corresponding to $basePath
* @return string the URL to the converted asset file.
* @return string the converted asset file path, relative to $basePath.
*/
public function convert($asset, $basePath, $baseUrl)
public function convert($asset, $basePath)
{
$pos = strrpos($asset, '.');
if ($pos !== false) {
if ($pos === false) {
$ext = substr($asset, $pos + 1);
if (isset($this->commands[$ext])) {
list ($ext, $command) = $this->commands[$ext];
@ -54,9 +53,9 @@ class AssetConverter extends Component implements IAssetConverter
exec($command, $output);
Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__);
}
return "$baseUrl/$result";
return $result;
}
}
return "$baseUrl/$asset";
return $asset;
}
}

6
yii/web/IAssetConverter.php

@ -19,9 +19,7 @@ interface IAssetConverter
* Converts a given asset file into a CSS or JS file.
* @param string $asset the asset file path, relative to $basePath
* @param string $basePath the directory the $asset is relative to.
* @param string $baseUrl the URL corresponding to $basePath
* @return string the URL to the converted asset file. If the given asset does not
* need conversion, "$baseUrl/$asset" should be returned.
* @return string the converted asset file path, relative to $basePath.
*/
public function convert($asset, $basePath, $baseUrl);
public function convert($asset, $basePath);
}

Loading…
Cancel
Save