<?php
/**
================================================================================
LISENCE
================================================================================
This file is part of php4dvd.
php4dvd is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
php4dvd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with php4dvd. If not, see <http://www.gnu.org/licenses/>.
**/
include_once($loc."/lib/util/resize.php");
class Movie extends DataObject {
// All variables
var $id;
var $imdbid;
var $name;
var $aka;
var $year;
var $duration;
var $rating;
var $languages;
var $country;
var $genres;
var $director;
var $writer;
var $producer;
var $music;
var $cast;
var $taglines;
var $plotoutline;
var $plots;
// Personal information
var $format;
var $own;
var $seen;
var $notes;
var $loaned;
var $loandate;
var $loanname;
// Create a new movie
function Movie() {
}
// Update this movie
function update() {
// MySQL query
$query = "UPDATE movies SET ";
$query .= "imdbid = '".addslashes($this->imdbid)."', ";
$query .= "name = '".addslashes($this->name)."', ";
$query .= "aka = '".addslashes($this->aka)."', ";
$query .= "year = '".addslashes($this->year)."', ";
$query .= "duration = '".addslashes($this->duration)."', ";
$query .= "rating = '".addslashes($this->rating)."', ";
$query .= "languages = '".addslashes($this->languages)."', ";
$query .= "country = '".addslashes($this->country)."', ";
$query .= "genres = '".addslashes($this->genres)."', ";
$query .= "director = '".addslashes($this->director)."', ";
$query .= "writer = '".addslashes($this->writer)."', ";
$query .= "producer = '".addslashes($this->producer)."', ";
$query .= "music = '".addslashes($this->music)."', ";
$query .= "cast = '".addslashes($this->cast)."', ";
$query .= "taglines = '".addslashes($this->taglines)."', ";
$query .= "plotoutline = '".addslashes($this->plotoutline)."', ";
$query .= "plots = '".addslashes($this->plots)."', ";
$query .= "format = '".addslashes($this->format)."', ";
$query .= "own = '".addslashes($this->own)."', ";
$query .= "seen = '".addslashes($this->seen)."', ";
$query .= "notes = '".addslashes($this->notes)."', ";
$query .= "loaned = '".addslashes($this->loaned)."', ";
$query .= "loandate = '".addslashes($this->loandate)."', ";
$query .= "loanname = '".addslashes($this->loanname)."' ";
$query .= "WHERE id = '".addslashes($this->id)."'";
mysql_query($query) or
die (mysql_error());
}
function getAKAs() {
$temp = str_replace("\r", "", $this->aka);
return split("\n", trim($temp));
}
function getList($field) {
$temp = trim($this->{$field});
$temp = str_replace("\r", "", $temp);
$temp = str_replace("\n", ", ", $temp);
return rtrim($temp, ",");
}
function getListBr($field) {
$temp = trim($this->{$field});
$temp = str_replace("\r", "", $temp);
$temp = str_replace("\n", "<br />", $temp);
return rtrim($temp, ",");
}
function getTip($dir = "") {
$return = "";
// Image
if($this->hasPhoto($dir))
$return .= "<img src=\"".$dir.$this->id.".jpg\" alt=\"\" title=\"\" style=\"float: left; margin-right: 10px; margin-bottom: 10px;\">";
// Genre
$genre = $this->getList("genres");
if(trim($genre) != "")
$return .= $genre;
// Plotlines
$plotlines = $this->getList("plotoutline");
if(trim($plotlines) != "")
$return .= "<br><br>".$plotlines;
// Taglines when no plotlines
if(trim($plotlines) == "") {
$taglines = $this->getListBr("taglines");
if(trim($taglines) != "")
$return .= "<br><br>".$taglines;
}
// Format to html
return htmlentities(addslashes($return), ENT_QUOTES, "UTF-8");
}
function hasPhoto($dir = "") {
return file_exists($dir.$this->id.".jpg");
}
function removePhoto($dir = "") {
if($this->hasPhoto($dir))
unlink($dir.$this->id.".jpg");
}
function hasCover($dir = "") {
return file_exists($dir.$this->id.".jpg");
}
function addCover($field, $dir = "") {
global $settings;
$bestand = $dir.$this->id.".jpg";
// Is it jpg?
$extentie = strtolower(findExtention($_FILES[$field]["name"]));
if((!eregi("jpg", $extentie))) {
return false;
}
// Remove old file
if(file_exists($bestand))
unlink($bestand);
// Copy
copy($_FILES[$field]["tmp_name"], $bestand);
// Thumbnail
$thumb = new thumbnail($bestand);
$thumb->size_width($settings["foto"]["tn_maxwidth"]);
$thumb->jpeg_quality(100);
$thumb->save($dir."tn_".$this->id.".jpg");
}
function removeCover($dir = "") {
if($this->hasCover($dir)) {
unlink($dir.$this->id.".jpg");
unlink($dir."tn_".$this->id.".jpg");
}
}
}
?>