mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-56046 dataformat_*: convert core plugins
This commit is contained in:
parent
ce3beb267c
commit
eb26be5b39
@ -42,11 +42,9 @@ class writer extends \core\dataformat\base {
|
||||
public $extension = ".html";
|
||||
|
||||
/**
|
||||
* Write the start of the format
|
||||
*
|
||||
* @param array $columns
|
||||
* Write the start of the output
|
||||
*/
|
||||
public function write_header($columns) {
|
||||
public function start_output() {
|
||||
echo "<!DOCTYPE html><html>";
|
||||
echo \html_writer::tag('title', $this->filename);
|
||||
echo "<style>
|
||||
@ -75,9 +73,16 @@ table {
|
||||
margin: auto;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<table border=1 cellspacing=0 cellpadding=3>
|
||||
";
|
||||
<body>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the start of the sheet we will be adding data to.
|
||||
*
|
||||
* @param array $columns
|
||||
*/
|
||||
public function start_sheet($columns) {
|
||||
echo "<table border=1 cellspacing=0 cellpadding=3>";
|
||||
echo \html_writer::start_tag('tr');
|
||||
foreach ($columns as $k => $v) {
|
||||
echo \html_writer::tag('th', $v);
|
||||
@ -100,12 +105,18 @@ table {
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the end of the format
|
||||
* Write the end of the sheet containing the data.
|
||||
*
|
||||
* @param array $columns
|
||||
*/
|
||||
public function write_footer($columns) {
|
||||
echo "</table></body></html>";
|
||||
public function close_sheet($columns) {
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the end of the sheet containing the data.
|
||||
*/
|
||||
public function close_output() {
|
||||
echo "</body></html>";
|
||||
}
|
||||
}
|
||||
|
@ -41,12 +41,31 @@ class writer extends \core\dataformat\base {
|
||||
/** @var $extension */
|
||||
public $extension = ".json";
|
||||
|
||||
/** @var $hasstarted */
|
||||
public $sheetstarted = false;
|
||||
|
||||
/** @var $sheetdatadded */
|
||||
public $sheetdatadded = false;
|
||||
|
||||
/**
|
||||
* Write the start of the format
|
||||
* Write the start of the file.
|
||||
*/
|
||||
public function start_output() {
|
||||
echo "[";
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the start of the sheet we will be adding data to.
|
||||
*
|
||||
* @param array $columns
|
||||
*/
|
||||
public function write_header($columns) {
|
||||
public function start_sheet($columns) {
|
||||
if ($this->sheetstarted) {
|
||||
echo ",";
|
||||
} else {
|
||||
$this->sheetstarted = true;
|
||||
}
|
||||
$this->sheetdatadded = false;
|
||||
echo "[";
|
||||
}
|
||||
|
||||
@ -57,19 +76,28 @@ class writer extends \core\dataformat\base {
|
||||
* @param int $rownum
|
||||
*/
|
||||
public function write_record($record, $rownum) {
|
||||
if ($rownum) {
|
||||
if ($this->sheetdatadded) {
|
||||
echo ",";
|
||||
}
|
||||
|
||||
echo json_encode($record);
|
||||
|
||||
$this->sheetdatadded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the end of the format
|
||||
* Write the end of the sheet containing the data.
|
||||
*
|
||||
* @param array $columns
|
||||
*/
|
||||
public function write_footer($columns) {
|
||||
public function close_sheet($columns) {
|
||||
echo "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the end of the file.
|
||||
*/
|
||||
public function close_output() {
|
||||
echo "]";
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user