144 lines
4.0 KiB
PHP
144 lines
4.0 KiB
PHP
<?php
|
|
require_once(ROOT."include/bbcode.inc.php");
|
|
|
|
/** Gallery Block
|
|
*
|
|
* @version 1.9.0
|
|
* @since 2007-04-16
|
|
* @author martin lenzelbauer
|
|
*
|
|
*/
|
|
class GalleryBlock extends BuildingBlock{
|
|
|
|
var $galleryId; //flexicon id of the gallery
|
|
|
|
|
|
/** C'tor
|
|
*/
|
|
//------------------------------------------------
|
|
function GalleryBlock($id=0){
|
|
//------------------------------------------------
|
|
parent::BuildingBlock($id);
|
|
$this->galleryId = 0;
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::install()
|
|
*/
|
|
//-----------------------------------------------
|
|
function install(){
|
|
//-----------------------------------------------
|
|
$query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_galleryblock (
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
galleryId INT UNSIGNED NOT NULL,
|
|
PRIMARY KEY(id)
|
|
)");
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::load()
|
|
*/
|
|
//-------------------------------------------------
|
|
function load(){
|
|
//-------------------------------------------------
|
|
$query = sprintf("SELECT * FROM bruckm_galleryblock WHERE id = %d", $this->id);
|
|
$result = dbQuery($query);
|
|
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
|
|
$this->galleryId = $line['galleryId'];
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::doSave()
|
|
*/
|
|
//-----------------------------------------------
|
|
function doSave(){
|
|
//-----------------------------------------------
|
|
$query = sprintf("UPDATE bruckm_galleryblock SET galleryId = %d WHERE id = %d",
|
|
sqlnum($this->galleryId),
|
|
$this->id);
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::doCreate()
|
|
*/
|
|
//-----------------------------------------------
|
|
function doCreate(){
|
|
//-----------------------------------------------
|
|
$query = sprintf("INSERT INTO bruckm_galleryblock (galleryId) VALUES (%d)",
|
|
sqlstring($this->content));
|
|
dbQuery($query);
|
|
return mysql_insert_id();
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::delete()
|
|
*/
|
|
//-------------------------------------------------
|
|
function delete(){
|
|
//-------------------------------------------------
|
|
$query = sprintf("DELETE FROM bruckm_galleryblock WHERE id = %d", $this->id);
|
|
dbQuery($query);
|
|
}
|
|
|
|
|
|
|
|
/** @see BuildingBlock::update()
|
|
*/
|
|
//-----------------------------------------------
|
|
function update(){
|
|
//-----------------------------------------------
|
|
$this->galleryId = $_POST["galleryblock_id".$this->id];
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::printContent()
|
|
*/
|
|
//-----------------------------------------------
|
|
function printContent($position){
|
|
//-----------------------------------------------
|
|
$t = new Template(CMS_TEMPLATE_DIR."galleryblock.html");
|
|
$t->setVar("ID", $this->id);
|
|
$t->setVar("POSITION", $position);
|
|
$query = sprintf("SELECT id,name FROM bruckm_index WHERE class = %s ORDER BY name ASC",
|
|
sqlstring("Gallery"));
|
|
$result = dbQuery($query);
|
|
$galleries = "<option value=\"0\">- Galerie wählen -</option>";
|
|
while($line = mysqli_fetch_array($result, MYSQLI_ASSOC)){
|
|
if($line['id'] == $this->galleryId){
|
|
$galleries .= "<option value=\"$line[id]\" selected=\"selected\">".htmlspecialchars($line['name'])."</option>";
|
|
}
|
|
else{
|
|
$galleries .= "<option value=\"$line[id]\">".htmlspecialchars($line['name'])."</option>";
|
|
}
|
|
}
|
|
$t->setVar("GALLERIES", $galleries);
|
|
return $t->toString();
|
|
}
|
|
|
|
|
|
/** @see BuildingBlock::publish()
|
|
*/
|
|
//----------------------------------------------
|
|
function publish(){
|
|
//----------------------------------------------
|
|
if(!$this->galleryId){
|
|
logError(3, "No gallery selected - id: ".$this->id, __FILE__, __LINE__);
|
|
return "";
|
|
}
|
|
if(!$gallery = FlexiconFactory::instanceById($this->galleryId)){
|
|
logError(3, "Selected gallery (ID: " . $this->galleryId . ") doesn't exist (Gallery Block: " . $this->id . ")", __FILE__, __LINE__);
|
|
return "";
|
|
}
|
|
$gallery->load();
|
|
$t = new Template(TEMPLATE_DIR."subparts/gallery.html");
|
|
$t->setVar("ID", $this->galleryId);
|
|
$t->setVar("TITLE", $gallery->toString());
|
|
return $t->toString();
|
|
}
|
|
|
|
|
|
};
|
|
|
|
?>
|