Removing code that should not have existed in the first place

This commit is contained in:
Jose Lorenzo Rodriguez 2011-05-27 01:41:13 -04:30
parent faa8b3d324
commit ad456bd479
2 changed files with 0 additions and 120 deletions

View file

@ -465,55 +465,4 @@ HTML;
$result = Sanitize::stripTags($string, 'h2', 'a', 'img');
$this->assertEqual($expected, $result);
}
/**
* testFormatColumns method
*
* @access public
* @return void
*/
function testFormatColumns() {
$this->autoFixtures = true;
$this->fixtureManager->load($this);
$this->loadFixtures('DataTest', 'Article');
$this->DataTest = new SanitizeDataTest(array('alias' => 'DataTest'));
$data = array('DataTest' => array(
'id' => 'z',
'count' => '12a',
'float' => '2.31456',
'updated' => '2008-01-01'
)
);
$this->DataTest->set($data);
$expected = array('DataTest' => array(
'id' => '0',
'count' => '12',
'float' => 2.31456,
'updated' => '2008-01-01 00:00:00',
));
Sanitize::formatColumns($this->DataTest);
$result = $this->DataTest->data;
$this->assertEqual($expected, $result);
$this->Article = new SanitizeArticle(array('alias' => 'Article'));
$data = array('Article' => array(
'id' => 'ZB',
'user_id' => '12',
'title' => 'title of article',
'body' => 'body text',
'published' => 'QQQQQQQ',
));
$this->Article->set($data);
$expected = array('Article' => array(
'id' => '0',
'user_id' => '12',
'title' => 'title of article',
'body' => 'body text',
'published' => 'QQQQQQQ',
));
Sanitize::formatColumns($this->Article);
$result = $this->Article->data;
$this->assertEqual($expected, $result);
}
}

View file

@ -257,73 +257,4 @@ class Sanitize {
return $data;
}
}
/**
* Formats column data from definition in DBO's $columns array
*
* @param Model $model The model containing the data to be formatted
*/
public static function formatColumns($model) {
foreach ($model->data as $name => $values) {
if ($name == $model->alias) {
$curModel = $model;
} elseif (isset($model->{$name}) && is_object($model->{$name}) && is_subclass_of($model->{$name}, 'Model')) {
$curModel = $model->{$name};
} else {
$curModel = null;
}
if ($curModel != null) {
foreach ($values as $column => $data) {
$colType = $curModel->getColumnType($column);
if ($colType != null) {
$db = ConnectionManager::getDataSource($curModel->useDbConfig);
$colData = $db->columns[$colType];
if (isset($colData['limit']) && strlen(strval($data)) > $colData['limit']) {
$data = substr(strval($data), 0, $colData['limit']);
}
if (isset($colData['formatter']) || isset($colData['format'])) {
switch (strtolower($colData['formatter'])) {
case 'date':
$data = date($colData['format'], strtotime($data));
break;
case 'sprintf':
$data = sprintf($colData['format'], $data);
break;
case 'intval':
$data = intval($data);
break;
case 'floatval':
$data = floatval($data);
break;
}
}
$model->data[$name][$column]=$data;
/*
switch ($colType) {
case 'integer':
case 'int':
return $data;
break;
case 'string':
case 'text':
case 'binary':
case 'date':
case 'time':
case 'datetime':
case 'timestamp':
case 'date':
return "'" . $data . "'";
break;
}
*/
}
}
}
}
}
}