function menu_produtos($ref = "", $subref = 0, $nivel = 0) { $con = BDConexao::__Abrir(); $con2 = BDConexao::__Abrir(); if ($ref == "") { $con->executar("SELECT * FROM `grupos` WHERE grp_classif LIKE '1.01.01.05.001%' OR grp_classif LIKE '1.01.01.03.001.004%' GROUP BY grp_classif ORDER BY grp_classif ASC"); } $ordem = 0; $idPai = str_replace(".", "", str_replace(" ", "", $ref)); $lPC = new ListaProdutoCategorias(); while ($row = $con->getRegistro()) { $ordem++; $id = str_replace(".", "", str_replace(" ", "", $row['grp_classif'])); $lPC->condicoes("", $id, ListaProdutoCategorias::ID); if ($lPC->getTotal() > 0) { $pC = $lPC->listar(); $pC->nome = Strings::__PrimeirasLetrasMaiusculas($row['grp_descricao']); $pC->getURL()->setURL(URL::cleanURL($pC->nome)); $pC->ordem = $ordem; $pC->subreferencia = $row['grp_classif']; $lPC->alterar($pC); } else { $con2->executar("INSERT INTO " . Sistema::$BDPrefixo . "produtos_categorias (id, categoriapai) VALUES('" . $id . "','" . $idPai . "')"); $lPC->condicoes("", $id, ListaProdutoCategorias::ID); $pC = $lPC->listar(); $pC->nome = Strings::__PrimeirasLetrasMaiusculas($row['grp_descricao']); $pC->getURL()->setURL(URL::cleanURL($pC->nome)); $pC->ordem = $ordem; $pC->disponivel = 1; $pC->subreferencia = $row['grp_classif']; $lPC->alterar($pC); } //if($nivel == 0){ // menu_produtos($row['grp_classif'], 0, $nivel+1); //} } }
$pC->nome = addslashes(str_replace("\"", "'", $_POST['nome'])); $pC->ordem = $_POST['ordem']; $pC->subreferencia = $_POST['subreferencia']; $pC->disponivel = $_POST['disponivel'] == ListaProdutoCategorias::VALOR_DISPONIVEL_TRUE ? true : false; $pC->visaoUnica = $_POST['visaoUnica'] == ListaProdutoCategorias::VALOR_VISAOUNICA_TRUE ? true : false; if (!empty($_POST['url'])) { $pC->getURL()->setURL($_POST['url']); } else { $pC->getURL()->setURL(($cP->getId() > 0 ? URL::cleanURL($cP->getNavegador(new Templates(Arquivos::__Create("{nome}")))) . "-" : '') . URL::cleanURL($_POST['nome'])); } $pC->descricaoPequena = eregi_replace('\\.\\./', Sistema::$caminhoURL, $_POST['descricaoPequena']); $pC->descricao = eregi_replace('\\.\\./', Sistema::$caminhoURL, $_POST['descricao']); if (!empty($_FILES['imagem']['name'])) { $pC->setImagem(new Image(Arquivos::__OpenArquivoByTEMP($_FILES['imagem']))); } $lCP->alterar($pC); while ($i = $lI->listar()) { $t = $i->getTraducaoById(ListaProdutoCategorias::NOME, $lCP->getTabela(), $pC->getId()); if ($t->getId()) { $t->conteudo = $pC->nome; $t->traducao = $_POST['inome'][$i->getId()]; $i->getTraducoes()->alterar($t); } else { $t = new Traducao(); $t->conteudo = $pC->nome; $t->traducao = $_POST['inome'][$i->getId()]; $t->setIdConteudo($pC->getId()); $t->setCampoConteudo(ListaProdutoCategorias::NOME); $t->setTabelaConteudo($lCP->getTabela()); $i->addTraducao($t); }