/** * Get the recordset to the data for the report * * @param array $filter Filter SQL and params * @param string $sort Sort SQL * @param string $limitfrom Limit from SQL * @param string $limitnum Limit number SQL * @return moodle_recordset */ public function get_recordset($filter = array(), $sort = '', $limitfrom = '', $limitnum = '') { global $DB; if (empty($filter)) { $filter = array('1 = 1', array()); } list($filtersql, $filterparams) = $filter; list($sql, $params) = $this->get_sql($this->table->get_sql_select(), $filtersql, $filterparams); if (!empty($sort)) { $sql .= "\nORDER BY {$sort}"; } $this->executedsql[] = array("{$sql}\nlimit {$limitfrom}, {$limitnum}", $params); return $DB->get_recordset_sql($sql, $params, $limitfrom, $limitnum); }
/** * Convert a mr_html_table into an array of html_table_row instances * * @param mr_html_table $table Instance * @return array */ protected function convert_to_htmlrows(mr_html_table $table) { $rows = $table->get_rows(); $columns = $table->get_columns(true); $suppress = array(); $htmlrows = array(); foreach ($rows as $row) { // Generate a html_table_row if ($row instanceof html_table_row) { $htmlrow = $row; } else { $htmlrow = new html_table_row(); foreach ($columns as $column) { $cell = $column->get_cell($row); if ($cell instanceof html_table_cell) { $htmlrow->cells[] = $cell; } else { $cell = new html_table_cell($cell); foreach ($column->get_config()->attributes as $name => $value) { if (property_exists($cell, $name)) { $cell->{$name} = $value; } else { $cell->attributes[$name] = $value; } } $htmlrow->cells[] = $cell; } } } // Apply column suppression to the row $position = -1; foreach ($columns as $column) { $position++; if (!$column->get_config()->suppress or !array_key_exists($position, $htmlrow->cells)) { continue; } $cell = $htmlrow->cells[$position]; if (isset($suppress[$position]) and $suppress[$position] == $cell->text) { $htmlrow->cells[$position]->text = ''; // Suppressed } else { // If a cell changes, reset suppression for all cells after it (left to right) if (isset($suppress[$position]) and $suppress[$position] != $cell->text) { foreach ($suppress as $key => $value) { if ($key > $position) { unset($suppress[$key]); } } } $suppress[$position] = $cell->text; } } $htmlrows[] = $htmlrow; } return $htmlrows; }