file = ""; $this->preview = ""; $this->type = "unknown"; $this->width = 320; $this->height = 240; $this->maxWidth = 500; $this->maxHeight = 500; $this->setUploadDirectories(VIDEO_DIR, IMG_DIR); } /** @see BuildingBlock::install() */ //----------------------------------------------- function install(){ //----------------------------------------------- $query = sprintf("CREATE TABLE IF NOT EXISTS bruckm_videoblock ( id INT not null AUTO_INCREMENT, file VARCHAR(128) not null, preview VARCHAR(128) not null, type ENUM('real','quicktime','windowsmedia','flash','unknown'), width INT not null, height INT not null, PRIMARY KEY(id) )"); $result = dbQuery($query); } /** @see BuildingBlock::load() */ //------------------------------------------------- function load(){ //------------------------------------------------- $query = sprintf("SELECT * FROM bruckm_videoblock WHERE id = %d", $this->id); $result = dbQuery($query); $line = mysqli_fetch_array($result, MYSQLI_ASSOC); $this->file = $line['file']; $this->preview = $line['preview']; $this->type = $line['type']; $this->width = $line['width']; $this->height = $line['height']; } /** @see BuildingBlock::doSave() */ //----------------------------------------------- function doSave(){ //----------------------------------------------- $query = sprintf("UPDATE bruckm_videoblock SET file = %s, preview = %s, type = %s, width = %d, height = %d WHERE id = %d", sqlstring($this->file), sqlstring($this->preview), sqlstring($this->type), sqlnum($this->width), sqlnum($this->height), $this->id); dbQuery($query); } /** @see BuildingBlock::doCreate() */ //----------------------------------------------- function doCreate(){ //----------------------------------------------- $query = sprintf("INSERT INTO bruckm_videoblock (file, type, width, height) VALUES (%s, %s, %d, %d)", sqlstring($this->file), sqlstring($this->type), sqlnum($this->width), sqlnum($this->height)); dbQuery($query); return mysql_insert_id(); } /** @see BuildingBlock::delete() */ //------------------------------------------------- function delete(){ //------------------------------------------------- $query = sprintf("DELETE FROM bruckm_videoblock WHERE id = %d", $this->id); dbQuery($query); @unlink($this->videoDir.$this->file); @unlink($this->previewDir.$this->preview); } /** @see BuildingBlock::update() */ //----------------------------------------------- function update(){ //----------------------------------------------- $this->width = $_POST["videoblock_width".$this->id]; $this->height = $_POST["videoblock_height".$this->id]; if(isset($_FILES["videoblock_file".$this->id]) && $_FILES["videoblock_file".$this->id]['error'] == UPLOAD_ERR_OK){ $this->file = $this->findName($this->videoDir, $_FILES["videoblock_file".$this->id]['name']); $this->uploadVideo($_FILES["videoblock_file".$this->id]); } if(isset($_FILES["videoblock_preview".$this->id]) && $_FILES["videoblock_preview".$this->id]['error'] == UPLOAD_ERR_OK){ $this->preview = $this->findName($this->previewDir, $_FILES["videoblock_preview".$this->id]['name']); $this->uploadPreview($_FILES["videoblock_preview".$this->id]); } } /** @see BuildingBlock::printContent() */ //----------------------------------------------- function printContent($position){ //----------------------------------------------- $t = new Template(CMS_TEMPLATE_DIR."videoblock.html"); $t->setVar("ID", $this->id); $t->setVar("POSITION", $position); $t->setVar("WIDTH", $this->width); $t->setVar("HEIGHT", $this->height); if(!empty($this->file) && file_exists($this->videoDir.$this->file)){ if ($this->type == "real") { $t->setVar("VIDEO", 'Video ansehen'); $t->removeBlock("UPLOADVIDEO"); } else if ($this->type == "quicktime") { $t->setVar("VIDEO", 'Video ansehen'); $t->removeBlock("UPLOADVIDEO"); } else if ($this->type == "windowsmedia") { $t->setVar("VIDEO", 'Video ansehen'); $t->removeBlock("UPLOADVIDEO"); } else if ($this->type == "flash") { $t->setVar("VIDEO", 'Video ansehen'); $t->removeBlock("UPLOADVIDEO"); } else { $t->setVar("VIDEO", 'Unbekannter Dateityp'); } } else{ $t->removeBlock("VIDEO"); } if(!empty($this->preview) && file_exists($this->previewDir.$this->preview)){ $t->setVar("PREVIEW", $this->previewDir . $this->preview); $t->removeBlock("UPLOADPREVIEW"); } else{ $t->removeBlock("PREVIEW"); } return $t->toString(); } /** @see BuildingBlock::publish() */ //---------------------------------------------- function publish(){ //---------------------------------------------- if(!file_exists($this->videoDir.$this->file)){ logError(3, "Video ".$this->videoDir.$this->file." doesn't exist", __FILE__, __LINE__); return ""; } $out = '
'; return $out; } // === ADDITIONAL METHODS ======================================================== // /** shows the video in a separate window */ //------------------------------------------------ function show(){ //------------------------------------------------ $t = new Template("video.html"); if ($this->type == "real") { $t->setVar("VIDEO", $this->printReal($this->file)); } else if ($this->type == "quicktime") { $t->setVar("VIDEO", $this->printQuicktime($this->file)); } else if ($this->type == "windowsmedia") { $t->setVar("VIDEO", $this->printWindowsMedia($this->file)); } else if ($this->type == "flash") { $t->setVar("VIDEO", $this->printFlash($this->file)); } else { $t->setVar("VIDEO", "Video nicht gefunden"); } $t->parse(); } /** prints the source code for embedding a real video * @param path path */ //------------------------------------------------ function printReal($path) { //------------------------------------------------ $width = $this->width; $height = $this->height; $v .= ''; return $v; } /** prints the source code for embedding a quicktime video * @param path path */ //------------------------------------------------ function printQuicktime($path) { //------------------------------------------------ $width = $this->width; $height = $this->height + 16; $v = '