<?php
/*
 * 注意：此文件由tpl_engine编译型模板引擎编译生成。
 * 如果您的模板要进行修改，请修改 templates/default/modules/album/photo_view.html
 * 如果您的模型要进行修改，请修改 models/modules/album/photo_view.php
 *
 * 修改完成之后需要您进入后台重新编译，才会重新生成。
 * 如果您开启了debug模式运行，那么您可以省去上面这一步，但是debug模式每次都会判断程序是否更新，debug模式只适合开发调试。
 * 如果您正式运行此程序时，请切换到service模式运行！
 * 
 * 如有您有问题请到官方论坛（http://tech.jooyea.com/bbs/）提问，谢谢您的支持。
 */
?><?php
	//引入语言包
	$a_langpackage=new albumlp;
	$mn_langpackage=new menulp;
	
	require("foundation/module_users.php");
	require("foundation/module_restore.php");
	
	//变量取得
	$photo_id = short_check(get_argg('photo_id'));
	$album_id=short_check(get_argg('album_id'));
	$img_num = short_check(get_argg('img_num'));
	$photo_id_array = get_session($album_id.'S_photo_id_array');
	$num = get_session($album_id.'S_num');
	$url_uid= short_check(get_argg('user_id'));
	$ses_uid=get_sess_userid();
	
	//引入模块公共权限过程文件
	$is_login_mode='';
	$is_self_mode='partLimit';
	require("foundation/auser_validate.php");
	require("foundation/module_mypals.php");
	
	//数据表定义区
	$t_photo = $tablePreStr."photo";
	$t_photo_comment = $tablePreStr."photo_comment";
	$t_holerpals = $tablePreStr."pals_mine";
	$t_users=$tablePreStr."users";
	$t_album=$tablePreStr."album";
	$dbo = new dbex;

	//读写分离定义函数
	dbtarget('r',$dbServs);
	$album_info=array();
	$sql="select album_name from $t_album where album_id=$album_id";
	$album_info=$dbo->getRow($sql);
	$album_name=$album_info['album_name'];
	$holder_pals=getHodlerpals($dbo,$t_holerpals,$url_uid);
	$p=strstr($holder_pals,",".$ses_uid.",");

	if(!get_session($album_id.'S_photo_id_array') or !get_session($album_id.'S_num')){
		$sql="select * from $t_photo where album_id='$album_id' order by add_time desc";
		$photo_rs = $dbo->getRs($sql);
		$num=$dbo->rowCount;
		set_session($album_id.'S_num',$num);
		$i=0;
		foreach($photo_rs as $val){
			$photo_id_array[$i]=$val['photo_id'];
			$i++;
		}
		set_session($album_id.'S_photo_id_array',$photo_id_array);
	}
	if($img_num==""){
		$img_num=@array_search($photo_id,$photo_id_array);
	}
	//翻页
	if($img_num == $num){$img_num=0;}
	if($img_num == -1){$img_num = $num-1;}
	$photo_id=$photo_id_array[$img_num];
	
	//数据显示控制
	$photo_lock="content_none";
	$show_data="";
	$show_error="content_none";
	$show_content="content_none";
	
	if($photo_id==""){
		$show_data="content_none";
		$show_error="";
	}else{
		$sql = "select * from $t_photo where photo_id=$photo_id";
		$photo_row = $dbo ->getRow($sql);
	}
	$is_admin=get_sess_admin();
	if($is_admin==''){
		if($photo_row['photo_pass']==0){
			$show_data="content_none";
			$photo_lock="";
		}
	}
	if(empty($photo_row)){
		$show_data="content_none";
		$show_error="";
		$photo_lock="content_none";
	}else{
		$img_info=getimagesize($photo_row['photo_src']);
	}
	
	if($photo_row['album_secret']==2 and $photo_row['user_id']!=$ses_uid){
		$show_data="content_none";
		$show_content="";
		$photo_lock="content_none";
	}else if($photo_row['album_secret']==1 and $photo_row['user_id']!=$ses_uid){
		if(!$p||empty($ses_uid)){
			$show_data="content_none";
			$show_content="";
			$photo_lock="content_none";
		}
	}
	$host_id=$photo_row['user_id'];
	if(empty($photo_row['photo_information'])){
		$photo_inf = $a_langpackage->a_pht_inf;
	}else{
		$photo_inf = $photo_row['photo_information'];
	}
	if($is_self=='Y'){
		$a_who=$a_langpackage->a_mine;
		$button="";
	}else{
		$user_name=get_hodler_name($dbo,$t_users,$url_uid);
		$a_who=str_replace('{holder}',filt_word($user_name),$a_langpackage->a_holder)."</div>";
		$button="content_none";
	}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/row_menus.css">
<link rel="stylesheet" type="text/css" href="skin/<?php echo $skinUrl;?>/css/iframe.css">
<SCRIPT language=JavaScript src="servtools/ajax_client/ajax.js"></SCRIPT>
<script type='text/javascript' src="skin/default/js/jooyea.js"></script>
<script type="text/javascript">
function xmlchange(){
	 if(xmlhttp.readyState==4&&xmlhttp.status==200){
	 	var return_text=xmlhttp.responseText;
		var return_text=return_text.replace(/[\s\n\r]/g,"");
	 	if(return_text==""){
	 	$("def_photo_info").innerHTML="<?php echo $a_langpackage->a_pht_inf;?>";}
	 	else{$("def_photo_info").innerHTML=return_text;}
	 	$("def_photo_info").style.display="";
	  $("photo_info").style.display="none";
	 }
}
function change_photo(){
	var photo_id=$("photo_id").value;
	var photo_information_value=$("information_value").value;
	 xmlhttp=InitAjax();
	 xmlhttp.open("POST","do.php?act=photo_im&photo_id=<?php echo $photo_id;?>&album_id=<?php echo $album_id;?>",true);
	 xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	 xmlhttp.onreadystatechange=xmlchange;
	 xmlhttp.send("photo_id="+photo_id+"&information_value="+photo_information_value);
}

function change_state(){
	var return_text=$("def_photo_info").innerHTML;
	var return_text=return_text.replace(/[\s\n\r]/g,"");
	if(return_text=="<?php echo $a_langpackage->a_pht_inf;?>"){
		var information="";
	}else{
		var information=return_text;
	}
	$("information_value").value=information;
	$("def_photo_info").style.display="none";
	$("photo_info").style.display="";
}

function chancel(){
	$("def_photo_info").style.display="";
	$("photo_info").style.display="none";
}

</script>
</head>
<body>
  <div class="main_right_title">
     <span class="main_title_dot2"></span>
     <span class="main_title_txt"><?php echo $a_who;?></span>
  </div>
	<div id="tabsB" class="<?php echo $button;?>">
	  <ul>
	    <li class="nowbutl"><a href="?app=album_list" title="<?php echo $a_langpackage->a_mine;?>" class="nowbutl"><span class="nowbutr"><?php echo $a_langpackage->a_mine;?></span></a></li>
	    <li><a href="?app=album_friend" title="<?php echo $a_langpackage->a_friend;?>"><span><?php echo $a_langpackage->a_friend;?></span></a></li>
	  </ul>
	    <div class="div_but" onclick="location.href='?app=album_creat'"><?php echo $a_langpackage->a_creat;?></div>
	    <div class="div_but_3" onclick="location.href='?app=photo_upload&album_id=<?php echo $album_id;?>'"><?php echo $a_langpackage->a_upload;?></div>
	</div>
<?php if($photo_row){?>
	<div class="iframe_contentbox">
		<div class="photo_showbox">
			<div class="sub_box">
				<div class="photo_name"><?php echo filt_word($photo_row['photo_name']);?><span>《<?php echo filt_word($album_name);?>》</span></div>
				<div class="photo_uploadtime"><?php echo str_replace("{date}",$photo_row['add_time'],$a_langpackage->a_send_time);?></div>
				<div class="photo_view">
					<a class="photo_pageup" href='?app=photo_view&photo_id=<?php echo $photo_id;?>&album_id=<?php echo $album_id;?>&img_num=<?php echo $img_num-1;?>&user_id=<?php echo $url_uid;?>' title="<?php echo $a_langpackage->a_page_up;?>"></a>
					<img id='show_pic' style='display:none;max-width:460' onerror="parent.pic_error(this)" />
					<img id='show_ajax' src='skin/<?php echo $skinUrl;?>/images/loading.gif' />
					<a class="photo_pagedown" href='?app=photo_view&photo_id=<?php echo $photo_id;?>&album_id=<?php echo $album_id;?>&img_num=<?php echo $img_num+1;?>&user_id=<?php echo $url_uid;?>' title="<?php echo $a_langpackage->a_page_down;?>>"></a>
				</div>

				<?php if($photo_row['user_id']==$ses_uid){?>
				<div class='photo_intro'>
					<input type='hidden' name='photo_id' id='photo_id' value=<?php echo $photo_id;?> />
					<div id='def_photo_info' onmouseover="this.style.backgroundColor='#ffffce';this.style.borderColor='#efcf7b';" onmouseout="this.style.backgroundColor='#fffbff';this.style.borderColor='#ececec';" onclick="change_state();"><?php echo filt_word($photo_inf);?></div>
					<div id='photo_info' style='display:none;text-align:center;'>
						<textarea cols='40' rows='2' name='information_value' id='information_value'></textarea><br />
						<input type='button' value='<?php echo $a_langpackage->a_b_con;?>' class='top_button' onclick='change_photo()' />
						<input type='button' value='<?php echo $a_langpackage->a_b_del;?>' class='top_button' onclick='chancel()' />
					</div>
				</div>
				<div class="photo_operate">
					<a href='do.php?act=album_skin&photo_id=<?php echo $photo_row['photo_id'];?>&album_id=<?php echo $album_id;?>'><?php echo $a_langpackage->a_set_cov;?></a>
					<a href="javascript:void(0);" onclick="change_state();"><?php echo $a_langpackage->a_set_info;?></a>
					<a href='do.php?act=photo_del&photo_id=<?php echo $photo_row['photo_id'];?>&album_id=<?php echo $album_id;?>' onclick="return confirm('<?php echo $a_langpackage->a_del_asc;?>');"><?php echo $a_langpackage->a_com_del;?></a>
					<a href="<?php echo $photo_row['photo_src'];?>" target="_blank"><?php echo $a_langpackage->a_see_pic;?></a>
					<a href="?app=photo_list&album_id=<?php echo $album_id;?>&user_id=<?php echo $url_uid;?>"><?php echo $a_langpackage->a_bak_list;?></a>					
				</div>
				<?php }?>
			</div>
		</div>
		<div class="photo_operate">
			<?php if($photo_row['user_id']!=$ses_uid){?>
			<div id='def_photo_info'><?php echo filt_word($photo_inf);?></div>
				<?php if($ses_uid){?>
				<a href="javascript:void(0);" onclick="parent.show_share(3,<?php echo $photo_row['photo_id'];?>,'<?php echo $photo_row['photo_information'];?>','','');"><?php echo $mn_langpackage->mn_share;?></a>
				<a href="javascript:void(0);" onclick="parent.report(3,<?php echo $photo_row['user_id'];?>,<?php echo $photo_row['photo_id'];?>);"><?php echo $mn_langpackage->mn_report;?></a>
				<?php }?>
			<a href="<?php echo $photo_row['photo_src'];?>" target="_blank"><?php echo $a_langpackage->a_see_pic;?></a>
			<a href="?app=photo_list&album_id=<?php echo $album_id;?>&user_id=<?php echo $url_uid;?>"><?php echo $a_langpackage->a_bak_list;?></a>			
			<?php }?>
		</div>
	</div>

	<div class="tleft ml20">
		<div class="replytip"></div>
		<div id='show_3_<?php echo $photo_row["photo_id"];?>'>
			<?php echo get_restore($dbo,3,$photo_row["photo_id"],0,20);?>
		</div>
		<?php if($ses_uid!=''){?>	
		<div class="reply" <?php echo $show_content;?>>
			<img src='<?php echo get_sess_userico();?>' />
			<textarea style="height:50px" maxlength="160" onkeyup="return isMaxLen(this)" id="reply_3_<?php echo $photo_row['photo_id'];?>_input"></textarea>
			<div class="replybt">
				<input class="left button2" onclick="parent.restore_com(<?php echo $photo_row['user_id'];?>,3,<?php echo $photo_row['photo_id'];?>);" type="submit" name="button" id="button" value="<?php echo $a_langpackage->a_b_com;?>" />
				<a class="right" href="javascript: void(0);" onclick="showim(''); showFace(this,'face_list_menu','reply_3_<?php echo $photo_row['photo_id'];?>_input');"><?php echo $a_langpackage->a_face;?></a>
			</div>
			<div class="clear"></div>
		</div>
		<?php }?>
	</div>
<?php }?>
	<!-- face begin -->
	<div id="face_list_menu" class="emBg" style="display:none;z-index:100;">
	</div>
	<!-- face end -->
<!--锁定控制-->
<div class="pageerr <?php echo $photo_lock;?>"><?php echo $a_langpackage->a_lock_photo;?></div>
<div class="pageerr <?php echo $show_error;?>"><?php echo $a_langpackage->a_ine;?></div>
<div class="pageerr <?php echo $show_content;?>"><?php echo $a_langpackage->a_add_pvw;?></div>

<?php if($photo_row){?>
	<script type='text/javascript'>
		var img_obj=$('show_pic');
		var ajax_obj=$('show_ajax');
		var show_img=new Image;
		show_img.src='<?php echo $photo_row["photo_src"];?>';
		var time_id=window.setTimeout("test_img_complete()",200);
		
		function test_img_complete(){
			if(show_img.complete==true){
				img_obj.src='<?php echo $photo_row["photo_src"];?>';
				if(<?php echo $img_info[0];?>>460){
					img_obj.width=460;
				}else{
					img_obj.width=<?php echo $img_info[0];?>;
				}
				img_obj.style.display='';
				ajax_obj.style.display='none';
				window.clearTimeout(time_id);
			}else{
				var time_id=window.setTimeout("test_img_complete()",200);
			}
		}
	</script>
<?php }?>
</body>
</html>