Replace od*_buffer globals with properties
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
159082f283
commit
676bef3ab7
@ -12261,24 +12261,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportMediawiki.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and ''\</office…'' results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOds.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and ''\<\?xml version\="1\.0"…'' results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOds.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and non\-falsy\-string results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOds.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\DatabaseInterface\:
|
||||
@ -12348,30 +12330,6 @@ parameters:
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and ''\</office\:text\>\<…'' results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and ''\<\?xml version\="1\.0"…'' results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and ''\<text\:h text…'' results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 1
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '#^Binary operation "\.\=" between mixed and non\-falsy\-string results in an error\.$#'
|
||||
identifier: assignOp.invalid
|
||||
count: 8
|
||||
path: src/Plugins/Export/ExportOdt.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\DatabaseInterface\:
|
||||
@ -21849,12 +21807,6 @@ parameters:
|
||||
count: 1
|
||||
path: tests/unit/Plugins/Export/ExportOdtTest.php
|
||||
|
||||
-
|
||||
message: '#^Parameter \#2 \$haystack of static method PHPUnit\\Framework\\Assert\:\:assertStringContainsString\(\) expects string, mixed given\.$#'
|
||||
identifier: argument.type
|
||||
count: 11
|
||||
path: tests/unit/Plugins/Export/ExportOdtTest.php
|
||||
|
||||
-
|
||||
message: '''
|
||||
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:
|
||||
|
||||
@ -13199,11 +13199,6 @@
|
||||
<code><![CDATA[$config->selectedServer]]></code>
|
||||
</InvalidPropertyAssignmentValue>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Export/ExportOdsTest.php">
|
||||
<TypeDoesNotContainType>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Export/ExportOdtTest.php">
|
||||
<DeprecatedMethod>
|
||||
<code><![CDATA[Config::getInstance()]]></code>
|
||||
@ -13217,12 +13212,6 @@
|
||||
<MixedAssignment>
|
||||
<code><![CDATA[$result]]></code>
|
||||
</MixedAssignment>
|
||||
<TypeDoesNotContainType>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
<code><![CDATA[assertSame]]></code>
|
||||
</TypeDoesNotContainType>
|
||||
</file>
|
||||
<file src="tests/unit/Plugins/Export/ExportSqlTest.php">
|
||||
<DeprecatedMethod>
|
||||
|
||||
@ -78,8 +78,6 @@
|
||||
maxsize: string,
|
||||
memory_limit: int,
|
||||
message: PhpMyAdmin\Message,
|
||||
ods_buffer: string,
|
||||
odt_buffer: string,
|
||||
offset: int,
|
||||
old_tz: string,
|
||||
onfly_compression: bool,
|
||||
|
||||
@ -32,9 +32,11 @@ use function strtotime;
|
||||
*/
|
||||
class ExportOds extends ExportPlugin
|
||||
{
|
||||
public string $buffer = '';
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
$GLOBALS['ods_buffer'] = '';
|
||||
$this->buffer = '';
|
||||
}
|
||||
|
||||
/** @psalm-return non-empty-lowercase-string */
|
||||
@ -86,7 +88,7 @@ class ExportOds extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$GLOBALS['ods_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
|
||||
$this->buffer .= '<?xml version="1.0" encoding="utf-8"?>'
|
||||
. '<office:document-content '
|
||||
. OpenDocument::NS . ' office:version="1.0">'
|
||||
. '<office:automatic-styles>'
|
||||
@ -140,12 +142,12 @@ class ExportOds extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$GLOBALS['ods_buffer'] .= '</office:spreadsheet></office:body></office:document-content>';
|
||||
$this->buffer .= '</office:spreadsheet></office:body></office:document-content>';
|
||||
|
||||
return $this->export->outputHandler(
|
||||
OpenDocument::create(
|
||||
'application/vnd.oasis.opendocument.spreadsheet',
|
||||
$GLOBALS['ods_buffer'],
|
||||
$this->buffer,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -205,30 +207,30 @@ class ExportOds extends ExportPlugin
|
||||
$fieldsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($tableAlias) . '">';
|
||||
$this->buffer .= '<table:table table:name="' . htmlspecialchars($tableAlias) . '">';
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['ods_columns'])) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-row>';
|
||||
$this->buffer .= '<table:table-row>';
|
||||
foreach ($fieldsMeta as $field) {
|
||||
$colAs = $field->name;
|
||||
if (! empty($aliases[$db]['tables'][$table]['columns'][$colAs])) {
|
||||
$colAs = $aliases[$db]['tables'][$table]['columns'][$colAs];
|
||||
}
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($colAs)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
}
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
// Format the data
|
||||
while ($row = $result->fetchRow()) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-row>';
|
||||
$this->buffer .= '<table:table-row>';
|
||||
/** @infection-ignore-all */
|
||||
for ($j = 0; $j < $fieldsCnt; $j++) {
|
||||
if ($fieldsMeta[$j]->isMappedTypeGeometry) {
|
||||
@ -237,18 +239,18 @@ class ExportOds extends ExportPlugin
|
||||
}
|
||||
|
||||
if (! isset($row[$j])) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($GLOBALS['ods_null'])
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif ($fieldsMeta[$j]->isBinary && $fieldsMeta[$j]->isBlob) {
|
||||
// ignore BLOB
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p></text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif ($fieldsMeta[$j]->isType(FieldMetadata::TYPE_DATE)) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date"'
|
||||
$this->buffer .= '<table:table-cell office:value-type="date"'
|
||||
. ' office:date-value="'
|
||||
. date('Y-m-d', strtotime($row[$j]))
|
||||
. '" table:style-name="DateCell">'
|
||||
@ -257,7 +259,7 @@ class ExportOds extends ExportPlugin
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif ($fieldsMeta[$j]->isType(FieldMetadata::TYPE_TIME)) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time"'
|
||||
$this->buffer .= '<table:table-cell office:value-type="time"'
|
||||
. ' office:time-value="'
|
||||
. date('\P\TH\Hi\Ms\S', strtotime($row[$j]))
|
||||
. '" table:style-name="TimeCell">'
|
||||
@ -266,7 +268,7 @@ class ExportOds extends ExportPlugin
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif ($fieldsMeta[$j]->isType(FieldMetadata::TYPE_DATETIME)) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date"'
|
||||
$this->buffer .= '<table:table-cell office:value-type="date"'
|
||||
. ' office:date-value="'
|
||||
. date('Y-m-d\TH:i:s', strtotime($row[$j]))
|
||||
. '" table:style-name="DateTimeCell">'
|
||||
@ -277,14 +279,14 @@ class ExportOds extends ExportPlugin
|
||||
} elseif (
|
||||
$fieldsMeta[$j]->isNumeric
|
||||
) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float"'
|
||||
$this->buffer .= '<table:table-cell office:value-type="float"'
|
||||
. ' office:value="' . $row[$j] . '" >'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($row[$j])
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} else {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($row[$j])
|
||||
. '</text:p>'
|
||||
@ -292,10 +294,10 @@ class ExportOds extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '</table:table>';
|
||||
$this->buffer .= '</table:table>';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -35,15 +35,14 @@ use function str_replace;
|
||||
*/
|
||||
class ExportOdt extends ExportPlugin
|
||||
{
|
||||
public string $buffer = '';
|
||||
private bool $doRelation = false;
|
||||
|
||||
private bool $doMime = false;
|
||||
|
||||
private bool $doComments = false;
|
||||
|
||||
protected function init(): void
|
||||
{
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->buffer = '';
|
||||
}
|
||||
|
||||
/** @psalm-return non-empty-lowercase-string */
|
||||
@ -150,7 +149,7 @@ class ExportOdt extends ExportPlugin
|
||||
*/
|
||||
public function exportHeader(): bool
|
||||
{
|
||||
$GLOBALS['odt_buffer'] .= '<?xml version="1.0" encoding="utf-8"?' . '>'
|
||||
$this->buffer .= '<?xml version="1.0" encoding="utf-8"?>'
|
||||
. '<office:document-content '
|
||||
. OpenDocument::NS . ' office:version="1.0">'
|
||||
. '<office:body>'
|
||||
@ -164,11 +163,11 @@ class ExportOdt extends ExportPlugin
|
||||
*/
|
||||
public function exportFooter(): bool
|
||||
{
|
||||
$GLOBALS['odt_buffer'] .= '</office:text></office:body></office:document-content>';
|
||||
$this->buffer .= '</office:text></office:body></office:document-content>';
|
||||
|
||||
return $this->export->outputHandler(OpenDocument::create(
|
||||
'application/vnd.oasis.opendocument.text',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->buffer,
|
||||
));
|
||||
}
|
||||
|
||||
@ -184,7 +183,7 @@ class ExportOdt extends ExportPlugin
|
||||
$dbAlias = $db;
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="1" text:style-name="Heading_1"'
|
||||
$this->buffer .= '<text:h text:outline-level="1" text:style-name="Heading_1"'
|
||||
. ' text:is-list-header="true">'
|
||||
. __('Database') . ' ' . htmlspecialchars($dbAlias)
|
||||
. '</text:h>';
|
||||
@ -236,12 +235,12 @@ class ExportOdt extends ExportPlugin
|
||||
$fieldsCnt = $result->numFields();
|
||||
$fieldsMeta = $dbi->getFieldsMeta($result);
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">';
|
||||
$tableAlias != ''
|
||||
? $GLOBALS['odt_buffer'] .= __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias)
|
||||
: $GLOBALS['odt_buffer'] .= __('Dumping data for query result');
|
||||
$GLOBALS['odt_buffer'] .= '</text:h>'
|
||||
? $this->buffer .= __('Dumping data for table') . ' ' . htmlspecialchars($tableAlias)
|
||||
: $this->buffer .= __('Dumping data for query result');
|
||||
$this->buffer .= '</text:h>'
|
||||
. '<table:table'
|
||||
. ' table:name="' . htmlspecialchars($tableAlias) . '_structure">'
|
||||
. '<table:table-column'
|
||||
@ -249,26 +248,26 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['odt_columns'])) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>';
|
||||
$this->buffer .= '<table:table-row>';
|
||||
foreach ($fieldsMeta as $field) {
|
||||
$colAs = $field->name;
|
||||
if (! empty($aliases[$db]['tables'][$table]['columns'][$colAs])) {
|
||||
$colAs = $aliases[$db]['tables'][$table]['columns'][$colAs];
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($colAs)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
// Format the data
|
||||
while ($row = $result->fetchRow()) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>';
|
||||
$this->buffer .= '<table:table-row>';
|
||||
/** @infection-ignore-all */
|
||||
for ($j = 0; $j < $fieldsCnt; $j++) {
|
||||
if ($fieldsMeta[$j]->isMappedTypeGeometry) {
|
||||
@ -277,27 +276,27 @@ class ExportOdt extends ExportPlugin
|
||||
}
|
||||
|
||||
if (! isset($row[$j])) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($GLOBALS['odt_null'])
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif ($fieldsMeta[$j]->isBinary && $fieldsMeta[$j]->isBlob) {
|
||||
// ignore BLOB
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p></text:p>'
|
||||
. '</table:table-cell>';
|
||||
} elseif (
|
||||
$fieldsMeta[$j]->isNumeric
|
||||
) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float"'
|
||||
$this->buffer .= '<table:table-cell office:value-type="float"'
|
||||
. ' office:value="' . $row[$j] . '" >'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($row[$j])
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} else {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($row[$j])
|
||||
. '</text:p>'
|
||||
@ -305,10 +304,10 @@ class ExportOdt extends ExportPlugin
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
$this->buffer .= '</table:table>';
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -351,13 +350,13 @@ class ExportOdt extends ExportPlugin
|
||||
/**
|
||||
* Displays the table structure
|
||||
*/
|
||||
$GLOBALS['odt_buffer'] .= '<table:table table:name="'
|
||||
$this->buffer .= '<table:table table:name="'
|
||||
. htmlspecialchars($viewAlias) . '_data">';
|
||||
$columnsCnt = 4;
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-column'
|
||||
$this->buffer .= '<table:table-column'
|
||||
. ' table:number-columns-repeated="' . $columnsCnt . '"/>';
|
||||
/* Header */
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>'
|
||||
$this->buffer .= '<table:table-row>'
|
||||
. '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Column') . '</text:p>'
|
||||
. '</table:table-cell>'
|
||||
@ -379,11 +378,11 @@ class ExportOdt extends ExportPlugin
|
||||
$colAs = $aliases[$db]['tables'][$view]['columns'][$colAs];
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column, $colAs);
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= $this->formatOneColumnDefinition($column, $colAs);
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
$this->buffer .= '</table:table>';
|
||||
|
||||
return '';
|
||||
}
|
||||
@ -416,7 +415,7 @@ class ExportOdt extends ExportPlugin
|
||||
/**
|
||||
* Displays the table structure
|
||||
*/
|
||||
$GLOBALS['odt_buffer'] .= '<table:table table:name="'
|
||||
$this->buffer .= '<table:table table:name="'
|
||||
. htmlspecialchars($tableAlias) . '_structure">';
|
||||
$columnsCnt = 4;
|
||||
if ($this->doRelation && $foreigners !== []) {
|
||||
@ -431,10 +430,10 @@ class ExportOdt extends ExportPlugin
|
||||
$columnsCnt++;
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-column'
|
||||
$this->buffer .= '<table:table-column'
|
||||
. ' table:number-columns-repeated="' . $columnsCnt . '"/>';
|
||||
/* Header */
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>'
|
||||
$this->buffer .= '<table:table-row>'
|
||||
. '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Column') . '</text:p>'
|
||||
. '</table:table-cell>'
|
||||
@ -448,26 +447,26 @@ class ExportOdt extends ExportPlugin
|
||||
. '<text:p>' . __('Default') . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
if ($this->doRelation && $foreigners !== []) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Links to') . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
}
|
||||
|
||||
if ($this->doComments) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Comments') . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$comments = $this->relation->getComments($db, $table);
|
||||
}
|
||||
|
||||
if ($this->doMime && $relationParameters->browserTransformationFeature !== null) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>' . __('Media type') . '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$mimeMap = $this->transformations->getMime($db, $table, true);
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
|
||||
$columns = $dbi->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
@ -476,7 +475,7 @@ class ExportOdt extends ExportPlugin
|
||||
$colAs = $aliases[$db]['tables'][$table]['columns'][$colAs];
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column, $colAs);
|
||||
$this->buffer .= $this->formatOneColumnDefinition($column, $colAs);
|
||||
if ($this->doRelation && $foreigners !== []) {
|
||||
$foreigner = $this->relation->searchColumnInForeigners($foreigners, $fieldName);
|
||||
if ($foreigner) {
|
||||
@ -491,7 +490,7 @@ class ExportOdt extends ExportPlugin
|
||||
}
|
||||
|
||||
$relation = htmlspecialchars($rtable . ' (' . $rfield . ')');
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($relation)
|
||||
. '</text:p>'
|
||||
@ -501,13 +500,13 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
if ($this->doComments) {
|
||||
if (isset($comments[$fieldName])) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($comments[$fieldName])
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} else {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p></text:p>'
|
||||
. '</table:table-cell>';
|
||||
}
|
||||
@ -515,7 +514,7 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
if ($this->doMime && $relationParameters->browserTransformationFeature !== null) {
|
||||
if (isset($mimeMap[$fieldName])) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars(
|
||||
str_replace('_', '/', $mimeMap[$fieldName]['mimetype']),
|
||||
@ -523,16 +522,16 @@ class ExportOdt extends ExportPlugin
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
} else {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p></text:p>'
|
||||
. '</table:table-cell>';
|
||||
}
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
$this->buffer .= '</table:table>';
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -545,7 +544,7 @@ class ExportOdt extends ExportPlugin
|
||||
*/
|
||||
protected function getTriggers(string $table, array $triggers): string
|
||||
{
|
||||
$GLOBALS['odt_buffer'] .= '<table:table'
|
||||
$this->buffer .= '<table:table'
|
||||
. ' table:name="' . htmlspecialchars($table) . '_triggers">'
|
||||
. '<table:table-column'
|
||||
. ' table:number-columns-repeated="4"/>'
|
||||
@ -565,33 +564,33 @@ class ExportOdt extends ExportPlugin
|
||||
. '</table:table-row>';
|
||||
|
||||
foreach ($triggers as $trigger) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-row>';
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($trigger->name->getName())
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($trigger->timing->value)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($trigger->event->value)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">'
|
||||
$this->buffer .= '<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars($trigger->statement)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
$this->buffer .= '</table:table-row>';
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
$this->buffer .= '</table:table>';
|
||||
|
||||
return $GLOBALS['odt_buffer'];
|
||||
return $this->buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -609,7 +608,7 @@ class ExportOdt extends ExportPlugin
|
||||
$this->initAlias($aliases, $dbAlias, $tableAlias);
|
||||
switch ($exportMode) {
|
||||
case 'create_table':
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">'
|
||||
. __('Table structure for table') . ' ' .
|
||||
htmlspecialchars($tableAlias)
|
||||
@ -619,7 +618,7 @@ class ExportOdt extends ExportPlugin
|
||||
case 'triggers':
|
||||
$triggers = Triggers::getDetails(DatabaseInterface::getInstance(), $db, $table);
|
||||
if ($triggers !== []) {
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">'
|
||||
. __('Triggers') . ' '
|
||||
. htmlspecialchars($tableAlias)
|
||||
@ -629,7 +628,7 @@ class ExportOdt extends ExportPlugin
|
||||
|
||||
break;
|
||||
case 'create_view':
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">'
|
||||
. __('Structure for view') . ' '
|
||||
. htmlspecialchars($tableAlias)
|
||||
@ -637,7 +636,7 @@ class ExportOdt extends ExportPlugin
|
||||
$this->getTableDef($db, $table, $aliases);
|
||||
break;
|
||||
case 'stand_in':
|
||||
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
$this->buffer .= '<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
. ' text:is-list-header="true">'
|
||||
. __('Stand-in structure for view') . ' '
|
||||
. htmlspecialchars($tableAlias)
|
||||
|
||||
@ -171,23 +171,24 @@ class ExportOdsTest extends AbstractTestCase
|
||||
|
||||
public function testExportHeader(): void
|
||||
{
|
||||
self::assertArrayHasKey('ods_buffer', $GLOBALS);
|
||||
|
||||
self::assertTrue(
|
||||
$this->object->exportHeader(),
|
||||
$this->object->buffer = '';
|
||||
self::assertTrue($this->object->exportHeader());
|
||||
self::assertStringStartsWith(
|
||||
'<?xml version="1.0" encoding="utf-8"?><office:document-content',
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
public function testExportFooter(): void
|
||||
{
|
||||
$GLOBALS['ods_buffer'] = 'header';
|
||||
$this->object->buffer = 'header';
|
||||
self::assertTrue($this->object->exportFooter());
|
||||
$output = $this->getActualOutputForAssertion();
|
||||
self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output));
|
||||
self::assertStringContainsString('header', $GLOBALS['ods_buffer']);
|
||||
self::assertStringContainsString('</office:spreadsheet>', $GLOBALS['ods_buffer']);
|
||||
self::assertStringContainsString('</office:body>', $GLOBALS['ods_buffer']);
|
||||
self::assertStringContainsString('</office:document-content>', $GLOBALS['ods_buffer']);
|
||||
self::assertStringContainsString('header', $this->object->buffer);
|
||||
self::assertStringContainsString('</office:spreadsheet>', $this->object->buffer);
|
||||
self::assertStringContainsString('</office:body>', $this->object->buffer);
|
||||
self::assertStringContainsString('</office:document-content>', $this->object->buffer);
|
||||
}
|
||||
|
||||
public function testExportDBHeader(): void
|
||||
@ -284,7 +285,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
'office:value="a&b" ><text:p>a&b</text:p></table:table-cell>' .
|
||||
'<table:table-cell office:value-type="string"><text:p><</text:p>' .
|
||||
'</table:table-cell></table:table-row></table:table>',
|
||||
$GLOBALS['ods_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
@ -347,7 +348,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
'-cell><table:table-cell office:value-type="string"><text:p>' .
|
||||
'fnam/<e2</text:p></table:table-cell></table:table-row>' .
|
||||
'</table:table>',
|
||||
$GLOBALS['ods_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// with no row count
|
||||
@ -381,7 +382,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
$GLOBALS['mediawiki_caption'] = true;
|
||||
$GLOBALS['mediawiki_headers'] = true;
|
||||
$GLOBALS['ods_null'] = '&';
|
||||
$GLOBALS['ods_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
|
||||
self::assertTrue(
|
||||
$this->object->exportData(
|
||||
@ -393,7 +394,7 @@ class ExportOdsTest extends AbstractTestCase
|
||||
|
||||
self::assertSame(
|
||||
'<table:table table:name="table"><table:table-row></table:table-row></table:table>',
|
||||
$GLOBALS['ods_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -312,34 +312,34 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$this->object->exportHeader(),
|
||||
);
|
||||
|
||||
self::assertStringContainsString('<office:document-content', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('office:version', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('<office:document-content', $this->object->buffer);
|
||||
self::assertStringContainsString('office:version', $this->object->buffer);
|
||||
}
|
||||
|
||||
public function testExportFooter(): void
|
||||
{
|
||||
$GLOBALS['odt_buffer'] = 'header';
|
||||
$this->object->buffer = 'header';
|
||||
self::assertTrue($this->object->exportFooter());
|
||||
$output = $this->getActualOutputForAssertion();
|
||||
self::assertMatchesRegularExpression('/^504b.*636f6e74656e742e786d6c/', bin2hex($output));
|
||||
self::assertStringContainsString('header', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('header', $this->object->buffer);
|
||||
self::assertStringContainsString(
|
||||
'</office:text></office:body></office:document-content>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
public function testExportDBHeader(): void
|
||||
{
|
||||
$GLOBALS['odt_buffer'] = 'header';
|
||||
$this->object->buffer = 'header';
|
||||
|
||||
self::assertTrue(
|
||||
$this->object->exportDBHeader('d&b'),
|
||||
);
|
||||
|
||||
self::assertStringContainsString('header', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('header', $this->object->buffer);
|
||||
|
||||
self::assertStringContainsString('Database d&b</text:h>', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('Database d&b</text:h>', $this->object->buffer);
|
||||
}
|
||||
|
||||
public function testExportDBFooter(): void
|
||||
@ -416,7 +416,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
'</table:table-cell><table:table-cell office:value-type="string">' .
|
||||
'<text:p>a&b</text:p></table:table-cell></table:table-row>' .
|
||||
'</table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
@ -479,7 +479,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
'value-type="string"><text:p>fna\"me</text:p></table:table-cell>' .
|
||||
'<table:table-cell office:value-type="string"><text:p>fnam/<e2' .
|
||||
'</text:p></table:table-cell></table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// with no row count
|
||||
@ -513,7 +513,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$GLOBALS['mediawiki_caption'] = true;
|
||||
$GLOBALS['mediawiki_headers'] = true;
|
||||
$GLOBALS['odt_null'] = '&';
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
|
||||
self::assertTrue(
|
||||
$this->object->exportData(
|
||||
@ -529,7 +529,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
'<table:table table:name="table_structure"><table:table-column ' .
|
||||
'table:number-columns-repeated="0"/><table:table-row>' .
|
||||
'</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
@ -565,7 +565,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
. '<table:table-cell office:value-type="string"><text:p>No</text:p></table:table-cell>'
|
||||
. '<table:table-cell office:value-type="string"><text:p>NULL</text:p></table:table-cell>'
|
||||
. '</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
@ -636,17 +636,17 @@ class ExportOdtTest extends AbstractTestCase
|
||||
|
||||
self::assertStringContainsString(
|
||||
'<table:table table:name="_structure"><table:table-column table:number-columns-repeated="6"/>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
self::assertStringContainsString(
|
||||
'<table:table-cell office:value-type="string"><text:p>Comments</text:p></table:table-cell>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
self::assertStringContainsString(
|
||||
'<table:table-cell office:value-type="string"><text:p>Media type</text:p></table:table-cell>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
self::assertStringContainsString(
|
||||
@ -654,7 +654,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
'<text:p></text:p></table:table-cell><table:table-cell office:value-' .
|
||||
'type="string"><text:p>Test<</text:p></table:table-cell>' .
|
||||
'</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// case 2
|
||||
@ -692,7 +692,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
|
||||
DatabaseInterface::$instance = $dbi;
|
||||
$this->object->relation = new Relation($dbi);
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
$relationParameters = RelationParameters::fromArray([
|
||||
'relwork' => true,
|
||||
'commwork' => true,
|
||||
@ -705,7 +705,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
|
||||
self::assertTrue($this->object->getTableDef('database', ''));
|
||||
|
||||
self::assertStringContainsString('<text:p>ftable (ffield)</text:p>', $GLOBALS['odt_buffer']);
|
||||
self::assertStringContainsString('<text:p>ftable (ffield)</text:p>', $this->object->buffer);
|
||||
}
|
||||
|
||||
public function testGetTriggers(): void
|
||||
@ -724,7 +724,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
$method = new ReflectionMethod(ExportOdt::class, 'getTriggers');
|
||||
$result = $method->invoke($this->object, 'ta<ble', $triggers);
|
||||
|
||||
self::assertSame($result, $GLOBALS['odt_buffer']);
|
||||
self::assertSame($result, $this->object->buffer);
|
||||
|
||||
self::assertStringContainsString('<table:table table:name="ta<ble_triggers">', $result);
|
||||
|
||||
@ -768,11 +768,11 @@ class ExportOdtTest extends AbstractTestCase
|
||||
. '<table:table-cell office:value-type="string"><text:p>No</text:p></table:table-cell>'
|
||||
. '<table:table-cell office:value-type="string"><text:p>NULL</text:p></table:table-cell>'
|
||||
. '</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// case 2
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
|
||||
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'triggers'));
|
||||
|
||||
@ -790,11 +790,11 @@ class ExportOdtTest extends AbstractTestCase
|
||||
. '<table:table-cell office:value-type="string"><text:p>INSERT</text:p></table:table-cell>'
|
||||
. '<table:table-cell office:value-type="string"><text:p>BEGIN END</text:p></table:table-cell>'
|
||||
. '</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// case 3
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
|
||||
$this->dummyDbi->addSelectDb('test_db');
|
||||
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'create_view'));
|
||||
@ -824,12 +824,12 @@ class ExportOdtTest extends AbstractTestCase
|
||||
. '<table:table-cell office:value-type="string"><text:p>No</text:p></table:table-cell>'
|
||||
. '<table:table-cell office:value-type="string"><text:p>NULL</text:p></table:table-cell>'
|
||||
. '</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
|
||||
// case 4
|
||||
$this->dummyDbi->addSelectDb('test_db');
|
||||
$GLOBALS['odt_buffer'] = '';
|
||||
$this->object->buffer = '';
|
||||
self::assertTrue($this->object->exportStructure('test_db', 'test_table', 'stand_in'));
|
||||
$this->dummyDbi->assertAllSelectsConsumed();
|
||||
|
||||
@ -857,7 +857,7 @@ class ExportOdtTest extends AbstractTestCase
|
||||
. '<table:table-cell office:value-type="string"><text:p>No</text:p></table:table-cell>'
|
||||
. '<table:table-cell office:value-type="string"><text:p>NULL</text:p></table:table-cell>'
|
||||
. '</table:table-row></table:table>',
|
||||
$GLOBALS['odt_buffer'],
|
||||
$this->object->buffer,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user