Commit 8eb4517da9da90a0757b280cab0e3a85d66779e6

Authored by eduardo.batista
1 parent e7bd1bd0
Exists in master and in 1 other branch desenv

[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 15 * @param $item
16 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 22 $itemArr = $item;
22   - }else if(is_object($item)) {
  23 + } else if (is_object($item)) {
23 24 $itemArr = get_object_vars($item);
24   - }else if(is_bool($item)){
  25 + } else if (is_bool($item)) {
25 26 return $item;
26   - }else{
  27 + } else {
27 28 return utf8_encode(htmlspecialchars($item));
28 29 }
29 30 $response = array();
30   - foreach($itemArr as $key => $val){
  31 + foreach ($itemArr as $key => $val) {
31 32 $response[$key] = MdWsSeiRest::dataToUtf8($val);
32 33 }
33 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 40 $itemArr = $item;
39   - }else if(is_object($item)) {
  41 + } else if (is_object($item)) {
40 42 $itemArr = get_object_vars($item);
41   - }else if(is_bool($item)){
  43 + } else if (is_bool($item)) {
42 44 return $item;
43   - }else{
  45 + } else {
44 46 return mb_convert_encoding($item, 'ISO-8859-1');
45 47 }
46 48 $response = array();
47   - foreach($itemArr as $key => $val){
  49 + foreach ($itemArr as $key => $val) {
48 50 $response[$key] = MdWsSeiRest::dataToIso88591($val);
49 51 }
50 52 return $response;
... ... @@ -58,16 +60,17 @@ class MdWsSeiRest extends SeiIntegracao
58 60 * @param bool $jsonEncode - Se alterado para true retornará como json_encode
59 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 65 $data = array();
63 66 $data['sucesso'] = true;
64   - if($mensagem){
  67 + if ($mensagem) {
65 68 $data['mensagem'] = $mensagem;
66 69 }
67   - if($result){
  70 + if ($result) {
68 71 $data['data'] = $result;
69 72 }
70   - if(!is_null($total)){
  73 + if (!is_null($total)) {
71 74 $data['total'] = $total;
72 75 }
73 76 $retorno = MdWsSeiRest::dataToUtf8($data);
... ... @@ -80,25 +83,26 @@ class MdWsSeiRest extends SeiIntegracao
80 83 * @param Exception $e
81 84 * @return array
82 85 */
83   - public static function formataRetornoErroREST(Exception $e){
  86 + public static function formataRetornoErroREST(Exception $e)
  87 + {
84 88 $mensagem = $e->getMessage();
85   - if($e instanceof InfraException){
86   - if(!$e->getStrDescricao()){
  89 + if ($e instanceof InfraException) {
  90 + if (!$e->getStrDescricao()) {
87 91 /** @var InfraValidacaoDTO $validacaoDTO */
88   - if(count($e->getArrObjInfraValidacao()) == 1){
  92 + if (count($e->getArrObjInfraValidacao()) == 1) {
89 93 $mensagem = $e->getArrObjInfraValidacao()[0]->getStrDescricao();
90   - }else{
91   - foreach($e->getArrObjInfraValidacao() as $validacaoDTO){
  94 + } else {
  95 + foreach ($e->getArrObjInfraValidacao() as $validacaoDTO) {
92 96 $mensagem[] = $validacaoDTO->getStrDescricao();
93 97 }
94 98 }
95   - }else{
  99 + } else {
96 100 $mensagem = $e->getStrDescricao();
97 101 }
98 102  
99 103 }
100 104 return MdWsSeiRest::dataToUtf8(
101   - array (
  105 + array(
102 106 "sucesso" => false,
103 107 "mensagem" => $mensagem,
104 108 "exception" => $e
... ... @@ -117,8 +121,8 @@ class MdWsSeiRest extends SeiIntegracao
117 121 {
118 122 global $SEI_MODULOS;
119 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 126 $ativo = true;
123 127 break;
124 128 }
... ... @@ -131,7 +135,8 @@ class MdWsSeiRest extends SeiIntegracao
131 135 * @param $strVersaoSEI
132 136 * @return bool
133 137 */
134   - public function verificaCompatibilidade($strVersaoSEI){
  138 + public function verificaCompatibilidade($strVersaoSEI)
  139 + {
135 140 if (substr($strVersaoSEI, 0, 2) != '3.') {
136 141 return false;
137 142 }
... ... @@ -145,7 +150,7 @@ class MdWsSeiRest extends SeiIntegracao
145 150  
146 151 public function getVersao()
147 152 {
148   - return '0.7.5';
  153 + return '0.7.6';
149 154 }
150 155  
151 156 public function getInstituicao()
... ... @@ -273,16 +278,16 @@ class MdWsSeiRest extends SeiIntegracao
273 278 public function adicionarElementoMenu()
274 279 {
275 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 288 $html = CacheSEI::getInstance()->getAtributo($nomeArquivo);
284 289  
285   - if($html){
  290 + if ($html) {
286 291 return $html;
287 292 }
288 293  
... ... @@ -301,28 +306,28 @@ class MdWsSeiRest extends SeiIntegracao
301 306 {
302 307 $htmlQrCode = '';
303 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 323 $infraException = new InfraException();
319   - if (!file_exists($caminhoFisicoQrCode)){
  324 + if (!file_exists($caminhoFisicoQrCode)) {
320 325 $infraException->lancarValidacao('Arquivo do QRCode não encontrado.');
321 326 }
322   - if (filesize($caminhoFisicoQrCode)==0){
  327 + if (filesize($caminhoFisicoQrCode) == 0) {
323 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 331 $infraException->lancarValidacao('Não foi possível ler o arquivo do QRCode.');
327 332 }
328 333  
... ...