Source for file ci18n.modulo.php

Documentation is available at ci18n.modulo.php

  1. <?php
  2.     /**
  3.      * cl10n.modulo.php
  4.      * 
  5.      * 
  6.      *
  7.      * @copyright 2008 Soomp
  8.      * @author Marcio Merlone <mmerlone@gmail.com>
  9.      * @version 1.0
  10.      * @since 25/05/2007
  11.      * @package Soomp
  12.      * 
  13.      * @todo
  14.      */
  15.     /* $Id: ci18n.modulo.php,v 1.1 2007/05/29 19:19:03 mmerlone Exp $ */
  16.  
  17.     require_once(CFG_LOCAL_FRAMEWORK.'control.classe.php');
  18.     /**
  19.      * Módulo controlador para gerenciamento de localizações (l10n) e
  20.      * internacionalização (l18n)
  21.      */
  22.     class ci18n extends control{
  23.  
  24.  
  25.         public $arrI18n = array('en' => array('en'array('id' => 0'value' => 'Inglês'))
  26.                                  );
  27.         /**
  28.          * Construtor
  29.          */
  30.         public function __contruct(){
  31.             require_once(CFG_LOCAL_FRAMEWORK.'idioma.classe.php');
  32.         }
  33.  
  34.         /**
  35.          * Exibe a listagem de idiomas ou verbetes caso isset($_GET['t'])
  36.          * @param object $req objeto de requisição
  37.          * @return string A ação a ser redirecionado ou null
  38.          */
  39.         public function lista(requisicao &$req){
  40.  
  41.             if($this->_smarty()){
  42.  
  43.                 if(isset($_GET['t'])){
  44.                     if(isset($this->arrI18n[$_GET['t']])){
  45.     
  46.                         $req->outputHead();
  47.                         $i idioma::getInstance();
  48.  
  49.                         $idListagem    $this->getIntIdListagem();
  50.                         $intPag        $this->getIntPag();
  51.                         $arrAcoes    array('delmulti' => array('id' => 31'value' => 'Remove selecionados'));
  52.         
  53.                         $lista $i->initPage($intPag$idListagem);
  54.                         $this->setPagePrefs($lista);
  55.                         $lista->setComboAcoes($arrAcoes);
  56.                         $lista->legenda 'Verbetes para idioma &quot;'.$_GET['t'].'&quot;';
  57.                         $lista $i->Page($lista'LANG_I18N="'.$_GET['t'].'"');
  58.     
  59.                         $this->smarty->assign('lista'$lista);
  60.                         $this->smarty->assign('t'$_GET['t']);
  61.                         $this->smarty->assign('pk''PK_I18N');
  62.                         $this->smarty->jsSrc('j/usuario.lista.js');
  63.                         $this->smarty->js('jsVarsLista.tpl');
  64.                         $this->smarty->display('i18n.listav.tpl');
  65.  
  66.                         $req->outputFoot();
  67.                         return;
  68.  
  69.                     }else{
  70.                         $this->msg(0'Idioma inválido: '.$_GET['t'].'.''erro');
  71.                         return 'lista';
  72.                     }
  73.  
  74.                 }else{
  75.  
  76.                     $req->outputHead();
  77.                     $i idioma::getInstance();
  78.  
  79.                     foreach($this->arrI18n as &$i18n){
  80.                         $i18n[1convertCharset($i->getString($i18n[1]));
  81.                     }
  82.     
  83.                     $idListagem    $this->getIntIdListagem();
  84.                     $intPag        $this->getIntPag();
  85.                     $arrAcoes    array('delmulti' => array('id' => 31'value' => 'Remove selecionados'));
  86.     
  87.                     $lista $i->initPage($intPag$idListagem);
  88.                     $this->setPagePrefs($lista);
  89.                     $lista->setComboAcoes($arrAcoes);
  90.                     $lista->legenda 'Localizações';
  91.                     $lista $i->Page($lista$this->arrI18n);
  92.  
  93.                     $this->smarty->assign('lista'$lista);
  94.                     $this->smarty->assign('pk''PK_I18N');
  95.                     $this->smarty->jsSrc('j/usuario.lista.js');
  96.                     $this->smarty->js('jsVarsLista.tpl');
  97.                     $this->smarty->display('i18n.lista.tpl');
  98.  
  99.                     $req->outputFoot();
  100.                     return;
  101.                 }
  102.  
  103.             }elseif(defind('AJAX')){
  104.                 $i idioma::getInstance();
  105.                 return $i->Find('');
  106.             }
  107.         }
  108.  
  109.         /**
  110.          * Exibe o formulário para adicionar um grupo
  111.          * @param object $req objeto de requisição
  112.          * @param object $objI objeto idioma ou $_POST de um grupo
  113.          * @return string A ação a ser redirecionado ou null
  114.          */
  115.         public function add(requisicao &$reqidioma $objI null){
  116.             if(defined('INDEX')){
  117.                 if(!is_null($objI)){
  118.                     $objI $objI;
  119.                 }else{
  120.                     $objI new idioma();
  121.                 }
  122.  
  123.                 $fields $objI->getFields();
  124.                 if($this->_smarty()){
  125.                     $req->outputHead();
  126.                     $this->smarty->assign('i'$objI);
  127.                     $this->smarty->assign('fields'$fields);
  128.                     $this->smarty->display('i18n.add.tpl');
  129.                     $req->outputFoot();
  130.                 }
  131.             }elseif(defined('AJAX')){
  132.                 return debug('','ci18n::add',3);
  133.             }
  134.             return;
  135.         }
  136.     
  137.         /**
  138.          * Exibe o formulário com os dados de um grupo existente.
  139.          * @param object $req objeto de requisição
  140.          */
  141.         public function edit(requisicao &$reqidioma $i null){
  142.             if(!$i){
  143.                 $i new idioma();
  144.                 $i->Load($_REQUEST['PK_I18N']);
  145.             }
  146.             if(is_object($i)){
  147.                 $this->add($req$i);
  148.             }else{
  149.                 $this->msg(0'Dados inválidos, informe o verbete a ser editado.''erro');
  150.                 debug(null'ci18n::edit'3);
  151.             }
  152.             return;
  153.         }
  154.  
  155.         /**
  156.          * Grava os dados de um grupo novo ou existente
  157.          * @param object $req objeto de requisição
  158.          * @return string A ação a ser redirecionado ou null
  159.          */
  160.         public function save(requisicao &$req){
  161.             if(!empty($_POST)){
  162.  
  163.                 require_once(CFG_LOCAL_FRAMEWORK.'validacao.classe.php');
  164.                 $v new validacao();
  165.                 $v->strObj 'idioma';
  166.                 $v->duplicado(array('PK_I18N' => $_POST['PK_I18N']'NO_I18N' => $_POST['NO_I18N']));
  167.  
  168.                 $i new idioma();
  169.                 if(isset($_POST['PK_I18N']&& $_POST['PK_I18N'])
  170.                     $i->Load($_POST['PK_I18N']);
  171.                 $i->NO_I18N   $_POST['NO_I18N'];
  172.                 $i->LO_I18N   $_POST['LO_I18N'];
  173.                 $i->LANG_I18N $_POST['LANG_I18N'];
  174.  
  175.                 if(!$v->valido){
  176.  
  177.                     /**
  178.                      * Dados inválidos
  179.                      */
  180.                     $erros $v->erros;
  181.                     foreach($erros as $erro){
  182.                         switch($erro[0]){
  183.  
  184.                             case 'duplicado':
  185.                                 $this->msg(0'Já existe um verbete com este texto: $verbete!''erro'array('verbete' => $i->PK_I18N));
  186.                                 break;
  187.                         }
  188.                     }
  189.                     $this->add($req$i);
  190.                     return;
  191.  
  192.                 }else{
  193.                     unset($v);
  194.                     if($ok $i->Save()){
  195.  
  196.                         if(empty($_POST['PK_I18N'])){
  197.                             $this->msg(0'Verbete criado com sucesso. ID=$id''sucesso'array('id' => $i->PK_I18N));
  198.  
  199.                         }else{
  200.                             $this->msg(0'Verbete $id alterado com sucesso.''sucesso'array('id' => $i->PK_I18N));
  201.                         }
  202.  
  203.                         if(isset($_POST['goto']&& $_POST['goto'== 'edit'){
  204.                             $goto 'index.php?m=i18n&a=edit&PK_I18N='.$i->PK_I18N.'&t='.$_POST['LANG_I18N'];
  205.                         }else{
  206.                             $goto 'index.php?m=i18n&a=lista&t='.$_POST['LANG_I18N'];
  207.                         }
  208.                         return $goto;
  209.  
  210.                     }else{
  211.                         $this->msg(0'Erro ao criar ou editar o verbete. '.$ok'erro');
  212.                         $this->add($req$i);
  213.                         debug($i'erro ci18n::save'3);
  214.                         return;
  215.                     }
  216.                 }
  217.             }
  218.             return 'index.php?m=i18n&a=lista&t='.$_POST['LANG_I18N'];
  219.         }
  220.  
  221.         /**
  222.          * Remove um verbete
  223.          * @param object $req objeto de requisição
  224.          * @return string A ação a ser redirecionado ou null
  225.          */
  226.         public function del(requisicao &$req){
  227.             if(isset($_GET['PK_I18N']&& is_numeric($_GET['PK_I18N'])){
  228.                 $i new idioma();
  229.                 if($i->Load($_GET['PK_I18N'])){
  230.                     $t $i->LANG_I18N;
  231.                     if($i->Delete()){
  232.                         $this->msg(0'Verbete removido com sucesso.''sucesso');
  233.                     }else{
  234.                         $this->msg(0'Erro ao remover verbete''erro');
  235.                     }
  236.                     return 'index.php?m=i18n&a=lista&t='.$t;
  237.                 }else{
  238.                     $this->msg(0'Verbete inexistente.''erro');
  239.                     return 'lista';
  240.                 }
  241.             }else{
  242.                 $this->msg(0'Dados inválidos, informe o verbete a ser removido.''erro');
  243.                 debug(null'ci18n::del'3);
  244.                 return 'lista';
  245.             }
  246.         }
  247.  
  248.         /**
  249.          * Remove um conjunto de grupos
  250.          * @param object $req objeto de requisição
  251.          * @return string A ação a ser redirecionado ou null
  252.          */
  253.         public function delmulti(requisicao &$req){
  254.             $i new idioma();
  255.             if(isset($_POST['ids']&& $i->Delete($_POST['ids'])){
  256.                 $this->msg(0'Registros removidos com sucesso.''sucesso');
  257.             }else{
  258.                 $this->msg(0'Erro removendo os registros ou nenhum registro selecionado.''erro');
  259.             }
  260.             if(isset($this->arrI18n[$_POST['t']])){
  261.                 return 'index.php?m=i18n&a=lista&t='.$_POST['t'];
  262.             }else{
  263.                 return 'lista';
  264.             }
  265.             
  266.         }
  267.  
  268.     }
  269.  
  270. ?>

Documentation generated on Sun, 09 Mar 2008 23:50:52 -0300 by phpDocumentor 1.4.0

SourceForge.net Logo Support This Project