/** * test if the method getInputType returns the correct inputtype */ public function testGetInputType() { $DataType = new DataType(); $this->assertEquals('number', $DataType->getInputType('int')); $this->assertEquals('checkbox', $DataType->getInputType('bool')); $this->assertEquals('file', $DataType->getInputType('blob')); $this->assertEquals('single', $DataType->getInputType('binary')); $this->assertEquals('text', $DataType->getInputType('text')); $this->assertEquals('select-multiple', $DataType->getInputType('set')); $this->assertEquals('date', $DataType->getInputType('date')); $this->assertEquals('datetime', $DataType->getInputType('datetime')); $this->assertEquals('number', $DataType->getInputType('year')); }
public function run() { $type = DataType::getInputType($this->column->dbType); $this->htmlOptions += $this->fixedHtmlOptions[$type]; $column = $this->column->name; $name = isset($this->htmlOptions['name']) ? $this->htmlOptions['name'] : 'Row[' . $column . ']'; switch ($type) { case 'number': echo CHtml::activeTextField($this->row, $column, $this->htmlOptions); break; case 'select': echo CHtml::activeDropDownList($this->row, $column, $this->getEnumValues(), $this->htmlOptions); break; case 'select-multiple': #echo CHtml::activeListBox($this->row, $column, $this->getSetValues(), $this->htmlOptions); echo CHtml::listBox($name, $this->row->getAttributeAsArray($column), $this->getSetValues(), $this->htmlOptions); break; case 'text': echo CHtml::activeTextArea($this->row, $column, $this->htmlOptions); break; case 'file': echo '<script type="text/javascript"> $(document).ready(function() { $("# echo CHtml::$idPrefix; ?>").submit(function() { alert("ok1"); }); }); </script>'; echo CHtml::activeFileField($this->row, $column, $this->htmlOptions); break; case 'date': $this->SetDateTimeHtmlOptions($column); echo CHtml::activeTextField($this->row, $column, $this->htmlOptions); echo '<script type="text/javascript"> $(document).ready(function() { $("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd", buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"}); }); </script>'; break; case 'datetime': $this->SetDateTimeHtmlOptions($column); echo CHtml::activeTextField($this->row, $column, $this->htmlOptions); echo '<script type="text/javascript"> $(document).ready(function() { now = new Date(); $("#' . $this->htmlOptions['id'] . '").datepicker({showOn: "button", dateFormat: "yy-mm-dd " + now.getHours() + ":" + now.getMinutes() + ":" + now.getSeconds(), buttonImage: "' . ICONPATH . '/16/calendar.png' . '", buttonImageOnly: true, buttonText: "' . Yii::t('core', 'showCalendar') . '"}); }); </script>'; break; default: echo CHtml::activeTextField($this->row, $column, $this->htmlOptions); break; } }
/** * @return array key value pairs of primary key (if no primary key, all column values will be returned) */ public function getOriginalIdentifier() { $table = $this->getMetaData()->tableSchema; if (is_string($table->primaryKey)) { return array($table->primaryKey => $this->originalAttributes[$table->primaryKey]); } else { if (is_array($table->primaryKey)) { $values = array(); foreach ($table->primaryKey as $name) { $values[$name] = $this->originalAttributes[$name]; } return $values; } else { $values = array(); foreach ($table->columns as $column) { if (DataType::getInputType($column->dbType) != "file") { $values[$column->name] = $this->originalAttributes[$column->name]; } } return $values; } } }
<?php } ?> <?php } else { ?> <?php foreach ($row as $key => $value) { ?> <td class="<?php echo $key; ?> "> <?php if ($model->singleTableSelect && DataType::getInputType($model->getTable()->columns[$key]->dbType) == "file" && $value) { ?> <?php if ($model->hasPrimaryKey()) { ?> <a href="javascript:void(0);" class="icon" onclick="globalBrowse.download('<?php echo Yii::app()->createUrl('row/download'); ?> ', {key: JSON.stringify(keyData[<?php echo $i; ?> ]), column: '<?php echo $key; ?> ', table: '<?php echo $model->table;
public function getKeyData() { $keyData = array(); $i = 0; foreach ($this->getData() as $row) { foreach ($row as $key => $value) { if ($this->getIsUpdatable() && (!$this->hasPrimaryKey() || $this->isPrimaryKey($key)) && DataType::getInputType($this->getTable()->columns[$key]->dbType) != "file") { $keyData[$i][$key] = is_null($value) ? null : $value; } } $i++; } return $keyData; }