Skip to content

Commit

Permalink
Update to release v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-v committed Jan 10, 2016
1 parent 084447f commit 36f9f49
Show file tree
Hide file tree
Showing 26 changed files with 192 additions and 71 deletions.
29 changes: 21 additions & 8 deletions CHANGE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
version 1.0.3
=============
Change Log: `yii2-widget-fileinput`
===================================

## Version 1.0.4

**Date:** 10-Jan-2016

- (enh #36): Add Indonesian Translations
- (enh #37): Add Greek Translations
- (enh #40): Add Persian Translations
- (enh #57): Enhance localizations and allow yii to generate message files via config.
- (enh #58): Enhancements for PJAX based reinitialization. Complements enhancements in kartik-v/yii2-krajee-base#52 and kartik-v/yii2-krajee-base#53.

## Version 1.0.3

**Date:** 26-Jun-2015

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

version 1.0.2
=============
## Version 1.0.2

**Date:** 03-May-2015

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

version 1.0.1
=============
## Version 1.0.1

**Date:** 30-Mar-2015

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

version 1.0.0
=============
## Version 1.0.0

**Date:** 08-Nov-2014

- Initial release
Expand Down
31 changes: 31 additions & 0 deletions CanvasBlobAsset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @package yii2-widgets
* @subpackage yii2-widget-fileinput
* @version 1.0.4
*/

namespace kartik\file;

use kartik\base\AssetBundle;

/**
* Asset bundle for FileInput Widget
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 1.0
*/
class CanvasBlobAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath('@vendor/kartik-v/bootstrap-fileinput');
$this->setupAssets('js', ['js/plugins/canvas-to-blob']);
parent::init();
}
}
61 changes: 41 additions & 20 deletions FileInput.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2015
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @package yii2-widgets
* @subpackage yii2-widget-fileinput
* @version 1.0.3
* @version 1.0.4
*/

namespace kartik\file;

use Yii;
use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\web\JsExpression;
use kartik\base\InputWidget;
use kartik\base\TranslationTrait;

/**
* FileInput widget styled for Bootstrap 3.0 with ability to multiple file
* selection and preview, format button styles and inputs. Runs on all modern
* browsers supporting HTML5 File Inputs and File Processing API. For browser
* versions IE9 and below, this widget will gracefully degrade to normal HTML
* file input.
*
* Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee
* Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee. The FileInput widget is styled for Bootstrap 3.0 with
* ability to multiple file selection and preview, format button styles and inputs. Runs on all modern browsers
* supporting HTML5 File Inputs and File Processing API. For browser versions IE9 and below, this widget will
* gracefully degrade to normal HTML file input.
*
* @see http://plugins.krajee.com/bootstrap-fileinput
* @see https://github.com/kartik-v/bootstrap-fileinput
Expand All @@ -30,10 +28,15 @@
* @since 2.0
* @see http://twitter.github.com/typeahead.js/examples
*/
class FileInput extends \kartik\base\InputWidget
class FileInput extends InputWidget
{
use \kartik\base\TranslationTrait;

use TranslationTrait;

/**
* @var bool whether to resize images on client side
*/
public $resizeImages = false;

/**
* @var bool whether to show 'plugin unsupported' message for IE browser versions 9 & below
*/
Expand All @@ -50,6 +53,11 @@ class FileInput extends \kartik\base\InputWidget
*/
public $i18n = [];

/**
* @inheritdoc
*/
public $pluginName = 'fileinput';

/**
* @var array initialize the FileInput widget
*/
Expand All @@ -66,8 +74,15 @@ public function init()
$input = $this->getInput('fileInput');
$script = 'document.getElementById("' . $this->options['id'] . '").className.replace(/\bfile-loading\b/,"");';
if ($this->showMessage) {
$validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ? 'file preview and multiple file upload' : 'multiple file upload';
$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]);
$validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ?
Yii::t('fileinput', 'file preview and multiple file upload') :
Yii::t('fileinput', 'multiple file upload');
$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]
);
$content = Html::tag('div', $message, $this->messageOptions) . "<script>{$script};</script>";
$input .= "\n" . $this->validateIE($content);
}
Expand All @@ -79,27 +94,33 @@ public function init()
*
* @param string $content
* @param string $validation
*
* @return string
*/
protected function validateIE($content, $validation = 'lt IE 10')
{
return "<!--[if {$validation}]><br>{$content}<![endif]-->";
}

/**
* Registers the asset bundle and locale
*/
public function registerAssetBundle() {
public function registerAssetBundle()
{
$view = $this->getView();
if ($this->resizeImages) {
CanvasBlobAsset::register($view);
$this->pluginOptions['resizeImage'] = true;
}
FileInputAsset::register($view)->addLanguage($this->language, 'fileinput_locale_');
}

/**
* Registers the needed assets
*/
public function registerAssets()
{
$this->registerAssetBundle();
$this->registerPlugin('fileinput');
$this->registerPlugin($this->pluginName);
}
}
}
12 changes: 8 additions & 4 deletions FileInputAsset.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<?php

/**
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2015
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @package yii2-widgets
* @subpackage yii2-widget-fileinput
* @version 1.0.3
* @version 1.0.4
*/

namespace kartik\file;

use kartik\base\AssetBundle;

/**
* Asset bundle for FileInput Widget
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 1.0
*/
class FileInputAsset extends \kartik\base\AssetBundle
class FileInputAsset extends AssetBundle
{

/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath('@vendor/kartik-v/bootstrap-fileinput');
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014 - 2015, Kartik Visweswaran
Copyright (c) 2014 - 2016, Kartik Visweswaran
Krajee.com
All rights reserved.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ to the ```require``` section of your `composer.json` file.

## Latest Release

> 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.
> 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.
## Demo

Expand Down
4 changes: 2 additions & 2 deletions messages/ar/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
51 changes: 51 additions & 0 deletions messages/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
return [
// string, required, root directory of all source files
'sourcePath' => __DIR__ . DIRECTORY_SEPARATOR . '..',
// string, required, root directory containing message translations.
'messagePath' => __DIR__,
// array, required, list of language codes that the extracted messages
// should be translated to. For example, ['zh-CN', 'de'].
'languages' => ['ar', 'da', 'de', 'el-GR', 'en', 'es', 'fa', 'fr', 'hr', 'hu', 'id', 'it', 'nl', 'pl', 'pt', 'ru', 'th', 'tr', 'zh'],
// string, the name of the function for translating messages.
// Defaults to 'Yii::t'. This is used as a mark to find the messages to be
// translated. You may use a string for single function name or an array for
// multiple function names.
'translator' => 'Yii::t',
// boolean, whether to sort messages by keys when merging new messages
// with the existing ones. Defaults to false, which means the new (untranslated)
// messages will be separated from the old (translated) ones.
'sort' => false,
// boolean, whether the message file should be overwritten with the merged messages
'overwrite' => true,
// boolean, whether to remove messages that no longer appear in the source code.
// Defaults to false, which means each of these messages will be enclosed with a pair of '' marks.
'removeUnused' => false,
// array, list of patterns that specify which files/directories should NOT be processed.
// If empty or not set, all files/directories will be processed.
// A path matches a pattern if it contains the pattern string at its end. For example,
// '/a/b' will match all files and directories ending with '/a/b';
// the '*.svn' will match all files and directories whose name ends with '.svn'.
// and the '.svn' will match all files and directories named exactly '.svn'.
// Note, the '/' characters in a pattern matches both '/' and '\'.
// See helpers/FileHelper::findFiles() description for more details on pattern matching rules.
'only' => ['*.php'],
// array, list of patterns that specify which files (not directories) should be processed.
// If empty or not set, all files will be processed.
// Please refer to "except" for details about the patterns.
// If a file/directory matches both a pattern in "only" and "except", it will NOT be processed.
'except' => [
'.svn',
'.git',
'.gitignore',
'.gitkeep',
'.hgignore',
'.hgkeep',
'/messages',
],
// Generated file format. Can be either "php", "po" or "db".
'format' => 'php',
// When format is "db", you may specify the following two options
//'db' => 'db',
//'sourceMessageTable' => '{{%source_message}}',
];
4 changes: 2 additions & 2 deletions messages/da/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
4 changes: 2 additions & 2 deletions messages/de/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
3 changes: 2 additions & 1 deletion messages/el-GR/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
4 changes: 2 additions & 2 deletions messages/en/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
4 changes: 2 additions & 2 deletions messages/es/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
4 changes: 2 additions & 2 deletions messages/fa/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
4 changes: 2 additions & 2 deletions messages/fr/fileinput.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

/**
* Message translations for \kartik\widgets\FileInput.
* Message translations.
*
* This file is automatically generated by 'yii message/extract' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
Expand Down
Loading

0 comments on commit 36f9f49

Please sign in to comment.