Add manufacturer and scale to album model
This commit is contained in:
parent
766d27301a
commit
ce726c4539
|
@ -6,6 +6,8 @@ class Album implements JsonSerializable {
|
|||
private $title = "";
|
||||
private $thumbnail = "";
|
||||
private $description = "";
|
||||
private $manufacturer = "";
|
||||
private $scale = "";
|
||||
private $createtime = "";
|
||||
|
||||
public function getID() {
|
||||
|
@ -87,6 +89,40 @@ class Album implements JsonSerializable {
|
|||
}
|
||||
}
|
||||
|
||||
public function getManufacturer($flag = 0) {
|
||||
switch ($flag) {
|
||||
case HTMLSAFE:
|
||||
return htmlspecialchars($this->manufacturer);
|
||||
break;
|
||||
case HTMLFORMSAFE:
|
||||
return htmlspecialchars($this->manufacturer, ENT_QUOTES);
|
||||
break;
|
||||
case CSVSAFE:
|
||||
return str_replace('"', '""', $this->manufacturer);
|
||||
break;
|
||||
default:
|
||||
return $this->manufacturer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getScale($flag = 0) {
|
||||
switch ($flag) {
|
||||
case HTMLSAFE:
|
||||
return htmlspecialchars($this->scale);
|
||||
break;
|
||||
case HTMLFORMSAFE:
|
||||
return htmlspecialchars($this->scale, ENT_QUOTES);
|
||||
break;
|
||||
case CSVSAFE:
|
||||
return str_replace('"', '""', $this->scale);
|
||||
break;
|
||||
default:
|
||||
return $this->scale;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCreateTime($flag = 0) {
|
||||
switch ($flag) {
|
||||
case TIMESTAMP:
|
||||
|
@ -225,6 +261,8 @@ class Album implements JsonSerializable {
|
|||
'thumburl' => ($this->getThumbnail() == "") ? "graphics/no-image-available_thm.gif" : THUMBNAILFOLDER . $this->getFolderName() . $this->getThumbnail(),
|
||||
'title' => $this->getTitle(),
|
||||
'description' => $this->getDescription(),
|
||||
'manufacturer' => $this->getManufacturer(),
|
||||
'scale' => $this->getScale(),
|
||||
'createtime' => $this->getCreateTime(),
|
||||
'images' => Image::getImagesForAlbum($this->getID())
|
||||
];
|
||||
|
@ -249,16 +287,18 @@ class Album implements JsonSerializable {
|
|||
global $globaldbh;
|
||||
|
||||
$query = "INSERT INTO " . AppDB::TABLE_ALBUMS . " ";
|
||||
$query .= "(id, foldername, title, thumbnail, description, createtime) ";
|
||||
$query .= "VALUES(NULL, :foldername, :title, :thumbnail, :description, NOW()) ";
|
||||
$query .= "(id, foldername, title, thumbnail, description, manufacturer, scale, createtime) ";
|
||||
$query .= "VALUES(NULL, :foldername, :title, :thumbnail, :description, :manufacturer, :scale, NOW()) ";
|
||||
$query .= "ON DUPLICATE KEY UPDATE ";
|
||||
$query .= "foldername=:foldername, title=:title, thumbnail=:thumbnail, description=:description";
|
||||
$query .= "foldername=:foldername, title=:title, thumbnail=:thumbnail, description=:description, manufacturer=:manufacturer, scale=:scale";
|
||||
$sth = $globaldbh->prepare($query);
|
||||
$sth->bindValue(":id", (int) $this->getID(), PDO::PARAM_INT);
|
||||
$sth->bindValue(":foldername", $this->getFolderName(), PDO::PARAM_STR);
|
||||
$sth->bindValue(":title", $this->getTitle(), PDO::PARAM_STR);
|
||||
$sth->bindValue(":thumbnail", $this->getThumbnail(), PDO::PARAM_STR);
|
||||
$sth->bindValue(":description", $this->getDescription(), PDO::PARAM_STR);
|
||||
$sth->bindValue(":manufacturer", $this->getManufacturer(), PDO::PARAM_STR);
|
||||
$sth->bindValue(":scale", $this->getScale(), PDO::PARAM_STR);
|
||||
$sth->execute();
|
||||
if ( $this->getID() == 0 ) {
|
||||
$this->setID($globaldbh->lastInsertId());
|
||||
|
@ -270,7 +310,7 @@ class Album implements JsonSerializable {
|
|||
global $globaldbh;
|
||||
|
||||
$reqid = intval($reqid);
|
||||
$query = "SELECT id, foldername, title, thumbnail, description, createtime " .
|
||||
$query = "SELECT id, foldername, title, thumbnail, description, manufacturer, scale, createtime " .
|
||||
"FROM " . AppDB::TABLE_ALBUMS . " WHERE id=:id";
|
||||
$sth = $globaldbh->prepare($query);
|
||||
$sth->bindValue(":id", $reqid, PDO::PARAM_INT);
|
||||
|
@ -281,6 +321,8 @@ class Album implements JsonSerializable {
|
|||
$this->setTitle($row['title']);
|
||||
$this->setThumbnail($row['thumbnail']);
|
||||
$this->setDescription($row['description']);
|
||||
$this->setManufacturer($row['manufacturer']);
|
||||
$this->setScale($row['scale']);
|
||||
$this->createtime = $row['createtime'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,8 @@ CREATE TABLE `albums` (
|
|||
`title` varchar(255) NOT NULL,
|
||||
`thumbnail` varchar(255) NOT NULL DEFAULT "",
|
||||
`description` text NOT NULL,
|
||||
`manufacturer` varchar(255) NOT NULL DEFAULT "",
|
||||
`scale` varchar(255) NOT NULL DEFAULT "",
|
||||
`createtime` datetime NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `al_foldername` (`foldername`)
|
||||
|
|
Loading…
Reference in New Issue
Block a user