public function addphoto() { if (isset(parameters()["input"]['name'])) { define('TARGET', './input/'); define('MAX_SIZE', 5000000); $tabExt = array('jpg', 'png', 'jpeg'); $extension = pathinfo($_FILES['input']['name'], PATHINFO_EXTENSION); if (in_array(strtolower($extension), $tabExt)) { if (filesize($_FILES['input']['tmp_name']) <= MAX_SIZE) { if (isset($_FILES['input']['error']) && UPLOAD_ERR_OK === $_FILES['input']['error']) { $nomImage = md5(uniqid()) . '.' . $extension; if (@move_uploaded_file($_FILES['input']['tmp_name'], TARGET . $nomImage)) { $photo = new T_E_PHOTO_PHO(); $photo->addPhoto(parameters()["jeu"], TARGET . $nomImage); } else { $m = new message(); $m->setFlash("Problème lors de l'upload !"); } } else { $m = new message(); $m->setFlash("Erreur interne"); } } else { $m = new message(); $m->setFlash("Taille de fichier trop importante"); } } else { $m = new message(); $m->setFlash("Erreur d'extension"); } } $this->render("addphoto", T_E_JEUVIDEO_JEU::findAll()); }
public static function findByGame($id_game) { $class = get_called_class(); $table = strtolower($class); $idtable = substr($table, -3) . "_id"; $list = array(); foreach (T_E_PHOTO_PHO::findAll() as $row) { if ($row->T_E_JEUVIDEO_JEU->jeu_id == $id_game) { $list[] = new $class($row->pho_id, $row->T_E_JEUVIDEO_JEU, $row->pho_url); } } return $list; }
public function displayById() { if (isset($_GET["jeu_id"])) { $idGame = $_GET["jeu_id"]; $idGame; $game = new T_E_JEUVIDEO_JEU($idGame); $photo = T_E_PHOTO_PHO::findByGame($idGame); $movie = T_E_VIDEO_VID::findByGame($idGame); $advice = T_E_AVIS_AVI::findByGame($idGame); $this->render('displayById', array($game, $photo, $movie, $advice)); } else { $this->render("find"); } }
public static function findBySelection($id_console) { $class = get_called_class(); $table = strtolower($class); $idtable = substr($table, -3) . "_id"; $list = array(); foreach (T_E_JEUVIDEO_JEU::findAll() as $row) { if ($row->T_R_CONSOLE_CON->con_id == $id_console) { $game = new T_E_JEUVIDEO_JEU($row->jeu_id); foreach (T_E_PHOTO_PHO::findByGame($row->jeu_id) as $key => $value) { $game->photo = $value->pho_url; break; } $list[] = $game; } } return $list; }
public function findGameByRay($id, $name) { if ($id == 'tous') { $st = db()->prepare("select * from t_e_jeuvideo_jeu where lower(jeu_nom) like lower(:name)"); } else { $st = db()->prepare("select * from t_e_jeuvideo_jeu where jeu_id in (select jeu_id from t_j_jeurayon_jer where ray_id=:rayid) and lower(jeu_nom) like lower(:name)"); $st->bindValue(":rayid", $id); } $st->bindValue(":name", "%{$name}%"); $st->execute(); $games = array(); if ($st->rowCount() >= 1) { while ($row = $st->fetch(PDO::FETCH_ASSOC)) { $game = new T_E_JEUVIDEO_JEU($row['jeu_id']); foreach (T_E_PHOTO_PHO::findByGame($row['jeu_id']) as $key => $value) { $game->photo = $value->pho_url; break; } $games[] = $game; } } return $games; }