mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
#773 Display boolean values from the stop watches as yes/no (localized, like enums) + took the opportunity to enable the export in spreadsheet format
SVN:trunk[2899]
This commit is contained in:
@@ -2568,7 +2568,7 @@ class AttributeDateTime extends AttributeDBField
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$sValue);
|
||||
return '"'.$sEscaped.'"';
|
||||
return $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3833,6 +3833,12 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
throw new CoreException("Unknown item code '$sItemCode' for attribute ".$this->GetHostClass().'::'.$this->GetCode());
|
||||
}
|
||||
|
||||
protected function GetBooleanLabel($bValue)
|
||||
{
|
||||
$sDictKey = $bValue ? 'yes' : 'no';
|
||||
return Dict::S('BooleanLabel:'.$sDictKey, 'def:'.$sDictKey);
|
||||
}
|
||||
|
||||
public function GetSubItemAsHTMLForHistory($sItemCode, $sOldValue, $sNewValue, $sLabel)
|
||||
{
|
||||
switch($sItemCode)
|
||||
@@ -3863,12 +3869,12 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
$sHtmlNew = (int)$sNewValue ? date(self::GetDateFormat(true /*full*/), (int)$sNewValue) : null;
|
||||
break;
|
||||
case 'passed':
|
||||
$sHtmlOld = (int)$sOldValue ? '1' : '0';
|
||||
$sHtmlNew = (int)$sNewValue ? '1' : '0';
|
||||
$sHtmlOld = $this->GetBooleanLabel((int)$sOldValue);
|
||||
$sHtmlNew = $this->GetBooleanLabel((int)$sNewValue);
|
||||
break;
|
||||
case 'triggered':
|
||||
$sHtmlOld = (int)$sOldValue ? '1' : '0';
|
||||
$sHtmlNew = (int)$sNewValue ? '1' : '0';
|
||||
$sHtmlOld = $this->GetBooleanLabel((int)$sOldValue);
|
||||
$sHtmlNew = $this->GetBooleanLabel((int)$sNewValue);
|
||||
break;
|
||||
case 'overrun':
|
||||
$sHtmlOld = (int)$sOldValue > 0 ? AttributeDuration::FormatDuration((int)$sOldValue) : '';
|
||||
@@ -3937,10 +3943,8 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
}
|
||||
break;
|
||||
case 'passed':
|
||||
$sHtml = $value ? '1' : '0';
|
||||
break;
|
||||
case 'triggered':
|
||||
$sHtml = $value ? '1' : '0';
|
||||
$sHtml = $this->GetBooleanLabel($value);
|
||||
break;
|
||||
case 'overrun':
|
||||
$sHtml = Str::pure2html(AttributeDuration::FormatDuration($value));
|
||||
@@ -3954,12 +3958,141 @@ class AttributeStopWatch extends AttributeDefinition
|
||||
|
||||
public function GetSubItemAsCSV($sItemCode, $value, $sSeparator = ',', $sTextQualifier = '"')
|
||||
{
|
||||
return $value;
|
||||
$sFrom = array("\r\n", $sTextQualifier);
|
||||
$sTo = array("\n", $sTextQualifier.$sTextQualifier);
|
||||
$sEscaped = str_replace($sFrom, $sTo, (string)$value);
|
||||
$sRet = $sTextQualifier.$sEscaped.$sTextQualifier;
|
||||
|
||||
switch($sItemCode)
|
||||
{
|
||||
case 'timespent':
|
||||
case 'started':
|
||||
case 'laststart':
|
||||
case 'stopped':
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo)
|
||||
{
|
||||
$sThPrefix = $iThreshold.'_';
|
||||
if (substr($sItemCode, 0, strlen($sThPrefix)) == $sThPrefix)
|
||||
{
|
||||
// The current threshold is concerned
|
||||
$sThresholdCode = substr($sItemCode, strlen($sThPrefix));
|
||||
switch($sThresholdCode)
|
||||
{
|
||||
case 'deadline':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
case 'triggered':
|
||||
$sRet = $sTextQualifier.$this->GetBooleanLabel($value).$sTextQualifier;
|
||||
break;
|
||||
|
||||
case 'overrun':
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sRet;
|
||||
}
|
||||
|
||||
public function GetSubItemAsXML($sItemCode, $value)
|
||||
{
|
||||
return Str::pure2xml((string)$value);
|
||||
$sRet = Str::pure2xml((string)$value);
|
||||
|
||||
switch($sItemCode)
|
||||
{
|
||||
case 'timespent':
|
||||
case 'started':
|
||||
case 'laststart':
|
||||
case 'stopped':
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo)
|
||||
{
|
||||
$sThPrefix = $iThreshold.'_';
|
||||
if (substr($sItemCode, 0, strlen($sThPrefix)) == $sThPrefix)
|
||||
{
|
||||
// The current threshold is concerned
|
||||
$sThresholdCode = substr($sItemCode, strlen($sThPrefix));
|
||||
switch($sThresholdCode)
|
||||
{
|
||||
case 'deadline':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
case 'triggered':
|
||||
$sRet = $this->GetBooleanLabel($value);
|
||||
break;
|
||||
|
||||
case 'overrun':
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sRet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented for the HTML spreadsheet format!
|
||||
*/
|
||||
public function GetSubItemAsEditValue($sItemCode, $value)
|
||||
{
|
||||
$sRet = $value;
|
||||
|
||||
switch($sItemCode)
|
||||
{
|
||||
case 'timespent':
|
||||
break;
|
||||
|
||||
case 'started':
|
||||
case 'laststart':
|
||||
case 'stopped':
|
||||
if (is_null($value))
|
||||
{
|
||||
$sRet = ''; // Undefined
|
||||
}
|
||||
else
|
||||
{
|
||||
$sRet = date(self::GetDateFormat(), $value);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
foreach ($this->ListThresholds() as $iThreshold => $aFoo)
|
||||
{
|
||||
$sThPrefix = $iThreshold.'_';
|
||||
if (substr($sItemCode, 0, strlen($sThPrefix)) == $sThPrefix)
|
||||
{
|
||||
// The current threshold is concerned
|
||||
$sThresholdCode = substr($sItemCode, strlen($sThPrefix));
|
||||
switch($sThresholdCode)
|
||||
{
|
||||
case 'deadline':
|
||||
if ($value)
|
||||
{
|
||||
$sRet = date(self::GetDateFormat(true /*full*/), $value);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sRet = '';
|
||||
}
|
||||
break;
|
||||
case 'passed':
|
||||
case 'triggered':
|
||||
$sRet = $this->GetBooleanLabel($value);
|
||||
break;
|
||||
case 'overrun':
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $sRet;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4069,7 +4202,7 @@ class AttributeSubItem extends AttributeDefinition
|
||||
public function GetAsCSV($value, $sSeparator = ',', $sTextQualifier = '"', $oHostObject = null, $bLocalize = true)
|
||||
{
|
||||
$oParent = $this->GetTargetAttDef();
|
||||
$res = $oParent->GetSubItemAsCSV($this->Get('item_code'), $value, $sSeparator = ',', $sTextQualifier = '"');
|
||||
$res = $oParent->GetSubItemAsCSV($this->Get('item_code'), $value, $sSeparator, $sTextQualifier);
|
||||
return $res;
|
||||
}
|
||||
|
||||
@@ -4088,6 +4221,16 @@ class AttributeSubItem extends AttributeDefinition
|
||||
$sValue = $oParent->GetSubItemAsHTMLForHistory($this->Get('item_code'), $sOldValue, $sNewValue, $sLabel);
|
||||
return $sValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* As of now, this function must be implemented to have the value in spreadsheet format
|
||||
*/
|
||||
public function GetEditValue($value, $oHostObj = null)
|
||||
{
|
||||
$oParent = $this->GetTargetAttDef();
|
||||
$res = $oParent->GetSubItemAsEditValue($this->Get('item_code'), $value);
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -194,6 +194,8 @@ Dict::Add('DE DE', 'German', 'Deutsch', array(
|
||||
'Class:URP_AttributeGrant/Attribute:actiongrantid+' => 'Aktion gewähren',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode' => 'Attribut',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode+' => 'Attribut-Code',
|
||||
'BooleanLabel:yes' => 'Ja',
|
||||
'BooleanLabel:no' => 'Nein',
|
||||
'Menu:WelcomeMenu' => 'Willkommen',
|
||||
'Menu:WelcomeMenu+' => 'Willkommen bei iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Willkommen',
|
||||
|
||||
@@ -309,6 +309,8 @@ Dict::Add('EN US', 'English', 'English', array(
|
||||
//
|
||||
|
||||
Dict::Add('EN US', 'English', 'English', array(
|
||||
'BooleanLabel:yes' => 'yes',
|
||||
'BooleanLabel:no' => 'no',
|
||||
'Menu:WelcomeMenu' => 'Welcome',
|
||||
'Menu:WelcomeMenu+' => 'Welcome to iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Welcome',
|
||||
|
||||
@@ -309,6 +309,8 @@ Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
|
||||
//
|
||||
|
||||
Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
|
||||
'BooleanLabel:yes' => 'si',
|
||||
'BooleanLabel:no' => 'no',
|
||||
'Menu:WelcomeMenu' => 'Bienvenido',
|
||||
'Menu:WelcomeMenu+' => 'Bienvenido a iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Bienvenido',
|
||||
|
||||
@@ -104,10 +104,10 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Class:URP_ActionGrant/Attribute:class+' => 'Target class',
|
||||
'Class:URP_ActionGrant/Attribute:permission' => 'Permission',
|
||||
'Class:URP_ActionGrant/Attribute:permission+' => 'allowed or not allowed?',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:no' => 'no',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:no+' => 'no',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:yes' => 'yes',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:yes+' => 'yes',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:no' => 'non',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:no+' => 'non',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:yes' => 'oui',
|
||||
'Class:URP_ActionGrant/Attribute:permission/Value:yes+' => 'oui',
|
||||
'Class:URP_ActionGrant/Attribute:action' => 'Action',
|
||||
'Class:URP_ActionGrant/Attribute:action+' => 'operations to perform on the given class',
|
||||
'Class:URP_StimulusGrant' => 'stimulus_permission',
|
||||
@@ -192,6 +192,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
|
||||
'Class:URP_ClassProjection/Attribute:value+' => 'OQL expression (using $this) | constant | | +attribute code',
|
||||
'Class:URP_ClassProjection/Attribute:attribute' => 'Attribute',
|
||||
'Class:URP_ClassProjection/Attribute:attribute+' => 'Target attribute code (optional)',
|
||||
'BooleanLabel:yes' => 'oui',
|
||||
'BooleanLabel:no' => 'non',
|
||||
'Menu:WelcomeMenu' => 'Bienvenue',
|
||||
'Menu:WelcomeMenu+' => 'Bienvenue dans iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Bienvenue',
|
||||
|
||||
@@ -182,6 +182,8 @@ Dict::Add('HU HU', 'Hungarian', 'Magyar', array(
|
||||
'Class:URP_ActionGrant/Attribute:profile+' => '',
|
||||
'Class:URP_StimulusGrant/Attribute:profile' => 'Profil',
|
||||
'Class:URP_StimulusGrant/Attribute:profile+' => '',
|
||||
'BooleanLabel:yes' => 'Igen',
|
||||
'BooleanLabel:no' => 'Nem',
|
||||
'Menu:WelcomeMenu' => 'Üdvözlöm',
|
||||
'Menu:WelcomeMenu+' => '',
|
||||
'Menu:WelcomeMenuPage' => 'Üdvözlöm',
|
||||
|
||||
@@ -311,6 +311,8 @@ Dict::Add('IT IT', 'Italian', 'Italiano', array(
|
||||
//
|
||||
|
||||
Dict::Add('IT IT', 'Italian', 'Italiano', array(
|
||||
'BooleanLabel:yes' => 'si',
|
||||
'BooleanLabel:no' => 'no',
|
||||
'Menu:WelcomeMenu' => 'Benveuto',
|
||||
'Menu:WelcomeMenu+' => '',
|
||||
'Menu:WelcomeMenuPage' => 'Benvenuto',
|
||||
|
||||
@@ -196,6 +196,8 @@ Dict::Add('JA JP', 'Japanese', '日本語', array(
|
||||
'Class:URP_AttributeGrant/Attribute:actiongrantid+' => '実行権限',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode' => '属性',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode+' => '属性コード',
|
||||
'BooleanLabel:yes' => 'はい',
|
||||
'BooleanLabel:no' => 'いいえ',
|
||||
'Menu:WelcomeMenu' => 'ようこそ',
|
||||
'Menu:WelcomeMenu+' => 'ようこそ、iTopへ',
|
||||
'Menu:WelcomeMenuPage' => 'ようこそ',
|
||||
|
||||
@@ -306,6 +306,8 @@ Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
|
||||
//
|
||||
|
||||
Dict::Add('PT BR', 'Brazilian', 'Brazilian', array(
|
||||
'BooleanLabel:yes' => 'sim',
|
||||
'BooleanLabel:no' => 'naõ',
|
||||
'Menu:WelcomeMenu' => 'Bem-vindo',
|
||||
'Menu:WelcomeMenu+' => 'Bem-vindo ao iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Bem-vindo',
|
||||
|
||||
@@ -195,6 +195,8 @@ Dict::Add('RU RU', 'Russian', 'Русский', array(
|
||||
'Class:URP_AttributeGrant/Attribute:actiongrantid+' => 'действие предоставления',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode' => 'Атрибут',
|
||||
'Class:URP_AttributeGrant/Attribute:attcode+' => 'Код атрибута',
|
||||
'BooleanLabel:yes' => 'да',
|
||||
'BooleanLabel:no' => 'нет',
|
||||
'Menu:WelcomeMenu' => 'Добро пожаловать',
|
||||
'Menu:WelcomeMenu+' => 'Добро пожаловать в iTop',
|
||||
'Menu:WelcomeMenuPage' => 'Добро пожаловать',
|
||||
|
||||
@@ -290,6 +290,8 @@ Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
|
||||
//
|
||||
|
||||
Dict::Add('TR TR', 'Turkish', 'Türkçe', array(
|
||||
'BooleanLabel:yes' => 'evet',
|
||||
'BooleanLabel:no' => 'hayır',
|
||||
'Menu:WelcomeMenu' => 'Hoşgeldiniz',
|
||||
'Menu:WelcomeMenu+' => 'iTop\'a Hoşgeldiniz',
|
||||
'Menu:WelcomeMenuPage' => 'Hoşgeldiniz',
|
||||
|
||||
@@ -289,6 +289,8 @@ Dict::Add('ZH CN', 'Chinese', '简体中文', array(
|
||||
//
|
||||
|
||||
Dict::Add('ZH CN', 'Chinese', '简体中文', array(
|
||||
'BooleanLabel:yes' => '是',
|
||||
'BooleanLabel:no' => '否',
|
||||
'Menu:WelcomeMenu' => '欢迎',
|
||||
'Menu:WelcomeMenu+' => '欢迎来到iTop',
|
||||
'Menu:WelcomeMenuPage' => '欢迎',
|
||||
|
||||
Reference in New Issue
Block a user