diff --git a/core/attributedef/AttributePropertySet.php b/core/attributedef/AttributePropertySet.php new file mode 100644 index 000000000..cedad14e3 --- /dev/null +++ b/core/attributedef/AttributePropertySet.php @@ -0,0 +1,108 @@ + (string)$proposedValue); + } + + return $proposedValue; + } + + 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 = ""; + $sRes .= ""; + foreach ($value as $sProperty => $sValue) { + if ($sProperty == 'auth_pwd') { + $sValue = '*****'; + } + $sRes .= ""; + $sCell = str_replace("\n", "
\n", Str::pure2html(@(string)$sValue)); + $sRes .= ""; + $sRes .= ""; + } + $sRes .= ""; + $sRes .= "
$sProperty$sCell
"; + + return $sRes; + } + + public function GetAsCSV( + $value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true, + $bConvertToPlainText = false + ) + { + if (!is_array($value) || count($value) == 0) { + return ""; + } + + $aRes = array(); + foreach ($value as $sProperty => $sValue) { + if ($sProperty == 'auth_pwd') { + $sValue = '*****'; + } + $sFrom = array(',', '='); + $sTo = array('\,', '\='); + $aRes[] = $sProperty . '=' . str_replace($sFrom, $sTo, (string)$sValue); + } + $sRaw = implode(',', $aRes); + + $sFrom = array("\r\n", $sTextQualifier); + $sTo = array("\n", $sTextQualifier . $sTextQualifier); + $sEscaped = str_replace($sFrom, $sTo, $sRaw); + + return $sTextQualifier . $sEscaped . $sTextQualifier; + } + + public function GetAsXML($value, $oHostObject = null, $bLocalize = true) + { + if (!is_array($value) || count($value) == 0) { + return ""; + } + + $sRes = ""; + foreach ($value as $sProperty => $sValue) { + if ($sProperty == 'auth_pwd') { + $sValue = '*****'; + } + $sRes .= ""; + $sRes .= Str::pure2xml((string)$sValue); + $sRes .= ""; + } + + return $sRes; + } +} \ No newline at end of file