public function setFetchArray($array) { $this->image_info_id = DataHandler::getValueByArrayIndex($array, "image_info_id"); $this->image_info_type = DataHandler::getValueByArrayIndex($array, "image_info_type"); $this->image_info_active = DataHandler::getValueByArrayIndex($array, "image_info_active"); $this->image_info_url = DataHandler::getValueByArrayIndex($array, "image_info_url"); $this->image_info_name = DataHandler::getValueByArrayIndex($array, "image_info_name"); $this->image_info_description = DataHandler::getValueByArrayIndex($array, "image_info_description"); $this->image_info_order = DataHandler::getValueByArrayIndex($array, "image_info_order"); $this->image_info_locale = DataHandler::getValueByArrayIndex($array, "image_info_locale"); $this->image_info_author = DataHandler::getValueByArrayIndex($array, "image_info_author"); $this->request_image_id = DataHandler::getValueByArrayIndex($array, "image_id"); $this->request_image_url = DataHandler::getValueByArrayIndex($array, "image_url"); //abaixo, ATENÇÃO: Filedata $this->file_data = DataHandler::getValueByArrayIndex($array, "Filedata"); $this->file_url = DataHandler::getValueByArrayIndex($array, "file_url"); //info de requisição de thumb $this->request_max_width = DataHandler::getValueByArrayIndex($array, "max_width"); $this->request_max_height = DataHandler::getValueByArrayIndex($array, "max_height"); $this->request_crop = DataHandler::getValueByArrayIndex($array, "crop"); $this->request_direct_show = DataHandler::getValueByArrayIndex($array, "direct_show"); $this->request_natural_size = DataHandler::getValueByArrayIndex($array, "natural_size"); //info de vinculo $this->table = DataHandler::getValueByArrayIndex($array, "table"); $this->table_id = DataHandler::getValueByArrayIndex($array, "table_id"); }
public function setFetchArray($array) { //print_r($array); $this->id = DataHandler::getValueByArrayIndex($array, "id"); $this->active = DataHandler::getValueByArrayIndex($array, "active"); $this->name = DataHandler::getValueByArrayIndex($array, "name"); $this->title = DataHandler::getValueByArrayIndex($array, "title"); $this->hat = DataHandler::getValueByArrayIndex($array, "hat"); $this->description = DataHandler::getValueByArrayIndex($array, "description"); $this->content = DataHandler::getValueByArrayIndex($array, "content"); $this->author = DataHandler::getValueByArrayIndex($array, "author"); $this->template_url = DataHandler::getValueByArrayIndex($array, "template_url"); $this->slug = DataHandler::getValueByArrayIndex($array, "slug"); $this->key_words = DataHandler::getValueByArrayIndex($array, "key_words"); $this->date = DataHandler::getValueByArrayIndex($array, "date"); $this->date_in = DataHandler::getValueByArrayIndex($array, "date_in"); $this->date_out = DataHandler::getValueByArrayIndex($array, "date_out"); $this->order = DataHandler::getValueByArrayIndex($array, "order"); $this->request_table_id = DataHandler::getValueByArrayIndex($array, "table_id"); $this->request_table = DataHandler::getValueByArrayIndex($array, "table"); $this->request_content_id = DataHandler::getValueByArrayIndex($array, "content_id"); $this->request_slug = DataHandler::getValueByArrayIndex($array, "slug"); $this->request_locale = DataHandler::getValueByArrayIndex($array, "locale"); $this->request_quant_start = DataHandler::getValueByArrayIndex($array, "quant_start"); $this->request_quant_limit = DataHandler::getValueByArrayIndex($array, "quant_limit"); $this->request_type_of_return = DataHandler::getValueByArrayIndex($array, "type_of_return"); }
public function setFetchArray($array) { //print_r($array); $this->captcha_code = DataHandler::getValueByArrayIndex($array, "captcha_code"); $this->captcha_image = DataHandler::getValueByArrayIndex($array, "captcha_image"); $this->captcha_value = DataHandler::getValueByArrayIndex($array, "captcha_value"); }
public function setFetchArray($array) { //print_r($array); $this->host = DataHandler::getValueByArrayIndex($array, "host"); $this->smtp_auth = DataHandler::getValueByArrayIndex($array, "smtp_auth") == NULL ? FALSE : TRUE; $this->username = DataHandler::getValueByArrayIndex($array, "username"); $this->password = DataHandler::getValueByArrayIndex($array, "password"); $this->from = DataHandler::getValueByArrayIndex($array, "from"); $this->from_name = DataHandler::getValueByArrayIndex($array, "from_name"); $this->to = DataHandler::getValueByArrayIndex($array, "to"); $this->is_html = DataHandler::getValueByArrayIndex($array, "is_html") == NULL ? FALSE : TRUE; $this->subject = DataHandler::getValueByArrayIndex($array, "subject"); $this->add_address = DataHandler::getValueByArrayIndex($array, "add_address"); $this->body = DataHandler::getValueByArrayIndex($array, "body"); if (DataHandler::getValueByArrayIndex($array, "char_set") != NULL) { switch (strtolower(DataHandler::getValueByArrayIndex($array, "char_set"))) { case "iso-8859-1": $this->char_set = "ISO-8859-1"; break; case "utf-8": default: $this->char_set = "UTF-8"; break; } } }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->setId(DataHandler::getValueByArrayIndex($array_dados, "id")); $this->setName(DataHandler::getValueByArrayIndex($array_dados, "name")); $this->setConfig(DataHandler::getValueByArrayIndex($array_dados, "config")); $this->setCountryId(DataHandler::getValueByArrayIndex($array_dados, "country_id")); $this->setCountryName(DataHandler::getValueByArrayIndex($array_dados, "country_name")); $this->setActive(DataHandler::getValueByArrayIndex($array_dados, "active")); }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->category_id = DataHandler::getValueByArrayIndex($array_dados, "category_id"); $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); $this->name = DataHandler::getValueByArrayIndex($array_dados, "name"); $this->slug = DataHandler::getValueByArrayIndex($array_dados, "slug"); $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); }
/** * envie por post uma array de ids de files, só os ids * file/get_ziped_files */ public function getZipedFiles() { if (!UserClient::getId() > 0) { //nao tem permissao Navigation::redirect("405"); exit; } $array_file_ids = DataHandler::getValueByArrayIndex($_POST, "file_id"); //Debug::print_r($_REQUEST); $array_file_vo = array(); if (is_array($array_file_ids)) { foreach ($array_file_ids as $id) { $FileVO = new FileVO(); $Result = $FileVO->setId($id, TRUE); if ($Result->success == TRUE) { $array_file_vo[] = $FileVO; } } } else { //erro, não é uma array, verifica se pelo menos é 1 único id $id = DataHandler::forceInt($array_file_ids); if ($id > 0) { //é um id único $FileVO = new FileVO(); $Result = $FileVO->setId($id, TRUE); if ($Result->success == TRUE) { $array_file_vo[] = $FileVO; } } else { //erro mesmo, esse dado é zoado, estoura excessão throw new Exception("No ids sended", 404); exit; } } //a pasta zip precisa existir DataHandler::createFolderIfNotExist("upload/zip/"); //verifica o nome do arquivo baseado nos ids enviados conforme regra inventada agora $zip_name = "upload/zip/" . md5(implode("|", $array_file_ids)); DataHandler::createFolderIfNotExist($zip_name); $zip_name = $zip_name . "/teto.zip"; if (!file_exists($zip_name)) { //echo Debug::li($zip_name);exit(); $Zip = new ZipArchive(); $Zip->open($zip_name, ZipArchive::CREATE); foreach ($array_file_vo as $FileVO) { $url = $FileVO->getUrl(); $array = explode("/", $url); $file = $array[count($array) - 1]; $Zip->addFile($url, $file); } $Zip->close(); } header("Location: " . Config::getRootPath($zip_name)); exit; }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->name = DataHandler::getValueByArrayIndex($array_dados, "name"); $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); $this->description = DataHandler::getValueByArrayIndex($array_dados, "description"); $this->type = DataHandler::getValueByArrayIndex($array_dados, "type"); $this->url = DataHandler::getValueByArrayIndex($array_dados, "url"); $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); $this->author = DataHandler::getValueByArrayIndex($array_dados, "author"); $this->locale = DataHandler::getValueByArrayIndex($array_dados, "locale"); }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); $this->user_id = DataHandler::getValueByArrayIndex($array_dados, "user_id"); $this->table = DataHandler::getValueByArrayIndex($array_dados, "table"); $this->table_id = DataHandler::getValueByArrayIndex($array_dados, "table_id"); $this->title = DataHandler::getValueByArrayIndex($array_dados, "title"); $this->description = DataHandler::getValueByArrayIndex($array_dados, "description"); $this->date = DataHandler::convertDateToDB(DataHandler::getValueByArrayIndex($array_dados, "date")); $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); $this->name = DataHandler::getValueByArrayIndex($array_dados, "name"); $this->link = DataHandler::getValueByArrayIndex($array_dados, "link"); $this->content = DataHandler::getValueByArrayIndex($array_dados, "content"); $this->image_url = DataHandler::getValueByArrayIndex($array_dados, "image_url"); $this->date = DataHandler::getValueByArrayIndex($array_dados, "date"); $this->date_in = DataHandler::getValueByArrayIndex($array_dados, "date_in"); $this->date_out = DataHandler::getValueByArrayIndex($array_dados, "date_out"); $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); }
public function add() { //name $nome = DataHandler::getValueByArrayIndex($_POST, "nome"); //title $sobreNome = DataHandler::getValueByArrayIndex($_POST, "sobreNome"); //author $email = DataHandler::getValueByArrayIndex($_POST, "email"); //hat $companhia = DataHandler::getValueByArrayIndex($_POST, "companhia"); //slug $profissao = DataHandler::getValueByArrayIndex($_POST, "provissao"); //key_words $arquiteto = DataHandler::getValueByArrayIndex($_POST, "arquiteto"); $erros = array(); //validação if (!Validation::validateEmail($email)) { $erros[] = "email inválido"; } if (!$nome) { $erros[] = "nome inválido"; } if (!$sobreNome) { $erros[] = "sobrenome incorreto"; } $ReturnResultVO = new ReturnResultVO($erros); if (!count($erros) > 0) { //nao tem erros na validação $ContentSiteVO = new ContentSiteVO(); $ContentSiteVO->setName($nome); $ContentSiteVO->setTitle($sobreNome); $ContentSiteVO->setAuthor($email); $ContentSiteVO->setHat($companhia); $ContentSiteVO->setSlug($profissao); $ContentSiteVO->setKeyWords($arquiteto); $ReturnResultVO = $ContentSiteVO->commit(); if ($ReturnResultVO->success) { //agora poe esse content na categoria correta $CategoryVO = new CategoryVO(); echo "id de category necessária para newslatter funcionar"; exit; $CategoryVO->setId(127, TRUE); if ($ContentSiteVO->getId() > 0) { $CategoryVO->addLink("newslatter", $ContentSiteVO->getId()); $CategoryVO->commit(); } } } echo $ReturnResultVO->toJson(); exit; }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); $this->table = DataHandler::getValueByArrayIndex($array_dados, "table"); $this->table_id = DataHandler::getValueByArrayIndex($array_dados, "table_id"); $this->name = DataHandler::getValueByArrayIndex($array_dados, "name"); $this->type = DataHandler::getValueByArrayIndex($array_dados, "type"); $this->locale = DataHandler::getValueByStdObjectIndex($obj_dados, "locale"); $this->varchar = DataHandler::getValueByStdObjectIndex($obj_dados, "varchar"); $this->text = DataHandler::getValueByStdObjectIndex($obj_dados, "text"); $this->number = DataHandler::getValueByStdObjectIndex($obj_dados, "number"); $this->int = DataHandler::getValueByArrayIndex($array_dados, "int"); $this->date = DataHandler::convertDateToDB(DataHandler::getValueByArrayIndex($array_dados, "date")); }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->id = DataHandler::getValueByArrayIndex($array_dados, "id"); $this->state_id = DataHandler::getValueByArrayIndex($array_dados, "state_id"); $this->country = DataHandler::getValueByArrayIndex($array_dados, "country"); $this->state = DataHandler::getValueByArrayIndex($array_dados, "state"); $this->alias = DataHandler::getValueByArrayIndex($array_dados, "alias"); $this->street = DataHandler::getValueByArrayIndex($array_dados, "street"); $this->number = DataHandler::getValueByArrayIndex($array_dados, "number"); $this->complement = DataHandler::getValueByArrayIndex($array_dados, "complement"); $this->neighborhood = DataHandler::getValueByArrayIndex($array_dados, "neighborhood"); $this->zip_code = DataHandler::getValueByArrayIndex($array_dados, "zip_code"); $this->city = DataHandler::getValueByArrayIndex($array_dados, "city"); $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); }
/** * /backend/image/update/id.N/ * e por post enviar descricao * @return void da echo de string */ public function update() { $ReturnResultVO = new ReturnResultVO(); $id = DataHandler::forceInt(DataHandler::getValueByArrayIndex($this->arrayVariable, "id")); $descricao = DataHandler::forceInt(DataHandler::getValueByArrayIndex($_POST, "descricao")); if ($id > 0) { $ImageVO = new ImageVO(); $ReturnResultVO = $ImageVO->setId($id, TRUE); if ($ReturnResultVO->success) { $ImageVO->setDescription($descricao); $ReturnResultVO = $ImageVO->commit(); } } echo $ReturnResultVO->toJson(); exit; }
public function check() { //busca o post $login = DataHandler::getValueByArrayIndex($_POST, "login"); $password = DataHandler::getValueByArrayIndex($_POST, "password"); //iniciando o retorno padrao em http client ajax $returnResult = new ReturnResultVO(); //se não validar retornar erro if (!Validation::blank($password, 1) && !Validation::blank($login, 1)) { $returnResult->success = 0; $returnResult->message = "Envie Login e Senha"; } else { //cadastra o usuario e os detalhes do mesmo $DAO = UserDetailDAO::getInstance(); $ReturnDataVO = $DAO->checkLogin($login, $password); //print_r($ReturnDataVO); if ($ReturnDataVO->success && count($ReturnDataVO->result) > 0) { if ($ReturnDataVO->result[0]->user_type_id == Config::ADMIN_USER_TYPE_ID || $ReturnDataVO->result[0]->user_type_id == Config::DEVELOPER_USER_TYPE_ID) { UserClient::setId($ReturnDataVO->result[0]->id); UserClient::setTypeId($ReturnDataVO->result[0]->user_type_id); UserClient::setActiveTime(time()); //setando sucesso true caso tenha dado certo $returnResult->success = $ReturnDataVO->success; $returnResult->message = "sucesso ao logar"; } else { //print_r($ReturnDataVO); $returnResult->success = 0; $returnResult->message = "Usuario sem permissão!"; } } else { //print_r($ReturnDataVO); $returnResult->success = 0; $returnResult->message = "Erro ao Logar!"; } } //Debug::print_r($returnResult); exit(); if ($returnResult->success) { if ($this->to != "") { Navigation::redirect($this->to); } else { Navigation::redirect("backend"); } } else { return $this->init($returnResult); } }
public function setFetchArray($array) { //print_r($array); $this->id = DataHandler::getValueByArrayIndex($array, "id"); $this->active = DataHandler::getValueByArrayIndex($array, "active"); $this->name = DataHandler::getValueByArrayIndex($array, "name"); $this->link = DataHandler::getValueByArrayIndex($array, "link"); $this->content = DataHandler::getValueByArrayIndex($array, "content"); $this->image_url = DataHandler::getValueByArrayIndex($array, "image_url"); $this->date = DataHandler::getValueByArrayIndex($array, "date"); $this->date_in = DataHandler::getValueByArrayIndex($array, "date_in"); $this->date_out = DataHandler::getValueByArrayIndex($array, "date_out"); $this->order = DataHandler::getValueByArrayIndex($array, "order"); $this->request_table_id = DataHandler::getValueByArrayIndex($array, "table_id"); $this->request_table = DataHandler::getValueByArrayIndex($array, "table"); $this->request_highlights_id = DataHandler::getValueByArrayIndex($array, "highlights_id"); $this->request_locale = DataHandler::getValueByArrayIndex($array, "locale"); $this->request_quant_start = DataHandler::getValueByArrayIndex($array, "quant_start"); $this->request_quant_limit = DataHandler::getValueByArrayIndex($array, "quant_limit"); $this->request_type_of_return = DataHandler::getValueByArrayIndex($array, "type_of_return"); }
public function setFetchArray($array) { //print_r($array); $this->file_info_id = DataHandler::getValueByArrayIndex($array, "file_info_id"); $this->file_info_type = DataHandler::getValueByArrayIndex($array, "file_info_type"); $this->file_info_active = DataHandler::getValueByArrayIndex($array, "file_info_active"); $this->file_info_url = DataHandler::getValueByArrayIndex($array, "file_info_url"); $this->file_info_name = DataHandler::getValueByArrayIndex($array, "file_info_name"); $this->file_info_description = DataHandler::getValueByArrayIndex($array, "file_info_description"); $this->file_info_order = DataHandler::getValueByArrayIndex($array, "file_info_order"); $this->file_info_locale = DataHandler::getValueByArrayIndex($array, "file_info_locale"); $this->file_info_author = DataHandler::getValueByArrayIndex($array, "file_info_author"); $this->request_file_id = DataHandler::getValueByArrayIndex($array, "file_id"); $this->request_file_url = DataHandler::getValueByArrayIndex($array, "file_url"); //abaixo, ATENÇÃO: Filedata recebe o arquivo a ser uplodado $this->file_data = DataHandler::getValueByArrayIndex($array, "Filedata"); $this->file_url = DataHandler::getValueByArrayIndex($array, "file_url"); //info de vinculo $this->table = DataHandler::getValueByArrayIndex($array, "table"); $this->table_id = DataHandler::getValueByArrayIndex($array, "table_id"); }
/** * pega a array e trata para transformar numa array de InfoPost dentro do padrão do plugin * @param $array_send_in_pattern ver a construct * @return void */ public function setFetchArray($array_send_info, $array_files) { $type = "file"; //Debug::print_r($array_send_info); //echo Debug::print_r($array_files); //exit(); for ($i = 0; $i < count($array_files["Filedata"]["name"]); $i++) { //cria uma array no padrao para a FileInfoPostVO $data = array($type . "_info_active" => isset($array_send_info[$type . '_info_active']) ? $array_send_info[$type . '_info_active'][$i] : "", $type . "_info_type" => isset($array_send_info[$type . '_info_type']) ? $array_send_info[$type . '_info_type'][$i] : "", $type . "_info_author" => isset($array_send_info[$type . '_info_author']) ? $array_send_info[$type . '_info_author'][$i] : "", $type . "_info_name" => isset($array_send_info[$type . '_info_name']) ? $array_send_info[$type . '_info_name'][$i] : "", $type . "_info_description" => isset($array_send_info[$type . '_info_description']) ? $array_send_info[$type . '_info_description'][$i] : "", $type . "_info_order" => isset($array_send_info[$type . '_info_order']) ? $array_send_info[$type . '_info_order'][$i] : "", $type . "_info_locale" => isset($array_send_info[$type . '_info_locale']) ? $array_send_info[$type . '_info_locale'][$i] : "", "Filedata" => array("name" => $array_files["Filedata"]["name"][$i], "type" => $array_files["Filedata"]["type"][$i], "tmp_name" => $array_files["Filedata"]["tmp_name"][$i], "error" => $array_files["Filedata"]["error"][$i], "size" => $array_files["Filedata"]["size"][$i])); $FileInfoPostVO = new FileInfoPostVO(); $FileInfoPostVO->setFetchArray($data); //verifica se precisa vincular e se essa info foi enviada if ($this->linked_table) { $FileInfoPostVO->table = $this->linked_table; $FileInfoPostVO->table_id = $this->linked_table_id; } else { if (isset($array_send_info[$type . "_table"]) && is_array($array_send_info[$type . "_table"])) { //se enviar array, significa que para cada conjunto de fotos terá um vinculo diferente //util para casos em que o conteudo tem mais de uma foto e cada uma para uma determinada utilidade $FileInfoPostVO->table = $array_send_info[$type . "_table"][$i]; $FileInfoPostVO->table_id = $array_send_info[$type . "_table_id"][$i]; } else { if (isset($array_send_info[$type . "_table"])) { //se todas as Filens obedecem ao mesmo vinculo, então envie somente o table e table_id sem ser array $FileInfoPostVO->table = $array_send_info[$type . "_table"]; $FileInfoPostVO->table_id = $array_send_info[$type . "_table_id"]; } } } //adiciona na array $this->addItemInfoPostVO($FileInfoPostVO); } //end for($i = 0 ; $i< count($array_files); $i++){ //agora o for de item a deletar for ($i = 0; $i < count(DataHandler::getValueByArrayIndex($array_send_info, $type . "_delete")); $i++) { //dentro de cada indice da array $array_send_info[$type."_delete"] deve vir o id da Filem //aqui ele só guarda a array $this->arrayToDelete[] = $array_send_info[$type . "_delete"][$i]; } }
public function check() { //busca o post $login = DataHandler::getValueByArrayIndex($_POST, "login"); $password = DataHandler::getValueByArrayIndex($_POST, "password"); //iniciando o retorno padrao em http client ajax $returnResult = new ReturnResultVO(); //se não validar retornar erro if (!Validation::blank($password, 1) && !Validation::blank($login, 1)) { $returnResult->success = 0; $returnResult->addMessage("Envie Login e Senha"); } else { //cadastra o usuario e os detalhes do mesmo $DAO = UserDetailDAO::getInstance(); $ReturnDataVO = $DAO->checkLogin($login, $password); if ($ReturnDataVO->success && count($ReturnDataVO->result) > 0) { UserClient::setId($ReturnDataVO->result[0]->id); UserClient::setTypeId($ReturnDataVO->result[0]->user_type_id); UserClient::setActiveTime(time()); //setando sucesso true caso tenha dado certo $returnResult->success = $ReturnDataVO->success; $message_success = file_get_contents(Config::getAsset("templates/login_sucesso.txt")); $returnResult->addMessage($message_success); } else { //print_r($ReturnDataVO); $returnResult->success = 0; $returnResult->addMessage("Erro ao Logar!"); } } if ($returnResult->success) { if ($this->to != "") { Navigation::redirect($this->to); } } echo $returnResult->toJson(); exit; }
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; }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->setDescription(DataHandler::getValueByArrayIndex($array_dados, "description")); parent::setFetchArray($array_dados); }
public function commit() { // echo "cococ";exit(); $this->redirect_with_id = FALSE; if (DataHandler::getValueByArrayIndex($_POST, "destaque")) { if (is_array($_POST["category"])) { $_POST["category"] = DataHandler::appendArray($_POST["category"], $_POST["destaque"]); } else { throw new Exception("envie a array de categoria. Sem isso a content nao funciona."); } } parent::commit(); }
public function delete() { $DAO = CategoryDAO::getInstance(); if (FALSE) { $DAO = new CategoryDAO(); } $DAO->delete(DataHandler::getValueByArrayIndex($this->arrayVariable, "id")); Navigation::redirect("admin/category/select"); }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados) { $this->login = DataHandler::getValueByArrayIndex($array_dados, "login"); $this->password = DataHandler::getValueByArrayIndex($array_dados, "password"); $this->email = DataHandler::getValueByArrayIndex($array_dados, "email"); }
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; }
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); }
/** * 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; }
/** * * Para acessar isso aqui seria a url: pdf_download/produto/id.N/ */ public function cliente($id = false) { if ($id == FALSE) { $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_tagged = $ContentSiteVO->getImages(NULL, "tagged", true); $html_start = "<html><body>"; $html_end = "</body></html>"; $detail_page = file_get_contents(Config::getFolderView("/PdfDownload/detail.tpl")); $image_page = file_get_contents(Config::getFolderView("/PdfDownload/image.tpl")); $dimension_page = file_get_contents(Config::getFolderView("/PdfDownload/dimension.tpl")); $tpl_img_path = "view/site/"; //Config::getAsset() ; $recover_logo = $stdProduct->hat == 1 ? '<img style=" margin-top: 4px; margin-left: 5px; " src="' . $tpl_img_path . '/PdfDownload/recover_logo.png" />' : ""; $stdProduct->description = utf8_decode($stdProduct->description); $stdProduct->title = utf8_decode($stdProduct->title); $stdProduct->content = utf8_decode($stdProduct->content); $common_tpl_data = array("###IMG_TPL_PATH###", "###content###", "###title###", "###PRODUCT_URI###", "###recover_logo###"); $common_data = array($tpl_img_path, $stdProduct->content, $stdProduct->title, Config::getRootPath('produto/id.' . $stdProduct->id . '/' . $stdProduct->slug), $recover_logo); $detail_page = str_replace($common_tpl_data, $common_data, $detail_page); $image_page = str_replace($common_tpl_data, $common_data, $image_page); $dimension_page = str_replace($common_tpl_data, $common_data, $dimension_page); $detail_page = str_replace("###description###", $stdProduct->description, $detail_page); $html = $html_start . $detail_page; foreach ($stdProduct->array_gallery as $image) { $w = 600; $h = 550; $img_url = "image/get_image/image_id." . $image->id . "/max_width.{$w}/max_height.{$h}/"; // Debug::print_r( $img_url ) ; // $tmp = file_get_contents( $img_url ) ; // unset( $tmp ) ; // $new_page = str_replace( "###IMAGE_SRC###" , Config::getRootPath( "image/get_image/image_id." . $image->id . "/max_width.600/max_height.525/" ) , $image_page ) ; // $new_page = str_replace( "###IMAGE_SRC###" , $image->url , $image_page ) ; $img_name = preg_replace("/\\.jpg\$/", "", $image->url); // $sys_img = $img_name . "_w{$w}_h{$h}_m_no_crop.jpg" ; $sys_img = $img_name . "_w{$w}_h{$h}_m_cache_crop.jpg"; // Debug::print_r($sys_img ) ; // var_dump( file_exists($sys_img) ) ; // die; $new_page = str_replace("###IMAGE_SRC###", $sys_img, $image_page); // Debug::print_r( $image ) ; die; $html .= $new_page; // break; } $html .= $html_end; // echo $html ; die; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->render(); //$dompdf->stream( "upload/pdf/" . $stdProduct->id . "/" . $stdProduct->slug . ".pdf") ; $file = $stdProduct->slug . ".pdf"; $path = "upload/pdf/" . $stdProduct->id . "/"; if (!dir($path)) { mkdir($path, 0777, true); } $html_file = "print.html"; $html = str_replace("src=\"", "src=\"" . Config::getRootPath(), $html); $fp = fopen($path . $html_file, "w"); fwrite($fp, $html); fclose($fp); $pdfoutput = $dompdf->output(); // $filename = $output; $fp = fopen($path . $file, "w"); fwrite($fp, $pdfoutput); fclose($fp); return true; } else { //não achou um produto com esse id return false; Navigation::redirect(""); } } else { return false; //não mandou o id, vai pra listagem ((!?) TODO: ver se é isso mesmo) Navigation::redirect("clientes"); } }
/** * @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; }
/** * precisa enviar uma array dentro dos padr�es dessa VO, pode enviar diretamente o $_POST * @param (array) $array_dados * @return void */ function setFetchArray($array_dados, $locale = NULL) { if (DataHandler::getValueByArrayIndex($array_dados, "id")) { $this->setId(DataHandler::getValueByArrayIndex($array_dados, "id")); } if (DataHandler::getValueByArrayIndex($array_dados, "active")) { $this->active = DataHandler::getValueByArrayIndex($array_dados, "active"); } if (DataHandler::getValueByArrayIndex($array_dados, "name")) { $this->setName(DataHandler::getValueByArrayIndex($array_dados, "name"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "title")) { $this->setTitle(DataHandler::getValueByArrayIndex($array_dados, "title"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "hat")) { $this->setHat(DataHandler::getValueByArrayIndex($array_dados, "hat"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "description")) { $this->setDescription(DataHandler::getValueByArrayIndex($array_dados, "description"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "content")) { $this->setContent(DataHandler::getValueByArrayIndex($array_dados, "content"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "author")) { $this->setAuthor(DataHandler::getValueByArrayIndex($array_dados, "author"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "template_url")) { $this->setTemplateUrl(DataHandler::getValueByArrayIndex($array_dados, "template_url"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "slug")) { $this->setSlug(DataHandler::getValueByArrayIndex($array_dados, "slug"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "key_words")) { $this->setKeyWords(DataHandler::getValueByArrayIndex($array_dados, "key_words"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "date")) { $this->setDate(DataHandler::getValueByArrayIndex($array_dados, "date")); } if (DataHandler::getValueByArrayIndex($array_dados, "date_id")) { $this->date_in = DataHandler::getValueByArrayIndex($array_dados, "date_in"); } if (DataHandler::getValueByArrayIndex($array_dados, "date_out")) { $this->date_out = DataHandler::getValueByArrayIndex($array_dados, "date_out"); } if (DataHandler::getValueByArrayIndex($array_dados, "order")) { $this->order = DataHandler::getValueByArrayIndex($array_dados, "order"); } if (DataHandler::getValueByArrayIndex($array_dados, "image_url")) { $this->setImageURL(DataHandler::getValueByArrayIndex($array_dados, "image_url"), $locale); } if (DataHandler::getValueByArrayIndex($array_dados, "link")) { $this->setLink(DataHandler::getValueByArrayIndex($array_dados, "link"), $locale); } }