Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3942579
D2538.id6440.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D2538.id6440.diff
View Options
diff --git a/src/Output/HTMLOutput.php b/src/Output/HTMLOutput.php
--- a/src/Output/HTMLOutput.php
+++ b/src/Output/HTMLOutput.php
@@ -15,48 +15,56 @@
public function render () : string {
$send = [];
- $title = $this->report->title;
- $send[] =
- '<h1 id="' . $this->makeId($title) . '">' . self::encode($title)
- . '</h1>';
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
- foreach ($this->report->sections as $section) {
- $title = $section->title;
+ $title = $this->report->title;
$send[] =
- '<h2 id="' . $this->makeId($title) . '">' .
- self::encode($title) . '</h2>';
- foreach ($section->entries as $entry) {
- $title = $entry->title;
- $send[] = '<h3 id="' . $this->makeId($title) . '">' .
- self::encode($title) . '</h3>';
+ '<h1 id="' . $this->makeId($title) . '">' . self::encode($title)
+ . '</h1>';
+ if ($this->report->sections) {
+ foreach ($this->report->sections as $section) {
+ $title = $section->title;
+ $send[] =
+ '<h2 id="' . $this->makeId($title) . '">' .
+ self::encode($title) . '</h2>';
+ foreach ($section->entries as $entry) {
+ $title = $entry->title;
+ $send[] = '<h3 id="' . $this->makeId($title) . '">' .
+ self::encode($title) . '</h3>';
- $text = explode("\n\n", $entry->text);
+ $text = explode("\n\n", $entry->text);
- foreach ($text as $value) {
- $send[] = '<p>' . self::encode($value) . '</p>';
+ foreach ($text as $value) {
+ $send[] = '<p>' . self::encode($value) . '</p>';
+ }
+ }
+ }
+ if ($this->report->properties && $this->report->sections) {
+ $send[] = '<hr>';
}
}
- }
- $send[] = '<hr>';
-
- $send[] = '<h2 id="report-properties">Report properties</h2>';
- $send[] = '<table>';
- $send[] = str_repeat(" ", 4) . '<tbody>';
+ if ($this->report->properties) {
+ $send[] = '<h2 id="report-properties">Report properties</h2>';
+ $send[] = '<table>';
+ $send[] = str_repeat(" ", 4) . '<tbody>';
- $properties = $this->report->properties;
+ $properties = $this->report->properties;
- foreach ($properties as $key => $value) {
- $send[] = str_repeat(" ", 4) . '<tr>';
- $send[] = str_repeat(" ", 8) .
+ foreach ($properties as $key => $value) {
+ $send[] = str_repeat(" ", 4) . '<tr>';
+ $send[] = str_repeat(" ", 8) .
- '<th>' . self::encode($key) . '</th>';
- $send[] = str_repeat(" ", 8) .
- '<td>' . self::encode($value) . '</td>';
+ '<th>' . self::encode($key) . '</th>';
+ $send[] = str_repeat(" ", 8) .
+ '<td>' . self::encode($value) . '</td>';
- $send[] = str_repeat(" ", 4) . '</tr>';
+ $send[] = str_repeat(" ", 4) . '</tr>';
+ }
+ $send[] = str_repeat(" ", 4) . '</tbody>';
+ $send[] = '</table>';
+ }
}
- $send[] = str_repeat(" ", 4) . '</tbody>';
- $send[] = '</table>';
$send[] = '';
return implode("\n", $send);
diff --git a/src/Output/MarkdownOutput.php b/src/Output/MarkdownOutput.php
--- a/src/Output/MarkdownOutput.php
+++ b/src/Output/MarkdownOutput.php
@@ -8,48 +8,61 @@
$send = [];
- $send[] = '# ' . $this->report->title;
- $send[] = '';
- foreach ($this->report->sections as $section) {
- $send[] = '## ' . $section->title;
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
+
+ $send[] = '# ' . $this->report->title;
$send[] = '';
- foreach ($section->entries as $entry) {
- $send[] = '### ' . $entry->title;
+ foreach ($this->report->sections as $section) {
+ $send[] = '## ' . $section->title;
$send[] = '';
- $send[] = $entry->text;
+ foreach ($section->entries as $entry) {
+
+ $send[] = '### ' . $entry->title;
+ $send[] = '';
+ $send[] = $entry->text;
+ $send[] = '';
+ }
+ }
+
+ if ($this->report->properties && $this->report->sections) {
+ $send[] = '---';
$send[] = '';
}
- }
+ if ($this->report->properties) {
+ $properties = $this->report->properties;
+ $propertyMaxLength = 0;
+ $maxValue = 0;
+ foreach ($properties as $key => $value) {
+ $propertyMaxLength = max($propertyMaxLength, strlen($key));
+ $maxValue = max($maxValue, strlen($value));
+ }
+ if ($propertyMaxLength < 8) {
+ $propertyMaxLength = 8;
+ }
- $send[] = '---';
- $send[] = '';
- $properties = $this->report->properties;
- $propertyMaxLength = 0;
- $maxValue = 0;
- foreach ($properties as $key => $value) {
- $propertyMaxLength = max($propertyMaxLength, strlen($key));
- $maxValue = max($maxValue, strlen($value));
- }
- if ($propertyMaxLength < 8) {
- $propertyMaxLength = 8;
- }
+ $send[] =
+ '| Property' . str_repeat(' ', $propertyMaxLength - 8)
+ . ' | '
+ . str_repeat(' ', $maxValue) . ' |';
- $send[] = '| Property' . str_repeat(' ', $propertyMaxLength - 8) . ' | '
- . str_repeat(' ', $maxValue) . ' |';
+ $send[] = '|' . str_repeat('-', $propertyMaxLength + 2) . '|'
+ . str_repeat('-', $maxValue + 2) . '|';
- $send[] = '|' . str_repeat('-', $propertyMaxLength + 2) . '|'
- . str_repeat('-', $maxValue + 2) . '|';
+ foreach ($properties as $key => $value) {
+ $send[] =
+ '| ' . $key . str_repeat(' ',
+ $propertyMaxLength - strlen($key))
+ . ' | '
+ . $value . str_repeat(' ', $maxValue - strlen($value))
+ . ' |';
+ }
- foreach ($properties as $key => $value) {
- $send[] =
- '| ' . $key . str_repeat(' ', $propertyMaxLength - strlen($key))
- . ' | '
- . $value . str_repeat(' ', $maxValue - strlen($value)) . ' |';
+ $send[] = '';
+ }
}
- $send[] = '';
-
return implode("\n", $send);
}
}
diff --git a/src/Output/XMLOutput.php b/src/Output/XMLOutput.php
--- a/src/Output/XMLOutput.php
+++ b/src/Output/XMLOutput.php
@@ -12,57 +12,66 @@
xmlwriter_set_indent($document, true);
xmlwriter_set_indent_string($document, ' ');
-
xmlwriter_start_document($document, '1.0', 'UTF-8');
xmlwriter_start_element($document, 'report');
xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $this->report->title);
- xmlwriter_end_attribute($document);
- foreach ($this->report->sections as $section) {
- xmlwriter_start_element($document, 'section');
- xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $section->title);
+ if ($this->report->sections || $this->report->properties
+ || $this->report->title) {
+
+ xmlwriter_text($document, $this->report->title);
xmlwriter_end_attribute($document);
- foreach ($section->entries as $entry) {
- xmlwriter_start_element($document, 'entry');
+ foreach ($this->report->sections as $section) {
+ xmlwriter_start_element($document, 'section');
xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, $entry->title);
+ xmlwriter_text($document, $section->title);
xmlwriter_end_attribute($document);
- xmlwriter_start_element($document, 'text');
- xmlwriter_text($document, $entry->text);
- xmlwriter_end_element($document);
+ foreach ($section->entries as $entry) {
+ xmlwriter_start_element($document, 'entry');
+
+ xmlwriter_start_attribute($document, 'title');
+ xmlwriter_text($document, $entry->title);
+ xmlwriter_end_attribute($document);
+
+ xmlwriter_start_element($document, 'text');
+ xmlwriter_text($document, $entry->text);
+ xmlwriter_end_element($document);
- xmlwriter_end_element($document);
+ xmlwriter_end_element($document);
+ }
+ xmlwriter_end_element($document); // section
}
- xmlwriter_end_element($document); // section
- }
- xmlwriter_start_element($document, 'data');
- xmlwriter_start_attribute($document, 'title');
- xmlwriter_text($document, "Properties");
- xmlwriter_end_attribute($document);
- foreach ($this->report->properties as $key => $value) {
- xmlwriter_start_element($document, 'entry');
+ if ($this->report->properties) {
- xmlwriter_start_element($document, 'key');
- xmlwriter_text($document, $key);
- xmlwriter_end_element($document);
+ xmlwriter_start_element($document, 'data');
+ xmlwriter_start_attribute($document, 'title');
+ xmlwriter_text($document, "Properties");
+ xmlwriter_end_attribute($document);
- xmlwriter_start_element($document, 'value');
- xmlwriter_text($document, $value);
- xmlwriter_end_element($document);
+ foreach ($this->report->properties as $key => $value) {
+ xmlwriter_start_element($document, 'entry');
- xmlwriter_end_element($document);
- }
- xmlwriter_end_element($document); // data
+ xmlwriter_start_element($document, 'key');
+ xmlwriter_text($document, $key);
+ xmlwriter_end_element($document);
+
+ xmlwriter_start_element($document, 'value');
+ xmlwriter_text($document, $value);
+ xmlwriter_end_element($document);
- xmlwriter_end_element($document); // report
+ xmlwriter_end_element($document);
+ }
+ xmlwriter_end_element($document); // data
+
+ xmlwriter_end_element($document);// report
+ }
+ }
xmlwriter_end_document($document);
return xmlwriter_output_memory($document);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 16:33 (11 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2315273
Default Alt Text
D2538.id6440.diff (11 KB)
Attached To
Mode
D2538: Handle incomplete reports
Attached
Detach File
Event Timeline
Log In to Comment