Advertisement
lordjackson

Index.php Adinti 2.0

Jun 23rd, 2015
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 12.04 KB | None | 0 0
  1. <?php
  2.  
  3. require_once 'init.php';
  4.  
  5. $uri = 'http://' . $_SERVER ['HTTP_HOST'] . $_SERVER ['REQUEST_URI'];
  6. $template = 'theme2';
  7.  
  8. new TSession ();
  9.  
  10. $menu_string = '';
  11. $cargo = '';
  12. $servidor = '';
  13. $title_bar = '';
  14. $pagina = '';
  15. $boxed = '';
  16. $validar = '';
  17. $avaliacao = '';
  18. $mural = '';
  19. $breadcrumb = '';
  20. $fotoservidor = '';
  21. $usuario = '';
  22. $lotacao = 0;
  23. $municipio = '';
  24. $municipiologado = '';
  25. $menuModulo = '';
  26. $menulateral = '';
  27. $msg = '';
  28. $sigla_empresa = '';
  29.  
  30. if (TSession::getValue('logged')) {
  31.     $content = file_get_contents("app/templates/{$template}/layout.html");
  32.  
  33.     ob_start();
  34.     // $callback = array('SystemPermission', 'checkPermission');
  35.     // $xml = new SimpleXMLElement(file_get_contents('menu.xml'));
  36.     // $menu = new TMenu($xml, $callback, 1, 'nav collapse', '');
  37.     // $menu->class = 'nav';
  38.     // $menu->id = 'side-menu';
  39.     // $menu->show();
  40.     $menu_string = ob_get_clean();
  41.  
  42.         // pega os modulos do usuario
  43.     $menuModulo = TMenu::montaModulo($_SESSION ['usuario_id']);
  44.     // carregar menu e modulos
  45.     // recebe modulo e armazena na sessao
  46.     if (filter_input(INPUT_GET, 'modulo')) {
  47.         $_SESSION ['modulo'] = filter_input(INPUT_GET, 'modulo');
  48.     }
  49.  
  50.     $menulateral = TMenu::montaMenu($_SESSION ['modulo'], $_SESSION ['usuario_id']);
  51.  
  52.     // carregar municipio e usuario
  53.     // inicia transacao com o banco 'pg_ceres'
  54.     TTransaction::open('pg_ceres');
  55.  
  56.     if ($_SESSION ['empresa_id']) {
  57.         // instancia um record da classe municipio
  58.         $repository = new TRepository('vw_selecaoempresaRecord');
  59.         $criteria = new TCriteria ();
  60.         $criteria->setProperty('order', 'sigla');
  61.         $criteria->add(new TFilter('login', '=', $_SESSION ["usuario"]));
  62.         // carrega os objetos de acordo com o criterio
  63.         $cadastros = $repository->load($criteria);
  64.  
  65.         // armazena o municipio do usuario
  66.         if ($cadastros) {
  67.             // $municipio = $municipiorecord->municipio;
  68.             foreach ($cadastros as $object) {
  69.                 $sigla_empresa .= '<option ';
  70.                 if ($_SESSION ['empresa_id'] == $object->empresa_id)
  71.                     $sigla_empresa .= ' selected ';
  72.                 $sigla_empresa .= 'value="?empresa=' . $object->empresa_id . '" >' . $object->sigla . '</option>';
  73.             }
  74.         }
  75.     }
  76.  
  77.     if ($_SESSION ['municipio_id']) {
  78.         // instancia um record da classe municipio
  79.         $repository = new TRepository('vw_selecaomunicipioRecord');
  80.         $criteria = new TCriteria ();
  81.         $criteria->setProperty('order', 'municipio');
  82.         $criteria->add(new TFilter('servidor_id', '=', $_SESSION ["servidor_id"]));
  83.         //$criteria->add ( new TFilter ( 'servidor_id', '=', $_SESSION ["servidor_id"] ) );
  84.         // carrega os objetos de acordo com o criterio
  85.         $cadastros = $repository->load($criteria);
  86.  
  87.         // armazena o municipio do usuario
  88.         if ($cadastros) {
  89.             // $municipio = $municipiorecord->municipio;
  90.             foreach ($cadastros as $object) {
  91.                 $municipiologado .= '<option ';
  92.                 if ($_SESSION ['municipio_id'] == $object->municipio_id)
  93.                     $municipiologado .= ' selected ';
  94.                 $municipiologado .= 'value="?lotacao=' . $object->municipio_id . '" >' . $object->municipio . '</option>';
  95.             }
  96.         }
  97.     }
  98.  
  99.     $lotacao = filter_input(INPUT_GET, 'lotacao');
  100.     if ($lotacao) {
  101.         $_SESSION ['municipio_id'] = $lotacao;
  102.         echo '<script language="javascript">window.location = "index.php"</script>';
  103.     }
  104.  
  105.     $usuariorecord = new UsuarioRecord($_SESSION ['usuario_id']);
  106.     if ($usuariorecord->nome_cargonovo) {
  107.         $cargo = ' (' . $usuariorecord->nome_cargonovo . ')';
  108.     }
  109.  
  110.     $servidor = $usuariorecord->nome_servidor . $cargo;
  111.     // finaliza a transacao
  112.     TTransaction::close();
  113.  
  114.     if (!$servidor) {
  115.         $servidor = 'INSTITUTO DE ASSISTÊNCIA TÉCNICA E EXTENSÃO RURAL DO RN / EMATER';
  116.     }
  117.  
  118.     if (empty($_SESSION ["municipio_id"])) {
  119.         $usuario = '&raquo;' . $servidor . ' / Usu&aacute;rio: ' . $_SESSION ["usuario"] . '/' . $_SESSION ['usuario_id'];
  120.     } else {
  121.         $usuario = '&raquo;' . $servidor . ' / Usu&aacute;rio: ' . $_SESSION ["usuario"] . '/' . $_SESSION ['usuario_id'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Município: <a href="?class=SelecionaCidadeList">' . $municipio . "</a>";
  122.         // $usuario = '&raquo;' . $servidor . ' / Usu&aacute;rio: ' . $_SESSION["usuario"];
  123.     }
  124.  
  125.     // ######### carregar foto servidor ##########
  126.     //
  127.     if (file_exists('app/images/servidor/servidor_' . $_SESSION ['servidor_id'] . '.jpg')) {
  128.         $fotoservidor = '<img src="app/images/servidor/servidor_' . $_SESSION ['servidor_id'] . '.jpg" alt="" />';
  129.     } else {
  130.         $fotoservidor = '<img src="app/images/profile-60x60.png" alt="" />';
  131.     }
  132.  
  133.     //
  134.     // ######### fim carregar foto servidor ##########
  135.     //
  136.     // ######### SE ESTIVER EXIBINDO ALGUMA CLASSE EXIBE O TITULO DA PAGINA ##########
  137.     //
  138.    
  139.     if (filter_input(INPUT_GET, 'class')) {
  140.         /*
  141.          * TTransaction::open('pg_ceres');
  142.          * $repository = new TRepository('vw_usuario_paginaspermitidasRecord');
  143.          * $criteria = new TCriteria;
  144.          * $criteria->add(new TFilter('arquivo', '=', filter_input(INPUT_GET, 'class')));
  145.          * // carrega os objetos de acordo com o criterio
  146.          * $cadastros = $repository->load($criteria);
  147.          *
  148.          * if ($cadastros) {
  149.          * // percorre os objetos retornados
  150.          * foreach ($cadastros as $object) {
  151.          * $pagina = $object->nome;
  152.          * }
  153.          * }
  154.          * // finaliza a transacao
  155.          * TTransaction::close();
  156.          *
  157.          * if ($cadastros) {
  158.          * // $title_bar = "<div class='title-bar'>" . $pagina . "</div>";
  159.          *
  160.          * }
  161.          */
  162.         //  var_dump ( $_SESSION ['title-bar'] );
  163.         $title_bar = $_SESSION ['title-bar'];
  164.     }
  165.     //
  166.     // ######### Breadcrumbs ##########
  167.     //
  168.    
  169.     if (filter_input(INPUT_GET, 'class')) {
  170.         $breadcrumb = "<!-- Breadcrumbs Start -->
  171.                 <div class=\"row breadcrumbs\">
  172.                   <div class=\"col-xs-12 col-sm-12 col-md-12 col-lg-12\">
  173.                     <ul class=\"breadcrumbs\">
  174.                       <li><a href=\"index.php\"><i class=\"fa fa-home\"></i></a></li>
  175.                       <li><a href=\"?modulo=" . $_SESSION ['modulo'] . "\">" . $_SESSION ['modulo'] . "</a></li>
  176.                       <li><a href=\"#\">" . $pagina . "</a></li>
  177.                     </ul>
  178.                   </div>
  179.                 </div>
  180.                <!-- Breadcrumbs End -->";
  181.     }
  182.     //
  183.     // ######### fim Breadcrumbs ##########
  184.     // ######### SE ESTIVER EXIBINDO ALGUMA CLASSE CARREGA A DIV BOXED ##########
  185.     //
  186.    
  187.     if (filter_input(INPUT_GET, 'class')) {
  188.         $boxed = 'boxed';
  189.     }
  190.     // ######### fim Breadcrumbs ##########
  191.     //
  192.     // ########## MONTAR MURAL ##########
  193.     //
  194.    
  195.     if ($_SERVER ['REQUEST_URI'] == "/template2/index.php") {
  196.  
  197.         // pega a funcao montaMural
  198.         $montaMural = TMenu::montaMural();
  199.         // pega a funcao montaError
  200.         $montaError = TMenu::montaError();
  201.         // pega a fun��o montavalida��o
  202.         $montaValidacao = TMenu::montaValidacao();
  203.         // pega a funcao montaAvaliacao
  204.         $montaAvaliacao = TMenu::montaAvaliacao();
  205.  
  206.         if (isset($_GET)) {
  207.             $class = filter_input(INPUT_GET, 'class');
  208.  
  209.             if (class_exists($class)) {
  210.                 // verifica se existe permissao para ver a classe
  211.                 $pagina = new $class ();
  212.                 ob_start();
  213.                 $pagina->show();
  214.                 $content = ob_get_contents();
  215.                 ob_end_clean();
  216.                 // }
  217.             } else if (function_exists($method)) {
  218.                 call_user_func($method, $_GET);
  219.             } else {
  220.                 $mural = $montaMural;
  221.                 $validar = $montaValidacao;
  222.                 $avaliacao = $montaAvaliacao;
  223.             }
  224.             // if (TMenu::validaClasse($class) == FALSE) {
  225.             // $_SESSION["validacao"] = "";
  226.             // }
  227.         } else {
  228.             $mural = $montaMural;
  229.             $validar = $montaValidacao;
  230.             $avaliacao = $montaAvaliacao;
  231.         }
  232.     }
  233.  
  234.     //
  235.     // ######### FIM MONTAR MURAL ##########
  236.     //
  237.     // ########## CARREGA A DIV MSG ##########
  238.     //
  239.     /*
  240.       if (isset ( $_GET ['msg'] )) {
  241.       if ($_GET ['msg'] == 'sucess') {
  242.       $msg = '<div id="content-table-inner">
  243.       <!--  start message-green -->
  244.       <div id="message-green">
  245.       <table border="0" width="100%" cellpadding="0" cellspacing="0">
  246.       <tr>
  247.       <td class="green-left">Salvo com sucesso!</td>
  248.       <td class="green-right"><a class="close-green"><img src="app/images/table/icon_close_green.gif"   alt="" /></a></td>
  249.       </tr>
  250.       </table>
  251.       </div>
  252.       <!--  end message-green -->
  253.       </div>';
  254.       }
  255.  
  256.       if ($_GET ['msg'] == 'delete') {
  257.       $msg = '<div id="content-table-inner">
  258.       <!--  start message-yellow -->
  259.       <div id="message-yellow">
  260.       <table border="0" width="100%" cellpadding="0" cellspacing="0">
  261.       <tr>
  262.       <td class="yellow-left">Removido com sucesso!</td>
  263.       <td class="yellow-right"><a class="close-yellow"><img src="app/images/table/icon_close_yellow.gif"   alt="" /></a></td>
  264.       </tr>
  265.       </table>
  266.       </div>
  267.       <!--  end message-yellow -->
  268.       </div>';
  269.       }
  270.       if ($_GET ['msg'] == 'negado') {
  271.       $msg = '<div id="content-table-inner">
  272.       <!--  start message-yellow -->
  273.       <div id="message-yellow">
  274.       <table border="0" width="100%" cellpadding="0" cellspacing="0">
  275.       <tr>
  276.       <td class="yellow-left">Acesso negado!</td>
  277.       <td class="yellow-right"><a class="close-yellow"><img src="app/images/table/icon_close_yellow.gif"   alt="" /></a></td>
  278.       </tr>
  279.       </table>
  280.       </div>
  281.       <!--  end message-yellow -->
  282.       </div>';
  283.       }
  284.  
  285.       }
  286.      */
  287.  
  288.     //
  289.     // ######### fim msg ##########
  290. } else {
  291.     $content = file_get_contents("app/templates/{$template}/login.php");
  292.     // $content = file_get_contents("app/templates/{$template}/login.html");
  293. }
  294.  
  295. $content = TApplicationTranslator::translateTemplate($content);
  296. $content = str_replace('{LIBRARIES}', file_get_contents("app/templates/{$template}/libraries.html"), $content);
  297. $content = str_replace('{URI}', $uri, $content);
  298. $content = str_replace('{class}', isset($_REQUEST ['class']) ? $_REQUEST ['class'] : '', $content);
  299. $content = str_replace('{template}', $template, $content);
  300. // #################### NovoCeres #####################
  301.  
  302. $content = str_replace('{SERVIDOR}', $servidor, $content);
  303. $content = str_replace('{FOTOSERVIDOR}', $fotoservidor, $content);
  304. $content = str_replace('{USUARIO}', $usuario, $content);
  305. $content = str_replace('{BREADCRUMB}', $breadcrumb, $content);
  306. $content = str_replace('{BOXED}', $boxed, $content);
  307. //$content = str_replace ( '{TITLE_BAR}', $title_bar, $content );
  308. $content = str_replace('{NOMEMUNICIPIO}', $municipiologado, $content);
  309. $content = str_replace('{MODULO}', $menuModulo, $content);
  310. $content = str_replace('{MENU}', $menulateral, $content);
  311. $content = str_replace('{MURAL}', $mural, $content);
  312. $content = str_replace('{MSG}', $msg, $content);
  313. $content = str_replace('{VALIDACAO}', $validar, $content);
  314. $content = str_replace('{AVALIACAO}', $avaliacao, $content);
  315. $content = str_replace('{EMPRESA}', $sigla_empresa, $content);
  316.  
  317. // #################### fim NovoCeres #####################
  318. // $content = str_replace('{MENU}', $menu_string, $content);
  319. //$content = str_replace ( '{username}', TSession::getValue ( 'username' ), $content );
  320. //$content = str_replace ( '{frontpage}', TSession::getValue ( 'frontpage' ), $content );
  321. $css = TPage::getLoadedCSS();
  322. $js = TPage::getLoadedJS();
  323. $content = str_replace('{HEAD}', $css . $js, $content);
  324.  
  325. if (isset($_REQUEST ['class']) and TSession::getValue('logged')) {
  326.     $url = http_build_query($_REQUEST);
  327.     $content = str_replace('//#javascript_placeholder#', "__adianti_load_page('engine.php?{$url}');", $content);
  328. }
  329. echo $content;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement