diff --git a/core/attributedef/AttributeTable.php b/core/attributedef/AttributeTable.php new file mode 100644 index 0000000000..09620a48a9 --- /dev/null +++ b/core/attributedef/AttributeTable.php @@ -0,0 +1,164 @@ + 0; + } + + + public function GetEditValue($sValue, $oHostObj = null) + { + return ''; + } + + // Facilitate things: allow the user to Set the value from a string + public function MakeRealValue($proposedValue, $oHostObj) + { + if (is_null($proposedValue)) { + return array(); + } else { + if (!is_array($proposedValue)) { + return array(0 => array(0 => $proposedValue)); + } + } + + return $proposedValue; + } + + public function FromSQLToValue($aCols, $sPrefix = '') + { + try { + $value = @unserialize($aCols[$sPrefix . '']); + if ($value === false) { + $value = @json_decode($aCols[$sPrefix . ''], true); + if (is_null($value)) { + $value = false; + } + } + if ($value === false) { + $value = $this->MakeRealValue($aCols[$sPrefix . ''], null); + } + } catch (Exception $e) { + $value = $this->MakeRealValue($aCols[$sPrefix . ''], null); + } + + return $value; + } + + public function GetSQLValues($value) + { + $aValues = array(); + try { + $sSerializedValue = serialize($value); + } catch (Exception $e) { + $sSerializedValue = json_encode($value); + } + $aValues[$this->Get("sql")] = $sSerializedValue; + + return $aValues; + } + + public function GetAsHTML($value, $oHostObject = null, $bLocalize = true) + { + if (!is_array($value)) { + throw new CoreException('Expecting an array', array('found' => get_class($value))); + } + if (count($value) == 0) { + return ""; + } + + $sRes = "
| $sCell | "; + } + $sRes .= "