Exemplo n.º 1
0
 /**
  * Cada plugin deve saber se ao deletar precisa apagar arquivos, desvincular, excluir ou não do banco
  * @param $item_id int da entrada do item a ser deletado no banco.
  * @return ReturnResultVO
  */
 public function delete($item_id)
 {
     //aqui precisa realmente deletar a imagem, ou desvincula-la, o que é melhor
     include_once "library/facil3/core/dao/LinkDAO.class.php";
     $LinkDAO = LinkDAO::getInstance();
     if (FALSE) {
         $LinkDAO = new LinkDAO();
     }
     //desvincula a foto ao table e table_id enviado
     $ReturnResultVinculoVO = $LinkDAO->deleteAllByTableAndTableId("image", $item_id);
     return $ReturnResultVinculoVO;
 }
Exemplo n.º 2
0
 private function getContents($category_id)
 {
     $LinkDAO = LinkDAO::getInstance();
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $category_id, "content", NULL, 1, NULL, NULL);
     //verifica se o resultado é uma categoryVO
     $arrayContentsVO = array();
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //Debug::print_r($LinkVO);
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //Debug::print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 if ($tempReturnDataVO->result->active >= 0) {
                     $arrayContentsVO[] = $tempReturnDataVO->result;
                 }
                 //end if active
             }
         }
         //exit();
     }
     return $arrayContentsVO;
 }
Exemplo n.º 3
0
 /**
  * para listagem de produtos
  */
 public function init()
 {
     //lista todos produtos vinculados a categoria 2
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new HttpRoot();
     $arrayContentsVO = array();
     //se foi passado o id da categoria entao vai buscar todos os contentents vinculados a mesma
     //echo Debug::li($this->category_id);exit();
     $LinkDAO = LinkDAO::getInstance();
     $category_id = 2;
     //categoria a que todos os produtos estão vinculados
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $category_id, "content", NULL, 1, NULL, NULL, $order_by = "order", $order_type = NULL);
     //verifica se o resultado é uma categoryVO
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //Debug::print_r($LinkVO);
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //Debug::print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 $stdClass = $tempReturnDataVO->result;
                 $dads = $stdClass->getCategoriesDad();
                 if ($stdClass->active == 1 && count($dads) > 1) {
                     //pega o nome da sub categoria e categoria que ele pertence
                     //Debug::print_r($dads);
                     $arrayContentsVO[] = $stdClass;
                 }
             }
         }
         //exit();
     }
     DataHandler::objectSort($arrayContentsVO, "title");
     $retornoDaPaginaHTML->arrayContentsVO = $arrayContentsVO;
     //salvando o objeto de resultado de html no retorno
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     //Debug::print_r($returnResult);
     //exit();
     return $returnResult;
 }
Exemplo n.º 4
0
 function delete()
 {
     $image_id = DataHandler::getValueByArrayIndex($_POST, "id");
     $ReturnResultVO = new ReturnResultVO();
     if ($image_id > 0) {
         //vai deletar
         $ImageVO = new ImageVO();
         $ImageVO->setId($image_id, TRUE);
         $ImageVO->delete();
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         $ReturnDataVO = $LinkDAO->deleteAllFromLinkedTableAndLinkedTableId("image", $image_id);
         $ReturnResultVO->success = $ReturnDataVO->success;
         if ($ReturnResultVO->success) {
             $ReturnResultVO->addMessage(Translation::text("Image deleted successfully."));
         } else {
             $ReturnResultVO->addMessage(Translation::text("Error when deleting image."));
         }
     }
     echo $ReturnResultVO->toJson();
     exit;
 }
Exemplo n.º 5
0
 public function select()
 {
     //iniciando o retorno padrao em http result
     $returnResult = new HttpResult();
     $resultPage = new DefaultPage();
     $resultPage->__array_category = $this->getCategoryCascade($this->category_id);
     //adicionando ContentVO na lista de category
     $LinkDAO = LinkDAO::getInstance();
     //Debug::print_r($resultPage->__array_category);exit();
     foreach ($resultPage->__array_category as $level1) {
         foreach ($level1->__array_category as $level2) {
             //Debug::print_r($level2);
             $level2->__array_category = array();
             //agora lista os contents e poe aqui como se fosse categoria
             $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $level2->id, "content", NULL, 1);
             //verifica se o resultado é uma categoryVO
             if ($returnDataVO->success && count($returnDataVO->result) > 0) {
                 foreach ($returnDataVO->result as $LinkVO) {
                     $tempReturnDataVO = $LinkVO->getLinkedVO();
                     //Debug::print_r($tempReturnDataVO);exit();
                     if ($tempReturnDataVO->success) {
                         //Debug::print_r($tempReturnDataVO->result);
                         $std = new stdClass();
                         $std->id = $tempReturnDataVO->result->id;
                         $std->name = $tempReturnDataVO->result->title;
                         $std->category_id = $level2->id;
                         $level2->__array_category[] = $std;
                     }
                 }
                 //exit();
             }
         }
     }
     $returnResult->setHttpContentResult($resultPage);
     return $returnResult;
 }
Exemplo n.º 6
0
 public function getCategoriesDad()
 {
     if (!$this->_array_categories_dad) {
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         $ReturnResultDAO = $LinkDAO->select(LinkDAO::RETURN_STD_OBJECT, "category", NULL, "content", $this->id, 1);
         if ($ReturnResultDAO->success && $ReturnResultDAO->count_total > 0) {
             $this->_array_categories_dad = array();
             foreach ($ReturnResultDAO->result as $linkVO) {
                 $this->_array_categories_dad[] = $linkVO->table_id;
             }
         }
     }
     return $this->_array_categories_dad;
 }
Exemplo n.º 7
0
 public function commit($redirect_page = TRUE, $gallery_type = "image")
 {
     //iniciando o retorno padrao
     $_POST["active"] = 1;
     if (!isset($_POST["category"]) || $_POST["category"] == NULL) {
         $_POST["category"] = array($this->category_id);
     } else {
         if (!is_array($_POST["category"])) {
             $_POST["category"] = array($_POST["category"], $this->category_id);
         } else {
             //é uma array, mas melhor garantir que tem o produto id
             $_POST["category"][] = $this->category_id;
         }
     }
     if (isset($_POST["hat"])) {
         $hat = $_POST["hat"];
         //tira o vinculo com a tabela ano (que nao existe)
         if ($content_id) {
             //adiciona o vinculo com a tabela ano de indice hat
             $LinkDAO = LinkDAO::getInstance();
         }
         //deleta vinculos com categoria
         $LinkDAO->deleteAllFromLinkedTableByTableAndTableId('content', $content_id, 'ano');
         $LinkDAO->insert('ano', $hat, 'content', $content_id, 1, 0);
     }
     if (isset($_POST["title"])) {
         $_POST["slug"] = DataHandler::strToURL($_POST["title"]);
     }
     if (!isset($_POST["id"]) && DataHandler::getValueByArrayIndex($this->arrayVariable, "id")) {
         $_POST["id"] = DataHandler::getValueByArrayIndex($this->arrayVariable, "id");
     }
     if (!isset($_POST["order"])) {
         $_POST["order"] = NULL;
     }
     $return = parent::commit(FALSE, $gallery_type);
     $this->updatePdf($return->id);
     if ($redirect_page) {
         //Navigation::redirect($this->my_redirect);
         Navigation::redirect("backend/client/change/id." . $return->id);
         exit;
     }
     return $return;
 }
Exemplo n.º 8
0
 /**
  * @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;
 }
Exemplo n.º 9
0
 /**
  * para detalhe de um produto
  */
 public function init()
 {
     //Debug::print_r($this->arrayVariable);
     //filtro vindo por parametro é o addres que ele tem que enviar de volta como busca
     //rel ids de produtos relacionados
     //exit();
     //echo 12;
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     if ($id > 0) {
         $ContentSiteVO = new ContentSiteVO();
         $ReturnResult_vo = $ContentSiteVO->setId($id, TRUE);
         if ($ReturnResult_vo->success) {
             $stdProduct = $ContentSiteVO->toStdClass();
             $stdProduct->array_gallery = $ContentSiteVO->getImages(NULL, "gallery", true);
             $stdProduct->array_dimensions = $ContentSiteVO->getImages(NULL, "dimensions", true);
             $stdProduct->array_video = $ContentSiteVO->getImages(NULL, "video", true);
             $stdProduct->array_360 = $ContentSiteVO->getImages(NULL, "360", true);
             $stdProduct->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", true);
             $LinkDAO = LinkDAO::getInstance();
             //passo 1, descobrir a qual família esse protudo pertence
             //passo 2, pegar todos os produtos pertencente a mesma família
             //passo 3, tirar o próprio produto da listagem de produtos da mesma família
             $array_links = array();
             $resultLinks = $LinkDAO->select(DbInterface::RETURN_STD_OBJECT, "content", $table_id = null, $linked_table = 'content', $linked_table_id = $id, $active = 1, $quant_started = NULL, $quant_limit = NULL, $order_by = "order", $order_type = " ASC ");
             if ($resultLinks->success && $resultLinks->count_total > 0) {
                 foreach ($resultLinks->result as $familia) {
                     $link = $familia;
                     //$resultLinks->result[0];
                     $ContentFamiliaVO = new ContentSiteVO();
                     $ContentFamiliaVO->setId($link->table_id, TRUE);
                     Debug::print_r($ContentFamiliaVO);
                     exit;
                     if ($ContentFamiliaVO->active > 0) {
                         $arrayResult_links = $ContentFamiliaVO->getLinks("content");
                         foreach ($arrayResult_links as $link) {
                             if ($link->linked_table_id != $id) {
                                 $ResultTempLink = $link->getLinkedVO();
                                 if ($ResultTempLink->success) {
                                     $produtoVO = $ResultTempLink->result;
                                     if ($produtoVO->active > 0) {
                                         $stdProduto = $produtoVO->toStdClass();
                                         $stdProduto->array_tagged = $produtoVO->getImages(NULL, "tagged", NULL);
                                         $array_links[] = $stdProduto;
                                     }
                                     //Debug::print_r($stdProduto);exit();
                                 }
                             }
                             //end if
                         }
                         //end foerach
                     }
                 }
             }
             //verifica a qual familia esse produto pertence
             $stdProduct->array_produtos_vinculados = $array_links;
             //Debug::print_r($array_links);
             //exit();
             //pegando array de vinculados enviados como id
             $str_ids_send = DataHandler::getValueByArrayIndex($this->arrayVariable, "rel");
             $array_ids_send = explode("|", $str_ids_send);
             $array_filtro = array();
             foreach ($array_ids_send as $id) {
                 $ContentSiteVO = new ContentSiteVO();
                 $tempResult = $ContentSiteVO->setId($id, TRUE);
                 if ($tempResult->success) {
                     $stdProduto = $ContentSiteVO->toStdClass();
                     $stdProduto->array_tagged = $ContentSiteVO->getImages(NULL, "tagged", NULL);
                     $array_filtro[] = $stdProduto;
                 }
             }
             $stdProduct->array_filtro = $array_filtro;
             //Debug::print_r($array_links);
             $returnResult = new HttpResult();
             //exit();
             //iniciando o resultado para o html
             $retornoDaPaginaHTML = new HttpRoot();
             $retornoDaPaginaHTML->vo = $stdProduct;
             $retornoDaPaginaHTML->addressToReturn = str_replace("|", "/", DataHandler::getValueByArrayIndex($this->arrayVariable, "filtro"));
             $strToResend = implode("/", $this->arrayRestFolder);
             $strToResend = explode("/:/", $strToResend);
             if (is_array($strToResend) && count($strToResend) > 1) {
                 $strToResend = $strToResend[1];
             } else {
                 $strToResend = "";
             }
             $retornoDaPaginaHTML->addressToResend = $strToResend;
             $returnResult->setHttpContentResult($retornoDaPaginaHTML);
             return $returnResult;
         } else {
             Navigation::redirect("");
         }
     } else {
         //não mandou o id, vai pra listagem
         Navigation::redirect("produtos");
     }
 }
Exemplo n.º 10
0
 private function createFormData($ReturnResultVO = NULL)
 {
     //adiciona o content na url de envio do formulario
     if ($this->content_id > 0) {
         $this->my_action .= "/id.{$this->content_id}/";
     }
     //echo $this->my_action;
     $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Selecionar Foto");
     $ImageFormView->setShowImageUrl(TRUE);
     //		$ImageFormView->setName(array("label"=>"link", "visible"=>TRUE));
     if ($this->sub == "unidades") {
         $ImageFormView->setQuantity(0);
     } else {
         $ImageFormView->setQuantity(1);
     }
     //		$ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText'));
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Selecionar Arquivo");
     $FileFormView->setQuantity($this->total_files);
     if ($this->sub == "blog") {
         //id do blog 36
         $CategoryVO = new CategoryVO();
         $CategoryVO->setId(36, TRUE);
         $array_categorias = $CategoryVO->selectCascade(CategoryDAO::RETURN_STD_OBJECT, 1);
         $selected_category = array();
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         if ($this->ContentSiteVO->id > 0) {
             $ReturnLinkCategory = $LinkDAO->select(LinkDAO::RETURN_STD_OBJECT, NULL, NULL, "content", $this->ContentSiteVO->id, 1);
             if ($ReturnLinkCategory->success && $ReturnLinkCategory->count_total > 0) {
                 foreach ($ReturnLinkCategory->result as $link_std) {
                     $selected_category[] = $link_std->table_id;
                 }
             }
         }
         //Debug::print_r($ReturnLinkCategory);exit();
         //new ContentSiteVO();
         $formData->setCategory(array("visible" => TRUE, "name" => "category[]", "label" => "Categorias", "selected" => $selected_category, "options" => $array_categorias));
     } else {
         $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id)));
     }
     if ($this->sub == "unidades") {
         $formData->setContent(array("label" => "Endereço:", "value" => "unidade"));
     } else {
         //trocando o rótulo para Content
         $formData->setContent(array("label" => "Descrição:"));
     }
     //trocando o rótulo para Title
     $formData->setTitle(array("label" => "Titulo:"));
     //		$formData->setHat(array("label"=>"Link:"));
     $formData->setDate(array("label" => "Data(formato: dd/mm/aaaa hh:mm:ss para 'agora' deixe vazio):"));
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $array_to_visible_false = array('Name', 'Hat', 'Description', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'DateIn', 'DateOut', 'Order');
     if ($this->sub == "unidades") {
         $array_to_visible_false = array('Name', 'Description', 'Content', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order');
         $formData->setHat(array("label" => "Endereço"));
         $formData->setAuthor(array("label" => "Link Mapa"));
     }
     $formData->setMassiveAttr('visible', FALSE, $array_to_visible_false);
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     //$this->my_redirect = "admin/page/select/";
     parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO);
 }
Exemplo n.º 11
0
 public function init()
 {
     //busca todas as paginas cadastradas na tabela content
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new HttpContentModule();
     $retornoDaPaginaHTML->arrayVariable = $this->arrayVariable;
     /*
     	$address1 = new stdClass();
     			$address1->area = 'Rio de Janeiro (RJ)';
     			$address1->description = 'Av. Das Nações Unidas, 4777 Lj 27 - Piso G1 / Tel: (11) 5042-7840';
     			$address1->google_maps_url = 'http://maps.google.com.br/maps?f=q&source=s_q&hl=pt-BR&geocode=&q=Avenida+dos+Eucaliptos,+762,+Moema,+S%C3%A3o+Paulo&sll=-23.484148,-46.838983&sspn=0.01234,0.022724&ie=UTF8&hq=&hnear=Av.+dos+Eucaliptos,+762+-+Moema,+S%C3%A3o+Paulo,+04517-050&ll=-23.609531,-46.669793&spn=0.012092,0.022724&z=16';
     			
     			$place1 = new stdClass();
     			$place1->area = 'SUDESTE';
     			$place1->addresses = array($address1,$address1,$address1,$address1);
     			
     			$region1 = new stdClass();
     			$region1->name = 'embreve';
     			$region1->title = 'Em breve nocas unidades:';
     			$region1->places = array($place1,$place1,$place1,$place1);
     
     	$region2 = new stdClass();
     	$region2->name = 'sp';
     	$region2->title = 'São Paulo';
     	$region2->places = array($place1,$place1,$place1,$place1);
     	
     	$region3 = new stdClass();
     	$region3->name = 'ba';
     	$region3->title = 'Bahia';
     	$region3->places = array($place1,$place1,$place1,$place1);
     	
     	$region4 = new stdClass();
     	$region4->name = 'mt';
     	$region4->title = 'Mato Grosso';
     	$region4->places = array($place1,$place1,$place1,$place1);
     	
     	$region4 = new stdClass();
     	$region4->name = 'ms';
     	$region4->title = 'Mato Grosso do Sul';
     	$region4->places = array($place1,$place1,$place1,$place1);
     	
     	$HttpContentResult->regions = array($region1,$region2,$region3,$region4);
     */
     //listar categorias de 19
     $array_category = $this->getCategoryCascade(19);
     //Debug::print_r($array_category);
     $arrayRegions = array();
     foreach ($array_category as $stdCategory) {
         $region = $this->getRegion($stdCategory->id, $stdCategory->name, $stdCategory->name);
         foreach ($stdCategory->__array_category as $stdCategory2) {
             //Debug::print_r($stdCategory2);
             $place = $this->getPlace($stdCategory2->name);
             $LinkDAO = LinkDAO::getInstance();
             $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", $stdCategory2->id, "content", NULL, 1);
             //verifica se o resultado é uma categoryVO
             if ($returnDataVO->success && count($returnDataVO->result) > 0) {
                 foreach ($returnDataVO->result as $LinkVO) {
                     $tempReturnDataVO = $LinkVO->getLinkedVO();
                     //Debug::print_r($tempReturnDataVO);exit();
                     if ($tempReturnDataVO->success) {
                         //Debug::print_r($tempReturnDataVO->result);
                         $address = new stdClass();
                         $address->area = $tempReturnDataVO->result->title;
                         $address->description = $tempReturnDataVO->result->hat;
                         $address->google_maps_url = $tempReturnDataVO->result->author;
                         $place->addresses[] = $address;
                     }
                 }
                 //exit();
             }
             $region->places[] = $place;
         }
         $arrayRegions[] = $region;
     }
     //Debug::print_r($arrayRegions);
     //em breve
     $retornoDaPaginaHTML->regions = $arrayRegions;
     //array($region1,$region2,$region3,$region4);
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
Exemplo n.º 12
0
 /**
  * 
  * Usar: backend/product/delete_file/id.N/type.TYPE/
  */
 public function deleteFile()
 {
     $ReturnResultVO = new ReturnResultVO();
     $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id"));
     $product_id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "product_id"));
     if ($id > 0) {
         $LinkDAO = LinkDAO::getInstance();
         $ReturnDataVO = $LinkDAO->deleteAllFromLinkedTableAndLinkedTableId("file", $id);
         $ReturnResultVO->success = $ReturnDataVO->success;
         //n√£o est√° tratando o tipo de erro
     } else {
         $ReturnResultVO->addMessage(Translation::text("id?"));
     }
     Navigation::redirect("backend/product/file/id.{$product_id}/");
     //echo $ReturnResultVO->toJson();
     exit;
 }
Exemplo n.º 13
0
 public function afiliateBanner()
 {
     //iniciando o retorno padrao em http result
     $returnResult = new HttpResult();
     //iniciando o resultado para o html
     $retornoDaPaginaHTML = new PurchaseInfo();
     //define a dao a ser usada em toda a controler
     $ContentSiteDAO = ContentSiteDAO::getInstance();
     $vo = $ContentSiteDAO->getVO();
     //define a vo a ser usada em toda a controler
     $ContentSiteVO = $ContentSiteDAO->getVO();
     //pega id passado na url
     $LinkDAO = LinkDAO::getInstance();
     $returnDataVO = $LinkDAO->select(LinkDAO::RETURN_VO, "category", 20, "content", NULL, 1);
     //			echo $this->category_id;
     //			print_r($returnDataVO);exit();
     //verifica se o resultado é uma categoryVO
     $arrayContentsVO = array();
     if ($returnDataVO->success && count($returnDataVO->result) > 0) {
         foreach ($returnDataVO->result as $LinkVO) {
             //					print_r($LinkVO);;
             $tempReturnDataVO = $LinkVO->getLinkedVO();
             //					print_r($tempReturnDataVO);exit();
             if ($tempReturnDataVO->success) {
                 $arrayContentsVO[] = $tempReturnDataVO->result;
             }
         }
     }
     $novo_content = array();
     foreach ($arrayContentsVO as $ContentsVO) {
         if ($ContentsVO->active > 1) {
             $images = $ContentsVO->getImages();
             $ContentsVO->images = $images;
             $novo_content[] = $ContentsVO;
         }
     }
     $arrayContentsVO = $novo_content;
     $returnResult->setSuccess(TRUE);
     $retornoDaPaginaHTML->array_banner = $arrayContentsVO;
     $returnResult->setHttpContentResult($retornoDaPaginaHTML);
     return $returnResult;
 }
Exemplo n.º 14
0
 /**
  * Da redirect
  * Envie redirect_with_id para o seu redirect_to ir com o parametro id no final
  * @return void
  */
 public function commit($redirect_page = TRUE, $link_table = "image")
 {
     $contentVO = new ContentSiteVO();
     if (isset($_POST["id"])) {
         $contentVO->setId($_POST["id"], TRUE);
     }
     $contentVO->setFetchArray($_POST);
     //antes de tudo, faz a validação
     $ValidationReturnResultVO = new ReturnResultVO();
     $ValidationReturnResultVO->success = TRUE;
     if (DataHandler::getValueByArrayIndex($_POST, "array_validation")) {
         $array_validation = DataHandler::getValueByArrayIndex($_POST, "array_validation");
         //array de fields que deveriam ser validados e estão errados
         $array_fields_errors = array();
         if (is_array($array_validation)) {
             //se for array, valida a array
             //varre a validação
             foreach ($array_validation as $field_name) {
                 $temp_ReturnResultVO = $this->validateContentFields($field_name, $contentVO);
                 if (!$temp_ReturnResultVO->success) {
                     //echo Debug::li("Content.php erro na validacao : $field_name ");
                     //da o push na array_fields error
                     $array_fields_errors[] = $field_name;
                     //já muda o success do result para false para saber que não precisa mais commitar
                     $ValidationReturnResultVO->success = FALSE;
                 }
             }
         } else {
             if (is_string($array_validation)) {
                 //se for só uma string valida só 1 deles
                 $temp_ReturnResultVO = $this->validateContentFields($field_name, $contentVO);
                 if (!$temp_ReturnResultVO->success) {
                     //da o push na array_fields error
                     $array_fields_errors[] = $field_name;
                     //já muda o success do result para false para saber que não precisa mais commitar
                     $ValidationReturnResultVO->success = FALSE;
                 }
             }
         }
     }
     if (!$ValidationReturnResultVO->success) {
         //coloco na result a array de fields com error
         $ValidationReturnResultVO->result = $array_fields_errors;
         //retorna para o edit de quem extends essa classe
         return $this->{$my_edit_method}($ValidationReturnResultVO);
         //daqui nao passa
         exit;
     }
     //vai criar as key_words do content
     $key_words = "";
     $key_words .= " " . DataHandler::removeAccent($contentVO->getAuthor());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getContent());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getDescription());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getHat());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getName());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getSlug());
     $key_words .= " " . DataHandler::removeAccent($contentVO->getTitle());
     $contentVO->setKeyWords($key_words);
     $returnResultVO = $contentVO->commit();
     $content_id = $contentVO->getId();
     //adicionando link com categoria(s) enviada(s)
     //pega a instancia
     $LinkDAO = LinkDAO::getInstance();
     if (FALSE) {
         $LinkDAO = new LinkDAO();
     }
     //deleta vinculos com categoria
     $LinkDAO->deleteAllFromLinkedTableByTableAndTableId('content', $content_id, 'category');
     $have_category_to_commit = FALSE;
     if (!is_array($_POST["category"])) {
         $_POST["category"] = array($_POST["category"]);
     }
     $arrayCategory = $_POST["category"];
     //Debug::print_r($arrayCategory);exit();
     $order = 10;
     if (!is_array($_POST["order"])) {
         $order = $_POST["order"];
     }
     foreach ($arrayCategory as $category_id) {
         ///print_r($category_id);
         //echo Debug::li("categoria id:".$category_id);
         //cada categoria enviada é mais um link com categoria que deve ser adicionado
         //echo $order;exit();
         $LinkDAO->insert('category', $category_id, 'content', $contentVO->getId(), 1, $order);
         // $contentVO->addLink("category", $category_id);
         $have_category_to_commit = TRUE;
     }
     //exit();
     //caso tenha o que adicionar como link em categoria, commita
     if ($have_category_to_commit) {
         $contentVO->commit();
     }
     //fim da adição do content em categoria
     //-----------------------------==================================== [[[  add imagens ]]]
     $array_image_file = DataHandler::getValueByArrayIndex($_FILES, "image");
     include_once "library/facil3/core/controller/image/FacilImage.php";
     $FacilImage = new FacilImage();
     //echo Debug::li(":link_table   [".$link_table."]");exit();
     $FacilImage->moduleName = $link_table;
     $FacilImage->defaultFolderForNewImages = "upload/image/";
     for ($i = 0; $i < count($array_image_file["name"]); $i++) {
         //Debug::print_r($array_image_file);
         $file_image = array();
         $file_image["name"] = $array_image_file["name"][$i];
         $file_image["type"] = $array_image_file["type"][$i];
         $file_image["tmp_name"] = $array_image_file["tmp_name"][$i];
         $file_image["error"] = $array_image_file["error"][$i];
         $file_image["size"] = $array_image_file["size"][$i];
         //adicionar cada image utilizando o módulo de imagem
         $array_config_info_post = array();
         $image_id = NULL;
         if (DataHandler::getValueByArrayIndex($_POST, "image_info_id")) {
             if (DataHandler::getValueByArrayIndex($_POST["image_info_id"], $i)) {
                 $image_id = $_POST["image_info_id"][$i];
             }
         }
         $array_config_info_post["image_info_id"] = $image_id;
         $array_config_info_post["image_info_name"] = isset($_POST["image_info_name"]) ? $_POST["image_info_name"][$i] : "";
         $array_config_info_post["image_info_description"] = isset($_POST["image_info_description"]) ? $_POST["image_info_description"][$i] : "";
         $array_config_info_post["image_info_order"] = isset($_POST["image_info_order"]) ? $_POST["image_info_order"][$i] : "";
         $array_config_info_post["image_info_locale"] = NULL;
         //$_POST["image_info_locale"][$i];
         $array_config_info_post["image_info_author"] = isset($_POST["image_info_author"][$i]) ? $_POST["image_info_author"][$i] : "";
         $array_config_info_post["table"] = "content";
         $array_config_info_post["table_id"] = $content_id;
         $array_config_info_post["Filedata"] = $file_image;
         $ImageInfoPostVO = new ImageInfoPostVO($array_config_info_post);
         //agora inicia o módulo passando esse info post configurado
         $FacilImage->resetInfoPost($ImageInfoPostVO);
         $ReturnResultVO = $FacilImage->insert();
     }
     //-----------------------------==================================== [[[  add file ]]]
     $array_image_file = DataHandler::getValueByArrayIndex($_FILES, "file");
     include_once "library/facil3/core/controller/file/FacilFile.php";
     $FacilFile = new FacilFile();
     //nome do módulo no sistema
     $FacilFile->moduleName = "file";
     $FacilFile->defaultFolderForNewFiles = "upload/file/";
     for ($i = 0; $i < count($array_image_file["name"]); $i++) {
         $file_image = array();
         $file_image["name"] = $array_image_file["name"][$i];
         $file_image["type"] = $array_image_file["type"][$i];
         $file_image["tmp_name"] = $array_image_file["tmp_name"][$i];
         $file_image["error"] = $array_image_file["error"][$i];
         $file_image["size"] = $array_image_file["size"][$i];
         //adicionar cada image utilizando o módulo de imagem
         $array_config_info_post = array();
         $array_config_info_post["file_info_id"] = isset($_POST["file_info_id"]) ? $_POST["file_info_id"][$i] : "";
         //$_POST["file_info_id"][$i];
         $array_config_info_post["file_info_name"] = isset($_POST["file_info_name"]) ? $_POST["file_info_name"][$i] : "";
         //$_POST["file_info_name"][$i];
         $array_config_info_post["file_info_description"] = isset($_POST["file_info_description"]) ? $_POST["file_info_description"][$i] : "";
         //$_POST["file_info_description"][$i];
         $array_config_info_post["file_info_order"] = isset($_POST["file_info_order"]) ? $_POST["file_info_order"][$i] : "";
         //$_POST["file_info_order"][$i];
         $array_config_info_post["file_info_locale"] = NULL;
         //$_POST["file_info_locale"][$i];
         $array_config_info_post["file_info_author"] = isset($_POST["file_info_author"]) ? $_POST["file_info_author"][$i] : "";
         //$_POST["file_info_author"][$i];
         $array_config_info_post["table"] = "content";
         $array_config_info_post["table_id"] = $content_id;
         $array_config_info_post["Filedata"] = $file_image;
         $FileInfoPostVO = new FileInfoPostVO($array_config_info_post);
         //agora inicia o módulo passando esse info post configurado
         $FacilFile->resetInfoPost($FileInfoPostVO);
         $FacilFile->insert();
     }
     //falta terminar
     //Navigation::redirect("admin/content/");
     $redirect_to = $this->my_redirect;
     if (DataHandler::getValueByArrayIndex($_POST, "redirect_to")) {
         $redirect_to = DataHandler::getValueByArrayIndex($_POST, "redirect_to");
     }
     if ($this->redirect_with_id) {
         $redirect_to .= "/id." . $content_id;
     }
     if ($redirect_page) {
         Navigation::redirect($redirect_to);
         exit;
     } else {
         return $contentVO;
     }
 }
Exemplo n.º 15
0
 public function startLinkDAO()
 {
     $this->LinkDAO = LinkDAO::getInstance();
     return $this->LinkDAO;
 }