From 17afdf71531006d9201ce0a72a136423105751cd Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Tue, 2 Jul 2013 23:40:24 +0300 Subject: [PATCH] configure exclusion of order field --- ipf/form/model.php | 18 ++++++++++++------ ipf/orm/template/orderable.php | 11 ++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/ipf/form/model.php b/ipf/form/model.php index 1bf2cdf..fd7a928 100644 --- a/ipf/form/model.php +++ b/ipf/form/model.php @@ -26,13 +26,19 @@ class IPF_Form_Model extends IPF_Form $exclude = array(); foreach ($db_columns as $name => $col) { - if (array_search($name, $exclude) === false && !isset($col['exclude'])) - $this->addDBField($name, $col); + if (array_search($name, $exclude) !== false) + continue; + if (isset($col['exclude']) && $col['exclude']) + continue; + $this->addDBField($name, $col); } foreach ($db_relations as $name => $relation) { - if (array_search($name, $exclude) === false && !isset($relation['exclude'])) - $this->addDBRelation($name, $relation, $col); // FIXME: $col is undefined + if (array_search($name, $exclude) !== false) + continue; + if (isset($relation['exclude']) && $relation['exclude']) + continue; + $this->addDBRelation($name, $relation, $col); // FIXME: $col is undefined } } else { foreach ($user_fields as $uname) { @@ -61,9 +67,9 @@ class IPF_Form_Model extends IPF_Form return; $defaults = array( - 'blank' => true, + 'blank' => true, 'help_text' => '', - 'editable' => true, + 'editable' => true, 'verbose' => isset($col['verbose']) ? $col['verbose'] : $name, ); diff --git a/ipf/orm/template/orderable.php b/ipf/orm/template/orderable.php index 0d26546..3270828 100644 --- a/ipf/orm/template/orderable.php +++ b/ipf/orm/template/orderable.php @@ -3,11 +3,16 @@ class IPF_ORM_Template_Orderable extends IPF_ORM_Template { private $columnName = 'ord'; + private $exclude = true; public function __construct(array $options=array()) { - if ($options && array_key_exists('name', $options)) - $this->columnName = $options['name']; + if ($options) { + if (array_key_exists('name', $options)) + $this->columnName = $options['name']; + if (array_key_exists('exclude', $options)) + $this->exclude = $options['exclude']; + } } public function getColumnName() @@ -17,7 +22,7 @@ class IPF_ORM_Template_Orderable extends IPF_ORM_Template public function setTableDefinition() { - $this->hasColumn($this->columnName, 'integer', null, array('exclude' => true)); + $this->hasColumn($this->columnName, 'integer', null, array('exclude' => $this->exclude)); $this->getTable()->listeners['Orderable_'.$this->columnName] = new IPF_ORM_Template_Listener_Orderable($this->columnName); } } -- 2.49.0