예제 #1
0
파일: Menu.php 프로젝트: reytuty/facil
 private function prepareCategories(&$array)
 {
     foreach ($array as $category) {
         $category->slug = DataHandler::strToURL($category->name);
         if (count($category->__array_category) > 0) {
             $this->prepareCategories($category->__array_category);
         }
     }
 }
예제 #2
0
파일: Client.php 프로젝트: reytuty/facil
 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;
 }
예제 #3
0
파일: Equipe.php 프로젝트: reytuty/facil
 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["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;
     }
     if (!isset($_POST["hat"])) {
         $_POST["hat"] = "nao";
     }
     if (!isset($_POST["author"])) {
         $_POST["author"] = "nao";
     }
     return parent::commit($redirect_page, $gallery_type);
 }
예제 #4
0
파일: Produtos.php 프로젝트: reytuty/facil
 /**
  * baixar o zip do mal
  * ?products={product_id:N,gallery:true,dimensions:true,files:[]}|{product_id:N,gallery:true,dimensions:true,files:[]}
  */
 public function getZip()
 {
     if (!UserClient::getId() > 0) {
         //nao tem permissao
         Navigation::redirect("405");
         exit;
     }
     set_time_limit(0);
     //tratando variaveis enviadas
     $files_id = DataHandler::getValueByArrayIndex($_POST, "file_id");
     $imagens = DataHandler::getValueByArrayIndex($_POST, "imagens");
     $pdf = DataHandler::getValueByArrayIndex($_POST, "pdf");
     //precisa saber quais sao os produtos envolvidos
     $array_products_id = array();
     $array_files = array();
     if ($files_id) {
         foreach ($files_id as $file_id) {
             $temp_array = explode("_", $file_id);
             $product_id = $temp_array[0];
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
                 $array_files[] = $product_id;
             }
         }
     }
     if ($imagens) {
         foreach ($imagens as $product_id) {
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
             }
         }
     }
     if ($pdf) {
         foreach ($pdf as $product_id) {
             if (!in_array($product_id, $array_products_id)) {
                 $array_products_id[] = $product_id;
             }
         }
     }
     $ReturnResultVO = new ReturnResultVO();
     $ProductVO = new ContentSiteVO();
     $FileVO = new FileVO();
     //se tiver produtos para tratar
     if (count($array_products_id) > 0) {
         //a pasta zip precisa existir
         $zip_path = "upload/zip/";
         DataHandler::createFolderIfNotExist($zip_path);
         $array_products_to_zip = array();
         $unique_str = "";
         //nome final do zip que vai baixar, adiciona alguns parametros indicadores
         $zip_name = "teto";
         if (count($array_products_id) > 0) {
             //sao varios produtos
             $zip_name = $zip_name . "_produtos";
         }
         //cada indice dessa array, tem que ser array, terá um json com as info:
         foreach ($array_products_id as $product_id) {
             $resultProduto = $ProductVO->setId($product_id, TRUE);
             if ($resultProduto->success) {
                 $stdProduct = $ProductVO->toStdClass();
                 $array_products_to_zip[] = $stdProduct;
                 $array_images = array();
                 if ($imagens) {
                     if (in_array($product_id, $imagens)) {
                         $array_gallery = $ProductVO->getImages(NULL, "gallery", true);
                         foreach ($array_gallery as $imageVO) {
                             $array_images[] = $imageVO->getURL();
                             $unique_str .= "|" . $imageVO->getId();
                             //add a imagem na pasta
                         }
                         //
                         $array_dimensions = $ProductVO->getImages(NULL, "dimensions", true);
                         foreach ($array_dimensions as $imageVO) {
                             $array_images[] = $imageVO->getURL();
                             //add a imagem na pasta
                             $unique_str .= "|" . $imageVO->getId();
                         }
                     }
                 }
                 $stdProduct->images = $array_images;
                 $array_file_vo = array();
                 //cria a pasta do produto no zip
                 $product_folder_name = DataHandler::strToURL($stdProduct->title);
                 if (count($array_files) > 0) {
                     if (in_array($product_id, $array_files)) {
                         //esse produto pediu algum file
                         $temp_array_files = $ProductVO->getFiles();
                         foreach ($temp_array_files as $FileVO) {
                             if (in_array($FileVO->id, $files_id)) {
                                 $array_file_vo[] = $FileVO;
                                 $unique_str .= "|f." . $file_id;
                                 //add a url do arquivo no zip na pasta
                             }
                         }
                     }
                 }
                 $stdProduct->files = $array_file_vo;
                 $stdProduct->pdf = null;
                 //verificar se quer o pdf
                 if (count($pdf) > 0) {
                     $unique_str .= "|pdf!|";
                     //quero pdf
                     //ver com onde foi salvo
                     if (in_array($product_id, $pdf)) {
                         //ele quer esse pdf, provavelmente se chegou aqui é porque ele realmente exite
                         //mas vou conferir de novo
                         $pdf_url = "upload/pdf/{$product_id}/" . $ProductVO->slug . ".pdf";
                         if (file_exists($pdf_url)) {
                             $stdProduct->pdf = $pdf_url;
                         }
                     }
                 }
             }
             //end if produto sucess
         }
         $folder_name = md5($unique_str);
         DataHandler::createFolderIfNotExist($zip_path . $folder_name . "/");
         $zip_name = $zip_path . $folder_name . "/" . $zip_name . ".zip";
         //echo $zip_name;exit();
         if (!file_exists($zip_name)) {
             //echo Debug::li($zip_name);exit();
             $Zip = new ZipArchive();
             $Zip->open($zip_name, ZipArchive::CREATE);
             //adicionando os arquivos escolhidos
             foreach ($array_products_to_zip as $ProductStd) {
                 $product_slug_folder = $ProductStd->id . "_" . DataHandler::strToURL($ProductStd->title);
                 foreach ($ProductStd->files as $FileVO) {
                     $url = $FileVO->getUrl();
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $Zip->addFile($url, $product_slug_folder . "/arquivos/" . $file);
                 }
                 foreach ($ProductStd->images as $url) {
                     //$url 	= $ImageVO->getUrl();
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $file = str_replace("original_", "", $file);
                     $Zip->addFile($url, $product_slug_folder . "/imagens/" . $file);
                 }
                 if ($ProductStd->pdf) {
                     $url = $ProductStd->pdf;
                     $array = explode("/", $url);
                     $file = $array[count($array) - 1];
                     $Zip->addFile($url, $product_slug_folder . "/ficha_tecnica.pdf");
                 }
             }
             $Zip->close();
         }
         header("Location: " . Config::getRootPath($zip_name));
         exit;
     }
     exit;
 }
예제 #5
0
파일: Product.php 프로젝트: reytuty/facil
 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["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;
     }
     if (!isset($_POST["hat"])) {
         $_POST["hat"] = "nao";
     }
     if (isset($_POST["nao_e_produto"])) {
         $_POST["active"] = 2;
     }
     if (!isset($_POST["author"])) {
         $_POST["author"] = "nao";
     }
     // Debug::print_r($_POST);exit();
     $return = parent::commit(FALSE, $gallery_type);
     $this->updatePdf($return->id);
     if ($redirect_page) {
         //Navigation::redirect($this->my_redirect);
         Navigation::redirect("backend/product/change/id." . $return->id);
         exit;
     }
     return $return;
 }