Viewing file: module.php (13.22 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? class Videogallery { var $UserMode = true; var $AdminMode = true; var $AdminAsynchMode = true; var $SearchMode = false; var $PanelMode = false; var $AlbumTable; var $VideosTable; var $Directory; var $FilesDirectory; var $ClassName = 'Videogallery'; function Videogallery() { $this->FilesDirectory = "data/videogallery/"; $this->Directory = dirname(__FILE__); $this->AlbumTable = new AMTable2('AMCMS_videogallery_albums'); $this->AlbumTable->AddIndexField('album_id'); $this->AlbumTable->AddPositionField("album_position"); $this->AlbumTable->Module($this->ClassName);
$this->VideosTable = new AMTable2('AMCMS_videogallery_videos'); $this->VideosTable->AddIndexField('video_id'); $this->VideosTable->Module($this->ClassName); $this->VideosTable->AddPositionField("video_position"); } function User() { global $ulang, $ULANG; /* if (isset($_GET['album_id'])) { $album = $this->AlbumTable->GetRowById($_GET['album_id']); if ($album == null) { header("Location: /videogallery"); return; } $rows = $this->VideosTable->GetRows("video_position DESC", "video_album_id='{$_GET['album_id']}'"); $html = "<table align=\"center\" class=\"videos\">\n"; $cols = GetParam("PhotogalleryPicturesInColumn"); if (isset($_SESSION['screen_width']) && $_SESSION['screen_width'] > 1024) { if (GetParam("PhotogalleryCols") == "float") $cols = GetParam("PhotogalleryPicturesInColumn") + floor(($_SESSION['screen_width'] - 1024) / GetParam("VideogalleryPictureSize")); } $index = 0; foreach($rows as $key => $value) { if ($index == 0) $html .= "<tr>\n"; $html .= "<td align=\"center\" valign=\"bottom\"><table><tr><td align=\"center\" valign=\"center\" >"; $html .= "<a class=\"fancybox video\" rel=\"group\" href=\"{$value['video_code']}\" >"; $html .= "<img src=\"/data/videogallery/"."s".$value['video_filename'].".jpg\" />"; $html .= "<br />"; $html .= $value['video_title_'.$ulang]; $html .= "</a>"; $html .= "</td></tr></table></td>\n"; $index++; if ($index == $cols) $html .= "</tr>\n"; $index = $index % $cols; } for ($i = 0; $i < $cols - $index; $i++) { $html .= "<td>"; $html .= " "; $html .= "</td>\n"; } if ($cols - 1!= $index) $html .= "</tr>\n"; $html .= "</table>\n"; $html = "<div class=\"gallery\">".$html."</div>"; $result['Title'] = $album['album_name_'.$ulang]; $result['Content'] = $html; $navigator = new AMNavigator(); $navigator->AddLink(GetParam("ModuleVideogallery", $ulang), "/videogallery"); $navigator->AddLink($album['album_name_'.$ulang], "/videogallery/".$album['album_id']); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Print'] = true; return $result; }*/ { $smarty = GetUserSmarty($this->ClassName); $rows = $this->VideosTable->GetRows("video_position DESC"); $videogallery_user_display_type = GetParam('videogallery_user_display_type'); $smarty->assign("rows", $rows); $navigator = new AMNavigator(); $navigator->AddLink(GetParam("ModuleVideogallery", $ulang), "/videogallery" ); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Title'] = GetParam("ModuleVideogallery", $ulang); $result['Print'] = true; $result['Content'] = $smarty->fetch("album.tpl"); return $result; } } function Menu() { global $ALANG; return array( // array('title' => $ALANG['VideogalleryMenuAlbumAdd'], 'link' => '?mod='.$this->ClassName.'&album&add'), // array('title' => $ALANG['VideogalleryMenuAlbumList'], 'link' => '?mod='.$this->ClassName.'&album&list'), array('title' => $ALANG['VideogalleryMenuVideoAdd'], 'link' => '?mod='.$this->ClassName.'&video&add'), array('title' => $ALANG['VideogalleryMenuVideoList'], 'link' => '?mod='.$this->ClassName.'&video&list'), // array('title' => $ALANG['VideogalleryMenuVideoOrder'], 'link' => '?mod='.$this->ClassName.'&video&order'), ); } function AdminAsynch() { if ($_POST['oper'] == 'cover') { $video = $this->VideosTable->GetRowById($_POST['id']); $row['album_cover_filename'] = $video['video_filename']; $this->AlbumTable->Update($row, $video['video_album_id']); $res["status"] = "ok"; echo json_encode($res); die; } if ($_POST['oper'] == 'first') { SetParam("first-video", $_POST['id']); $res["status"] = "ok"; echo json_encode($res); die; } $this->AlbumTable->Run($_POST); $this->VideosTable->Run($_POST); } function Admin() { global $ALANG, $alang; $this->UpdateAlbumsInfo(); $smarty = GetAdminSmarty($this->ClassName); if (isset($_GET['album']) && isset($_GET['list'])) { $rows = $this->AlbumTable->GetRows("album_position DESC"); $smarty->assign("rows", $rows); $html = $smarty->Fetch('videoalbumblock.tpl'); $result['Title'] = $ALANG['VideogalleryAlbumList']; $result['Content'] = $html; return $result; } if (isset($_GET['edit']) && isset($_GET['album_id'])) { if (isset($_POST['edit'])) { $_POST['album_date_of_edition'] = GetCurrentDateAndTime(); $id = $_GET['album_id']; $this->AlbumTable->Update($_POST, $id); header("Location: ?mod=".$this->ClassName."&album&list"); die; } $id = $_GET['album_id']; $row = $this->AlbumTable->GetRowById($id); foreach($row as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'edit'); $result['Title'] = $ALANG['VideoalbumEdition']; $result['Content'] = $smarty->fetch('videoalbum.tpl'); return $result; } if (isset($_GET['video']) && isset($_GET['order'])) { $albums = $this->AlbumTable->GetRows("album_position DESC"); if (!isset($_REQUEST['album_id'])) $album_id = $albums[0]['album_id']; else $album_id = $_REQUEST['album_id']; $videos = $this->VideosTable->GetRows("video_position DESC", "video_album_id='{$album_id}'"); $smarty->assign('albums', $albums); $smarty->assign('videos', $videos); $result['Title'] = $ALANG['VideogalleryVideoOrder']; $result['Content'] = $html.$smarty->Fetch('videosorder.tpl');; return $result; } if (isset($_GET['video']) && isset($_GET['list'])) { /*$albums = $this->AlbumTable->GetRows("album_position DESC"); if (!isset($_REQUEST['album_id'])) $album_id = $albums[0]['album_id']; else $album_id = $_REQUEST['album_id'];*/ $videos = $this->VideosTable->GetRows("video_position DESC"); $smarty->assign('albums', $albums); $smarty->assign('videos', $videos); { $html = $smarty->Fetch('videoblock.tpl'); } $result['Title'] = $ALANG['VideogalleryVideoList']; $result['Content'] = $html; return $result; } if (isset($_GET['album']) && isset($_GET['add'])) { if (isset($_POST['add'])) { $_POST['album_date_of_creation'] = GetCurrentDateAndTime(); $_POST['album_date_of_edition'] = GetCurrentDateAndTime(); $id = $this->AlbumTable->Insert($_POST); $this->UpdateAlbumsInfo(); header("Location: ?mod=".$this->ClassName."&album&list"); } foreach($_POST as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'add'); $result['Title'] = $ALANG['VideogalleryAlbumAdd']; $result['Content'] = $smarty->fetch('videoalbum.tpl'); return $result; } if (isset($_GET['video']) && isset($_GET['add'])) { if (isset($_POST['add'])) { $_POST['video_date_of_creation'] = GetCurrentDateAndTime(); $url = $_POST['video_code']; if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) { $_POST['video_youtube_id'] = $match[1]; } $extension = "jpg"; $sourceFile = $_FILES['video_filename']['tmp_name']; $filename = uniqid(""); $destantionFileI = $this->FilesDirectory."i".$filename.".".$extension; $destantionFileS = $this->FilesDirectory."s".$filename.".".$extension; $sizeSmall = explode("x", GetParam("VideogalleryPictureSize")); ImageResize($sourceFile, $destantionFileI, 80, 80, 0xFFFFFF, 90); ImageResize($sourceFile, $destantionFileS, $sizeSmall[0], $sizeSmall[1], 0xFFFFFF, 75); $_POST['video_filename'] = $filename; $id = $this->VideosTable->Insert($_POST); $this->UpdateAlbumsInfo(); header("Location: ?mod=".$this->ClassName."&video&list"); } foreach($_POST as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'add'); $albums = $this->AlbumTable->GetRows("album_position DESC"); $video_album_values = array(); $video_album_captions = array(); foreach($albums as $key => $value) { $video_album_values[] = $value['album_id']; $video_album_captions[] = $value['album_name_'.$alang]; } $smarty->assign('video_album_values', $video_album_values); $smarty->assign('video_album_captions', $video_album_captions); $smarty->assign('video_album_id', $_GET['album_id']); if (isset($_GET['ok'])) $smarty->assign("message", $ALANG['PictureAddOK']); if (isset($_GET['fail'])) $smarty->assign("message", $ALANG['PictureAddFail']); $result['Title'] = $ALANG['VideogalleryVideoAdd']; $result['Content'] = $smarty->fetch('video.tpl'); return $result; } if (isset($_GET['edit']) && isset($_GET['video_id'])) { if (isset($_POST['edit'])) { $row = $this->VideosTable->GetRowById($_GET['video_id']); $url = $_POST['video_code']; if (preg_match('%(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $url, $match)) { $_POST['video_youtube_id'] = $match[1]; } if (strlen($_FILES['video_filename']['tmp_name']) > 0) { @unlink($this->FilesDirectory."i".$row['video_filename'].".jpg"); @unlink($this->FilesDirectory."s".$row['video_filename'].".jpg"); $extension = "jpg"; $sourceFile = $_FILES['video_filename']['tmp_name']; $filename = uniqid(""); $destantionFileI = $this->FilesDirectory."i".$filename.".".$extension; $destantionFileS = $this->FilesDirectory."s".$filename.".".$extension; $sizeSmall = explode("x", GetParam("VideogalleryPcitureSize")); ImageResize($sourceFile, $destantionFileI, 80, 80, 0xFFFFFF, 90); ImageResize($sourceFile, $destantionFileS, $sizeSmall[0], $sizeSmall[1], 0xFFFFFF, 75); ImageResize($sourceFile, $destantionFileB, $sizeBig[0], $sizeBig[1], 0xFFFFFF, 75); $_POST['video_filename'] = $filename; } $this->VideosTable->Update($_POST, $_GET['video_id']); $this->UpdateAlbumsInfo(); header("Location: admin.php?mod=Videogallery&video&list&album_id=".$row['video_album_id']); } $row = $this->VideosTable->GetRowById($_GET['video_id']); $albums = $this->AlbumTable->GetRows("album_position DESC"); foreach($row as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'edit'); $video_album_values = array(); $video_album_captions = array(); foreach($albums as $key => $value) { $video_album_values[] = $value['album_id']; $video_album_captions[] = $value['album_name_'.$alang]; } $smarty->assign('video_album_values', $video_album_values); $smarty->assign('video_album_captions', $video_album_captions); $result['Title'] = $ALANG['VideogalleryVideoEdit']; $result['Content'] = $smarty->fetch('video.tpl'); return $result; } } function UpdateAlbumsInfo() { $res1 = mysql_query("SELECT album_id FROM AMCMS_videogallery_albums"); while ($row1 = mysql_fetch_array($res1)) { $res2 = mysql_query("SELECT COUNT(*) FROM AMCMS_videogallery_videos WHERE video_album_id = '{$row1['album_id']}'"); $row2 = mysql_fetch_array($res2); mysql_query("UPDATE AMCMS_videogallery_albums SET album_count_of_videos = '{$row2['COUNT(*)']}' WHERE album_id = '{$row1['album_id']}'"); } } function Panel() { global $ULANG, $ulang; $res = mysql_query("SELECT * FROM AMCMS_videos WHERE video_album_id = 0 ORDER BY RAND()"); if (mysql_num_rows($res) == 0) return; $html = "<div align=\"center\" id=\"MySlideshow\">"; while( ($row = mysql_fetch_array($res)) != 0) { $html .= "<img src=\"/data/videogallery/b".$row['video_filename'].".".$row['video_filetype']."\" />"; } $html .= "</div>"; // $html = "<div align=\"center\" id=\"MySlideshow\">"."<a href=\"/videogallery/{$row['video_album_id']}\"><img src=\"/data/videogallery/b".$row['video_filename'].".".$row['video_filetype']."\" /></a>"; $result['Videogallery'] = array('panelName' => GetParam('RandomVideoPanelName_'.$ulang), 'panelHtml' => $html.strip_tags($row['video_caption_'.$ulang])."</div>", 'PanelLink' => MOD_REWRITE ? "/videogallery" : "?videogallery", 'PanelLinkTitle' => $ULANG['Videogallery'], 'PanelLinkClass' => "LinkAll"); return $result; } }
$Modules [] = new Videogallery(); ?>
|