private function createFormData($ReturnResultVO = NULL) { //busca o primeiro content vinculada com essa categoria if ($this->category_id > 0) { $CategoryVO = new CategoryVO(); $CategoryVO->setId($this->category_id, TRUE); $array_content = $CategoryVO->getLinks("content", 1); //se tiver mais de um link if (count($array_content) > 0) { //pega o primeiro pois aqui só importa 1. $LinkVO = $array_content[0]; if (FALSE) { //ajuda aptana $LinkVO = new LinkVO(); } //echo Debug::li("tem content vinculada com id:".$LinkVO->getLinkedTableId()); //inicia a ContentForumVO $this->ContentSiteVO->setId($LinkVO->getLinkedTableId(), TRUE); } } else { if ($this->content_id > 0) { $this->my_action .= "/id.{$this->content_id}/"; } } $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action)); $ImageFormView = new ImageFormView(); $ImageFormView->setFormLabel("Selecionar Foto"); $ImageFormView->setQuantity(0); // $ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText')); $FileFormView = new FileFormView(); $FileFormView->setFormLabel("Selecionar Arquivo"); $FileFormView->setQuantity(0); // $formData->setPersonalInput(array("name"=>"destaque[]","label"=>"Mostrar em qual Menu?", "options"=>array((object) array("name"=>"Menu Topo", "id"=>"2"), (object) array("name"=>"Menu Rodapé", "id"=>"3")))); //trocando o rótulo para Content $formData->setDescription(array("label" => "Edite a coluna da Esquerda:", 'type' => 'htmlText')); $formData->setContent(array("label" => "Edite a coluna da Direita:")); $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id))); $formData->setImage($ImageFormView); $formData->setFile($FileFormView); $formData->setMassiveAttr('visible', FALSE, array('Name', 'Title', 'Hat', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order')); $formData->setActive(array("value" => "1", "visible" => FALSE)); $this->my_redirect = "admin/contact/edit/"; parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO); }
public function edit() { //busca o primeiro content vinculada com essa categoria if ($this->category_id > 0) { $CategoryVO = new CategoryVO(); $CategoryVO->setId($this->category_id, TRUE); $array_content = $CategoryVO->getLinks("content", 1); //se tiver mais de um link if (count($array_content) > 0) { //pega o primeiro pois aqui só importa 1. $LinkVO = $array_content[0]; if (FALSE) { //ajuda aptana $LinkVO = new LinkVO(); } //echo Debug::li("tem content vinculada com id:".$LinkVO->getLinkedTableId()); //inicia a ContentEncVO $this->ContentEncVO->setId($LinkVO->getLinkedTableId(), TRUE); } } //criar o formView $formData = new ContentFormView($this->ContentEncVO, Config::getRootPath($this->my_action)); //trocando o rótulo para Content $formData->setContent(array("label" => "Edite o texto:")); $ImageFormView = new ImageFormView(); $ImageFormView->setFormLabel("Inserir Imagem"); //quando ta em outro idioma que não o padrao, não pode ter imagem $ImageFormView->setQuantity(0); $FileFormView = new FileFormView(); $FileFormView->setFormLabel("Inserir Arquivo"); $FileFormView->setQuantity(0); if ($this->ContentEncVO->getId() > 0) { //se tiver id significa que o content já foi adicionado alguma vez, então deixa queto } else { //seta o id dessa categoria caso não tenha nenhum content vinculado, pois essa categoria só admite 1 content $formData->setCategory(array("selected" => array($this->category_id))); } $formData->setImage($ImageFormView); $formData->setFile($FileFormView); $formData->setMassiveAttr('visible', FALSE, array('Name', 'Title', 'Hat', 'Description', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order')); $formData->setSlug(array("value" => "entre_em_contato", "visible" => FALSE)); $formData->setActive(array("value" => "1", "visible" => FALSE)); parent::edit($formData, TRUE, NULL, $this->my_redirect); }
public function getFiles($LOCALE = NULL) { if (!$this->_array_files) { $this->_array_files = array(); $arrayLinkVO = $this->getLinks("file", 1); //varre a array de LinkVO para transformar em ImageVO foreach ($arrayLinkVO as $LinkVO) { if (FALSE) { //para o aptana me ajudar $LinkVO = new LinkVO(); } $ReturnDataVO = $LinkVO->getLinkedVO(); if ($ReturnDataVO->success) { //pega o VO e da push na array interna $this->_array_files[] = $ReturnDataVO->result; } else { //se der erro, veja sua config para ver se o módulo file está cadastrado } } } return $this->_array_files; //Debug::print_r($this->_array_files); $arrayRetorno = array(); //chegando aqui ele já buscou as imagens que possuia e transformou em VO, varre foreach ($this->_array_files as $VO) { if (FALSE) { $VO = new FileVO(); //para o aptana me ajudar } //agora vai filtar pelo locale recebido //if($LOCALE == $VO->getLocale()){ $arrayRetorno[] = $VO; //} } return $arrayRetorno; }
/** * @return void da echo de string */ public function link() { $LinkDAO = LinkDAO::getInstance(); if (FALSE) { $LinkDAO = new LinkDAO(); } $ReturnResultVO = new ReturnResultVO(); $ReturnResultVO->success = TRUE; //enviar por post: //category_id //array_content_id if (DataHandler::getValueByArrayIndex($_POST, "category_id") && DataHandler::getValueByArrayIndex($_POST, "array_content_id")) { $category_id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($_POST, "category_id")); //talvez não seja array $array_content_id = DataHandler::getValueByArrayIndex($_POST, "array_content_id"); $table = DataHandler::getValueByArrayIndex($_POST, "table"); $linked_table = DataHandler::getValueByArrayIndex($_POST, "linked_table"); if (!is_array($array_content_id)) { $array_content_id = explode(",", $array_content_id); } if (is_array($array_content_id)) { $contador = 0; foreach ($array_content_id as $content_id) { //inicia a linkVO se existir $ReturnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, $table, $category_id, $linked_table, $content_id, 1); if (FALSE) { $ReturnDataVO = new ReturnDataVO(); } if ($ReturnDataVO->success) { $arrayResults = $ReturnDataVO->result; if ($ReturnDataVO->count_total > 0) { //pega só o primeiro, mas se tiver mais do que 1 poderia dar um warning if ($ReturnDataVO->count_total > 1) { //warning, deveria ter só 1 } $LinkVO = $arrayResults[0]; //para ajuda do aptana if (FALSE) { $LinkVO = new LinkVO(); } $LinkVO->setOrder($contador); $ReturnDataVO = $LinkDAO->update($LinkVO->getId(), $LinkVO->getActive(), $LinkVO->getTable(), $LinkVO->getTableId(), $LinkVO->getLinkedTable(), $LinkVO->getLinkedTableId(), $LinkVO->getOrder()); if (!$ReturnDataVO->success) { $ReturnResultVO->success = FALSE; $ReturnResultVO->addMessage("erro ao atualizar o item de id:" . $LinkVO->getLinkedTableId()); } $contador++; } } } //end foreach } else { $ReturnResultVO->success = FALSE; $ReturnResultVO->addMessage("Enviar content_id por POST em array"); } //end if array } else { $ReturnResultVO->success = FALSE; $ReturnResultVO->addMessage("Enviar por POST category_id e array_content_id."); } //end if foi enviado posts if ($ReturnResultVO->success) { $ReturnResultVO->addMessage("Ordem definida com sucesso."); } echo $ReturnResultVO->toJson(); exit; }