From ef624137933b83834e1825ae56da48e6c72e2258 Mon Sep 17 00:00:00 2001 From: Anupam Ghosh Date: Tue, 12 Dec 2017 14:02:21 +0530 Subject: [PATCH] fix(report): rearrange common and additional obligation text for report --- src/lib/php/common-sysconfig.php | 11 ++++- src/unifiedreport/agent/reportStatic.php | 56 ++++++++++++++++++------ 2 files changed, 51 insertions(+), 16 deletions(-) diff --git a/src/lib/php/common-sysconfig.php b/src/lib/php/common-sysconfig.php index 1269308130..cb8784c64f 100644 --- a/src/lib/php/common-sysconfig.php +++ b/src/lib/php/common-sysconfig.php @@ -279,14 +279,21 @@ function Populate_sysconfig() $Variable = "CommonObligation"; $contextNamePrompt = _("Common Obligation"); $contextValue = ""; - $contextDesc = _("Common Obligation Text, add line break with \n at the end of the line"); + $contextDesc = _("Common Obligation Text, add line break at the end of the line"); $ValueArray[$Variable] = "'$Variable', '$contextValue', '$contextNamePrompt', " . CONFIG_TYPE_TEXTAREA . ",'ReportText', null, '$contextDesc', null"; $Variable = "AdditionalObligation"; $contextNamePrompt = _("Additional Obligation"); $contextValue = ""; - $contextDesc = _("Additional Obligation Text, add line break with \n at the end of the line"); + $contextDesc = _("Additional Obligation Text, add line break at the end of the line"); + $ValueArray[$Variable] = "'$Variable', '$contextValue', '$contextNamePrompt', " + . CONFIG_TYPE_TEXTAREA . + ",'ReportText', null, '$contextDesc', null"; + $Variable = "ObligationAndRisk"; + $contextNamePrompt = _("Obligation And Risk Assessment"); + $contextValue = ""; + $contextDesc = _("Obligations and risk assessment, add line break at the end of the line"); $ValueArray[$Variable] = "'$Variable', '$contextValue', '$contextNamePrompt', " . CONFIG_TYPE_TEXTAREA . ",'ReportText', null, '$contextDesc', null"; diff --git a/src/unifiedreport/agent/reportStatic.php b/src/unifiedreport/agent/reportStatic.php index 438ead82ae..05b9c83b88 100644 --- a/src/unifiedreport/agent/reportStatic.php +++ b/src/unifiedreport/agent/reportStatic.php @@ -224,14 +224,26 @@ function assessmentSummaryTable(Section $section, $otherStatement) } + /** + * @param string $text + * @return array $texts + */ + protected function reArrangeObligationText($text) + { + $texts = explode(PHP_EOL, $text); + return $texts; + } + + /** * @param Section $section */ function todoTable(Section $section) { global $SysConf; - $text1 = $SysConf['SYSCONFIG']["CommonObligation"]; - $text2 = $SysConf['SYSCONFIG']["AdditionalObligation"]; + $textCommonObligation = $this->reArrangeObligationText($SysConf['SYSCONFIG']["CommonObligation"]); + $textAdditionalObligation = $this->reArrangeObligationText($SysConf['SYSCONFIG']["AdditionalObligation"]); + $textObligationAndRisk = $this->reArrangeObligationText($SysConf['SYSCONFIG']["ObligationAndRisk"]); $rowStyle = array("bgColor" => "E0E0E0", "spaceBefore" => 0, "spaceAfter" => 0, "spacing" => 0); $secondRowColorStyle = array("color" => "008000"); @@ -252,10 +264,12 @@ function todoTable(Section $section) $r1c1 = "2.1.1"; $r2c1 = "2.1.2"; + $r3c1 = "2.1.3"; $r1c2 = "Documentation of license conditions and copyright notices in product documentation (License Notice File / README_OSS) is provided by this component clearing report:"; $r2c2 = "Additional Common Obligations:"; - $r2c3 = "Need to be ensured by the distributing party:"; + $r2c21 = "Need to be ensured by the distributing party:"; + $r3c2 = "Obligations and risk assessment regarding distribution"; $table = $section->addTable($this->tablestyle); @@ -266,34 +280,48 @@ function todoTable(Section $section) $table->addRow($rowWidth); $cell = $table->addCell($firstColLen); $cell = $table->addCell($secondColLen); - if (!empty($text1) && strpos($text1, '\n')!==FALSE){ - $texts = explode('\n', $text1); - foreach($texts as $text){ - $cell->addText(htmlspecialchars($text), $secondRowColorStyle, "pStyle"); - } + if(empty($textCommonObligation)){ + $cell->addText(htmlspecialchars($textCommonObligation), $secondRowColorStyle, "pStyle"); } else{ - $cell->addText(htmlspecialchars($text1),$secondRowColorStyle , "pStyle"); + foreach($textCommonObligation as $text){ + $cell->addText(htmlspecialchars($text), $secondRowColorStyle, "pStyle"); + } } $table->addRow($rowWidth); $cell = $table->addCell($firstColLen, $rowStyle)->addText(htmlspecialchars($r2c1), $rowTextStyleLeft, "pStyle"); $cell = $table->addCell($secondColLen, $rowStyle); $cell->addText(htmlspecialchars($r2c2), $rowTextStyleRightBold, "pStyle"); - $cell->addText(htmlspecialchars($r2c3), $rowTextStyleRightBold, "pStyle"); + $cell->addText(htmlspecialchars($r2c21), $rowTextStyleRightBold, "pStyle"); $table->addRow($rowWidth); $cell = $table->addCell($firstColLen); $cell = $table->addCell($secondColLen); - if (!empty($text1) && strpos($text2, '\n')!==FALSE){ - $texts = explode('\n', $text2); - foreach($texts as $text){ + if (empty($textAdditionalObligation)){ + $cell->addText(htmlspecialchars($textAdditionalObligation), null, "pStyle"); + } + else{ + foreach($textAdditionalObligation as $text){ $cell->addText(htmlspecialchars($text), null, "pStyle"); } } + $table->addRow($rowWidth); + $cell = $table->addCell($firstColLen, $rowStyle)->addText(htmlspecialchars($r3c1), $rowTextStyleLeft, "pStyle"); + $cell = $table->addCell($secondColLen, $rowStyle)->addText(htmlspecialchars($r3c2), $rowTextStyleRightBold, "pStyle"); + + $table->addRow($rowWidth); + $cell = $table->addCell($firstColLen); + $cell = $table->addCell($secondColLen); + if(empty($textObligationAndRisk)){ + $cell->addText(htmlspecialchars($textObligationAndRisk), $secondRowColorStyle, "pStyle"); + } else{ - $cell->addText(htmlspecialchars($text2), null, "pStyle"); + foreach($textObligationAndRisk as $text){ + $cell->addText(htmlspecialchars($text), $secondRowColorStyle, "pStyle"); + } } + $section->addTextBreak(); }