function navigateToCategory(ProdutoCategoria $pC) { $array['navegador'] = $pC->getNavegador(); if ($pC->getSubCategorias()->getTotal() > 0) { $array['filhos'] = new ArrayObject(); while ($sPC = $pC->getSubCategorias()->listar('ASC', ListaProdutoCategorias::NOME)) { $array['filhos']->append(navigateToCategory($sPC)); } } else { $array['produtos'] = new ArrayObject(); while ($p = $pC->getProdutos()->listar("ASC", ListaProdutos::NOME)) { $array['produtos']->append($p); } } return $array; }
$cP = new ProdutoCategoria(); } if (empty($_POST['nome'])) { $erro = "<b>Nome</b> não preenchido!<br><br>"; } if (empty($erro)) { $pC = new ProdutoCategoria(); $pC->nome = $_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 = $_POST['descricaoPequena']; $pC->descricao = $_POST['descricao']; $pC->setIdCategoriaPai($cP->getId()); if (!empty($_FILES['imagem']['name'])) { $pC->setImagem(new Image(Arquivos::__OpenArquivoByTEMP($_FILES['imagem']))); } $lCP->inserir($pC); while ($i = $lI->listar()) { $t = new Traducao(); $t->setIdConteudo($pC->getId()); $t->setCampoConteudo(ListaProdutoCategorias::NOME); $t->setTabelaConteudo($lCP->getTabela()); $t->conteudo = $pC->nome; $t->traducao = $_POST['inome'][$i->getId()];