content = ""; } /** @see BuildingBlock::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_textblock ( 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_textblock 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_textblock SET content = %s WHERE id = %d", sqlstring($this->content), $this->id); dbQuery($query); } /** @see BuildingBlock::doCreate() */ //----------------------------------------------- function doCreate(){ //----------------------------------------------- $query = sprintf("INSERT INTO bruckm_textblock (content) VALUES (%s)", sqlstring($this->content)); dbQuery($query); return mysql_insert_id(); } /** @see BuildingBlock::delete() */ //------------------------------------------------- function delete(){ //------------------------------------------------- $query = sprintf("DELETE FROM bruckm_textblock WHERE id = %d", $this->id); dbQuery($query); } /** @see BuildingBlock::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- $this->content = html_entity_decode($_POST["textblock_content".$this->id]); } /** @see BuildingBlock::printContent() */ //----------------------------------------------- function printContent($position){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."textblock.html"); $c = htmlspecialchars($this->content); $c = str_replace("&#", "&#", $c); $t->setVar("CONTENT", $c); $t->setVar("ID", $this->id); $t->setVar("POSITION", $position); return $t->toString(); } /** @see BuildingBlock::publish() */ //---------------------------------------------- function publish(){ //---------------------------------------------- $content = bbcode2html($this->content); $p = new Template(); $p->setString(''. 'Druckversion'. 'Druckversion'); $p->setVar("ID", $this->id); $p->setVar("TYPE", "stdpage"); //$content = str_replace("[print]", $p->toString(), $content); return "

$content

"; } /** @see BuildingBlock::publishAsPlainText() */ //---------------------------------------------- function publishAsPlainText(){ //---------------------------------------------- return bbcode2plaintext($this->content) . "\r\n\r\n"; } /** @see BuildingBlock::publishForNewsletter() */ //---------------------------------------------- function publishForNewsletter(){ //---------------------------------------------- $p = new Template(NEWSLETTER_DIR . "subparts/text.html"); $p->setVar("CONTENT", bbcode2html($this->content)); return $p->toString(); } /** @see BuildingBlock::publishForPdf() */ //---------------------------------------------- function publishForPdf($pdf){ //---------------------------------------------- $pdf->SetFont("Arial", "", 12); $pdf->SetTextColor(0, 0, 0); $content = preg_split("(\[(.+)\])U", $this->content, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); $style = ""; for ($i = 0; $i < sizeof($content); $i++) { $str = $content[$i]; $tag = strtolower(substr($str, 0, 4)); // bold tag if ($tag == "f") { $style .= "B"; $pdf->SetFont("Arial", $style, 12); } else if ($tag == "/f") { $style = ereg_replace("B", "", $style); $pdf->setFont("Arial", $style, 12); } // italic tag else if ($tag == "k") { $style .= "I"; $pdf->SetFont("Arial", $style, 12); } else if ($tag == "/k") { $style = ereg_replace("I", "", $style); $pdf->setFont("Arial", $style, 12); } // hyperlink else if ($tag == "url=") { $href = substr($str, 4, strpos($str, " ") - 4); $pdf->SetTextColor(0, 0, 127); $pdf->SetFont("Arial", "I", 12); $i++; $pdf->Write(5, $content[$i], $href); $i++; $pdf->setTextColor(0, 0, 0); $pdf->SetFont("Arial", $style, 12); } // just text... else { $pdf->Write(5, $str); } } $pdf->Ln(); $pdf->Ln(); } }; ?>