diff --git a/framework/yii/gii/ActiveField.php b/framework/yii/gii/ActiveField.php
new file mode 100644
index 0000000..9a03987
--- /dev/null
+++ b/framework/yii/gii/ActiveField.php
@@ -0,0 +1,21 @@
+
+ * @since 2.0
+ */
+class ActiveField extends \yii\widgets\ActiveField
+{
+ public function sticky()
+ {
+ $this->options['class'] .= ' sticky';
+ return $this;
+ }
+}
diff --git a/framework/yii/gii/Generator.php b/framework/yii/gii/Generator.php
index 13b7c54..40588d9 100644
--- a/framework/yii/gii/Generator.php
+++ b/framework/yii/gii/Generator.php
@@ -35,7 +35,7 @@ abstract class Generator extends Model
{
parent::init();
if (!isset($this->templates['default'])) {
- $this->templates['default'] = $this->getDefaultTemplate();
+ $this->templates['default'] = $this->defaultTemplate();
}
}
@@ -60,13 +60,13 @@ abstract class Generator extends Model
return array();
}
- public function getViewFile()
+ public function formView()
{
$class = new ReflectionClass($this);
return dirname($class->getFileName()) . '/views/form.php';
}
- public function getDefaultTemplate()
+ public function defaultTemplate()
{
$class = new ReflectionClass($this);
return dirname($class->getFileName()) . '/templates';
diff --git a/framework/yii/gii/assets/gii.js b/framework/yii/gii/assets/gii.js
index 1ff3f4a..58c50cb 100644
--- a/framework/yii/gii/assets/gii.js
+++ b/framework/yii/gii/assets/gii.js
@@ -10,6 +10,15 @@ yii.gii = (function ($) {
content: $hint.html()
});
});
+
+ var $checkAll = $('#check-all');
+ $checkAll.click(function() {
+ $('.code-files .check input').prop('checked', this.checked);
+ });
+ $('.code-files .check input').click(function() {
+ $checkAll.prop('checked', !$('.code-files .check input:not(:checked)').length);
+ });
+ $checkAll.prop('checked', !$('.code-files .check input:not(:checked)').length);
}
};
})(jQuery);
diff --git a/framework/yii/gii/controllers/DefaultController.php b/framework/yii/gii/controllers/DefaultController.php
index f206c61..619df2c 100644
--- a/framework/yii/gii/controllers/DefaultController.php
+++ b/framework/yii/gii/controllers/DefaultController.php
@@ -43,6 +43,7 @@ class DefaultController extends Controller
$params['result'] = $generator->save($files, $_POST['answers']);
} else {
$params['files'] = $files;
+ $params['answers'] = isset($_POST['answers']) ? $_POST['answers'] : null;
}
}
}
diff --git a/framework/yii/gii/generators/controller/Generator.php b/framework/yii/gii/generators/controller/Generator.php
index 04fee04..56b8f6d 100644
--- a/framework/yii/gii/generators/controller/Generator.php
+++ b/framework/yii/gii/generators/controller/Generator.php
@@ -20,6 +20,7 @@ class Generator extends \yii\gii\Generator
{
public $controller;
public $baseClass = 'yii\web\Controller';
+ public $ns = 'app\controllers';
public $actions = 'index';
public function getName()
@@ -36,12 +37,13 @@ class Generator extends \yii\gii\Generator
public function rules()
{
return array_merge(parent::rules(), array(
- array('controller, actions, baseClass', 'filter', 'filter' => 'trim'),
+ array('controller, actions, baseClass, ns', 'filter', 'filter' => 'trim'),
array('controller, baseClass', 'required'),
array('controller', 'match', 'pattern' => '/^[\w+\\/]*$/', 'message' => 'Only word characters and slashes are allowed.'),
array('actions', 'match', 'pattern' => '/^\w+[\w\s,]*$/', 'message' => 'Only word characters, spaces and commas are allowed.'),
array('baseClass', 'match', 'pattern' => '/^[a-zA-Z_][\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'),
- array('baseClass', 'validateReservedWord', 'skipOnError' => true),
+ array('baseClass', 'validateReservedWord'),
+ array('ns', 'match', 'pattern' => '/^[a-zA-Z_][\w\\\\]*$/', 'message' => 'Only word characters and backslashes are allowed.'),
));
}
@@ -51,6 +53,7 @@ class Generator extends \yii\gii\Generator
'baseClass' => 'Base Class',
'controller' => 'Controller ID',
'actions' => 'Action IDs',
+ 'ns' => 'Namespace',
);
}
@@ -153,4 +156,10 @@ class Generator extends \yii\gii\Generator
}
return $module->getControllerPath() . '/' . $id . 'Controller.php';
}
+
+ public function getViewFile($action)
+ {
+ $module=$this->getModule();
+ return $module->getViewPath().'/'.$this->getControllerID().'/'.$action.'.php';
+ }
}
diff --git a/framework/yii/gii/generators/controller/views/form.php b/framework/yii/gii/generators/controller/views/form.php
index b08c3c3..2e48889 100644
--- a/framework/yii/gii/generators/controller/views/form.php
+++ b/framework/yii/gii/generators/controller/views/form.php
@@ -1,8 +1,4 @@
admin/user
generates UserController.php
within the admin
module.
'); ?>
-field($generator, 'baseClass')->hint('
- This is the class that the new controller class will extend from.
- Please make sure the class exists and can be autoloaded.
-'); ?>
field($generator, 'actions')->hint('
Provide one or multiple action IDs to generate empty action method(s) in the controller.
Separate multiple action IDs with commas or spaces.
'); ?>
+field($generator, 'ns')->sticky()->hint('
+ This is the namespace that the new controller class will should use.
+'); ?>
+field($generator, 'baseClass')->sticky()->hint('
+ This is the class that the new controller class will extend from.
+ Please make sure the class exists and can be autoloaded.
+'); ?>
diff --git a/framework/yii/gii/views/default/_files.php b/framework/yii/gii/views/default/_files.php
index 05c8ee5..3fe1048 100644
--- a/framework/yii/gii/views/default/_files.php
+++ b/framework/yii/gii/views/default/_files.php
@@ -8,6 +8,7 @@ use yii\gii\CodeFile;
* @var $this \yii\base\View
* @var $generator \yii\gii\Generator
* @var CodeFile[] $files
+ * @var array $answers
*/
?>
Code File | Action | -+ | 1) { - echo ''; + echo ''; } ?> | @@ -36,7 +37,7 @@ use yii\gii\CodeFile;getRelativePath()), array('code', 'file' => $i), array('class' => 'view-code', 'rel' => $file->path)); ?> operation === CodeFile::OP_OVERWRITE): ?> - ( $i), array('class' => 'view-code', 'rel' => $file->path)); ?>) + $i), array('class' => 'view-code label label-warning', 'rel' => $file->path)); ?> | @@ -54,7 +55,7 @@ use yii\gii\CodeFile; echo ' '; } else { $key = md5($file->path); - echo Html::checkBox("answers[$key]"); + echo Html::checkBox("answers[$key]", isset($answers) ? isset($answers[$key]) : ($file->operation === CodeFile::OP_NEW)); } ?> | diff --git a/framework/yii/gii/views/default/view.php b/framework/yii/gii/views/default/view.php index d0738aa..541ae26 100644 --- a/framework/yii/gii/views/default/view.php +++ b/framework/yii/gii/views/default/view.php @@ -11,6 +11,7 @@ use yii\gii\CodeFile; * @var yii\widgets\ActiveForm $form * @var string $result * @var CodeFile[] $files + * @var array $answers */ $this->title = $generator->getName(); @@ -24,10 +25,10 @@ foreach ($generator->templates as $name => $path) {
---|