@@ -36,7 +36,7 @@ |
||
| 36 | 36 | { |
| 37 | 37 | |
| 38 | 38 | private static $idioma = 'es'; ///< Idioma por defecto de los mensajes |
| 39 | - private static $locales = [ ///< Mapeo de idioma a locales |
|
| 39 | + private static $locales = [///< Mapeo de idioma a locales |
|
| 40 | 40 | 'es' => 'es_CL.utf8', |
| 41 | 41 | 'en' => 'en_US.utf8', |
| 42 | 42 | ]; |
@@ -53,8 +53,9 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public static function getCiudad($comuna) |
| 55 | 55 | { |
| 56 | - if (!$comuna) |
|
| 57 | - return false; |
|
| 56 | + if (!$comuna) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 58 | 59 | $comuna = mb_strtoupper($comuna, 'UTF-8'); |
| 59 | 60 | return isset(self::$ciudades[$comuna]) ? self::$ciudades[$comuna] : false; |
| 60 | 61 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | public static function mergeRecursiveDistinct(array $array1, array $array2) |
| 43 | 43 | { |
| 44 | 44 | $merged = $array1; |
| 45 | - foreach ( $array2 as $key => &$value ) { |
|
| 45 | + foreach ($array2 as $key => &$value) { |
|
| 46 | 46 | if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
| 47 | 47 | $merged [$key] = self::mergeRecursiveDistinct( |
| 48 | 48 | $merged [$key], |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public static function read($archivo, $separador = ';', $delimitadortexto = '"') |
| 48 | 48 | { |
| 49 | - if (($handle = fopen($archivo, 'r')) !== FALSE) { |
|
| 49 | + if (($handle = fopen($archivo, 'r'))!==FALSE) { |
|
| 50 | 50 | $data = array(); |
| 51 | 51 | $i = 0; |
| 52 | - while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto)) !== FALSE) { |
|
| 52 | + while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto))!==FALSE) { |
|
| 53 | 53 | $j = 0; |
| 54 | 54 | foreach ($row as &$col) { |
| 55 | 55 | $data[$i][$j++] = $col; |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | header('Content-Disposition: attachment; filename='.$archivo.'.csv'); |
| 78 | 78 | header('Pragma: no-cache'); |
| 79 | 79 | header('Expires: 0'); |
| 80 | - foreach($data as &$row) { |
|
| 81 | - foreach($row as &$col) { |
|
| 80 | + foreach ($data as &$row) { |
|
| 81 | + foreach ($row as &$col) { |
|
| 82 | 82 | $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto; |
| 83 | 83 | } |
| 84 | - echo implode($separador, $row),"\r\n"; |
|
| 84 | + echo implode($separador, $row), "\r\n"; |
|
| 85 | 85 | unset($row); |
| 86 | 86 | } |
| 87 | 87 | unset($data); |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | public static function save(array $data, $archivo, $separador = ';', $delimitadortexto = '"') |
| 101 | 101 | { |
| 102 | 102 | $fd = fopen($archivo, 'w'); |
| 103 | - foreach($data as &$row) { |
|
| 104 | - foreach($row as &$col) { |
|
| 103 | + foreach ($data as &$row) { |
|
| 104 | + foreach ($row as &$col) { |
|
| 105 | 105 | $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto; |
| 106 | 106 | } |
| 107 | 107 | fwrite($fd, implode($separador, $row)."\r\n"); |
@@ -174,12 +174,14 @@ |
||
| 174 | 174 | public static function get($codigo, $args = null) |
| 175 | 175 | { |
| 176 | 176 | // si no hay glosa asociada al código se entrega el mismo código |
| 177 | - if (!isset(self::$glosas[(int)$codigo])) |
|
| 178 | - return (int)$codigo; |
|
| 177 | + if (!isset(self::$glosas[(int)$codigo])) { |
|
| 178 | + return (int)$codigo; |
|
| 179 | + } |
|
| 179 | 180 | // si los argumentos no son un arreglo se obtiene arreglo a partir |
| 180 | 181 | // de los argumentos pasados a la función |
| 181 | - if (!is_array($args)) |
|
| 182 | - $args = array_slice(func_get_args(), 1); |
|
| 182 | + if (!is_array($args)) { |
|
| 183 | + $args = array_slice(func_get_args(), 1); |
|
| 184 | + } |
|
| 183 | 185 | // entregar glosa |
| 184 | 186 | return vsprintf(I18n::translate(self::$glosas[(int)$codigo], 'estados'), $args); |
| 185 | 187 | } |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | public static function rmdir($dir) |
| 50 | 50 | { |
| 51 | 51 | // List the contents of the directory table |
| 52 | - $dir_content = scandir ($dir); |
|
| 52 | + $dir_content = scandir($dir); |
|
| 53 | 53 | // Is it a directory? |
| 54 | 54 | if ($dir_content!==false) { |
| 55 | 55 | // For each directory entry |
| 56 | 56 | foreach ($dir_content as &$entry) { |
| 57 | 57 | // Unix symbolic shortcuts, we go |
| 58 | - if (!in_array ($entry, array ('.','..'))) { |
|
| 58 | + if (!in_array($entry, array('.', '..'))) { |
|
| 59 | 59 | // We find the path from the beginning |
| 60 | - $entry = $dir.DIRECTORY_SEPARATOR. $entry; |
|
| 60 | + $entry = $dir.DIRECTORY_SEPARATOR.$entry; |
|
| 61 | 61 | // This entry is not an issue: it clears |
| 62 | 62 | if (!is_dir($entry)) { |
| 63 | - unlink ($entry); |
|
| 63 | + unlink($entry); |
|
| 64 | 64 | } else { // This entry is a folder, it again on this issue |
| 65 | 65 | self::rmdir($entry); |
| 66 | 66 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | // It has erased all entries in the folder, we can now erase |
| 71 | - rmdir ($dir); |
|
| 71 | + rmdir($dir); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | // enviar archivo |
| 161 | 161 | if ($options['download']) { |
| 162 | 162 | ob_clean(); |
| 163 | - header ('Content-Disposition: attachment; filename='.$file_compressed); |
|
| 163 | + header('Content-Disposition: attachment; filename='.$file_compressed); |
|
| 164 | 164 | $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 165 | 165 | if ($mimetype) |
| 166 | - header ('Content-Type: '.$mimetype); |
|
| 167 | - header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
|
| 166 | + header('Content-Type: '.$mimetype); |
|
| 167 | + header('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
|
| 168 | 168 | readfile($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 169 | 169 | unlink($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 170 | 170 | } |
@@ -80,8 +80,9 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function mimetype($file) |
| 82 | 82 | { |
| 83 | - if (!function_exists('finfo_open')) |
|
| 84 | - return false; |
|
| 83 | + if (!function_exists('finfo_open')) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 85 | 86 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 86 | 87 | $mimetype = finfo_file($finfo, $file); |
| 87 | 88 | finfo_close($finfo); |
@@ -121,8 +122,11 @@ discard block |
||
| 121 | 122 | } |
| 122 | 123 | // si es formato gz y es directorio se cambia a tgz |
| 123 | 124 | if (is_dir($file)) { |
| 124 | - if ($options['format']=='gz') $options['format'] = 'tar.gz'; |
|
| 125 | - else if ($options['format']=='bz2') $options['format'] = 'tar.bz2'; |
|
| 125 | + if ($options['format']=='gz') { |
|
| 126 | + $options['format'] = 'tar.gz'; |
|
| 127 | + } else if ($options['format']=='bz2') { |
|
| 128 | + $options['format'] = 'tar.bz2'; |
|
| 129 | + } |
|
| 126 | 130 | } |
| 127 | 131 | // obtener directorio que contiene al archivo/directorio y el nombre de este |
| 128 | 132 | $filepath = $file; |
@@ -162,8 +166,9 @@ discard block |
||
| 162 | 166 | ob_clean(); |
| 163 | 167 | header ('Content-Disposition: attachment; filename='.$file_compressed); |
| 164 | 168 | $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 165 | - if ($mimetype) |
|
| 166 | - header ('Content-Type: '.$mimetype); |
|
| 169 | + if ($mimetype) { |
|
| 170 | + header ('Content-Type: '.$mimetype); |
|
| 171 | + } |
|
| 167 | 172 | header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
| 168 | 173 | readfile($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 169 | 174 | unlink($dir.DIRECTORY_SEPARATOR.$file_compressed); |
@@ -171,8 +176,11 @@ discard block |
||
| 171 | 176 | // borrar directorio o archivo que se está comprimiendo si así se ha |
| 172 | 177 | // solicitado |
| 173 | 178 | if ($options['delete']) { |
| 174 | - if (is_dir($filepath)) self::rmdir($filepath); |
|
| 175 | - else unlink($filepath); |
|
| 179 | + if (is_dir($filepath)) { |
|
| 180 | + self::rmdir($filepath); |
|
| 181 | + } else { |
|
| 182 | + unlink($filepath); |
|
| 183 | + } |
|
| 176 | 184 | } |
| 177 | 185 | } |
| 178 | 186 | |
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -98,5 +98,6 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // si hubo errores mostrar |
| 101 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 101 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 102 | 102 | echo $error,"\n"; |
| 103 | +} |
|
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -65,5 +65,6 @@ |
||
| 65 | 65 | var_dump($track_id); |
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 69 | 69 | echo $error,"\n"; |
| 70 | +} |
|
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -98,5 +98,6 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // si hubo errores mostrar |
| 101 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 101 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 102 | 102 | echo $error,"\n"; |
| 103 | +} |
|