Files
bm/public_html/public/bg/htmlblock.class.php
2025-09-24 13:26:28 +02:00

129 lines
3.1 KiB
PHP

<?php
/** HTML Block
*
* @version 1.9.0
* @since 2007-04-16
* @author martin lenzelbauer
*
*/
class HtmlBlock extends BuildingBlock{
var $content; //html code
/** C'tor
*/
//------------------------------------------------
function HtmlBlock($id=0){
//------------------------------------------------
parent::BuildingBlock($id);
$this->content = "";
}
/** @see BuildingBlock::install()
*/
//-----------------------------------------------
function install(){
//-----------------------------------------------
$query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_htmlblock (
id INT not null AUTO_INCREMENT,
content TEXT not null,
PRIMARY KEY(id)
)");
dbQuery($query);
}
/** @see BuildingBlock::load()
*/
//-------------------------------------------------
function load(){
//-------------------------------------------------
$query = sprintf("SELECT * FROM bruckm_htmlblock WHERE id = %d", $this->id);
$result = dbQuery($query);
$line = mysqli_fetch_array($result, MYSQLI_ASSOC);
$this->content = $line['content'];
}
/** @see BuildingBlock::doSave()
*/
//-----------------------------------------------
function doSave(){
//-----------------------------------------------
$query = sprintf("UPDATE bruckm_htmlblock SET content = %s WHERE id = %d",
sqlstring($this->content),
$this->id);
dbQuery($query);
}
/** @see BuildingBlock::doCreate()
*/
//-----------------------------------------------
function doCreate(){
//-----------------------------------------------
$query = sprintf("INSERT INTO bruckm_htmlblock (content) VALUES (%s)",
sqlstring($this->content));
dbQuery($query);
return mysql_insert_id();
}
/** @see BuildingBlock::delete()
*/
//-------------------------------------------------
function delete(){
//-------------------------------------------------
$query = sprintf("DELETE FROM bruckm_htmlblock WHERE id = %d", $this->id);
dbQuery($query);
}
/** @see BuildingBlock::update()
*/
//-----------------------------------------------
function update(){
//-----------------------------------------------
if(isset($_POST["htmlblock_content".$this->id])){
$this->content = html_entity_decode($_POST["htmlblock_content".$this->id]);
}
}
/** @see BuildingBlock::printContent()
*/
//-----------------------------------------------
function printContent($position){
//-----------------------------------------------
$t = new Template(CMS_TEMPLATE_DIR."htmlblock.html");
$c = htmlentities($this->content);
$c = str_replace("&amp;#", "&#", $c);
$t->setVar("CONTENT", $c);
$t->setVar("ID", $this->id);
$t->setVar("POSITION", $position);
if($_SESSION['userlevel'] == USER_ADMIN){
$t->setVar("DISABLED", "");
}
else{
$t->setVar("DISABLED", "disabled=\"disabled\"");
}
return $t->toString();
}
/** @see BuildingBlock::publish()
*/
//----------------------------------------------
function publish(){
//----------------------------------------------
return $this->content;
}
};
?>