1616use kartik \base \TranslationTrait ;
1717
1818/**
19- * Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee. The FileInput widget is styled for Bootstrap 3.x
20- * & 4.x with ability to multiple file selection and preview, format button styles and inputs. Runs on all modern
19+ * Wrapper for the Bootstrap FileInput JQuery Plugin by Krajee. The FileInput widget is styled for Bootstrap 3.x
20+ * & 4.x with ability to multiple file selection and preview, format button styles and inputs. Runs on all modern
2121 * browsers supporting HTML5 File Inputs and File Processing API. For browser versions IE9 and below, this widget
2222 * will gracefully degrade to a native HTML file input.
2323 *
@@ -63,11 +63,6 @@ class FileInput extends InputWidget
6363 */
6464 public $ messageOptions = ['class ' => 'alert alert-warning ' ];
6565
66- /**
67- * @var array the internalization configuration for this widget
68- */
69- public $ i18n = [];
70-
7166 /**
7267 * @inheritdoc
7368 */
@@ -76,14 +71,25 @@ class FileInput extends InputWidget
7671 /**
7772 * @var array the list of inbuilt themes
7873 */
79- private static $ _themes = ['fa ' , 'gly ' , 'explorer ' , 'explorer-fa ' ];
74+ protected static $ _themes = ['fa ' , 'fas ' , 'gly ' , 'explorer ' , 'explorer-fa ' , 'explorer-fas ' ];
75+
76+ /**
77+ * @inheritdoc
78+ * @throws \ReflectionException
79+ * @throws \yii\base\InvalidConfigException
80+ */
81+ public function run ()
82+ {
83+ return $ this ->initWidget ();
84+ }
8085
8186 /**
82- * @var array initialize the FileInput widget
87+ * Initializes widget
88+ * @throws \ReflectionException
89+ * @throws \yii\base\InvalidConfigException
8390 */
84- public function init ()
91+ protected function initWidget ()
8592 {
86- parent ::init ();
8793 $ this ->_msgCat = 'fileinput ' ;
8894 $ this ->initI18N (__DIR__ );
8995 $ this ->initLanguage ();
@@ -109,7 +115,7 @@ public function init()
109115 $ content = Html::tag ('div ' , $ message , $ this ->messageOptions ) . "<script> {$ script };</script> " ;
110116 $ input .= "\n" . $ this ->validateIE ($ content );
111117 }
112- echo $ input ;
118+ return $ input ;
113119 }
114120
115121 /**
@@ -127,6 +133,7 @@ protected function validateIE($content, $validation = 'lt IE 10')
127133
128134 /**
129135 * Registers the asset bundle and locale
136+ * @throws \yii\base\InvalidConfigException
130137 */
131138 public function registerAssetBundle ()
132139 {
@@ -136,6 +143,9 @@ public function registerAssetBundle()
136143 if ($ this ->resizeImages || $ this ->autoOrientImages ) {
137144 PiExifAsset::register ($ view );
138145 }
146+ if (empty ($ this ->pluginOptions ['theme ' ]) && $ this ->isBs4 ()) {
147+ $ this ->pluginOptions ['theme ' ] = 'fas ' ;
148+ }
139149 $ theme = ArrayHelper::getValue ($ this ->pluginOptions , 'theme ' );
140150 if (!empty ($ theme ) && in_array ($ theme , self ::$ _themes )) {
141151 FileInputThemeAsset::register ($ view )->addTheme ($ theme );
@@ -152,6 +162,7 @@ public function registerAssetBundle()
152162
153163 /**
154164 * Registers the needed assets
165+ * @throws \yii\base\InvalidConfigException
155166 */
156167 public function registerAssets ()
157168 {
0 commit comments