- var $levels; //array of available levels /** C'tor */ //------------------------------------------------ function HeadingBlock($id=0){ //------------------------------------------------ parent::BuildingBlock($id); $this->content = ""; $this->level = 1; $this->levels = array(1); } /** @see BuildingBlock::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_headingblock ( id INT NOT NULL AUTO_INCREMENT, content TEXT NOT NULL, level TINYINT NOT NULL DEFAULT 1, PRIMARY KEY(id) )"); dbQuery($query); } /** @see BuildingBlock::load() */ //------------------------------------------------- function load(){ //------------------------------------------------- $query = sprintf("SELECT * FROM bruckm_headingblock WHERE id = %d", $this->id); $result = dbQuery($query); $line = mysqli_fetch_array($result, MYSQLI_ASSOC); $this->content = $line['content']; $this->level = $line['level']; } /** @see BuildingBlock::doSave() */ //----------------------------------------------- function doSave(){ //----------------------------------------------- $query = sprintf("UPDATE bruckm_headingblock SET content = %s, level = %d WHERE id = %d", sqlstring($this->content), sqlnum($this->level), $this->id); dbQuery($query); } /** @see BuildingBlock::doCreate() */ //----------------------------------------------- function doCreate(){ //----------------------------------------------- $query = sprintf("INSERT INTO bruckm_headingblock (content) VALUES (%s)", sqlstring($this->content)); dbQuery($query); return mysql_insert_id(); } /** @see BuildingBlock::delete() */ //------------------------------------------------- function delete(){ //------------------------------------------------- $query = sprintf("DELETE FROM bruckm_headingblock WHERE id = %d", $this->id); dbQuery($query); } /** @see BuildingBlock::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- $this->content = html_entity_decode($_POST["headingblock_content".$this->id]); $this->level = $_POST["headingblock_level".$this->id]; } /** @see BuildingBlock::printContent() */ //----------------------------------------------- function printContent($position){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."headingblock.html"); $c = htmlspecialchars($this->content); $c = str_replace("&#", "&#", $c); $t->setVar("CONTENT", $c); $t->setVar("ID", $this->id); $t->setVar("POSITION", $position); $levels = ""; foreach($this->levels as $i){ if($i == $this->level){ $levels .= ''; } else{ $levels .= ''; } } $t->setVar("LEVELS", $levels); return $t->toString(); } /** @see BuildingBlock::publish() */ //---------------------------------------------- function publish(){ //---------------------------------------------- if($this->level < 1 || $this->level > 7){ logError(3, "Illegal heading level (".$this->level.") - ID: ".$this->id, __FILE__, __LINE__); $this->level = 1; } return "level.">".htmlspecialchars($this->content)."level.">"; } /** @see BuildingBlock::publishAsPlainText() */ //---------------------------------------------- function publishAsPlainText(){ //---------------------------------------------- return $this->content . "\r\n\r\n"; } /** @see BuildingBlock::publishForNewsletter() */ //---------------------------------------------- function publishForNewsletter(){ //---------------------------------------------- $p = new Template(NEWSLETTER_DIR . "subparts/heading.html"); $p->setVar("CONTENT", htmlspecialchars($this->content)); return $p->toString(); } /** @see BuildingBlock::publishForPdf() */ //---------------------------------------------- function publishForPdf($pdf){ //---------------------------------------------- $pdf->SetFont("Arial", "B", 16); $pdf->SetTextColor(0, 0, 0); $pdf->Write(5, $this->content . "\n\n"); } }; ?>