Changeset 57110

Show
Ignore:
Timestamp:
30/06/08 17:08:43 (2 months ago)
Author:
nlou
Message:

FEATURE:

Location:
modules/sapphire/branches/roa
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • modules/sapphire/branches/roa/core/model/DataObject.php

    r56816 r57110  
    25902590         */ 
    25912591        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; 
    25922598 
    25932599} 
  • modules/sapphire/branches/roa/forms/TableListField.php

    r56413 r57110  
    173173         
    174174        /** 
     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        /** 
    175183         * @var string 
    176184         */ 
     
    319327                        $dataQuery = $this->getQuery(); 
    320328                         
    321                         // we don't limit when doing certain actions 
     329                        // we don't limit when doing certain actions        T 
    322330                        if(!isset($_REQUEST['methodName']) || !in_array($_REQUEST['methodName'],array('printall','export'))) { 
    323331                                $dataQuery->limit(array( 
     
    342350                $fieldItems = new DataObjectSet(); 
    343351                if($items = $this->sourceItems()) foreach($items as $item) { 
     352                        $fieldItem = new TableListField_Item($item, $this); 
    344353                        if($item) $fieldItems->push(new TableListField_Item($item, $this)); 
    345354                } 
    346  
    347355                return $fieldItems; 
    348356        } 
     
    747755                        $this->totalCount = $record['TotalCount']; 
    748756                } 
    749  
    750757                return $this->totalCount; 
    751758        } 
     
    790797         
    791798        /** 
     799         * Get the CSV separator character.  Defaults to , 
     800         */ 
     801        function getCsvSeparator() { 
     802                return $this->csvSeparator; 
     803        } 
     804         
     805        /** 
    792806         * Remove the header row from the CSV export 
    793807         */ 
     
    819833                $dataQuery = $this->getCsvQuery(); 
    820834                $records = $dataQuery->execute(); 
     835                 
    821836                $sourceClass = $this->sourceClass; 
    822837                $dataobject = new $sourceClass(); 
    823838                $items = $dataobject->buildDataObjectSet($records, 'DataObjectSet'); 
    824839                 
    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 
    836861                        HTTP::sendFileToBrowser($fileData, $fileName); 
    837862                } else { 
     
    845870         */ 
    846871        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; 
    848875        } 
    849876 
     
    909936        function setFieldFormatting($formatting) { 
    910937                $this->fieldFormatting = $formatting; 
     938        } 
     939         
     940        function setFieldEscape($escape){ 
     941                $this->fieldEscape = $escape; 
    911942        } 
    912943         
     
    10641095                                eval('$value = "' . $format . '";'); 
    10651096                        } 
     1097                         
     1098                        //escape 
     1099                        if($escape = $this->parent->fieldEscape){ 
     1100                                foreach($escape as $search => $replace){ 
     1101                                        $value = str_replace($search, $replace, $value); 
     1102                                } 
     1103                        } 
    10661104                                                 
    10671105                        $fields[] = new ArrayData(array( 
     
    10691107                                "Title" => $fieldTitle, 
    10701108                                "Value" => $value, 
     1109                                "CsvSeparator" => $this->parent->getCsvSeparator(), 
    10711110                        )); 
    10721111                } 
    1073                  
    10741112                return new DataObjectSet($fields); 
    10751113        } 
  • modules/sapphire/branches/roa/search/SearchContext.php

    r57057 r57110  
    115115                $query->orderby($SQL_sort); 
    116116                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!='') { 
    118121                                $key = str_replace('__', '.', $key); 
    119122                                $filter = $this->getFilter($key);