From 1ba9c9a90a2d4b4ee9ba68e6abe44ba97fe255af Mon Sep 17 00:00:00 2001
From: Sean Harvey
Date: Fri, 12 Sep 2008 04:58:06 +0000
Subject: [PATCH] API CHANGE Moved DataReport and SQLReport into the ecommerce
module, since this is the only place it is used, plus it's going to be
deprecated soon anyway
BUGFIX Removed DataReport.js calls in LeftAndMain until we figure out a better way of doing
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62325 467b73ca-7a2a-4603-9d3b-597d59a354a9
---
forms/DataReport.php | 591 ---------------------------------------
forms/SQLReport.php | 25 --
javascript/DataReport.js | 19 --
lang/en_US.php | 1 -
4 files changed, 636 deletions(-)
delete mode 100755 forms/DataReport.php
delete mode 100755 forms/SQLReport.php
delete mode 100755 javascript/DataReport.js
diff --git a/forms/DataReport.php b/forms/DataReport.php
deleted file mode 100755
index c5eee150f..000000000
--- a/forms/DataReport.php
+++ /dev/null
@@ -1,591 +0,0 @@
-"Date->Nice")
- */
- protected $fieldCasting = array();
-
- /**
- * Construct a OrderReport.
- *
- * @param name Name of the data report
- * @param title Title of the data report as displayed in the CMS.
- * @param value The value of the data report as a form field, usually could be a empty string
- * @param form The form that the containing the date report, usually dose matter if set null
- * @param baseClass the base object that this report works oon
- * @param fieldMap A mapthat works out Header cell of report table and which content will be for the colums, using array of "$k=>$v"s
- * @param headFields If keys in fieldMap is numerical, header of the report table can be worked out here
- * @param filter The filter on the object for the report, usually this filter is "=" type filter for the database table field.
- * @param dateFilter The dateFitler on the object for the report, usually this filter is for time and works on Created using "Between ... And ..."
- * @param join The joined database table is put in this parameter
- * @param sort The sort clause will be made from this parameter
- */
- function __construct($name, $title, $value, $form, $baseClass, $fieldMap=null, $headFields=null, $filter=null, $dateFilter=null, $sort=null, $join=null) {
-
- $this->baseClass = $baseClass;
-
- //Work out $filters, $sort, $join, $filters need to be further processed in getRecords();
- if($filter) $this->filter = $filter;
-
- if($dateFilter) $this->dateFilter=$dateFilter;
- if($sort) $this->sort = $sort;
- if($join) $this->join = $join;
-
- //Work out $headFields, $dataFields
- if($fieldMap){
-
- if(is_array($fieldMap)){
- foreach($fieldMap as $k => $v){
- $fields[] = $v;
- if(!$headFields)
- $heads[] = $k;
- }
- }
- }
-
- if($fields)
- $this->dataFields = $fields;
-
- if(!$headFields)
- $this->headFields = $heads;
- else
- $this->headFields = $headFields;
-
- parent::__construct($name, $title, $value, $form);
- }
-
- /*protected function expandWildcards($fieldMap){
- $records = $this->getRecords();
- if($records){
- foreach($records as $record){
- Debug::show($record);
- die('here');
- }
- }
- }*/
-
- /**
- * @todo: to set export flag to be $export
- */
- public function setExport($export){
- $this->export = $export;
- }
-
- /**
- * Todo: to export the reported table as a CSV
- */
- function exportToCSV( $fileName ) {
- $fileData = $this->columnheaders( 'csvRow', 'csvHeadCell' ) . $this->datacells('csvRow', 'csvDataCell' );
- HTTP::sendFileToBrowser($fileData, $fileName);
- }
-
- /**
- * @todo: to overwrite its parent's FieldHolder, the returned HTML
section contains the reported Table and a export button.
- */
- function FieldHolder() {
- //Requirements::javascript( "sapphire/javascript/DataReport.js" );
-
- $reportList = $this->htmlReportList();
- $exportButton = $this->htmlExportButton();
-
- return <<
-
- $reportList
- $exportButton
-
-HTML
-;
- }
-
- /**
- * @todo: to return a export button in HTML Style if $this->export flag is true (it defaults as true)
- */
- protected function htmlExportButton(){
- $idexport = $this->id() . '_exportToCSV';
- $idtype = $this->id() . '_Type';
- $class = $this->class;
- if($this->export){
- $value = _t('DataReport.EXPORTCSV', 'Export to CSV');
- $exportButton =<<
-
-HTML
-;
- }else{
- $exportButton = "";
- }
-
- return $exportButton;
- }
-
- /**
- *Todo: to return block of HTML code, containing a table wrapped with a
section for Ajax Updator loading the table inside.
- */
- protected function htmlReportList(){
-
-
- $table = $this->htmlReportTable();
- // display the table of results
- $html = <<
- $table
-
-HTML;
- return $html;
-}
-
- /**
- *Todo: return the reported table in HTML format
- */
- protected function htmlReportTable(){
- $headerHTML = $this->columnheaders();
- $dataCellHTML = $this->datacells();
-
- return <<
-
- $headerHTML
-
-
- $dataCellHTML
-
-
-HTML
-;
- }
-
-
- /**
- * @todo: Returns the HTML for the headers of the columns.
- */
- protected function columnheaders( $rowCallBack = 'htmlTableRow', $cellCallBack = 'htmlTableHeadCell' ) {
- $html = "";
- foreach( $this->headFields as $field ) {
- $html .= $this->$cellCallBack($field);
- }
- foreach( $this->extraFields as $fieldHeader => $fieldContent ) {
- $html .= $this->$cellCallBack($fieldHeader);
- }
- return $this->$rowCallBack($html);
- }
-
- /**
- *Todo: Returns the HTML for the body of the reported table, excluding table header
- * @param rowCallBack: the function name for how the rows are formated
- * @param cellCallBack: the function name for how the cells are formated
- */
- protected function datacells($rowCallBack = 'htmlTableRow', $cellCallBack = 'htmlTableDataCell' ) {
- $records = $this->getRecords();
-
- $body = "";
- if($records){
-
- foreach($records as $record){
- $html = "";
- $fieldInd = 0;
- foreach( $this->dataFields as $field ) {
- $html .= $this->$cellCallBack($record, $field, $fieldInd);
- $fieldInd++;
- }
- foreach( $this->extraFields as $fieldHeader => $fieldContent ) {
- $html .= $this->htmlTableExtraDataCell($record, $fieldContent, $fieldInd);
- }
- $row = $this->$rowCallBack($html);
- $body .= $row;
- }
- }
- return $body;
- }
-
- /**
- * @todo: Return the HTML for one cell of the table header
- */
- function htmlTableHeadCell($value) {
- return "
" . htmlentities( $value ) . "
";
- }
-
- /**
- * @todo: Return one cell of the table header in csv format
- */
- function csvHeadCell($value) {
- return $this->csvCell( $value );
- }
-
- /**
- * @todo: Return the HTML for one cell of one row of the table
- */
- function htmlTableDataCell($record, $field, $fieldIndex=null){
- $value = $this->getRecordFieldValue($record, $field);
-
- return "