<?php if(!defined('IN_SYS'))exit();?>
<script language="JavaScript">
<?php foreach($this->_lang['common']['js_languages'] as $k=>$v){
echo 'var  '.$k . '=" '.$v.'";'."\n";
}?>
</script>
<link type="text/css" media="screen" rel="stylesheet"  href="images/colorbox/colorbox.css" />
<!--[if IE]>
<link type="text/css" media="screen" rel="stylesheet" href="images/colorbox/colorbox-ie.css" title="example" />
<![endif]-->
<script type="text/javascript" src="../js/jquery.colorbox.js"></script>
<script type="text/javascript" src="../js/jquery.form.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$("a[rel='jqcolorbox']").colorbox({width:750, height:550,slideshow:true,transition:"fade",slideshowAuto:false});
		$('.flv_review').colorbox({iframe:true, width:650, height:550});
		
	})
</script>
<style type="text/css">
div,li,ul,p,span,dl,dt,dd{ margin:0px; padding:0px; line-height:normal; font-size:12px;}
li{ list-style:none;}
h2{font-size:13px;}
.hidden{display:none;}
.clear{ display:block; clear:both; line-height:0px; height:0px;}
#upload_file_plugin{ margin:0px auto; padding:0px;}
#file_main_content{ margin:0px auto;}
.file_pic_list{height:150px; margin:5px; width:142px;overflow:hidden; float:left;}
.file_pic_list p{ height:20px; line-height:20px;text-align:center;}
.file_pic_list p a{}
.red{ color:#C00;}
.hoho{width:130px; height:120px; cursor:pointer; overflow:hidden; border:none;}
#upload_ok{ display: none; border:1px solid  #D2F0FF; margin:10px;padding:3px; line-height:180%; text-align: left; background-color:#F7FCFF;}

</style>
<?php
 if($this->_task =='default'){ 
?>
<script type="text/javascript">
function reset_ajax_sent(){}
function add_loading(obj_id){
$("#"+obj_id).html('<div style="margin:20px auto;text-align:center;border:10px;"><img src="./images/windows_loading.gif" /></div>');
}
<!--追加数据到编辑器里去-->

function addData(obj){
	$(file_children_obj).val(obj.name)
	$.closeLayer();
	$(".window-container").remove();
	$(file_children_obj).focus();
	return false;
}
function get_val(){
	var s = '';
	$("#file_selector").find('option').each(function(){
		if($(this).attr("selected")==true)s = $(this).val();
	})	
	return s ;
}
function empty (string){
	return $.trim(string)==''?true:false;
}
function refresh_page(){
	reset_ajax_sent();
	$.ajax({beforeSend:function(){
			add_loading('file_main_content');
		}
	})
	var sec = get_val();
	sec = empty(sec)?'default':sec;
	$.get('admincp.php?action=file&a=ajaxPic&type='+sec+'&rand='+Math.random(),function(data){
			$("#upload_ok").hide();
			$("#file_main_content").html(data);
	});	
}
$(document).ready(function(){
	<?php if(!empty($this->_ajax_url)){?>
		reset_ajax_sent();
		$.ajax({type:'get',beforeSend:function(){add_loading('file_main_content');},url:'<?php  echo $this->_ajax_url;?>',success:function(d){$("#file_main_content").html(d);}})
		<?php  } ?>
	$(this).click(function(e){
			if(e.which==3){<!--右键-->
				//return false;
			}
		});
		$("#upload_file_set_action").submit(function(){
			$(this).ajaxSubmit({
							   success:function(response){
									$("#file_loading").html('');var ee = response.split('|');var e = ee[0];var m = ee[1];
									switch(e){
										case '1':
										alert(m);return false;
										break;
										case '2':
										var end = m.split('+');var file = end[0];var size = end[1];var file_type = $.trim(end[2]);
										$("#upload_ok").show().html(file_upload_ok+'<br />'+file+'<br />'+file_size+size);
										uri = "admincp.php?action=file&a=ajaxPic&type="+file_type;
										$.get(uri,function(data){
											$("#file_main_content").html(data);
											$("#file_selector").find('option').each(function(){
												if($.trim($(this).val())==file_type){
													$(this).attr("selected",true);	
												}
											})
										});	
										return true;
										break;
										default:alert(response);return false;
								   }
							   }
							 });
			return false;
		})
});<!--end document ready-->

<!--选择数据-->
function selectData(obj){
	$(obj).find('option').each(function(){
		var a = $(this).attr('selected');
		if(a==true){
			reset_ajax_sent();
			$.ajax({beforeSend:function(){
					add_loading('file_main_content');
				}
			})
			$.get('admincp.php?action=file&a=ajaxPic&type='+$(this).val()+'&rand='+Math.random(),function(d){
				$("#file_main_content").html(d);
			});	
		}
	})
}
<!--删除文件-->
function deleteFile(obj){
	$.get('admincp.php?action=file&a=delete&fid='+encodeURIComponent($(obj).attr('name'))+'&rand='+Math.random(),function(data){
		if($.trim(data)=='ok'){
			$.get('admincp.php?action=file&a=ajaxPic&type='+$(obj).attr('type'),function(d){
					$("#file_main_content").html(d);
			})	
		}
	});
}

//close_open_helper('open_file_heper','file_helper_content');
</script>
<div id="upload_file_plugin">
<div class="notice_msg"  id="file_helper_content" style="display:none;">
<?php echo $this->_lang['file']['water_desc']; ?>
</div>
<br class="clear" />
<form  id="upload_file_set_action" method="post" action="admincp.php?action=file&a=ajaxUpload" autocomplete="off" enctype="multipart/form-data">
<div style="padding-top:5px;">
<li style="float:left;">
<!--
<div style="display:none">
<input type="checkbox"  style="display:none" value="true" id="create_thumb_id" name="create_thumb" /> <?php echo $this->_lang['file']['create_thumb']; ?>&nbsp;<input type="checkbox" value="true" name="create_watermark"  id="create_watermark_id"/> <?php echo $this->_lang['file']['add_watermark']; ?>&nbsp;<?php echo $this->_lang['file']['w_h']; ?>:<input style="width:20px;" type="text" name="c_h" value="0" id="c_h" /> <?php echo $this->_lang['file']['w_w']; ?>:<input  style="width:20px" type="text" value="0" name="c_w" id="c_w" /> 
</div>
-->
<input type="file"  name="upload_files_self" id="file_upload_plugin" />
<input type="submit" value="<?php echo $this->_lang['file']['water_save']; ?>" />
</li>
<li style="float:left; margin-top:-5px;">
<span class="block_button"  onclick="refresh_page();"><?php echo $this->_lang['common']['refresh_page']; ?></span>

<span class="block_button" style=" background-color:#FFF; cursor:default; color: #900;"><?php echo $this->_lang['file']['file_type_set'] ?></span>
 <span style="color:#F00"><?php echo $this->_lang['file']['file_limit_desc']; ?></span>

<span  class="block_button" id="open_file_heper" style="display:none;"><?php echo $this->_lang['php188_open_help']; ?></span>
</li>
</div>
</form>
<div style="height:2px; border-bottom:1px solid  #CCC; clear:both; display:block; margin-bottom:4px;"></div>
<br class="clear"/>
<span id="file_loading"></span> 
 <div style="border:1px solid #F1F1F1; height:30px; line-height:30px; color: #900; display:none;"><?php echo $this->_lang['file']['file_type_set'] ?> <span style="color:#F00"><?php echo $this->_lang['file']['file_limit_desc']; ?></span></div>
 <div id="upload_ok"></div>
      <br  class="clear"/>
<div><?php echo $this->_lang['file']['file_type'] ?>
<select id="file_selector" onchange="selectData(this);">
            	<option value="default" selected="selected"><?php echo $this->_lang['file']['old_file']; ?></option>
                <option value="thumb" <?php if($this->_type=='thumb'){echo 'selected="selected"';} ?>><?php echo $this->_lang['file']['pic_thumb'];?></option>
                 <option value="water" <?php if($this->_type=='water'){echo 'selected="selected"';} ?>><?php echo $this->_lang['file']['pic_water']; ?></option>
                 <option value="flash" <?php if($this->_type=='flash'){echo 'selected="selected"';} ?>><?php echo $this->_lang['file']['flash_file'] ?></option>
                 <option value="flv" <?php if($this->_type=='flv'){echo 'selected="selected"';} ?>><?php echo $this->_lang['file']['flv_file'] ?></option>
                 <option value="other" <?php if($this->_type=='other'){echo 'selected="selected"';} ?>>其他格式文件</option>
            </select>
            </div>
            <br  class="clear"/>

<div id="file_main_content">

</div>

<br  class="clear"/>
</div>
<?php 
}/*end task default*/
?>
<!--action -->

<?php 
/*end action*/
if($this->_task =='ajaxPic'){
	if(!empty($this->_data['data'])){
		if($this->_data['type']=='thumb' || $this->_data['type']=='water' || $this->_data['type']=='default'){
				foreach($this->_data['data'] as $k=>$file){
		?>
<div class="file_pic_list">
<a href="<?php  echo $file['part'];?>"  title="<?php echo $this->_lang['file']['file_name']; ?>:<?php echo $file['file_name'];?> 文件大小:<?php echo $file['file_size']; ?>"  style="display:block;width:130px; height:120px; overflow: hidden;">
<img src="<?php  echo $file['part'];?>" class="hoho file_img" onclick="addData(this);return false;" name="<?php  echo $file['part'];?>"/>
</a>
<p align="center">
<?php if($file['system']!='yes'){ ?>
<a href="javascript:void(0);" name="<?php  echo $file['fid'];?>" type="<?php echo $this->_data['type']; ?>"  onclick="deleteFile(this);"><?php echo $this->_lang['php188_delete']; ?></a>&nbsp; | <?php } ?> &nbsp;<a href="<?php  echo $file['part'];?>"  rel="jqcolorbox" ><?php echo $this->_lang['file']['preview']; ?></a></p>
        </div>
        <?php  
			}/*end foreach*/?>
            <br  class="clear"/>
            <?php if(!empty($this->_data['page'])){?>
            <div id="file_page"><?php echo $this->_data['page']; ?></div>
            <?php
			}/*end page check*/
			
			}elseif($this->_data['type']=='flash'){
				/*flash*/
				foreach($this->_data['data'] as $k=>$file){
		?>
<div  class="file_pic_list">
<div style="margin:0px; padding:0px;"><embed src="<?php echo $file['part'];?>" title="<?php echo $this->_lang['file']['file_name']; ?>:<?php echo $file['file_name'];?> <?php echo $this->_lang['file']['file_size']; ?>:<?php echo $file['file_size']; ?>" width="150" height="130" type="application/x-shockwave-flash"></embed></div>
<p align="center"><a href="javascript:void(0);" name="<?php  echo $file['fid'];?>  jqcolorbox" type="<?php echo $this->_data['type']; ?>" onclick="deleteFile(this);"><?php echo $this->_lang['php188_delete'] ?></a>&nbsp;&nbsp;
<a href="javascript:void(0);" name="<?php  echo $file['part'];?>"   onclick="addData(this);return false;"><?php echo $this->_lang['file']['add_item'];?></a></p>
        </div>
        <?php  
			}/*end foreach*/?>
            <br  class="clear"/>
            <?php if(!empty($this->_data['page'])){?>
            <div id="file_page"><?php echo $this->_data['page']; ?></div>
            <?php
			}/*end page check*/

			}elseif($this->_data['type']=='flv' || $this->_data['type']=='other'){
				//flash
				foreach($this->_data['data'] as $k=>$file){
		?>
<p style="text-align:left;"><b class="red"><?php echo $this->_lang['file']['file_name']; ?>:</b><?php echo $file['file_name'];?> &nbsp;<b class="red"><?php echo $this->_lang['file']['file_size']; ?>:</b><?php echo $file['file_size']; ?>&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" name="<?php  echo $file['fid'];?>" type="<?php echo $this->_data['type']; ?>" onclick="deleteFile(this);"><?php echo $this->_lang['php188_delete'] ?></a>&nbsp;<a href="javascript:void(0);" name="<?php  echo $file['part'];?>" onclick="addData(this);return false;"><?php echo $this->_lang['file']['add_item'];?></a>&nbsp; 
<?php  if($this->_data['type']!='other'){?><a class="flv_review" title="<?php echo $file['file_name'];?>"  href="admincp.php?action=file&a=view&file=<?php echo base64_encode($file['part']); ?>"><?php echo $this->_lang['file']['file_view']; ?></a> <?php  }//end if this->_data['type']是other?></p>
        <?php  
			}//end foreach?>
            <br  class="clear"/>
            <?php if(!empty($this->_data['page'])){?>
            <div id="file_page"><?php echo $this->_data['page']; ?></div>
            <?php
			}//end page check
			

			}else{
				//在这增加	
			}
		}else{
			?>
            <div style="margin:8px; padding:5px; line-height:180%;"><?php echo $this->_lang['php188_nodata']; ?></div>
       <?php
		}?>

<?php  }?>
<script type="text/javascript">
	$(document).ready(function(){
		page_function('file_page','file_main_content');
	})
</script>