Commit 8eb4517da9da90a0757b280cab0e3a85d66779e6
1 parent
e7bd1bd0
Exists in
master
and in
1 other branch
[Feat] Atualizando versão do módulo
Showing
1 changed file
with
57 additions
and
52 deletions
Show diff stats
MdWsSeiRest.php
@@ -15,36 +15,38 @@ class MdWsSeiRest extends SeiIntegracao | @@ -15,36 +15,38 @@ class MdWsSeiRest extends SeiIntegracao | ||
15 | * @param $item | 15 | * @param $item |
16 | * @return array|string | 16 | * @return array|string |
17 | */ | 17 | */ |
18 | - public static function dataToUtf8($item){ | 18 | + public static function dataToUtf8($item) |
19 | + { | ||
19 | 20 | ||
20 | - if(is_array($item)){ | 21 | + if (is_array($item)) { |
21 | $itemArr = $item; | 22 | $itemArr = $item; |
22 | - }else if(is_object($item)) { | 23 | + } else if (is_object($item)) { |
23 | $itemArr = get_object_vars($item); | 24 | $itemArr = get_object_vars($item); |
24 | - }else if(is_bool($item)){ | 25 | + } else if (is_bool($item)) { |
25 | return $item; | 26 | return $item; |
26 | - }else{ | 27 | + } else { |
27 | return utf8_encode(htmlspecialchars($item)); | 28 | return utf8_encode(htmlspecialchars($item)); |
28 | } | 29 | } |
29 | $response = array(); | 30 | $response = array(); |
30 | - foreach($itemArr as $key => $val){ | 31 | + foreach ($itemArr as $key => $val) { |
31 | $response[$key] = MdWsSeiRest::dataToUtf8($val); | 32 | $response[$key] = MdWsSeiRest::dataToUtf8($val); |
32 | } | 33 | } |
33 | return $response; | 34 | return $response; |
34 | } | 35 | } |
35 | 36 | ||
36 | - public static function dataToIso88591($item){ | ||
37 | - if(is_array($item)){ | 37 | + public static function dataToIso88591($item) |
38 | + { | ||
39 | + if (is_array($item)) { | ||
38 | $itemArr = $item; | 40 | $itemArr = $item; |
39 | - }else if(is_object($item)) { | 41 | + } else if (is_object($item)) { |
40 | $itemArr = get_object_vars($item); | 42 | $itemArr = get_object_vars($item); |
41 | - }else if(is_bool($item)){ | 43 | + } else if (is_bool($item)) { |
42 | return $item; | 44 | return $item; |
43 | - }else{ | 45 | + } else { |
44 | return mb_convert_encoding($item, 'ISO-8859-1'); | 46 | return mb_convert_encoding($item, 'ISO-8859-1'); |
45 | } | 47 | } |
46 | $response = array(); | 48 | $response = array(); |
47 | - foreach($itemArr as $key => $val){ | 49 | + foreach ($itemArr as $key => $val) { |
48 | $response[$key] = MdWsSeiRest::dataToIso88591($val); | 50 | $response[$key] = MdWsSeiRest::dataToIso88591($val); |
49 | } | 51 | } |
50 | return $response; | 52 | return $response; |
@@ -58,16 +60,17 @@ class MdWsSeiRest extends SeiIntegracao | @@ -58,16 +60,17 @@ class MdWsSeiRest extends SeiIntegracao | ||
58 | * @param bool $jsonEncode - Se alterado para true retornará como json_encode | 60 | * @param bool $jsonEncode - Se alterado para true retornará como json_encode |
59 | * @return array | 61 | * @return array |
60 | */ | 62 | */ |
61 | - public static function formataRetornoSucessoREST($mensagem = null, $result = null, $total = null, $jsonEncode = false){ | 63 | + public static function formataRetornoSucessoREST($mensagem = null, $result = null, $total = null, $jsonEncode = false) |
64 | + { | ||
62 | $data = array(); | 65 | $data = array(); |
63 | $data['sucesso'] = true; | 66 | $data['sucesso'] = true; |
64 | - if($mensagem){ | 67 | + if ($mensagem) { |
65 | $data['mensagem'] = $mensagem; | 68 | $data['mensagem'] = $mensagem; |
66 | } | 69 | } |
67 | - if($result){ | 70 | + if ($result) { |
68 | $data['data'] = $result; | 71 | $data['data'] = $result; |
69 | } | 72 | } |
70 | - if(!is_null($total)){ | 73 | + if (!is_null($total)) { |
71 | $data['total'] = $total; | 74 | $data['total'] = $total; |
72 | } | 75 | } |
73 | $retorno = MdWsSeiRest::dataToUtf8($data); | 76 | $retorno = MdWsSeiRest::dataToUtf8($data); |
@@ -80,25 +83,26 @@ class MdWsSeiRest extends SeiIntegracao | @@ -80,25 +83,26 @@ class MdWsSeiRest extends SeiIntegracao | ||
80 | * @param Exception $e | 83 | * @param Exception $e |
81 | * @return array | 84 | * @return array |
82 | */ | 85 | */ |
83 | - public static function formataRetornoErroREST(Exception $e){ | 86 | + public static function formataRetornoErroREST(Exception $e) |
87 | + { | ||
84 | $mensagem = $e->getMessage(); | 88 | $mensagem = $e->getMessage(); |
85 | - if($e instanceof InfraException){ | ||
86 | - if(!$e->getStrDescricao()){ | 89 | + if ($e instanceof InfraException) { |
90 | + if (!$e->getStrDescricao()) { | ||
87 | /** @var InfraValidacaoDTO $validacaoDTO */ | 91 | /** @var InfraValidacaoDTO $validacaoDTO */ |
88 | - if(count($e->getArrObjInfraValidacao()) == 1){ | 92 | + if (count($e->getArrObjInfraValidacao()) == 1) { |
89 | $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); | 93 | $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao(); |
90 | - }else{ | ||
91 | - foreach($e->getArrObjInfraValidacao() as $validacaoDTO){ | 94 | + } else { |
95 | + foreach ($e->getArrObjInfraValidacao() as $validacaoDTO) { | ||
92 | $mensagem[] = $validacaoDTO->getStrDescricao(); | 96 | $mensagem[] = $validacaoDTO->getStrDescricao(); |
93 | } | 97 | } |
94 | } | 98 | } |
95 | - }else{ | 99 | + } else { |
96 | $mensagem = $e->getStrDescricao(); | 100 | $mensagem = $e->getStrDescricao(); |
97 | } | 101 | } |
98 | 102 | ||
99 | } | 103 | } |
100 | return MdWsSeiRest::dataToUtf8( | 104 | return MdWsSeiRest::dataToUtf8( |
101 | - array ( | 105 | + array( |
102 | "sucesso" => false, | 106 | "sucesso" => false, |
103 | "mensagem" => $mensagem, | 107 | "mensagem" => $mensagem, |
104 | "exception" => $e | 108 | "exception" => $e |
@@ -117,8 +121,8 @@ class MdWsSeiRest extends SeiIntegracao | @@ -117,8 +121,8 @@ class MdWsSeiRest extends SeiIntegracao | ||
117 | { | 121 | { |
118 | global $SEI_MODULOS; | 122 | global $SEI_MODULOS; |
119 | $ativo = false; | 123 | $ativo = false; |
120 | - foreach($SEI_MODULOS as $modulo){ | ||
121 | - if($modulo instanceof self){ | 124 | + foreach ($SEI_MODULOS as $modulo) { |
125 | + if ($modulo instanceof self) { | ||
122 | $ativo = true; | 126 | $ativo = true; |
123 | break; | 127 | break; |
124 | } | 128 | } |
@@ -131,7 +135,8 @@ class MdWsSeiRest extends SeiIntegracao | @@ -131,7 +135,8 @@ class MdWsSeiRest extends SeiIntegracao | ||
131 | * @param $strVersaoSEI | 135 | * @param $strVersaoSEI |
132 | * @return bool | 136 | * @return bool |
133 | */ | 137 | */ |
134 | - public function verificaCompatibilidade($strVersaoSEI){ | 138 | + public function verificaCompatibilidade($strVersaoSEI) |
139 | + { | ||
135 | if (substr($strVersaoSEI, 0, 2) != '3.') { | 140 | if (substr($strVersaoSEI, 0, 2) != '3.') { |
136 | return false; | 141 | return false; |
137 | } | 142 | } |
@@ -145,7 +150,7 @@ class MdWsSeiRest extends SeiIntegracao | @@ -145,7 +150,7 @@ class MdWsSeiRest extends SeiIntegracao | ||
145 | 150 | ||
146 | public function getVersao() | 151 | public function getVersao() |
147 | { | 152 | { |
148 | - return '0.7.5'; | 153 | + return '0.7.6'; |
149 | } | 154 | } |
150 | 155 | ||
151 | public function getInstituicao() | 156 | public function getInstituicao() |
@@ -273,16 +278,16 @@ class MdWsSeiRest extends SeiIntegracao | @@ -273,16 +278,16 @@ class MdWsSeiRest extends SeiIntegracao | ||
273 | public function adicionarElementoMenu() | 278 | public function adicionarElementoMenu() |
274 | { | 279 | { |
275 | $nomeArquivo = 'QRCODE_' | 280 | $nomeArquivo = 'QRCODE_' |
276 | - .self::NOME_MODULO | ||
277 | - ."_" | ||
278 | - .SessaoSEI::getInstance()->getNumIdOrgaoUsuario() | ||
279 | - ."_" | ||
280 | - .SessaoSEI::getInstance()->getNumIdContextoUsuario() | ||
281 | - ."_" | ||
282 | - .self::getVersao(); | 281 | + . self::NOME_MODULO |
282 | + . "_" | ||
283 | + . SessaoSEI::getInstance()->getNumIdOrgaoUsuario() | ||
284 | + . "_" | ||
285 | + . SessaoSEI::getInstance()->getNumIdContextoUsuario() | ||
286 | + . "_" | ||
287 | + . self::getVersao(); | ||
283 | $html = CacheSEI::getInstance()->getAtributo($nomeArquivo); | 288 | $html = CacheSEI::getInstance()->getAtributo($nomeArquivo); |
284 | 289 | ||
285 | - if($html){ | 290 | + if ($html) { |
286 | return $html; | 291 | return $html; |
287 | } | 292 | } |
288 | 293 | ||
@@ -301,28 +306,28 @@ class MdWsSeiRest extends SeiIntegracao | @@ -301,28 +306,28 @@ class MdWsSeiRest extends SeiIntegracao | ||
301 | { | 306 | { |
302 | $htmlQrCode = ''; | 307 | $htmlQrCode = ''; |
303 | $caminhoAtual = explode("/sei/web", __DIR__); | 308 | $caminhoAtual = explode("/sei/web", __DIR__); |
304 | - $urlSEI = ConfiguracaoSEI::getInstance()->getValor('SEI','URL') | ||
305 | - .$caminhoAtual[1] | ||
306 | - .'/controlador_ws.php/api/v1'; | ||
307 | - $conteudoQrCode = 'url: '.$urlSEI | ||
308 | - .';' | ||
309 | - .'siglaorgao: '.SessaoSEI::getInstance()->getStrSiglaOrgaoUsuario() | ||
310 | - .';' | ||
311 | - .'orgao: '.SessaoSEI::getInstance()->getNumIdOrgaoUsuario() | ||
312 | - .';' | ||
313 | - .'contexto: '.SessaoSEI::getInstance()->getNumIdContextoUsuario(); | ||
314 | - $caminhoFisicoQrCode = DIR_SEI_TEMP.'/'.$nomeArquivo; | ||
315 | - | ||
316 | - InfraQRCode::gerar($conteudoQrCode, $caminhoFisicoQrCode,'L',2,1); | 309 | + $urlSEI = ConfiguracaoSEI::getInstance()->getValor('SEI', 'URL') |
310 | + . $caminhoAtual[1] | ||
311 | + . '/controlador_ws.php/api/v1'; | ||
312 | + $conteudoQrCode = 'url: ' . $urlSEI | ||
313 | + . ';' | ||
314 | + . 'siglaorgao: ' . SessaoSEI::getInstance()->getStrSiglaOrgaoUsuario() | ||
315 | + . ';' | ||
316 | + . 'orgao: ' . SessaoSEI::getInstance()->getNumIdOrgaoUsuario() | ||
317 | + . ';' | ||
318 | + . 'contexto: ' . SessaoSEI::getInstance()->getNumIdContextoUsuario(); | ||
319 | + $caminhoFisicoQrCode = DIR_SEI_TEMP . '/' . $nomeArquivo; | ||
320 | + | ||
321 | + InfraQRCode::gerar($conteudoQrCode, $caminhoFisicoQrCode, 'L', 2, 1); | ||
317 | 322 | ||
318 | $infraException = new InfraException(); | 323 | $infraException = new InfraException(); |
319 | - if (!file_exists($caminhoFisicoQrCode)){ | 324 | + if (!file_exists($caminhoFisicoQrCode)) { |
320 | $infraException->lancarValidacao('Arquivo do QRCode não encontrado.'); | 325 | $infraException->lancarValidacao('Arquivo do QRCode não encontrado.'); |
321 | } | 326 | } |
322 | - if (filesize($caminhoFisicoQrCode)==0){ | 327 | + if (filesize($caminhoFisicoQrCode) == 0) { |
323 | $infraException->lancarValidacao('Arquivo do QRCode vazio.'); | 328 | $infraException->lancarValidacao('Arquivo do QRCode vazio.'); |
324 | } | 329 | } |
325 | - if (($binQrCode = file_get_contents($caminhoFisicoQrCode))===false){ | 330 | + if (($binQrCode = file_get_contents($caminhoFisicoQrCode)) === false) { |
326 | $infraException->lancarValidacao('Não foi possível ler o arquivo do QRCode.'); | 331 | $infraException->lancarValidacao('Não foi possível ler o arquivo do QRCode.'); |
327 | } | 332 | } |
328 | 333 |