public function formSucceeded(Form $form, $values) { // pro odchytavani chyb $error = null; // ostatni akce $product = new Model\Product($this->database); $values['id_user'] = $this->id_user; $imgs = $values['img']; unset($values['img']); // add / edit if ($values['id'] == null) { // add $p = $product->add($values); $product_id = $p->id; $form->getPresenter()->flashMessage('Produkt byl úspěšně vytvořen.'); } else { // edit $error = $product->update($values, $values['id']); $product_id = $values['id']; $form->getPresenter()->flashMessage('Produkt byl úspěšně upraven.'); } if ($error == null) { // nahrani fotek k produktu if ($imgs != null) { $photo_manager = new Model\Photo($this->database); $photo_manager->uploadProductPhotos($imgs, $product_id); } // presmerovani $form->getPresenter()->redirect('Homepage:product', $product_id); } else { $form->addError($error); } }
public function formSucceeded(Form $form, $values) { if ($this->photos != null) { $photo_manager = new Model\Photo($this->database); $photo_manager->setMainPhoto($values, $this->photos); } }
public function formSucceeded(Form $form, $values) { $photo = new Model\Photo($this->database); $error = $photo->uploadProfileImage($values->img, $this->id); if ($error) { $form->addError($error); } if ($form->getPresenter()->isAjax()) { $form->getPresenter()->redrawControl('profileImage'); } }
public function deletePhoto($id) { try { unlink(self::SAVE_DIR . $id . '.big.jpg'); unlink(self::SAVE_DIR . $id . '.small.jpg'); } catch (\Exception $e) { return false; } $photo = new Photo($this->db); $photo->where('id', $id)->delete(); return true; }
public function formSucceeded(Form $form, $values) { $product = $this->database->findById('product', $this->id_product); if ($product) { if ($product->related('bid.id_product')->count() <= 0) { $photo_manager = new Model\Photo($this->database); $photo_manager->deleteAllProductPhotos($this->id_product); // smazu fotky produktu $product->delete(); // smazu produkt } else { $form->addError('Produkt nelze smazat. O produkt již nějaký uživatel projevil zájem.'); } } else { $form->addError('Produkt nebyl nalezen. Pravděpodobně jej někdo smazal.'); } }
public function photo($photo_id) { $photo = Photo::find($photo_id); if (empty($photo)) { abort(404); } else { var_dump($photo); } }
public function actionEdit($i, $goodsId) { $item = $this->item->get($i); if (!$item) { $this->error('Data nebyla nalezena v databázi.', 404); } $this['descriptionForm']->setDefaults($item->toArray()); $this->template->item = $item; }
public function formSucceeded(Form $form, $values) { $product = $this->database->findById('product', $this->id_product); if ($product) { if ($product->related('bid.id_product')->count() <= 0) { if ($this->photos != null) { $photo_manager = new Model\Photo($this->database); $photo_manager->deleteProductPhotos($values, $this->photos); // presmerovani $form->getPresenter()->flashMessage('Vybrané fotografie byly smazány.'); $form->getPresenter()->redirect('Homepage:product', $this->id_product); } } else { $form->addError('Fotografie nelze smazat. O produkt již nějaký uživatel projevil zájem.'); } } else { $form->addError('Produkt nebyl nalezen. Pravděpodobně jej někdo smazal.'); } }
public function index() { // inclui os arquivos require_once '../App/Model/photo.class.php'; require_once '../App/Model/characteristics.class.php'; require_once '../App/Model/presentation.class.php'; require_once '../App/Model/skills.class.php'; require_once '../App/Model/portifolio.class.php'; // instancia os objetos $photo = new Photo(); $characteristics = new Characteristics(); $presentation = new Presentation(); $skills = new Skills(); $portifolio = new Portifolio(); // chama os metodos $selectPhoto = $photo->selectPhoto(); $selectCharacteristics = $characteristics->selectCharacteristics(); $selectPresentation = $presentation->selectPresentation(); $selectBasicSkills = $skills->selectBasicSkills(); $selectIntermediateSkills = $skills->selectIntermediateSkills(); $selectAdvancedSkills = $skills->selectAdvancedSkills(); $selectPortifolio = $portifolio->selectPortifolio(); // Enviando mensagem de contato $to = '*****@*****.**'; $subject = 'Contato do site'; $contactName = $_POST['name']; $contactEmail = $_POST['email']; $contactPhone = $_POST['phone']; $contactMessage = $_POST['message']; $body = '<strong>Mensagem de contato</strong><br><br>'; $body .= '<strong>Nome: </strong>' . $contactName . '<br>'; $body .= '<strong>Email: </strong>' . $contactEmail . '<br>'; $body .= '<strong>Telefone: </strong>' . $contactPhone . '<br>'; $body .= '<strong>Mensagem: </strong>' . $contactMessage . '<br>'; $header = 'From: ' . $contactEmail . ' Reply-to: ' . $contactEmail; $header .= 'Content-type: text/html; charset=utf-8'; $resposta = mail($to, $subject, $body, $header); // envia os resultados para o index require_once '../App/View/Index/index.php'; }
public function itemFormSucceeded(UI\Form $form, $values) { if (isset($values['manufacturer_id']) && !$values['manufacturer_id']) { $values['manufacturer_id'] = $values['manufacturer_id'] ? $values['manufacturer_id'] : null; } foreach ($values as $k => $v) { if ($k != 'category_id' && $k != 'photo') { $updateOrInsert[$k] = $v; } } $itemId = $this->getParameter('id'); if ($itemId) { $item = $this->item->get($itemId); if (!$item) { $this->error('Data nebyla nalezena v databázi.', 404); } else { $item->update($updateOrInsert); } $this->categoryGoods->where('goods_id', $itemId)->delete(); $forInsert = array(); foreach ($values['category_id'] as $categoryId) { $forInsert[] = ['category_id' => $categoryId, 'goods_id' => $itemId]; } $this->categoryGoods->insert($forInsert); $this->flashMessage('Změny uloženy.', 'success'); } else { $item = $this->item->insert($updateOrInsert); // categories $forInsert = array(); foreach ($values['category_id'] as $categoryId) { $forInsert[] = ['category_id' => $categoryId, 'goods_id' => $item->id]; } $this->categoryGoods->insert($forInsert); $this->flashMessage('Výrobek vložen do databáze.', 'success'); } if ($item && $values['photo']) { if ($this->photo->insertPhoto($values['photo'], $item->id)) { $this->flashMessage('Byl přiložen obrázek.', 'success'); } } $this->redirect('edit', $item->id); }
public function photo() { require_once '../App/Model/photo.class.php'; $photo = new Photo(); $id = $this->getURL(); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'insert': if (!empty($_FILES['photo']['name'])) { $photo_size = $_FILES['photo']['size']; $photo_type = $_FILES['photo']['type']; $photo_tmp_name = $_FILES['photo']['tmp_name']; $photo_type = substr($photo_type, 6); if (strstr('.jpg;.jpeg;.gif;.png', $photo_type)) { $photo_name = md5(uniqid(time())) . "." . $photo_type; if (file_exists('assets/img/photo/')) { $photo_path = "assets/img/photo/" . $photo_name; } else { echo '<h2>A imagem nao pode ser salva no diretorio assets/img/photo/ devido erro</h2>'; } move_uploaded_file($photo_tmp_name, $photo_path); $photo = new Photo($photo_name, $photo_size, $photo_type); $insertPhoto = $photo->insertPhoto(); if (!empty($insertPhoto)) { echo $insertPhoto; } } else { echo '<h2>Tipo de arquivo incorreto</h2>'; } } break; case 'edit': $selectOnePhoto_edit = $photo->selectOnePhoto($id); if (isset($_GET['operation']) && $_GET['operation'] == 'ok') { if (!empty($_FILES['photo_edit']['name'])) { if (file_exists('assets/img/photo/')) { unlink('assets/img/photo/' . $selectOnePhoto_edit[0]->content_photo_name); } else { echo '<h2>A imagem nao foi deletada do diretorio assets/img/photo/</h2>'; } $photo_edit_size = $_FILES['photo_edit']['size']; $photo_edit_type = $_FILES['photo_edit']['type']; $photo_edit_tmp_name = $_FILES['photo_edit']['tmp_name']; $photo_edit_type = substr($photo_edit_type, 6); if (strstr('.jpg;.jpeg;.gif;.png', $photo_edit_type)) { $photo_edit_name = md5(uniqid(time())) . "." . $photo_edit_type; $photo_edit_path = "assets/img/photo/" . $photo_edit_name; move_uploaded_file($photo_edit_tmp_name, $photo_edit_path); $photo = new Photo($photo_edit_name, $photo_edit_size, $photo_edit_type); $updateOnePhoto = $photo->updateOnePhoto($id); if (!empty($updateOnePhoto)) { echo $updateOnePhoto; } } else { echo '<h2>Tipo de arquivo incorreto</h2>'; } } } break; case 'delete': $selectOnePhoto_delete = $photo->selectOnePhoto($id); $deleteOnePhoto = $photo->deleteOnePhoto($id); if (!empty($selectOnePhoto_delete[0]->content_photo_name) && !empty($deleteOnePhoto)) { if (file_exists('assets/img/photo/')) { unlink('assets/img/photo/' . $selectOnePhoto_delete[0]->content_photo_name); } else { echo '<h2>A imagem nao foi deletada do diretorio assets/img/photo/</h2>'; } echo $deleteOnePhoto; } } } else { echo '<h2>Acao diferente de insert, edit e delete</h2>'; } $selectPhoto = $photo->selectPhoto(); require_once '../App/View/Adm_content/photo.php'; }
public function singlePhotoAction(Request $request, Application $app) { $photo = Photo::where('photo_id', $request->get('id'))->first(); $user = User::find($photo->user_id); return $app['twig']->render('photo.html.twig', $this->getParamsTwig(['photo' => $photo, 'user' => $user])); }
<?php header('content-type: text/html; charset=utf-8'); error_reporting(E_ALL); ini_set('display_errors', 1); $app = (require_once __DIR__ . '/../app/bootstrap.php'); use Illuminate\Database\Capsule\Manager as Capsule; use App\Model\User; use App\Model\Photo; $user = new User(); $photo = new Photo(); try { Capsule::schema()->create($user->getTable(), function ($table) { $table->increments('id'); $table->string('email'); $table->string('first_name'); $table->string('last_name'); $table->string('gender'); $table->bigInteger('facebook_id'); $table->timestamps(); }); Capsule::schema()->create($photo->getTable(), function ($table) { $table->increments('id'); $table->integer('user_id')->unsigned()->index(); $table->string('link'); $table->string('title'); $table->string('description'); $table->string('photo_id'); $table->timestamps(); $table->foreign('user_id')->references('id')->on('user')->onDelete('cascade'); });