public function listar($ordem = "ASC", $campo = self::ID) { $info = parent::listar($ordem, $campo); if (!empty($info)) { parent::resgatarObjetos($info); $temp = new ProdutoCategoria($info[self::ID]); $temp->nome = $info[self::NOME]; $temp->ordem = $info[self::ORDEM]; $temp->disponivel = $info[self::DISPONIVEL] == self::VALOR_DISPONIVEL_TRUE ? true : false; $temp->visaoUnica = $info[self::VISAOUNICA] == self::VALOR_VISAOUNICA_TRUE ? true : false; $temp->descricaoPequena = $info[self::DESCRICAOPEQUENA]; $temp->descricao = $info[self::DESCRICAO]; $temp->subreferencia = $info[self::SUBREFERENCIA]; if (!empty($info[self::IMAGEM])) { $temp->setImagem(new Image(new Arquivos(Sistema::$caminhoURL . Sistema::$caminhoDataProdutoCategorias . $info[self::IMAGEM]))); } $temp->setURL($info[parent::URL]); $temp->setIdCategoriaPai($info[self::CATEGORIAPAI]); return $temp; } }
$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()]; $i->addTraducao($t); $t->setCampoConteudo(ListaProdutoCategorias::DESCRICAOPEQUENA); $t->conteudo = $pC->descricaoPequena; $t->traducao = $_POST['idescricaoPequena'][$i->getId()]; $i->addTraducao($t); $t->setCampoConteudo(ListaProdutoCategorias::DESCRICAO);