<?php
mb_http_input("utf-8");
mb_http_output("utf-8");
?>
<?php 
	require_once('_approot.php');	
	$lso=$_GET['lso'];
	$id=$_GET['id'];

	switch ($lso)
	{
		case "default":	
		$folderPic=$defaultMotifFolders;
		$motifText="";
		$ls_msg="修改默认主题图";
		$motifTexttitle="默认主题图简介";
		break;


		case "pagemotif":	
		$folderPic=urldecode($_GET['folderPic']);
		$menuName=urldecode($_GET['menuName']);
		
		$ls_msg="修改".$menuName."主题图";
		$motifTexttitle=$menuName."说明";
		$menu_sql2="select * from ls_menu where menuName='".$menuName."' ";
		$menu_query2=$opendb->query($menu_sql2);
		$menu_rows2=mysqli_fetch_assoc($menu_query2);
		$motifText=htmlspecialchars_decode($menu_rows2['description'],ENT_QUOTES);
		
		break;
		
		default:
		$motif_sql="select * from ls_motif where ID=".$id."   ";
		$motif_query=$opendb->query($motif_sql);
		$motif_rows=mysqli_fetch_assoc($motif_query);
		$Pic=$motif_rows['motifPic'];
		$folderPic="../" .($MotifFolders=="motif"?$MotifFolders."/".$BigFoldersProducts:$MotifFolders)."/" .$Pic;
		$motifText=$motif_rows['motifText'];
		$ls_msg="修改主题图片操作";
		$motifTexttitle="主题图简介";
	}
?>
<!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">
		<link href="css/admin.css" rel="stylesheet" type="text/css">
          <link rel="stylesheet" href="css/style2.css" />
		<script language="JavaScript" src="js/ls.js"></script>
		<title>无标题文档</title>
		
	</head>

	<body>
		<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" >
			<tr>
				<td height="18" style="border-bottom:2px solid #00c0ef; padding-bottom:5px;" ><div align="center"> <font color="#3c8dbc" style="font-size:16px;">修改主题图片</font></div>
				</td>
			</tr>
			<tr>
				<td height="213" valign="top"  ><br>
				 <form name="myform" enctype="multipart/form-data" method="post" action="savemotif.php" >
					<input type="hidden" value="update" name="ls">
					<input type="hidden" value="<?php echo $lso;?>" name="lso">
					<input type="hidden" value="<?php echo $id;?>" name="id">
					<input type="hidden" value="<?php echo urlencode($menuName);?>" name="menuName">
					<input type="hidden" value="<?php echo $Pic;?>" name="Pic">
					<input type="hidden" value="<?php echo urlencode($folderPic);?>" name="folderPic">
					<input type="hidden" name="ChangecatePagePic" value="no">
	      <table border="0" width="96%" align="center">
						<tr>
							<td>提示：<font color="#FF0000"><?php echo $ls_msg; ?></font></td>
							<td align="right"><img src="images/shao.gif">&nbsp;<a href="<?=($lso=="pagemotif"?"ls_menu.php":"motif.php")?>">返回</a></td>
						</tr>
					</table>
					<table width="96%" border="0" align="center" cellpadding="3" cellspacing="0" bgcolor="#FFFFFF">
					  <tr bgcolor="#f4f4f4">
					    <td style="padding-left:15px;" >&nbsp;</td>
					    <td colspan="2" style="padding-left:15px;" >&nbsp;</td>
				      </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td width=12% style="padding-left:15px;" >图 </td>
						<td width=88% colspan="2" style="padding-left:15px;" ><div id="preview"><img src="<?php echo file_exists($folderPic)?$folderPic."?i=".rand():"images/noimagelong.png";?>" width="700" border="1" name="pic" style="float:left;" /></div>
<script type="text/javascript">  
function preview(file)
{
var prevDiv = document.getElementById('preview');
if (file.files && file.files[0])
{
var reader = new FileReader();
reader.onload = function(evt){
prevDiv.innerHTML = '<img src="' + evt.target.result + '" width="700" border="1" name="pic" style="float:left;" />';
}  
reader.readAsDataURL(file.files[0]);
}
else  
{
prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';
}
}
</script>
                        <div  style="padding-left:10px; padding-right:10px; float:left"  >
                        <p><?=$Pic!=""?getmotifnav($Pic):""?></p>
						<?php                        		if(file_exists($folderPic))
							{
								$picsize=getimagewh($folderPic);
								echo "宽：".$picsize[0]."  高：".$picsize[1];
								echo "<br/>图片文件：<br/>".$folderPic;
							}
						
						?>
                     	</div>
                        <br><br><br><br></td>
					  </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:15px;" >图片 *</td>
						<td style="padding-left:15px;"><input type="file" name="productPic" style="width:26%;" onBlur="document.pic.src=myform.productPic.value"; onChange="myform.ChangecatePagePic.value='yes';document.pic.src=myform.productPic.value;preview(this);">
					    <span style="padding-left:5px;"><?=$nmpic_tips?></span></td>
						<td style="padding-left:15px;">&nbsp;</td>
					  </tr>
                      <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:15px;" >图片名称 *</td>
						<td colspan="2" style="padding-left:15px;"><input type="text" name="motif_name" value="<?=$motif_rows['motifPic'] ?>" style="width: 700px;" readonly="readonly"/><input type="hidden" name="old_motif_name" value="<?=$motif_rows['motifPic'] ?>" style="width: 300px;" /></td>
					  </tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:15px;" >图片链接</td>
						<td colspan="2" style="padding-left:15px;"><input type="text" name="motif_href" value="<?=$motif_rows['motif_href'] ?>" style="width: 700px;"/></td>
						</tr>
					  <tr bgcolor="#f4f4f4"> 
						<td style="padding-left:15px;" width="12%"><?=$motifTexttitle?></td>
						<td colspan="2" style="padding-left:15px;">
                        <textarea name="motifText" style="width:700px; height:40px;" ><?php echo $motifText;?></textarea>
                       </td>
					  </tr>
					  <tr bgcolor="#f4f4f4">
					    <td height="49" colspan="3" align="center" style="padding-left:15px;"><button type="submit" value="保存">保存</button>
							<button type="button" value="刷新本页" onClick="JavaScript:history.go(0);">刷新本页</button></td>
				      </tr>
					  <tr  > 
						<td height="25" colspan="3" align="center"></td>
					  </tr>
					</table>
					<br />
                 </form>
				</td>
			</tr>
		</table>
	</body>
</html>