Viewing file: module.php (16.35 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<? class Photogallery { var $UserMode = true; var $AdminMode = false; var $AdminAsynchMode = true; var $SearchMode = false; var $PanelMode = false; var $AlbumTable; var $PhotosTable; var $Directory; var $FilesDirectory; var $ClassName = 'Photogallery'; function Photogallery() { $this->FilesDirectory = "data/photogallery/"; $this->Directory = dirname(__FILE__); $this->AlbumTable = new AMTable2('AMCMS_photogallery_albums'); $this->AlbumTable->AddIndexField('album_id'); $this->AlbumTable->AddPositionField("album_position"); $this->AlbumTable->Module($this->ClassName);
$this->PhotosTable = new AMTable2('AMCMS_photogallery_photos'); $this->PhotosTable->AddIndexField('photo_id'); $this->PhotosTable->Module($this->ClassName); $this->PhotosTable->AddPositionField("photo_position"); } static function GetPhotoheader() { $PhotosTable = new AMTable2('AMCMS_photogallery_photos'); $PhotosTable->AddIndexField('photo_id'); $PhotosTable->Module("Photogallery"); $PhotosTable->AddPositionField("photo_position"); $rows = $PhotosTable->GetRows("photo_position DESC", "photo_album_id='".GetParam("HeaderPhotoAlbum")."'"); foreach($rows as $key => $value) { $html .= "<span><img src=\"/data/photogallery/"."b".$value['photo_filename'].".jpg\" /></span>"; } echo $html; } function User() { global $ulang, $ULANG; if (isset($_GET['photogallery']) && isset($_GET['album_id'])) { $album = $this->AlbumTable->GetRowById($_GET['album_id']); if ($album == null) { header("Location: /photogallery"); return; } $rows = $this->PhotosTable->GetRows("photo_position DESC", "photo_album_id='{$_GET['album_id']}'"); $html = "<table align=\"center\" class=\"photos\">\n"; $cols = GetParam("VideogalleryPicturesInColumn"); $arr = explode("x",GetParam("PhotogallerySmallPhotoSize")); if (isset($_SESSION['screen_width']) && $_SESSION['screen_width'] > 1024) { if (GetParam("PhotogalleryCols") == "float") $cols = GetParam("PhotogalleryPicturesInColumn") + floor(($_SESSION['screen_width'] - 1024) / $arr[0]); } $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\" rel=\"group\" title=\"".strip_tags($value['photo_caption_'.$ulang])."\" href=\"/data/photogallery/"."b".$value['photo_filename'].".jpg\" >"; $html .= "<img src=\"/data/photogallery/"."s".$value['photo_filename'].".jpg\" />"; $html .= "<br />"; $html .= $value['photo_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("ModulePhotogallery", $ulang), "/photogallery"); $navigator->AddLink($album['album_name_'.$ulang], "/photogallery/".$album['album_id']); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Print'] = true; return $result; } if (isset($_GET['photogallery'])) { $smarty = GetUserSmarty($this->ClassName); $rows = $this->AlbumTable->GetRows("album_position DESC"); $photogallery_user_display_type = GetParam('photogallery_user_display_type'); $smarty->assign("rows", $rows); $navigator = new AMNavigator(); $navigator->AddLink(GetParam("ModulePhotogallery", $ulang), "/photogallery" ); $result['GlobalParams']['Navigator'] = $navigator->Fetch(); $result['GlobalParams']['PageTitle'] = $navigator->GetTitleForPage(); $result['Module'] = $this->ClassName; $result['Title'] = GetParam("ModulePhotogallery", $ulang); $result['Print'] = true; $result['Content'] = $smarty->fetch("album.tpl"); return $result; } } function Menu() { global $ALANG; return array( array('title' => $ALANG['PhotogalleryMenuAlbumAdd'], 'link' => '?mod='.$this->ClassName.'&album&add'), array('title' => $ALANG['PhotogalleryMenuAlbumList'], 'link' => '?mod='.$this->ClassName.'&album&list'), // array('title' => $ALANG['PhotogalleryMenuPhotoAdd'], 'link' => '?mod='.$this->ClassName.'&photo&add'), array('title' => $ALANG['PhotogalleryMenuPhotoList'], 'link' => '?mod='.$this->ClassName.'&photo&list'), array('title' => $ALANG['PhotogalleryMenuPhotoOrder'], 'link' => '?mod='.$this->ClassName.'&photo&order'), array('title' => $ALANG['PhotogalleryMenuPhotoPacket'], 'link' => '?mod='.$this->ClassName.'&photo&packet'), ); } function AdminAsynch() { if (isset($_REQUEST['mod']) && ($_REQUEST['mod'] == $this->ClassName)) { if (isset($_REQUEST['photo']) && isset($_REQUEST['add']) && !empty($_FILES)) { $_POST['photo_date_of_creation'] = GetCurrentDateAndTime(); $_POST['photo_date_of_edition'] = GetCurrentDateAndTime(); $extension = "jpg"; $sourceFile = $_FILES['Filedata']['tmp_name']; $filename = uniqid(""); $destantionFileI = $this->FilesDirectory."i".$filename.".".$extension; $destantionFileB = $this->FilesDirectory."b".$filename.".".$extension; $destantionFileS = $this->FilesDirectory."s".$filename.".".$extension; $sizeSmall = explode("x", GetParam("PhotogallerySmallPhotoSize")); $sizeBig = explode("x", "200x150"); 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); $thumb = PhpThumbFactory::create($sourceFile); $thumb->adaptiveResize(240, 180); $thumb->save($destantionFileB); $_POST['photo_filename'] = $filename; $_POST['photo_album_id'] = $_POST['album_id']; $id = $this->PhotosTable->Insert($_POST); $this->UpdateAlbumsInfo(); echo '1'; die; } } if ($_POST['oper'] == 'cover') { $photo = $this->PhotosTable->GetRowById($_POST['id']); $row['album_cover_filename'] = $photo['photo_filename']; $this->AlbumTable->Update($row, $photo['photo_album_id']); $res["status"] = "ok"; echo json_encode($res); die; } $this->AlbumTable->Run($_POST); $this->PhotosTable->Run($_POST); $this->UpdateAlbumsInfo(); } function Admin() { global $ALANG, $alang; $smarty = GetAdminSmarty($this->ClassName); if (isset($_GET['album_id']) && isset($_GET['SetAlbumForHeader'])) { SetParam("HeaderPhotoAlbum", $_GET['album_id']); } if (isset($_GET['album']) && isset($_GET['list'])) { $rows = $this->AlbumTable->GetRows("album_position DESC"); $smarty->assign("rows", $rows); $html = $smarty->Fetch('photoalbumblock.tpl'); $result['Title'] = $ALANG['PhotogalleryAlbumList']; $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."&PhotoalbumsList"); 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['PhotoalbumEdition']; $result['Content'] = $smarty->fetch('photoalbum.tpl'); return $result; } if (isset($_GET['photo']) && isset($_GET['packet'])) { $albums = $this->AlbumTable->GetRows("album_position DESC"); $photo_album_values = array(); $photo_album_captions = array(); foreach($albums as $key => $value) { $photo_album_values[] = $value['album_id']; $photo_album_captions[] = $value['album_name_'.GetParam("DefaultLanguage")]; } $smarty->assign('sid', session_id()); $smarty->assign('photo_album_values', $photo_album_values); $smarty->assign('photo_album_captions', $photo_album_captions); $smarty->assign('photo_album_id', $_GET['album_id']); $result['Title'] = $ALANG['PhotogalleryPhotoPacket']; $result['Content'] = $smarty->Fetch('addmanyphotos.tpl'); return $result; } if (isset($_GET['photo']) && 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']; $photos = $this->PhotosTable->GetRows("photo_position DESC", "photo_album_id='{$album_id}'"); $smarty->assign('albums', $albums); $smarty->assign('photos', $photos); $result['Title'] = $ALANG['PhotogalleryPhotoOrder']; $result['Content'] = $html.$smarty->Fetch('photosorder.tpl');; return $result; } if (isset($_GET['photo']) && 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']; $photos = $this->PhotosTable->GetRows("photo_position DESC", "photo_album_id='{$album_id}'"); $smarty->assign('albums', $albums); $smarty->assign('photos', $photos); if (isset($album_id)) { $html = $smarty->Fetch('photoblock.tpl'); } $result['Title'] = $ALANG['PhotogalleryPhotoList']; $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['PhotogalleryAlbumAdd']; $result['Content'] = $smarty->fetch('photoalbum.tpl'); return $result; } if (isset($_GET['photo']) && isset($_GET['add'])) { if (isset($_POST['add'])) { $_POST['photo_date_of_creation'] = GetCurrentDateAndTime(); $extension = "jpg"; $sourceFile = $_FILES['photo_filename']['tmp_name']; $filename = uniqid(""); $destantionFileI = $this->FilesDirectory."i".$filename.".".$extension; $destantionFileB = $this->FilesDirectory."b".$filename.".".$extension; $destantionFileS = $this->FilesDirectory."s".$filename.".".$extension; $sizeSmall = explode("x", GetParam("PhotogallerySmallPhotoSize")); $sizeBig = explode("x", GetParam("PhotogalleryBigPhotoSize")); 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); $thumb = PhpThumbFactory::create($sourceFile); $thumb->adaptiveResize(267, 200); $thumb->save($destantionFileB); $_POST['photo_filename'] = $filename; $id = $this->PhotosTable->Insert($_POST); $this->UpdateAlbumsInfo(); header("Location: ?mod=".$this->ClassName."&photo&add&album_id=".$_POST['photo_album_id'].'&ok'); } foreach($_POST as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'add'); $albums = $this->AlbumTable->GetRows("album_position DESC"); $photo_album_values = array(); $photo_album_captions = array(); foreach($albums as $key => $value) { $photo_album_values[] = $value['album_id']; $photo_album_captions[] = $value['album_name_'.GetParam("DefaultLanguage")]; } $smarty->assign('photo_album_values', $photo_album_values); $smarty->assign('photo_album_captions', $photo_album_captions); $smarty->assign('photo_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['PhotogalleryPhotoAdd']; $result['Content'] = $smarty->fetch('photo.tpl'); return $result; } if (isset($_GET['edit']) && isset($_GET['photo_id'])) { if (isset($_POST['edit'])) { $row = $this->PhotosTable->GetRowById($_GET['photo_id']); if (strlen($_FILES['photo_filename']['tmp_name']) > 0) { @unlink($this->FilesDirectory."i".$row['photo_filename'].".jpg"); @unlink($this->FilesDirectory."b".$row['photo_filename'].".jpg"); @unlink($this->FilesDirectory."s".$row['photo_filename'].".jpg"); $extension = "jpg"; $sourceFile = $_FILES['photo_filename']['tmp_name']; $filename = uniqid(""); $destantionFileI = $this->FilesDirectory."i".$filename.".".$extension; $destantionFileB = $this->FilesDirectory."b".$filename.".".$extension; $destantionFileS = $this->FilesDirectory."s".$filename.".".$extension; $sizeSmall = explode("x", GetParam("PhotogallerySmallPhotoSize")); $sizeBig = explode("x", GetParam("PhotogalleryBigPhotoSize")); 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['photo_filename'] = $filename; } $this->PhotosTable->Update($_POST, $_GET['photo_id']); $this->UpdateAlbumsInfo(); header("Location: admin.php?mod=Photogallery&photo&list&album_id=".$row['photo_album_id']); } $row = $this->PhotosTable->GetRowById($_GET['photo_id']); $albums = $this->AlbumTable->GetRows("album_position DESC"); foreach($row as $key => $value) $smarty->assign($key, $value); $smarty->assign('oper', 'edit'); $photo_album_values = array(); $photo_album_captions = array(); foreach($albums as $key => $value) { $photo_album_values[] = $value['album_id']; $photo_album_captions[] = $value['album_name_'.$alang]; } $smarty->assign('photo_album_values', $photo_album_values); $smarty->assign('photo_album_captions', $photo_album_captions); $result['Title'] = $ALANG['PhotogalleryPhotoEdit']; $result['Content'] = $smarty->fetch('photo.tpl'); return $result; } } function UpdateAlbumsInfo() { $res1 = mysql_query("SELECT album_id FROM AMCMS_photogallery_albums"); while ($row1 = mysql_fetch_array($res1)) { $res2 = mysql_query("SELECT COUNT(*) FROM AMCMS_photogallery_photos WHERE photo_album_id = '{$row1['album_id']}'"); $row2 = mysql_fetch_array($res2); mysql_query("UPDATE AMCMS_photogallery_albums SET album_count_of_photos = '{$row2['COUNT(*)']}' WHERE album_id = '{$row1['album_id']}'"); } } function Panel() { global $ULANG, $ulang; $res = mysql_query("SELECT * FROM AMCMS_photos WHERE photo_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/photogallery/b".$row['photo_filename'].".".$row['photo_filetype']."\" />"; } $html .= "</div>"; // $html = "<div align=\"center\" id=\"MySlideshow\">"."<a href=\"/photogallery/{$row['photo_album_id']}\"><img src=\"/data/photogallery/b".$row['photo_filename'].".".$row['photo_filetype']."\" /></a>"; $result['Photogallery'] = array('panelName' => GetParam('RandomPhotoPanelName_'.$ulang), 'panelHtml' => $html.strip_tags($row['photo_caption_'.$ulang])."</div>", 'PanelLink' => MOD_REWRITE ? "/photogallery" : "?photogallery", 'PanelLinkTitle' => $ULANG['Photogallery'], 'PanelLinkClass' => "LinkAll"); return $result; } }
$Modules [] = new Photogallery(); ?>
|