mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
mlanthaler: Bugfix: Class created invalid HTML (<td>...</t>).
(merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42020 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
8d89050618
commit
db42713e1c
@ -1,4 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
/**
|
||||
* Displays complex reports based on the list of tables and fields provided to
|
||||
* the object.
|
||||
@ -39,10 +41,12 @@ class ReportField extends FormField{
|
||||
$this->fields = $this->expandWildcards( $fields );
|
||||
}
|
||||
|
||||
|
||||
public function setExport($export){
|
||||
$this->export = $export;
|
||||
}
|
||||
|
||||
|
||||
protected function expandWildcards( $fields ) {
|
||||
|
||||
$newFields = array();
|
||||
@ -56,6 +60,7 @@ class ReportField extends FormField{
|
||||
return $newFields;
|
||||
}
|
||||
|
||||
|
||||
protected function expandWildcard( $field ) {
|
||||
list( $table, $column ) = $this->parseField( $field );
|
||||
|
||||
@ -65,8 +70,8 @@ class ReportField extends FormField{
|
||||
return $columns;
|
||||
}
|
||||
|
||||
function exportToCSV( $fileName ) {
|
||||
|
||||
function exportToCSV( $fileName ) {
|
||||
|
||||
$fileData = $this->columnheaders( 'csvRow', 'csvCell' ) . $this->datacells( 'csvRow', 'csvCell' );
|
||||
|
||||
@ -78,6 +83,7 @@ class ReportField extends FormField{
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
function FieldHolder() {
|
||||
Requirements::javascript("sapphire/javascript/ReportField.js");
|
||||
|
||||
@ -110,6 +116,7 @@ HTML;
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the HTML for the data cells for the current report.
|
||||
* This can be used externally via ajax as the report might be filtered per column.
|
||||
@ -149,6 +156,7 @@ HTML;
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the HTML for the headers of the columns.
|
||||
* Can also be called via ajax to reload the headers.
|
||||
@ -171,11 +179,13 @@ HTML;
|
||||
return $this->$rowCallBack( $html, null, null );
|
||||
}
|
||||
|
||||
|
||||
protected function getColumnsInTable( $table ) {
|
||||
$result = DB::query( "SELECT * FROM `$table` LIMIT 1" );
|
||||
return array_keys( $result->next() );
|
||||
}
|
||||
|
||||
|
||||
protected function parseField( $field ) {
|
||||
if( $field{0} == '!' )
|
||||
$field = substr( $field, 1 );
|
||||
@ -186,6 +196,7 @@ HTML;
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Joins the given record together with the extra information in the other tables.
|
||||
* This is only used in a situation in which the database can't do the join and I'll
|
||||
@ -225,6 +236,7 @@ HTML;
|
||||
return $completeRecord;*/
|
||||
}
|
||||
|
||||
|
||||
protected function joinFields( $object, $fields ) {
|
||||
$partialRecord = array();
|
||||
foreach( $fields as $field )
|
||||
@ -233,6 +245,7 @@ HTML;
|
||||
return $partialRecord;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sort the data in the cells
|
||||
*/
|
||||
@ -240,6 +253,7 @@ HTML;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the primary set of records for the cells. This returns a data object set.
|
||||
*/
|
||||
@ -276,27 +290,34 @@ HTML;
|
||||
return $query->execute();
|
||||
}
|
||||
|
||||
|
||||
function htmlHeaderCell( $value, $table, $column ) {
|
||||
return "<th>" . htmlentities( $value ) . "</th>";
|
||||
}
|
||||
|
||||
|
||||
function htmlTableCell( $value, $table, $column ) {
|
||||
return "<td>" . htmlentities( $value ) . "</t>";
|
||||
return "<td>" . htmlentities( $value ) . "</td>";
|
||||
}
|
||||
|
||||
|
||||
function htmlTableRow( $value, $table, $column ) {
|
||||
return "<tr>" . $value . "</tr>";
|
||||
}
|
||||
|
||||
|
||||
function csvCell( $value, $table, $column ) {
|
||||
return '"' . str_replace( '"', '""', $value ) . '",';
|
||||
}
|
||||
|
||||
|
||||
function csvRow( $value, $table, $column ) {
|
||||
return substr( $value, 0, strlen( $value ) - 1 )."\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Assisting class. Determines whether or not a column is hidden.
|
||||
* Not so helpful here, but we could overload it in other classes.
|
||||
@ -322,6 +343,8 @@ class ReportField_SimpleFilter extends Object {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This class instantiates an instance of the report field and receives ajax requests
|
||||
* to the report field.
|
||||
@ -357,8 +380,11 @@ class ReportField_Controller extends Controller {
|
||||
$reportField->exportToCSV( $fileName );
|
||||
}
|
||||
|
||||
|
||||
function Link() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user