Skip to content

Commit 36f9f49

Browse files
committed
Update to release v1.0.4
1 parent 084447f commit 36f9f49

26 files changed

+192
-71
lines changed

CHANGE.md

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
version 1.0.3
2-
=============
1+
Change Log: `yii2-widget-fileinput`
2+
===================================
3+
4+
## Version 1.0.4
5+
6+
**Date:** 10-Jan-2016
7+
8+
- (enh #36): Add Indonesian Translations
9+
- (enh #37): Add Greek Translations
10+
- (enh #40): Add Persian Translations
11+
- (enh #57): Enhance localizations and allow yii to generate message files via config.
12+
- (enh #58): Enhancements for PJAX based reinitialization. Complements enhancements in kartik-v/yii2-krajee-base#52 and kartik-v/yii2-krajee-base#53.
13+
14+
## Version 1.0.3
15+
316
**Date:** 26-Jun-2015
417

518
- (bug #33): Initialize `language` correctly.
619

7-
version 1.0.2
8-
=============
20+
## Version 1.0.2
21+
922
**Date:** 03-May-2015
1023

1124
- (enh #23): Add Chinese translations.
1225
- (enh kartik-v/yii2-krajee-base#34, kartik-v/yii2-krajee-base#35): Enhance i18n translation locales.
1326
- (enh #29): Better validation for graceful downgrade for older browsers.
1427

15-
version 1.0.1
16-
=============
28+
## Version 1.0.1
29+
1730
**Date:** 30-Mar-2015
1831

1932
- (enh #4): Hungarian translations
@@ -23,8 +36,8 @@ version 1.0.1
2336
- The `language` property can be set at the widget level to set the language (this will default to `Yii::$app->language`).
2437
- (enh #22): Added Thai language translations.
2538

26-
version 1.0.0
27-
=============
39+
## Version 1.0.0
40+
2841
**Date:** 08-Nov-2014
2942

3043
- Initial release

CanvasBlobAsset.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
/**
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
5+
* @package yii2-widgets
6+
* @subpackage yii2-widget-fileinput
7+
* @version 1.0.4
8+
*/
9+
10+
namespace kartik\file;
11+
12+
use kartik\base\AssetBundle;
13+
14+
/**
15+
* Asset bundle for FileInput Widget
16+
*
17+
* @author Kartik Visweswaran <[email protected]>
18+
* @since 1.0
19+
*/
20+
class CanvasBlobAsset extends AssetBundle
21+
{
22+
/**
23+
* @inheritdoc
24+
*/
25+
public function init()
26+
{
27+
$this->setSourcePath('@vendor/kartik-v/bootstrap-fileinput');
28+
$this->setupAssets('js', ['js/plugins/canvas-to-blob']);
29+
parent::init();
30+
}
31+
}

FileInput.php

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2015
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
55
* @package yii2-widgets
66
* @subpackage yii2-widget-fileinput
7-
* @version 1.0.3
7+
* @version 1.0.4
88
*/
99

1010
namespace kartik\file;
1111

1212
use Yii;
1313
use yii\helpers\Html;
1414
use yii\helpers\ArrayHelper;
15-
use yii\web\JsExpression;
15+
use kartik\base\InputWidget;
16+
use kartik\base\TranslationTrait;
1617

1718
/**
18-
* FileInput widget styled for Bootstrap 3.0 with ability to multiple file
19-
* selection and preview, format button styles and inputs. Runs on all modern
20-
* browsers supporting HTML5 File Inputs and File Processing API. For browser
21-
* versions IE9 and below, this widget will gracefully degrade to normal HTML
22-
* file input.
23-
*
24-
* Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee
19+
* Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee. The FileInput widget is styled for Bootstrap 3.0 with
20+
* ability to multiple file selection and preview, format button styles and inputs. Runs on all modern browsers
21+
* supporting HTML5 File Inputs and File Processing API. For browser versions IE9 and below, this widget will
22+
* gracefully degrade to normal HTML file input.
2523
*
2624
* @see http://plugins.krajee.com/bootstrap-fileinput
2725
* @see https://github.com/kartik-v/bootstrap-fileinput
@@ -30,10 +28,15 @@
3028
* @since 2.0
3129
* @see http://twitter.github.com/typeahead.js/examples
3230
*/
33-
class FileInput extends \kartik\base\InputWidget
31+
class FileInput extends InputWidget
3432
{
35-
use \kartik\base\TranslationTrait;
36-
33+
use TranslationTrait;
34+
35+
/**
36+
* @var bool whether to resize images on client side
37+
*/
38+
public $resizeImages = false;
39+
3740
/**
3841
* @var bool whether to show 'plugin unsupported' message for IE browser versions 9 & below
3942
*/
@@ -50,6 +53,11 @@ class FileInput extends \kartik\base\InputWidget
5053
*/
5154
public $i18n = [];
5255

56+
/**
57+
* @inheritdoc
58+
*/
59+
public $pluginName = 'fileinput';
60+
5361
/**
5462
* @var array initialize the FileInput widget
5563
*/
@@ -66,8 +74,15 @@ public function init()
6674
$input = $this->getInput('fileInput');
6775
$script = 'document.getElementById("' . $this->options['id'] . '").className.replace(/\bfile-loading\b/,"");';
6876
if ($this->showMessage) {
69-
$validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ? 'file preview and multiple file upload' : 'multiple file upload';
70-
$message = '<strong>' . Yii::t('fileinput', 'Note:') . '</strong> ' . Yii::t('fileinput', 'Your browser does not support {validation}. Try an alternative or more recent browser to access these features.', ['validation' => $validation]);
77+
$validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ?
78+
Yii::t('fileinput', 'file preview and multiple file upload') :
79+
Yii::t('fileinput', 'multiple file upload');
80+
$message = '<strong>' . Yii::t('fileinput', 'Note:') . '</strong> ' .
81+
Yii::t(
82+
'fileinput',
83+
'Your browser does not support {validation}. Try an alternative or more recent browser to access these features.',
84+
['validation' => $validation]
85+
);
7186
$content = Html::tag('div', $message, $this->messageOptions) . "<script>{$script};</script>";
7287
$input .= "\n" . $this->validateIE($content);
7388
}
@@ -79,27 +94,33 @@ public function init()
7994
*
8095
* @param string $content
8196
* @param string $validation
97+
*
8298
* @return string
8399
*/
84100
protected function validateIE($content, $validation = 'lt IE 10')
85101
{
86102
return "<!--[if {$validation}]><br>{$content}<![endif]-->";
87103
}
88-
104+
89105
/**
90106
* Registers the asset bundle and locale
91107
*/
92-
public function registerAssetBundle() {
108+
public function registerAssetBundle()
109+
{
93110
$view = $this->getView();
111+
if ($this->resizeImages) {
112+
CanvasBlobAsset::register($view);
113+
$this->pluginOptions['resizeImage'] = true;
114+
}
94115
FileInputAsset::register($view)->addLanguage($this->language, 'fileinput_locale_');
95116
}
96-
117+
97118
/**
98119
* Registers the needed assets
99120
*/
100121
public function registerAssets()
101122
{
102123
$this->registerAssetBundle();
103-
$this->registerPlugin('fileinput');
124+
$this->registerPlugin($this->pluginName);
104125
}
105-
}
126+
}

FileInputAsset.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
<?php
22

33
/**
4-
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2015
4+
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
55
* @package yii2-widgets
66
* @subpackage yii2-widget-fileinput
7-
* @version 1.0.3
7+
* @version 1.0.4
88
*/
99

1010
namespace kartik\file;
1111

12+
use kartik\base\AssetBundle;
13+
1214
/**
1315
* Asset bundle for FileInput Widget
1416
*
1517
* @author Kartik Visweswaran <[email protected]>
1618
* @since 1.0
1719
*/
18-
class FileInputAsset extends \kartik\base\AssetBundle
20+
class FileInputAsset extends AssetBundle
1921
{
20-
22+
/**
23+
* @inheritdoc
24+
*/
2125
public function init()
2226
{
2327
$this->setSourcePath('@vendor/kartik-v/bootstrap-fileinput');

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2014 - 2015, Kartik Visweswaran
1+
Copyright (c) 2014 - 2016, Kartik Visweswaran
22
Krajee.com
33
All rights reserved.
44

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ to the ```require``` section of your `composer.json` file.
4040

4141
## Latest Release
4242

43-
> NOTE: The latest version of the module is v1.0.3. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-fileinput/blob/master/CHANGE.md) for details.
43+
> NOTE: The latest version of the module is v1.0.4. Refer the [CHANGE LOG](https://github.com/kartik-v/yii2-widget-fileinput/blob/master/CHANGE.md) for details.
4444
4545
## Demo
4646

messages/ar/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/config.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
return [
3+
// string, required, root directory of all source files
4+
'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..',
5+
// string, required, root directory containing message translations.
6+
'messagePath' => __DIR__,
7+
// array, required, list of language codes that the extracted messages
8+
// should be translated to. For example, ['zh-CN', 'de'].
9+
'languages' => ['ar', 'da', 'de', 'el-GR', 'en', 'es', 'fa', 'fr', 'hr', 'hu', 'id', 'it', 'nl', 'pl', 'pt', 'ru', 'th', 'tr', 'zh'],
10+
// string, the name of the function for translating messages.
11+
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
12+
// translated. You may use a string for single function name or an array for
13+
// multiple function names.
14+
'translator' => 'Yii::t',
15+
// boolean, whether to sort messages by keys when merging new messages
16+
// with the existing ones. Defaults to false, which means the new (untranslated)
17+
// messages will be separated from the old (translated) ones.
18+
'sort' => false,
19+
// boolean, whether the message file should be overwritten with the merged messages
20+
'overwrite' => true,
21+
// boolean, whether to remove messages that no longer appear in the source code.
22+
// Defaults to false, which means each of these messages will be enclosed with a pair of '' marks.
23+
'removeUnused' => false,
24+
// array, list of patterns that specify which files/directories should NOT be processed.
25+
// If empty or not set, all files/directories will be processed.
26+
// A path matches a pattern if it contains the pattern string at its end. For example,
27+
// '/a/b' will match all files and directories ending with '/a/b';
28+
// the '*.svn' will match all files and directories whose name ends with '.svn'.
29+
// and the '.svn' will match all files and directories named exactly '.svn'.
30+
// Note, the '/' characters in a pattern matches both '/' and '\'.
31+
// See helpers/FileHelper::findFiles() description for more details on pattern matching rules.
32+
'only' => ['*.php'],
33+
// array, list of patterns that specify which files (not directories) should be processed.
34+
// If empty or not set, all files will be processed.
35+
// Please refer to "except" for details about the patterns.
36+
// If a file/directory matches both a pattern in "only" and "except", it will NOT be processed.
37+
'except' => [
38+
'.svn',
39+
'.git',
40+
'.gitignore',
41+
'.gitkeep',
42+
'.hgignore',
43+
'.hgkeep',
44+
'/messages',
45+
],
46+
// Generated file format. Can be either "php", "po" or "db".
47+
'format' => 'php',
48+
// When format is "db", you may specify the following two options
49+
//'db' => 'db',
50+
//'sourceMessageTable' => '{{%source_message}}',
51+
];

messages/da/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/de/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/el-GR/fileinput.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<?php
22
/**
3-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
44
*
5+
* This file is automatically generated by 'yii message/extract' command.
56
* It contains the localizable messages extracted from source code.
67
* You may modify this file by translating the extracted messages.
78
*

messages/en/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/es/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/fa/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

messages/fr/fileinput.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
2-
32
/**
4-
* Message translations for \kartik\widgets\FileInput.
3+
* Message translations.
54
*
5+
* This file is automatically generated by 'yii message/extract' command.
66
* It contains the localizable messages extracted from source code.
77
* You may modify this file by translating the extracted messages.
88
*

0 commit comments

Comments
 (0)