public static function selectIdiomas($lang) { $html = "<select class='form-control' id='select-idioma'>"; foreach (IdiomaController::getAll("", "Id") as $idi) { $html .= "\t<option value='" . $idi->Id . "' " . ($lang == $idi->Id ? "selected" : "") . ">\n\t\t\t\t\t\t\t\t" . $idi->Nome . "\n\t\t\t\t\t\t\t</option>"; } $html .= "</select>"; return $html; }
<?php session_start(); // carrega opções de idiomas ativos $idiomas = IdiomaController::getAtivos(); // identifica e carrega idioma selecionado if (isset($_SESSION['mh_language_id']) && isset($_SESSION['mh_language_sigla'])) { if (file_exists("./lib/" . $_SESSION['mh_language_sigla'] . ".xml")) { $xml = simplexml_load_file("./lib/" . $_SESSION['mh_language_sigla'] . ".xml"); } } else { $_SESSION['mh_language_id'] = 1; $_SESSION['mh_language'] = "Português"; $_SESSION['mh_language_sigla'] = "pt_BR"; $xml = simplexml_load_file("./lib/pt_BR.xml"); } // configurações gerais $config = new ConfiguracaoController(); $configGeralModel = $config->getConfiguracoesUnicas("geral"); ?> <!DOCTYPE html> <html> <head> <meta name="robots" content="noindex, nofollow"> <!-- TODO: retirar essa tag antes de mandar o site pra produção --> <meta http-equiv="X-UA-Compatible" content="IE=9" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<div class="col-sm-12 align-right"> <a href="idiomas-form" class="btn btn-primary"><i class="icon-plus icon-white"></i> Novo idioma</a> </div> <div class="col-sm-12"> <table class="table table-hover"> <thead> <tr> <th>Nome</th> <th style="width: 30%;">Sigla</th> <th class='align-center' style="width: 50px;">Ativo</th> <th style="width: 20%;"></th> </tr> </thead> <tbody> <?php foreach (IdiomaController::getAll() as $idioma) { echo "\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $idioma->Nome . "</td>\n\t\t\t\t <td>" . $idioma->Sigla . "</td>\n\t\t <td class='align-center'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . ($idioma->Ativo == '1' ? "<span class='fa fa-fw fa-check' style='color: green'></span>" : "<span class='fa fa-fw fa-remove' style='color: red'></span>") . "\n\t\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t <td class='align-right'>\n\t\t\t\t\t\t\t\t \t<a href='idiomas-form?id=" . $idioma->Id . "' class='btn btn-default'>Editar</a>\n\t\t\t\t\t\t\t\t \t" . ($idioma->Id > 1 ? "<button type='button' class='btn btn-danger del' value='" . $idioma->Id . "'>Excluir</button>" : "") . "\n\t\t\t\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t\t\t\t</tr>"; } ?> </tbody> </table> </div> </div> </div> </div> <script src="js/idiomas.js"></script> <?php
$str = ArquivoHelper::upload("../lib/", $_POST['sigla'], $_FILES['file-xml']); } // $res = IdiomaController::insert($_POST); if ($res) { header("Location: idiomas"); exit; } else { die("ERRO"); } } else { // upload xml if (!empty($_FILES['file-xml']['name'])) { $str = ArquivoHelper::upload("../lib/", $_POST['sigla'], $_FILES['file-xml']); } // $res = IdiomaController::update($_POST); if ($res) { header("Location: idiomas"); exit; } else { die("ERRO"); } } } elseif ($_POST['action'] == "del") { if (IdiomaController::delete($_POST)) { die("OK"); } else { die("ERRO"); } }
</div> </div> </div> <div class="form-group"> <label for="ativo" class="col-sm-2 control-label">Ativo</label> <div class="col-sm-4"> <input id="ativo" name="ativo" type="checkbox" /> </div> </div> </fieldset> </form> </div> </div> <script> $("#div-xml .remove").click(function(){ $("#delete-xml").val("1"); }); </script> <?php if (isset($_GET['id'])) { $idioma = IdiomaController::getIdioma($_GET); echo "\t<script>\n\t\t\t\t\t\$('#id').val('" . $idioma->Id . "');\n\t\t\t\t\t\$('#nome').val('" . $idioma->Nome . "');\n\t\t\t\t\t\$('#sigla').val('" . $idioma->Sigla . "');\n\t\t\t\t\t\$('#sigla').attr('readonly', true);\n\t\t\t\t\t" . (is_file("../lib/" . $idioma->Sigla . ".xml") ? "\t\$('.fileinput-filename').html(\"<a href='../lib/" . $idioma->Sigla . ".xml'>" . $idioma->Sigla . ".xml</a>\");\n\t\t\t\t\t\t\t\$('.fileinput-filename').show();\n\t\t\t\t\t\t\t\$('.fileinput-new.aux').hide();\n\t\t\t\t\t\t\t\$('.fileinput-exists').show();" : "") . "\n\t\t\t\t\t" . ($idioma->Ativo == '1' ? "\$('#ativo').attr('checked', true);" : "") . "\n\t\t\t\t\t\$('#subtitle').text('/ Editar idioma');\n\t\t\t\t</script>"; } else { echo "\t<script>\n\t\t\t\t\t\$('#senha').attr('readonly', false);\n\t\t\t\t\t\$('#alterarSenha').hide();\n\t\t\t\t</script>"; } include "helper/rodape.php";