From 75e9318cfbcb2970abd40bc1e449a8eb2c3a3e62 Mon Sep 17 00:00:00 2001 From: avl Date: Thu, 21 Aug 2008 06:44:29 +0300 Subject: [PATCH] File Uploads & Ready for first project --- ipf/orm/record.php | 15 +++++++-------- ipf/orm/table.php | 4 ++++ ipf/orm/utils.php | 2 ++ ipf/orm/validator/file.php | 8 ++++++++ ipf/orm/validator/image.php | 8 ++++++++ 5 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 ipf/orm/validator/file.php create mode 100644 ipf/orm/validator/image.php diff --git a/ipf/orm/record.php b/ipf/orm/record.php index 7b2b03c..fd81dcc 100644 --- a/ipf/orm/record.php +++ b/ipf/orm/record.php @@ -1257,16 +1257,15 @@ abstract class IPF_ORM_Record extends IPF_ORM_Record_Abstract implements Countab return null; } - function SetFromFormData($cleaned_values) + public function SetFromFormData($cleaned_values) { - //$relations = $this->getTable()->getRelations(); foreach ($cleaned_values as $key=>$val) { - /* - if (array_key_exists($key,$relations)){ - - - }else*/ - $this->$key = $val; + $validators = $this->getTable()->getFieldValidators($key); + if (array_key_exists('image',$validators) || array_key_exists('file',$validators)){ + if ($val=='') + continue; + } + $this->$key = $val; } } } \ No newline at end of file diff --git a/ipf/orm/table.php b/ipf/orm/table.php index 6403fa8..9f00d7b 100644 --- a/ipf/orm/table.php +++ b/ipf/orm/table.php @@ -1271,6 +1271,10 @@ class IPF_ORM_Table extends IPF_ORM_Configurable implements Countable $columnName = $this->getColumnName($fieldName); // this loop is a dirty workaround to get the validators filtered out of // the options, since everything is squeezed together currently + + if (!isset($this->_columns[$columnName])) + return array(); + foreach ($this->_columns[$columnName] as $name => $args) { if (empty($name) || $name == 'primary' diff --git a/ipf/orm/utils.php b/ipf/orm/utils.php index 5afd7da..5664c70 100644 --- a/ipf/orm/utils.php +++ b/ipf/orm/utils.php @@ -54,6 +54,8 @@ class IPF_ORM_Utils { 'unique', 'unsigned', 'usstate', + 'file', + 'image', ); } diff --git a/ipf/orm/validator/file.php b/ipf/orm/validator/file.php new file mode 100644 index 0000000..b235643 --- /dev/null +++ b/ipf/orm/validator/file.php @@ -0,0 +1,8 @@ +