From ad456bd479891df5e7d685d28b7676f63484cb49 Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Fri, 27 May 2011 01:41:13 -0430 Subject: [PATCH] Removing code that should not have existed in the first place --- lib/Cake/Test/Case/Utility/SanitizeTest.php | 51 --------------- lib/Cake/Utility/Sanitize.php | 69 --------------------- 2 files changed, 120 deletions(-) diff --git a/lib/Cake/Test/Case/Utility/SanitizeTest.php b/lib/Cake/Test/Case/Utility/SanitizeTest.php index 3f8428d6a..a702d9655 100644 --- a/lib/Cake/Test/Case/Utility/SanitizeTest.php +++ b/lib/Cake/Test/Case/Utility/SanitizeTest.php @@ -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); - } } diff --git a/lib/Cake/Utility/Sanitize.php b/lib/Cake/Utility/Sanitize.php index f521654f3..11ebec756 100644 --- a/lib/Cake/Utility/Sanitize.php +++ b/lib/Cake/Utility/Sanitize.php @@ -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; - } - */ - } - } - } - } - } }