mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-01 22:48:45 +02:00
N°8699 - attributedef.class.inc.php to PSR4 [3-PSR4]
- Add namespaces - Add use statements - reformat code
This commit is contained in:
committed by
Benjamin Dalsass
parent
f0adbbba29
commit
3fa500c9c1
@@ -1,108 +1,118 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2024 Combodo SAS
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Core\AttributeDefinition;
|
||||
|
||||
use CoreException;
|
||||
use Exception;
|
||||
use Str;
|
||||
|
||||
class AttributePropertySet extends AttributeTable
|
||||
{
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
*
|
||||
* @see https://www.php.net/manual/fr/language.oop5.decon.php states that child constructor can be ommited
|
||||
* @see https://bugs.php.net/bug.php?id=79010 bug solved in PHP 7.4.9
|
||||
*
|
||||
* @param string $sCode
|
||||
* @param array $aParams
|
||||
*
|
||||
* @throws \Exception
|
||||
* @noinspection SenselessProxyMethodInspection
|
||||
*/
|
||||
public function __construct($sCode, $aParams)
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
/**
|
||||
* Useless constructor, but if not present PHP 7.4.0/7.4.1 is crashing :( (N°2329)
|
||||
*
|
||||
* @see https://www.php.net/manual/fr/language.oop5.decon.php states that child constructor can be ommited
|
||||
* @see https://bugs.php.net/bug.php?id=79010 bug solved in PHP 7.4.9
|
||||
*
|
||||
* @param string $sCode
|
||||
* @param array $aParams
|
||||
*
|
||||
* @throws Exception
|
||||
* @noinspection SenselessProxyMethodInspection
|
||||
*/
|
||||
public function __construct($sCode, $aParams)
|
||||
{
|
||||
parent::__construct($sCode, $aParams);
|
||||
}
|
||||
|
||||
public function GetEditClass()
|
||||
{
|
||||
return "PropertySet";
|
||||
}
|
||||
public function GetEditClass()
|
||||
{
|
||||
return "PropertySet";
|
||||
}
|
||||
|
||||
// Facilitate things: allow the user to Set the value from a string
|
||||
public function MakeRealValue($proposedValue, $oHostObj)
|
||||
{
|
||||
if (!is_array($proposedValue)) {
|
||||
return array('?' => (string)$proposedValue);
|
||||
}
|
||||
// Facilitate things: allow the user to Set the value from a string
|
||||
public function MakeRealValue($proposedValue, $oHostObj)
|
||||
{
|
||||
if (!is_array($proposedValue)) {
|
||||
return array('?' => (string)$proposedValue);
|
||||
}
|
||||
|
||||
return $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 "";
|
||||
}
|
||||
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 = "<TABLE class=\"listResults\">";
|
||||
$sRes .= "<TBODY>";
|
||||
foreach ($value as $sProperty => $sValue) {
|
||||
if ($sProperty == 'auth_pwd') {
|
||||
$sValue = '*****';
|
||||
}
|
||||
$sRes .= "<TR>";
|
||||
$sCell = str_replace("\n", "<br>\n", Str::pure2html(@(string)$sValue));
|
||||
$sRes .= "<TD class=\"label\">$sProperty</TD><TD>$sCell</TD>";
|
||||
$sRes .= "</TR>";
|
||||
}
|
||||
$sRes .= "</TBODY>";
|
||||
$sRes .= "</TABLE>";
|
||||
$sRes = "<TABLE class=\"listResults\">";
|
||||
$sRes .= "<TBODY>";
|
||||
foreach ($value as $sProperty => $sValue) {
|
||||
if ($sProperty == 'auth_pwd') {
|
||||
$sValue = '*****';
|
||||
}
|
||||
$sRes .= "<TR>";
|
||||
$sCell = str_replace("\n", "<br>\n", Str::pure2html(@(string)$sValue));
|
||||
$sRes .= "<TD class=\"label\">$sProperty</TD><TD>$sCell</TD>";
|
||||
$sRes .= "</TR>";
|
||||
}
|
||||
$sRes .= "</TBODY>";
|
||||
$sRes .= "</TABLE>";
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
return $sRes;
|
||||
}
|
||||
|
||||
public function GetAsCSV(
|
||||
$value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true,
|
||||
$bConvertToPlainText = false
|
||||
)
|
||||
{
|
||||
if (!is_array($value) || count($value) == 0) {
|
||||
return "";
|
||||
}
|
||||
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);
|
||||
$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);
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sEscaped = str_replace($sFrom, $sTo, $sRaw);
|
||||
|
||||
return $sTextQualifier . $sEscaped . $sTextQualifier;
|
||||
}
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
}
|
||||
|
||||
public function GetAsXML($value, $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
if (!is_array($value) || count($value) == 0) {
|
||||
return "";
|
||||
}
|
||||
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 .= "<property id=\"$sProperty\">";
|
||||
$sRes .= Str::pure2xml((string)$sValue);
|
||||
$sRes .= "</property>";
|
||||
}
|
||||
$sRes = "";
|
||||
foreach ($value as $sProperty => $sValue) {
|
||||
if ($sProperty == 'auth_pwd') {
|
||||
$sValue = '*****';
|
||||
}
|
||||
$sRes .= "<property id=\"$sProperty\">";
|
||||
$sRes .= Str::pure2xml((string)$sValue);
|
||||
$sRes .= "</property>";
|
||||
}
|
||||
|
||||
return $sRes;
|
||||
}
|
||||
return $sRes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user