Commit d57b607f03b33ca493b95a47a60b6f73352ce802

Authored by Adriano Vieira
1 parent 1157e698
Exists in master and in 1 other branch 3.1

Atualização "Trunk"

- mais idéias no mapa mental (CACIC.mm)
- início de implementação de tradução no instalador
- correções no tradutor do CACIC
- melhorias no template da classe phpTranslator
- atualização ToDo.txt da classe phpTranslator
- excluídos métodos obsoletos de phpTranslator
- correções em define.php
- adição de texto de idiomas

git-svn-id: http://svn.softwarepublico.gov.br/svn/cacic/cacic/trunk/gerente@219 fecfc0c7-e812-0410-ae72-849f08638ee7
admin/tradutor.php
... ... @@ -6,16 +6,22 @@ session_start();
6 6 if(!isset($_SESSION['id_usuario']))
7 7 die('Acesso negado!');
8 8 else { // Inserir regras para outras verificações (ex: permissões do usuário)!
9   - define(CACIC,1);
  9 + define('CACIC',1);
10 10 }
11 11  
12 12 require_once('../include/config.php');
13 13 require_once('../include/define.php');
14 14  
  15 + if(!@include_once( TRANSLATOR_PATH.'/Translator.php'))
  16 + die ("<h1>There is a trouble with phpTranslator package. It isn't found.</h1>");
  17 +
  18 + $_objTranslator = new Translator( CACIC_LANGUAGE, CACIC_PATH."/language/", CACIC_LANGUAGE_STANDARD );
  19 + $_objTranslator->setURLPath(TRANSLATOR_PATH_URL);
  20 + $_objTranslator->initStdLanguages();
  21 +
15 22 ?>
16 23 <html>
17 24 <head>
18   - <title>Tradução do CACIC</title>
19 25 <link type="text/css" rel="stylesheet"
20 26 href="../bibliotecas/phpTranslator/templates/css/template_css.css" />
21 27 <link type="text/css" rel="stylesheet"
... ... @@ -25,7 +31,7 @@ else { // Inserir regras para outras verificações (ex: permissões do usuário)!
25 31 </script>
26 32 </head>
27 33 <body>
28   - <h2>Tradução de textos do CACIC<h2>
  34 + <h2><?php echo $_objTranslator->_('kciq_mnt_tradutor');?><h2>
29 35 <!--
30 36 <table class="adminlist" width="100%">
31 37 <tr>
... ... @@ -95,11 +101,7 @@ else { // Inserir regras para outras verificações (ex: permissões do usuário)!
95 101 -->
96 102  
97 103 <?php
98   - if(!@include_once( TRANSLATOR_PATH.'/Translator.php'))
99   - die ("<h1>There is a trouble with phpTranslator package. It isn't found.</h1>");
100 104  
101   - $_objTranslator = new Translator( CACIC_LANGUAGE, CACIC_PATH."/language/", CACIC_LANGUAGE_STANDARD );
102   - $_objTranslator->setURLPath(TRANSLATOR_PATH_URL);
103   - $_objTranslator->Translate();
  105 + $_objTranslator->translatorGUI();
104 106  
105 107 ?>
106 108 \ No newline at end of file
... ...
bibliotecas/phpTranslator/ToDo.txt
... ... @@ -20,8 +20,9 @@ OK - tamanhos dos campos conforme os proprios atributos definidos
20 20 * formularios devem prever valor zero para o tamanho dos campos: idioma, contexto, tipo;
21 21 nos formularios: codificacao, listagem e traducao
22 22 - campos que nao podem ser zero (obvio): codigo_mensagem e texto_mensagem
23   - * path para o arquivo de idiomas deve ser informado na construtora
  23 +OK * path para o arquivo de idiomas deve ser informado na construtora
24 24 * inicializar array de mensagens de texto "destino" na construtora
  25 + * possibilitar uso de textos com instruções html
25 26  
26 27 version: 0.2.1
27 28  
... ... @@ -49,4 +50,4 @@ version: ?
49 50 - usando javascript
50 51 * Implementar armazenamento em banco de dados
51 52 - usar pacote para abstracao de banco (ex: ADOdb)
52   - - verificar adicao remocao de contra barra
  53 + - verificar adicao remocao de contra barra
53 54 \ No newline at end of file
... ...
bibliotecas/phpTranslator/Translator.php
... ... @@ -362,7 +362,8 @@
362 362 /**
363 363 * Prove a interface de cadastramento de codigos de mensagems ou a de traducao
364 364 *
365   - * @param boolean $_translate_only FALSE - Se apenas para traduzir
  365 + * @access public
  366 + * @param boolean $_translate_only FALSE - Se apenas para traduzir
366 367 * TRUE - tambem para fazer manutencao (default)
367 368 */
368 369 function translatorGUI( $_translate_only=true ) {
... ... @@ -398,9 +399,8 @@
398 399 // inicio de Montagem pagina HTML
399 400 $_objTmpl->readTemplatesFromInput( 'translate_mnt_tmpl.html' );
400 401 $_objTmpl->addVar( 'ini_page_form', 'classSelfPath', $this->classSelfPath );
401   - $_objTmpl->addVar( 'ini_page_form', 'translatorUrlPath', $this->translatorUrlPath );
402   - $_objTmpl->addVar( 'ini_page_form_mos', 'translatorUrlPath', $this->translatorUrlPath );
403   -
  402 + $_objTmpl->addVar( 'ini_page_form', 'TRANSLATOR_URL_PATH', $this->translatorUrlPath );
  403 +
404 404 // Se acionado o botao para traduzir, retira-o e mostra o SALVAR/RESTAURAR
405 405 if($_translate_only) {
406 406 $_objTmpl->addVar( 'ini_page_form_btn', 'mnt_btn_show',"translate");
... ... @@ -430,7 +430,7 @@
430 430  
431 431 $this->initStdLanguages();
432 432 $this->buildArrayVars();
433   -
  433 +
434 434 $titulo = $this->getText('#phpTranslator_page_title#');
435 435 $_objTmpl->addVar( 'ini_page_form', 'titulo', $titulo );
436 436 $_objTmpl->addVar( 'ini_page_form', 'PHPTRANSLATOR_EXCLUIR_CODIGO',
... ... @@ -586,13 +586,26 @@
586 586 $_objTmpl->displayParsedTemplate('end_page_form');
587 587  
588 588 } //end func: Translate
589   -
  589 +
  590 + /**
  591 + * Busca o texto a ser traduzido
  592 + *
  593 + * @access public
  594 + * @see getText()
  595 + * @return string O texto traduzido, o texto padrao ou o codigo da mensagem
  596 + *
  597 + */
  598 + function _( $_msg_code, $_sigla=false, $_text_case=0, $_args = array() ) {
  599 + return $this->getText( $_msg_code, $_sigla, $_text_case, $_args );
  600 + }
  601 +
590 602 /**
591 603 * Busca o texto a ser traduzido
592 604 *
593 605 * Busca a traducao do texto - caso o texto traduzido nao exista retorna o texto padrao e caso este
594 606 * tambem nao exista retorna o codigo de pesquisa
595 607 *
  608 + * @access public
596 609 * @param string $_msg_code O codigo da mensagem a ser traduzida
597 610 * @param boolean $_sigla Se retorna a sigla em lugar da mensagem completa
598 611 * @param boolean $_text_case Se o texto retorna o texto como cadastrado, em maiusculas ou minusculas
... ... @@ -625,7 +638,7 @@
625 638 return $_msg_text;
626 639  
627 640 } // end func: getText
628   -
  641 +
629 642 /**
630 643 * Metodo para retornar a mensagens de erros ocorridas
631 644 *
... ... @@ -998,6 +1011,7 @@
998 1011 $_file_name = $this->_makeFileName($_abbr_i18n);
999 1012  
1000 1013 $this->error = true;
  1014 + $this->mensagem = "";
1001 1015  
1002 1016 if(is_writable($this->languageFilePath)) {
1003 1017 if (is_writable($_file_name) or !file_exists($_file_name)) {
... ... @@ -1005,7 +1019,7 @@
1005 1019 $_resource = @fopen($_file_name,'w+');
1006 1020 else
1007 1021 $_resource = @fopen($_file_name,'w');
1008   -
  1022 +
1009 1023 if($_resource){
1010 1024 fwrite($_resource,$_content_to_file);
1011 1025 fclose($_resource);
... ... @@ -1027,7 +1041,7 @@
1027 1041 if($this->inDebugMode() ) echo "phpTranslator: ".$this->getMessage();
1028 1042 $this->error = false;
1029 1043 }
1030   -
  1044 +
1031 1045 return $this->error;
1032 1046 } // end func: SaveFile
1033 1047  
... ... @@ -1445,51 +1459,6 @@
1445 1459 * Deprecated Methods
1446 1460 */
1447 1461  
1448   - /**
1449   - * @access private
1450   - * @deprecated since v 0.1.41
1451   - * @see setURLPath()
1452   - */
1453   - function setTabPaneURLPath($_translatorUrlPath="") {
1454   - $this->setURLPath($_translatorUrlPath);
1455   - }
1456   -
1457   - /**
1458   - * @access private
1459   - * @deprecated since v 0.1.41
1460   - * @see setLangFilePath()
1461   - */
1462   - function setFilePath($_languageFilePath="") {
1463   - $this->setLangFilePath($_languageFilePath);
1464   - } // end func: setFilePath
1465   -
1466   - /**
1467   - * @access private
1468   - * @deprecated since v 0.1.41
1469   - * @see setLangFileSections()
1470   - */
1471   - function setLangSections($_languageSections=array()) {
1472   - $this->setLangFileSections($_languageSections);
1473   - }
1474   -
1475   - /**
1476   - * @access private
1477   - * @deprecated since v 0.1.41
1478   - * @see setLangFilePrefix()
1479   - */
1480   - function setFilePrefix($_file_prefix="") {
1481   - $this->setLangFilePrefix($_file_prefix);
1482   - } // end func: setFilePrefix
1483   -
1484   - /**
1485   - * Prove a interface de cadastramento de codigos de mensagems ou a de traducao
1486   - * @access private
1487   - * @deprecated since v 0.1.99-28
1488   - * @see translatorGUI()
1489   - */
1490   - function Translate( $_translate_only=true ) {
1491   - $this->translatorGUI( $_translate_only );
1492   - }
1493 1462 /* END OF DEPRECATED METHODS */
1494 1463 } // end Class: Translator
1495 1464 ?>
1496 1465 \ No newline at end of file
... ...
bibliotecas/phpTranslator/templates/translate_mnt_tmpl.html
... ... @@ -30,9 +30,6 @@
30 30 <meta name="keywords" lang="en-gb" content="internationalisation, localisation, globalisation">
31 31 <meta name="robots" content="all">
32 32 <meta name="description" content="Useful tool for Translation PHP applications">
33   - <link id="luna-tab-style-sheet" type="text/css" rel="stylesheet"
34   - href="{TRANSLATOR_URL_PATH}./templates/css/template_css.css" />
35   -
36 33 </mos:sub>
37 34 <mos:sub condition="inside">
38 35 <mos:comment>
... ... @@ -40,7 +37,8 @@
40 37 </mos:comment>
41 38 </mos:sub>
42 39 </mos:tmpl>
43   -
  40 + <link id="luna-tab-style-sheet" type="text/css" rel="stylesheet"
  41 + href="{TRANSLATOR_URL_PATH}./templates/css/template_css.css" />
44 42 <!-- Tab Pane 1.02 - by ... -->
45 43 <link id="luna-tab-style-sheet" type="text/css" rel="stylesheet"
46 44 href="{TRANSLATOR_URL_PATH}./templates/js/tabs/tabpane.css" />
... ... @@ -78,11 +76,11 @@
78 76 }
79 77  
80 78 function hasCodeSelected(theForm, action_msg) {
81   - var lResp = false;
82   - if(theForm.mnt_code_selected) {
83   - if( !( theForm.mnt_code_selected.length > 0 ) ) {
84   - lResp = theForm.mnt_code_selected.checked;
85   - }
  79 + var lResp = false;
  80 + if(theForm.mnt_code_selected) {
  81 + if( !( theForm.mnt_code_selected.length > 0 ) ) {
  82 + lResp = theForm.mnt_code_selected.checked;
  83 + }
86 84 else {
87 85 // if it has more then one row
88 86 for (i=0; i<theForm.mnt_code_selected.length; i++ ) {
... ... @@ -90,7 +88,7 @@
90 88 var mntCodeSel = theForm.mnt_code_selected[i].value;
91 89 lResp = true;
92 90 break;
93   - }
  91 + }
94 92 }
95 93 }
96 94 }
... ... @@ -103,13 +101,13 @@
103 101  
104 102 function delCodeSelected(theForm, action_msg) {
105 103 var lResp = hasCodeSelected(theForm, action_msg);
106   - if(!lResp) return false;
107   -
  104 + if(!lResp) return false;
  105 +
108 106 var mntCodeSel;
109 107  
110   - if( !( theForm.mnt_code_selected.length > 0 ) ) {
  108 + if( !( theForm.mnt_code_selected.length > 0 ) ) {
111 109 mntCodeSel = theForm.mnt_code_selected.value;
112   - }
  110 + }
113 111 else {
114 112 // if it has more then one row
115 113 for (i=0; i<theForm.mnt_code_selected.length; i++ ) {
... ... @@ -118,8 +116,8 @@
118 116 lResp = true;
119 117 break;
120 118 }
121   - }
122   - }
  119 + }
  120 + }
123 121  
124 122 lResp = confirm("{PHPTRANSLATOR_EXCLUIR_CODIGO}\n"+mntCodeSel);
125 123  
... ... @@ -375,4 +373,4 @@
375 373 </body>
376 374  
377 375 </html>
378   -</mos:tmpl>
  376 +</mos:tmpl>
379 377 \ No newline at end of file
... ...
include/define.php
... ... @@ -109,15 +109,15 @@ defined( &#39;CACIC&#39; ) or die( &#39;Acesso restrito (Restricted access)!&#39; );
109 109 * CACIC application language
110 110 */
111 111 if(isset($cacic_language))
112   - define( CACIC_LANGUAGE, $cacic_language );
  112 + define( 'CACIC_LANGUAGE', $cacic_language );
113 113 else
114   - define( CACIC_LANGUAGE, 'pt_br');
  114 + define( 'CACIC_LANGUAGE', 'pt_br');
115 115  
116 116 /*
117 117 * CACIC application standard language
118 118 * (Language to be used if the above one fail)
119 119 */
120   - define( CACIC_LANGUAGE_STANDARD, $cacic_language_standard );
  120 + define( 'CACIC_LANGUAGE_STANDARD', $cacic_language_standard );
121 121  
122 122 /**
123 123 * Atribui CHARSET padrao
... ... @@ -130,16 +130,17 @@ defined( &#39;CACIC&#39; ) or die( &#39;Acesso restrito (Restricted access)!&#39; );
130 130 /*
131 131 * path for CACIC
132 132 */
133   - define(CACIC_PATH, $path_aplicacao );
  133 + define('CACIC_PATH', $path_aplicacao );
134 134  
135 135 /*
136   - * PATH for phpTranslator class
137   - */
138   - define(TRANSLATOR_PATH, CACIC_PATH."/bibliotecas/phpTranslator/");
139   -/*
140   - * URL for phpTranslator class
  136 + * Atribui URL CACIC
141 137 */
142   - define(TRANSLATOR_PATH_URL, CACIC_URL."/bibliotecas/phpTranslator/");
  138 + $urlRequest = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']);
  139 + $urlRequest = str_replace("instalador/", '', $urlRequest);
  140 + if(isset($url_aplicacao))
  141 + define( 'CACIC_URL', $url_aplicacao);
  142 + else
  143 + define( 'CACIC_URL', "http://" . $_SERVER['SERVER_NAME'] . $urlRequest);
143 144  
144 145 /*
145 146 * Obtem PATH_SEPARATOR
... ... @@ -162,16 +163,6 @@ defined( &#39;CACIC&#39; ) or die( &#39;Acesso restrito (Restricted access)!&#39; );
162 163 define( 'CACIC_CFGFILE_PATH', CACIC_PATH.CACIC_DS.'include');
163 164  
164 165 /*
165   - * Atribui URL CACIC
166   - */
167   - $urlRequest = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['REQUEST_URI']);
168   - $urlRequest = str_replace("instalador/", '', $urlRequest);
169   - if(isset($url_aplicacao))
170   - define( CACIC_URL, $url_aplicacao);
171   - else
172   - define( CACIC_URL, "http://" . $_SERVER['SERVER_NAME'] . $urlRequest);
173   -
174   -/*
175 166 * Atribui URL de instalação do CACIC
176 167 */
177 168 if(isset($cacicURL))
... ... @@ -180,6 +171,15 @@ defined( &#39;CACIC&#39; ) or die( &#39;Acesso restrito (Restricted access)!&#39; );
180 171 define( 'CACIC_URL_INSTALL', CACIC_URL.'instalador');
181 172  
182 173 /*
  174 + * PATH for phpTranslator class
  175 + */
  176 + define('TRANSLATOR_PATH', CACIC_PATH."/bibliotecas/phpTranslator/");
  177 +/*
  178 + * URL for phpTranslator class
  179 + */
  180 + define('TRANSLATOR_PATH_URL', CACIC_URL."/bibliotecas/phpTranslator/");
  181 +
  182 +/*
183 183 * Atribui tema padrao para o instalador
184 184 */
185 185 if(isset($cacicTema))
... ...
instalador/classes/install.php
... ... @@ -14,8 +14,8 @@
14 14 // direct access is denied
15 15 defined( 'CACIC' ) or die( 'Acesso restrito (Restricted access)!' );
16 16  
17   -include_once("classes/install.tmpl.php");
18   -include_once("classes/install.ado.php");
  17 +require_once("classes/install.tmpl.php");
  18 +require_once("classes/install.ado.php");
19 19  
20 20 /**
21 21 * Prove a Instalação pela WEB
... ...
instalador/index.php
... ... @@ -49,6 +49,18 @@
49 49 die("Install mal construído (Install miss-built)!");
50 50 }
51 51  
  52 + if(!@include_once( TRANSLATOR_PATH.'/Translator.php'))
  53 + die ("<h1>There is a trouble with phpTranslator package. It isn't found.</h1>");
  54 +
  55 + // exemplo de uso do tradutor
  56 + define('CACIC_LANGUAGE', 'pt-br');
  57 + define('CACIC_LANGUAGE_STANDARD', 'en-us');
  58 + $_objTranslator = new Translator( CACIC_LANGUAGE, CACIC_PATH."/language/", CACIC_LANGUAGE_STANDARD );
  59 + $_objTranslator->setURLPath(TRANSLATOR_PATH_URL);
  60 + $_objTranslator->initStdLanguages();
  61 + //echo $_objTranslator->getText('kciq_mnt_tradutor');
  62 + // FIM de exemplo de uso do tradutor
  63 +
52 64 /**
53 65 * Prove a instanciação da Instalação pela WEB
54 66 */
... ...
instalador/templates/install_introducao.tmpl
... ... @@ -14,6 +14,28 @@
14 14 </cacicInstall:comment>
15 15  
16 16 <cacicInstall:tmpl name="tmplIntroducao">
  17 +
  18 + <fieldset>
  19 + <table width="100%">
  20 + <tr align="right" >
  21 + <td>Idioma:
  22 + <select name="translate_lang" onchange="submitForm( installForm, 'preinstall' );">
  23 + <option value=""></option>
  24 + <option value="en-us">Inglês (US)</option>
  25 + <option value="pt-br">Português brasileiro</option>
  26 + </select>
  27 + </td>
  28 + </tr>
  29 + <tfoot>
  30 + <tr>
  31 + <td colspan="2">
  32 + </td>
  33 + </tr>
  34 + </tfoot>
  35 + </table>
  36 + </fieldset>
  37 +
  38 +
17 39 <div id="introducao">
18 40 <fieldset>
19 41 <legend>Introdução</legend>
... ... @@ -55,4 +77,4 @@
55 77 </ul>
56 78 </fieldset>
57 79 </div>
58 80 -</cacicInstall:tmpl>
  81 +</cacicInstall:tmpl>
59 82 \ No newline at end of file
... ...
language/language.en-us.inc.php
... ... @@ -2,3 +2,6 @@ en-us instalador
2 2 en-us kciq_installertitle instaladorinfo CACIC Web Installer
3 3 en-us kciq_installerintrotitle instaladorinfo Introdution
4 4 en-us kciq_installerresources instaladorinfo Installer features:
  5 +en-us kciq_mnt_lang traducao Manutençãoinfo Language
  6 +en-us manutenção ManutençãoTagHeader Maintence
  7 +en-us kciq_mnt_tradutor Manutençãoinfo CACIC Language translate
... ...
language/language.pt-br.inc.php
  1 +pt-br kciq_mnt_lang traducao Manutençãoinfo Idioma a traduzir
1 2 pt-br instalador InstaladorTagHeader Instalador
2 3 pt-br kciq_installertitle instaladorinfo Instalador WEB para o CACIC
3 4 pt-br kciq_installerintrotitle instaladorinfo Introdução
  5 +pt-br manutenção ManutençãoTagHeader Manutenção
4 6 pt-br kciq_intallerintrodution instaladorinfo O CACIC é capaz de fornecer um diagnóstico preciso do parque computacional e disponibilizar informações como o número de equipamentos e sua distribuição nos mais diversos órgãos, os tipos de softwares utilizados e licenciados, configurações de hardware, entre outras. Também pode fornecer informações patrimoniais e a localização física dos equipamentos, ampliando o controle do parque computacional e a segurança na rede.
5   -pt-br kciq_installerResources instaladorinfo Recursos do Instalador:
6   -
7   - * Verifica versões mínimas de softwares/bibliotecas para execução do CACIC.
8   - * Verifica e cria configurações básicas para execução do CACIC.
9   - * Criação do banco de dados (opcional).
10   - * Criação das tabelas.
11   - * Inclusão de dados básicos nas tabelas.
12   - * Inclusão de dados para demonstração do produto (opcional).
  7 +pt-br kciq_installerresources instaladorinfo Recursos do Instalador:
  8 +pt-br kciq_mnt_tradutor Manutençãoinfo Tradução de texto do CACIC
... ...