<?php
if (!defined('_GNUBOARD_')) exit; // 개별 페이지 접근 불가

if (!$g5['amina_ajax'] && !defined('LAL_BASIC')) {
	define('LAL_BASIC', true);
	echo '<link rel="stylesheet" href="'.$latest_list_url.'/latest.list.css">'."\n";
}

$set = array();
$dList = array(); //Details Item
$bList = array(); //Btn Item
$print = array(); //Print Item

//Setting
$key = array("list", "list_type", "list_size", "list_row", "subj", "subj_cmt", "subj_cate", "subj_icon", "subj_type", "cont", "details", "btn", "date", "star", "star_type", "icon", "rank_icon", "attach_icon", "img_icon", "img_rank_icon", "img_h", "img_full", "img_hover", "thumb", "no_img", "linked_img", "photo_img", "more", "print");

$key_cnt = count($key);
for($i=0; $i < $key_cnt; $i++) {
	$kn = $key[$i];
	if(!$opt[$kn]) continue;
	$set[$kn] = explode(",", $opt[$kn]);
}

//Count
$area_num = count($set['list']);
$area_num = ($area_num > 1) ? $area_num : 1; //최소 1개는 출력함
$list_num = count($list);

//ID
$chars_array = range('a','z');
shuffle($chars_array);
$list_id = implode('', $chars_array);

$css = '';
for($s=0; $s < $area_num; $s++) {
	$set['list_size'][$s] = $set['list_size'][$s] ? $set['list_size'][$s] : '100%';
	$css .= '.'.$list_id.$s.' { width:'.$set['list_size'][$s].'; }'."\n";
	if($set['list_type'][$s] == 'img') {
		$set['img_h'][$s] = $set['img_h'][$s] ? $set['img_h'][$s] : '56.25%'; 
		$css .= '.'.$list_id.$s.' .la-img { padding-bottom:'.$set['img_h'][$s].'; }'."\n";
	} 
}

//fancyBox
$fbox_w = $fbox_q = '';
if($opt['fbox']) {
	if($opt['fbox'] == 'full') {
		$fbox_w = 'class="fbox-full" ';
	} else {
		$fbox_w = 'class="fbox-win" ';
		$fbox_q = '&frame=2';

		if($opt['fbox'] > 1) {
			$fbox_w .= 'data-fbox-width="'.$opt['fbox'].'" ';
			$fbox_q .= '&fwidth='.$opt['fbox'];
		}
	}
} 

$row_start = 0;

$tooltip = $opt['tooltip'] ? ' tooltip-'.$list_id : '';

?>
<style>
	<?php echo $css;?>
</style>
<div class="lal-basic">
	<?php for ($s=0; $s < $area_num; $s++) { ?>
		<div class="la-area <?php echo $list_id.$s;?>">
		<?php 
			$row_end = $set['list_row'][$s] ? $set['list_row'][$s] : $list_num;
			$row_end = $row_start + $row_end;
			$row_end = ($row_end > $list_num) ? $list_num : $row_end;

			switch($set['list_type'][$s]) {
				case 'img'	 : include($latest_list_path.'/latest.row.img.php'); break;	
				default		 : include($latest_list_path.'/latest.row.list.php'); break;
			}

			$row_start = $row_end;
			unset($fa);
			unset($dList);
		?>
		</div>
	<?php } ?>
	<?php if($list_num == 0) { ?>
		<div class="la-none">게시물이 없습니다.</div>
	<?php } ?>
	<div class="clear"></div>
</div>
<?php if($opt['tooltip']) { 
	list($e_theme, $e_time, $e_ani) = explode(";", $opt['tooltip']);
	$theme = array('light', 'noir', 'punk', 'noir', 'shadow'); //툴팁테마 
?>
	<script>
	$(document).ready(function() {
		$('.<?php echo trim($tooltip);?>').tooltipster({
		   <?php if(in_array($e_theme, $theme)) { ?>
			   theme: 'tooltipster-<?php echo $e_theme;?>',
		   <?php } ?>
		   <?php if($e_ani) { ?>
			   animation: '<?php echo $e_ani;?>',
		   <?php } ?>
		   <?php if($e_time) { ?>
			   speed: <?php echo $e_time;?>,
		   <?php } ?>
		   delay: 100,
		   contentAsHTML: true
	   });
	});
	</script>
<?php } ?>