HCE Project DC service web UI  0.2
Hierarchical Cluster Engine DC service web UI
 All Classes Namespaces Files Functions Variables Pages
BootstrapCode.php
Go to the documentation of this file.
1 <?php
10 Yii::import('gii.generators.crud.CrudCode');
11 
17 class BootstrapCode extends CrudCode {
18 
19  public function generateActiveGroup($modelClass, $column) {
20 
21  if ($column->type === 'boolean') {
22  return "\$form->checkBoxGroup(\$model,'{$column->name}')";
23  } else if (stripos($column->dbType, 'text') !== false) {
24  return "\$form->textAreaGroup(\$model,'{$column->name}', array('widgetOptions'=>array('htmlOptions'=>array('rows'=>6, 'cols'=>50, 'class'=>'span8'))))";
25  } else {
26  if (preg_match('/^(password|pass|passwd|passcode)$/i', $column->name)) {
27  $inputField = 'passwordFieldGroup';
28  } else {
29  $inputField = 'textFieldGroup';
30  }
31 
32  if ($column->type !== 'string' || $column->size === null) {
33  if($column->dbType == 'date') {
34  return "\$form->datePickerGroup(\$model,'{$column->name}',array('widgetOptions'=>array('options'=>array(),'htmlOptions'=>array('class'=>'span5')), 'prepend'=>'<i class=\"glyphicon glyphicon-calendar\"></i>', 'append'=>'Click on Month/Year to select a different Month/Year.'))";
35  } else {
36  return "\$form->{$inputField}(\$model,'{$column->name}',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5'))))";
37  }
38  } else {
39  if (strpos ( $column->dbType, 'enum(' ) !== false) {
40  $temp = $column->dbType;
41  $temp = str_replace ( 'enum', 'array', $temp );
42  // FIXME: What. The. Seriously, parse the enum declaration from MySQL as an array definition in PHP?!
43  eval ( '$options = ' . $temp . ';' );
44  $dropdown_options = "array(";
45  foreach ( $options as $option ) {
46  $dropdown_options .= "\"$option\"=>\"$option\",";
47  }
48  $dropdown_options .= ")";
49  return "\$form->dropDownListGroup(\$model,'{$column->name}', array('widgetOptions'=>array('data'=>{$dropdown_options}, 'htmlOptions'=>array('class'=>'input-large'))))";
50  } else {
51  return "\$form->{$inputField}(\$model,'{$column->name}',array('widgetOptions'=>array('htmlOptions'=>array('class'=>'span5','maxlength'=>$column->size))))";
52  }
53  }
54  }
55  }
56 }