<?php
	$table = "photos";  #Таблица фото
	$table_a = $table."_album"; #Таблица альбома
	
	$thisLink = "/{$thisPage}";

	$id = intval($_GET['id']);
	$att = [];
	$att['l'] = "";



	if(isset($_GET['act'])) {
		if($_GET['act'] == "create_album"){ require("inc/create_album.php"); } #Создать альбом
		if($_GET['act'] == "album"){ require("inc/album.php"); } #посмотреть альбом 
		if($_GET['act'] == "photo_view"){ require("inc/photo.php"); } #Посмотреть фото
	}
	

	$data = profile :: getUser($id); 
	


	if($data['id'] == $user['id']){ $you = true; }
		
	$title = "Фотографии";
	$thisLink .= $data['id'];
	$l = "Фотографии";
	  $lBack = profile :: getLink($user);
	$back = system :: back(profile :: getLink($data), "В профиль", true); #назад 
	require (CORE."head.php"); #Шапка
	echo "<div class=\"app-block\">";
	
	if(isset($you)){ echo "<div class=\"_oh\" style=\"background: #FFF;\"><a href=\"{$thisLink}/?act=create_album\" class=\"app-action\">".system :: ico('add')." ".language::text('photo', $language, 'photo')."</a></div>"; }
	
	?>
	<div class="list_">
		<?php
				
		$query = "SELECT * FROM `{$table_a}` WHERE `id_user` = ? ORDER by `time` DESC ";
	
		$total = $data['count_albums'];
		if($total > 10) {
			$p = (($_GET['p']) ? intval($_GET['p']) : 1);
			$pagination = new pagination(10, $total, $p);
			$query .= $pagination -> limit;
		}
		$q = DB :: $pdo -> query("{$query}", array($data['id']));

		$i = 0;
		$in = 0;
		
		echo "	<div class=\"_photos-main list\">	";
		while($r = $q -> fetch()) {
			++$i;

			?>
			<a href="<?=$thisLink."/album{$r['id']}?{$att['l']}"?>" class="_photos-item">
				<div class="_photos-item-padd">
				<div class="_photos-cont">
					<div class="_photos-ph">
						<div class="_photos-ph-t"><img src="<?=FILES_SERVER.system :: photosGetCover($r['id']); ?>" class="_photos-prew" style="border-radius: 5px">
						</div>
						<div>
							<div class="_font-s _photos-title"><?=$r['name']?></div>
							<div class="_font-m"><?="{$r['count']} фотографи".profile :: getPhrase($r['count'], array('я','ии','ий'))?></div>
						</div>
					</div>
				</div>
				</div>
			</a>
			<?php
	
		}
		if($i == 0){
			echo "<div class=\"list _center _gray _font-s\">Фотоальбомы отсутствуют.</div>";
		}
		echo "</div>";
		?>
			
	</div>
	<?php
	if($total > 10) { echo $pagination -> printPages($thisLink."?{$att['l']}&"); }
	
	echo $back;
	echo "</div>";
	require (CORE."foot.php");