<{include file="file:admin_header.html"}>
<script type="text/javascript" src="../js/prototype.js">
</script>
<script type="text/javascript" charset="utf-8">
function do_file_rescan(mode, num){
	var url = '<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/maintenance_filesearch.php';
	var params = 'op=rescan' + '&' + 'mode=' + mode + '&' + 'num=' + num;
	var myAjax = new Ajax.Request(url, {
	    method: 'post',
	    parameters: params,
	    asynchronous: true,
	    requestHeaders: ['Referer', '<{$smarty.const.XOOPS_MODULE_URL}>/<{$dirname}>/admin/maintenance_filesearch.php'],
	    onComplete: oncomplete_file
	});
}

function oncomplete_file(request){
	if(request.responseText.isJSON()){
    	var json = eval('(' + request.responseText + ')');
    	var mode = json.mode;
    	var num = json.num;
    	update_file_count(mode, num);
	}else{
		alert('unexpected error occured.');
	}
}

function start_file_rescan(mode){
	var prefix = '#<{$dirname}>_admin_file_';
	var postfix = '_rescan_';
	var bt = jQuery(prefix + mode + postfix + 'button');
	var work = jQuery(prefix + mode + postfix + 'working');
	var field = jQuery(prefix + mode + postfix + 'field');
	work.show();
	bt.hide();
	field.text('');
}

function stop_file_rescan(mode){
	var prefix = '#<{$dirname}>_admin_file_';
	var postfix = '_rescan_';
	var bt = jQuery(prefix + mode + postfix + 'button');
	var work = jQuery(prefix + mode + postfix + 'working');
	work.hide();
	bt.show();
}

function update_file_count(mode, num){
	var prefix = '#<{$dirname}>_admin_file_';
	var postfix = '_rescan_';
	var field = jQuery(prefix + mode + postfix + 'field');
	if(num == 1) {
		field.append(' 1 ');
	}else if(num % 10 == 0){
		field.append(' ' + num + ' ');
	}else{
		field.append(' . ');
	}
	num = parseInt(num) + 1;
	if (num <= <{$file_count}>){
		do_file_rescan(mode,num);
	}else{
		stop_file_rescan(mode);    	
    }
}

function onclick_file_rescan(mode){
	if(<{$file_count}> > 0){
	    start_file_rescan(mode);
    	do_file_rescan(mode,1);
	}
}

</script>

<h4 style="margin-top: 20px; margin-bottom: 10px;">&raquo;&nbsp;<{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_PLUGINS_TITLE}></h4>
<table width="100%" cellspacing="1" class="outer">
  <tbody>
  <tr>
    <th style="width: 20%; text-align: left;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_PLUGIN}></th>
    <th style="width: 40%; text-align: left;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_MIMETYPE}></th>
    <th style="width: 30%; text-align: left;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_SUFFIX}></th>
    <th style="width: 10%; text-align: left;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_VERSION}></th>
  </tr>
  <{if $has_plugins == 'ture'}>
   <{foreach item=obj from=$plugins}>
   <tr class="<{cycle values='odd,even'}>"> 
    <td style="width: 20%; vertical-align: top; text-align: left;">
      <{$obj.plugin|xoops_escape}>
    </td>
    <td style="width: 40%; vertical-align: top; text-align: left;">
      <{$obj.mimetype|xoops_escape}>
    </td>
    <td style="width: 30%; vertical-align: top; text-align: left;">
      <{$obj.suffixes|xoops_escape}>
    </td>
    <td style="width: 10%; vertical-align: top; text-align: left;">
      <{$obj.version|xoops_escape}>
    </td>
  </tr>
  <{/foreach}>
 <{else}>
  <tr>
    <td class="odd" colspan="2" style="text-align: center;">
      <span style="color: red; font-weight: bold;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_PLUGINS_EMPTY}></span>
    </td>
  </tr>
  <{/if}>
  </tbody>
</table>
<h4 style="margin-top: 20px; margin-bottom: 10px;">&raquo;&nbsp;<{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_TITLE}></h4>
<table width="100%" cellspacing="1" class="outer">
  <tbody>
  <tr>
    <th colspan="2"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_LABEL_FILECOUNT}> : <{$file_count}></th>
  </tr>
  <tr>
    <td class="head" style="width: 40%;">
    <span style="font-weight: bold;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_INFO_TITLE}></span>
    <br /><br />
    <{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_INFO_DESC}>
    </td>
    <td style="width: 60%;">
    <div id="<{$dirname}>_admin_file_info_rescan_field"></div>
    <div id="<{$dirname}>_admin_file_info_rescan_working" style="font-weight: bold; color: red; text-decoration: blink; display: none;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_RESCANNING}></div>
    <button id="<{$dirname}>_admin_file_info_rescan_button" onclick="return onclick_file_rescan( 'info' );"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_RESCAN}></button>
    </td>
  </tr>
  <tr>
    <td class="head" style="width: 40%;">
    <span style="font-weight: bold;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_INDEX_TITLE}></span>
    <br /><br />
    <{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_RESCAN_INDEX_DESC}>
    </td>
    <td style="width: 60%;">
    <div id="<{$dirname}>_admin_file_index_rescan_field"></div>
    <div id="<{$dirname}>_admin_file_index_rescan_working" style="font-weight: bold; color: red; text-decoration: blink; display: none;"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_RESCANNING}></div>
    <button id="<{$dirname}>_admin_file_index_rescan_button" onclick="return onclick_file_rescan( 'index' );"><{$smarty.const._AM_XOONIPS_MAINTENANCE_FILESEARCH_LABEL_RESCAN}></button>
    </td>
  </tr>
  </tbody>
</table>
<{include file="file:admin_footer.html"}>