[795] | 1 | <?php |
---|
| 2 | /** |
---|
| 3 | * importa classe do módulo |
---|
| 4 | */ |
---|
| 5 | require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'class.utils.php'); |
---|
| 6 | /** |
---|
| 7 | * Classe utilitária |
---|
| 8 | * @author Carlos Eduardo Nogueira Gonçalves |
---|
| 9 | * @version 1.0 |
---|
| 10 | * @license http://www.gnu.org/copyleft/gpl.html GPL |
---|
| 11 | * @package Workflow |
---|
| 12 | * @subpackage local |
---|
| 13 | */ |
---|
| 14 | class wf_util extends Utils { |
---|
| 15 | |
---|
| 16 | function wf_util() |
---|
| 17 | { |
---|
| 18 | return true; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | /* desabilita métodos */ |
---|
| 22 | function includeFile($filePath, $return=FALSE) {} |
---|
| 23 | function scriptName() {} |
---|
| 24 | function serverName() {} |
---|
| 25 | function get($key) {} |
---|
| 26 | function anchor($url, $text, $statusBarText='', $cssClass='', $jsEvents=array(), $target='', $name='', $id='', $rel='', $accessKey='') {} |
---|
| 27 | |
---|
| 28 | /** |
---|
| 29 | * Formata um array em uma linha do formato CSV |
---|
| 30 | * |
---|
| 31 | * @return string Linha no formato CSV |
---|
| 32 | * @access public |
---|
| 33 | */ |
---|
| 34 | function createCSVLine($item, $separator, $quotes = false) |
---|
| 35 | { |
---|
| 36 | if(is_array($item)){ |
---|
| 37 | if ($quotes){ |
---|
| 38 | foreach ($item as $key => $value){ |
---|
| 39 | $item[$key] = '"' . str_replace('"', '""', $value) . '"'; |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | return implode($separator, $item) . "\n"; |
---|
| 43 | } |
---|
| 44 | return false; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | /** |
---|
| 48 | * Cria um arquivo CSV baseado em um array |
---|
| 49 | * |
---|
| 50 | * @return string Linha no formato CSV |
---|
| 51 | * @access public |
---|
| 52 | */ |
---|
| 53 | function createCSVFile($data, $separator, $quotes = false) |
---|
| 54 | { |
---|
| 55 | if(!is_array($data)) |
---|
| 56 | return false; |
---|
| 57 | |
---|
| 58 | foreach($data as $item){ |
---|
| 59 | $output .= $this->createCSVLine($item, $separator, $quotes); |
---|
| 60 | } |
---|
| 61 | return $output; |
---|
| 62 | } |
---|
| 63 | } |
---|
| 64 | ?> |
---|