Changeset 57110
- Timestamp:
- 30/06/08 17:08:43 (2 months ago)
- Location:
- modules/sapphire/branches/roa
- Files:
-
- 3 modified
-
core/model/DataObject.php (modified) (1 diff)
-
forms/TableListField.php (modified) (10 diffs)
-
search/SearchContext.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/sapphire/branches/roa/core/model/DataObject.php
r56816 r57110 2590 2590 */ 2591 2591 public static $summary_fields = null; 2592 2593 /** 2594 * User defined permissions for search result table by ModelAdmin to act on. 2595 * Such as print search 2596 */ 2597 public static $results_permissions = null; 2592 2598 2593 2599 } -
modules/sapphire/branches/roa/forms/TableListField.php
r56413 r57110 173 173 174 174 /** 175 * @var array Specify custom escape for the fields, e.g. to escape all accurance of "\r", "\r\n" and "\n" of the field 176 * value, we need to set this field as array("\r"=>"", "\r\n"=>"", "\n"=>"") ; 177 * Example: setFieldEscape(array("\""=>"\"\"","\r"=>"", "\r\n"=>"", "\n"=>"") is needed for exporting the table to a .csv 178 * file 179 */ 180 public $fieldEscape = array(); 181 182 /** 175 183 * @var string 176 184 */ … … 319 327 $dataQuery = $this->getQuery(); 320 328 321 // we don't limit when doing certain actions 329 // we don't limit when doing certain actions T 322 330 if(!isset($_REQUEST['methodName']) || !in_array($_REQUEST['methodName'],array('printall','export'))) { 323 331 $dataQuery->limit(array( … … 342 350 $fieldItems = new DataObjectSet(); 343 351 if($items = $this->sourceItems()) foreach($items as $item) { 352 $fieldItem = new TableListField_Item($item, $this); 344 353 if($item) $fieldItems->push(new TableListField_Item($item, $this)); 345 354 } 346 347 355 return $fieldItems; 348 356 } … … 747 755 $this->totalCount = $record['TotalCount']; 748 756 } 749 750 757 return $this->totalCount; 751 758 } … … 790 797 791 798 /** 799 * Get the CSV separator character. Defaults to , 800 */ 801 function getCsvSeparator() { 802 return $this->csvSeparator; 803 } 804 805 /** 792 806 * Remove the header row from the CSV export 793 807 */ … … 819 833 $dataQuery = $this->getCsvQuery(); 820 834 $records = $dataQuery->execute(); 835 821 836 $sourceClass = $this->sourceClass; 822 837 $dataobject = new $sourceClass(); 823 838 $items = $dataobject->buildDataObjectSet($records, 'DataObjectSet'); 824 839 825 if($items) { 826 foreach($items as $item) { 827 $columnData = array(); 828 foreach($csvColumns as $columnName => $columnTitle) { 829 $tmpColumnData = "\"" . str_replace("\"", "\"\"", $item->$columnName) . "\""; 830 $tmpColumnData = str_replace(array("\r", "\n"), "", $tmpColumnData); 831 $columnData[] = $tmpColumnData; 832 } 833 $fileData .= implode($separator, $columnData); 834 $fileData .= "\n"; 835 } 840 $fieldItems = new DataObjectSet(); 841 842 if($items&&$items->count()) foreach($items as $item) { 843 $fieldItem = new TableListField_Item($item, $this); 844 if($item) $fieldItems->push(new TableListField_Item($item, $this)); 845 } 846 847 $this->setFieldFormatting(array()); 848 $this->setFieldEscape(array( 849 "\""=>"\"\"", 850 "\r\n"=>"", 851 "\r"=>"", 852 "\n"=>"", 853 )); 854 855 if($fieldItems) { 856 857 foreach($fieldItems as $fieldItem) { 858 $fileData .= $fieldItem->renderwith("TableListField_Item_export"); 859 } 860 836 861 HTTP::sendFileToBrowser($fileData, $fileName); 837 862 } else { … … 845 870 */ 846 871 function ExportLink() { 847 return Controller::join_links($this->Link(), 'export'); 872 $exportLink = Controller::join_links($this->Link(), 'export'); 873 if($this->extraLinkParams) $exportLink .= "?" . http_build_query($this->extraLinkParams); 874 return $exportLink; 848 875 } 849 876 … … 909 936 function setFieldFormatting($formatting) { 910 937 $this->fieldFormatting = $formatting; 938 } 939 940 function setFieldEscape($escape){ 941 $this->fieldEscape = $escape; 911 942 } 912 943 … … 1064 1095 eval('$value = "' . $format . '";'); 1065 1096 } 1097 1098 //escape 1099 if($escape = $this->parent->fieldEscape){ 1100 foreach($escape as $search => $replace){ 1101 $value = str_replace($search, $replace, $value); 1102 } 1103 } 1066 1104 1067 1105 $fields[] = new ArrayData(array( … … 1069 1107 "Title" => $fieldTitle, 1070 1108 "Value" => $value, 1109 "CsvSeparator" => $this->parent->getCsvSeparator(), 1071 1110 )); 1072 1111 } 1073 1074 1112 return new DataObjectSet($fields); 1075 1113 } -
modules/sapphire/branches/roa/search/SearchContext.php
r57057 r57110 115 115 $query->orderby($SQL_sort); 116 116 foreach($searchParams as $key => $value) { 117 //if ($value != '0') { 117 /*We add $value!='' here to not include a filter like this: $fieldname like '%%', which abviously filter out some 118 records with the $fieldname set to null. and this is not the search intention. 119 */ 120 if ($value != '0'&&$value!='') { 118 121 $key = str_replace('__', '.', $key); 119 122 $filter = $this->getFilter($key);
