<?php
/**
* @version 1.0.0
* @package RSFiles! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined('_JEXEC') or die('Restricted access');
?>
<script type="text/javascript">
function newFile()
{
	document.getElementById('screenshotsDiv').innerHTML += '<br/><input type="file" name="screenshots[]" size="40"/>';
}
</script>
<form action="index.php" method="post" name="adminForm" id="adminForm" enctype="multipart/form-data" >
<?php echo $this->tabs->startPane('content-pane'); ?>
<?php echo $this->tabs->startPanel(JText::_('RSFL_GENERAL_FILES'),"general-files"); ?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="adminform">
	<tr>
		<td width="200"><label for="FilePath"><?php echo JText::_('RSFL_FILE_PATH'). ':'; ?></label></td>
		<td colspan="2"><?php echo $this->data->FilePath; ?></td>
	</tr>
	<tr>
		<td width="200"><label for="FilePath"><?php echo JText::_('RSFL_PUBLISHED'). ':'; ?></label></td>
		<td colspan="2"><?php echo JHTML::_('select.booleanlist','published','class="inputbox"',isset($this->data->published) ? $this->data->published : 1); ?></td>
	<tr>
		<td width="200"><label for="FileName"><?php echo JText::_('RSFL_FILE_NAME'). ':'; ?></label></td>
		<td><input type="text" name="FileName" value="<?php echo $this->data->FileName; ?>" id="FileName" size="120" maxlength="255" /></td>
	</tr>
	<tr>
		<td width="200"><label for="DateAdded"><?php echo JText::_('RSFL_FILE_DATE'). ':'; ?></label></td>
		<td><?php echo JHTML::_('calendar', date('Y-m-d',$this->data->DateAdded), "DateAdded", "DateAdded"); ?></td>
	</tr>
	<?php if (is_file($this->data->FilePath)) { ?>
	<tr>
		<td width="200"><label for="FileStatistics"><?php echo JText::_('RSFL_FILE_STATISTICS'). ':'; ?></label></td>
		<td><?php echo JHTML::_('select.booleanlist','FileStatistics','class="inputbox"',$this->data->FileStatistics); ?></td>
	</tr>
	<tr>
		<td width="200"><label for="FileVersion"><?php echo JText::_('RSFL_FILE_VERSION'). ':'; ?></label></td>
		<td><input id="FileVersion" type="text" name="FileVersion" size="10" value="<?php echo $this->data->FileVersion; ?>" /></td>
	</tr>
	<tr>
		<td width="200"><label for="IdLicense"><?php echo JText::_('RSFL_FILE_LICENSE'). ':'; ?></label></td>
		<td><?php echo $this->lists['licenses']; ?></td>
	</tr>
	<tr>
		<td width="200"><label for="DownloadMethod"><?php echo JText::_('RSFL_DOWNLOAD_METHOD'). ':'; ?></label></td>
		<td><?php echo $this->lists['downloads']; ?></td>
	</tr>
	<?php } ?>
	<tr>
		<td width="200" valign="top"><label for="description"><?php echo JText::_('RSFL_FILE_DESCRIPTION'). ':'; ?></label></td>
		<td><?php echo $this->editor->display('FileDescription',$this->data->FileDescription,500,250,70,10); ?></td>
	</tr>
	<tr>
		<td width="200"><label for="thumb"><?php echo JText::_('RSFL_FILE_THUMB').':'; ?></label></td>
		<td>
		<?php if (!empty($this->data->FileThumb)) { ?>
		<p>
		<?php echo JHTML::_('image', JURI::root().'components/com_rsfiles/images/thumbs/files/'.$this->data->FileThumb, '','style="vertical-align: middle;"'); ?>
		<a href="index.php?option=com_rsfiles&task=deletethumb&controller=files&cid=<?php echo $this->data->IdFile; ?>"><?php echo JHTML::_('image', JURI::root().'administrator/components/com_rsfiles/assets/images/icons/delete.png', ''); ?></a>
		</p>
		<?php } else { ?>
		<input type="file" name="thumb" value="" id="thumb" size="100" />
		<?php } ?>
		</td>
	</tr>
</table>

<?php echo $this->tabs->endPanel(); ?>

<?php echo $this->tabs->startPanel(JText::_('RSFL_PERMISSIONS_FILES'),"permissions-files"); ?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" class="adminform">
	<tr>
		<td width="200"><label for="CanPerformMaintnanace"><?php echo JText::_('RSFL_FILE_MAINTAINANCE'). ':'; ?></label></td>
		<td><?php echo $this->lists['canedit']; ?> <?php if(is_dir($this->data->FilePath)) { ?> <input name="ExtendMaintnance" type="checkbox" value="1" />  <?php echo JText::_('RSFL_EXTEND_PERMISSIONS'); } ?> </td>
	</tr>
	<tr>
		<td width="200"><label for="CanView"><?php echo JText::_('RSFL_FILE_CANVIEW'). ':'; ?></label></td>
		<td><?php echo $this->lists['canview']; ?> <?php if(is_dir($this->data->FilePath)) { ?> <input name="ExtendView" type="checkbox" value="1" />  <?php echo JText::_('RSFL_EXTEND_PERMISSIONS'); } ?> </td>
	</tr>
	<tr>
		<td width="200"><label for="CanDownload"><?php echo JText::_('RSFL_FILE_CANDOWNLOAD'). ':'; ?></label></td>
		<td><?php echo $this->lists['candownload']; ?> <?php if(is_dir($this->data->FilePath)) { ?> <input name="ExtendDownload" type="checkbox" value="1" />  <?php echo JText::_('RSFL_EXTEND_PERMISSIONS'); } ?> </td>
	</tr>
</table>
<?php echo $this->tabs->endPanel(); ?>

<?php if(is_file($this->data->FilePath)) { ?>
<?php echo $this->tabs->startPanel(JText::_('RSFL_MIRROR_FILES'),"mirror-files"); ?>
	<table class="adminform">
		<tr>
			<td>
			<div class="button2-left">
				<div class="blank">
					<a id="valuesChange" href="index.php?option=com_rsfiles&task=editmirror&tmpl=component&IdFile=<?php echo $this->data->IdFile; ?>" class="modal"><?php echo JText::_('RSFL_ADD_MIRROR'); ?></a>
				</div>
			</div>
			</td>
		</tr>
	</table>

	<div id="editcell1">
		<table class="adminlist">
			<thead>
			<tr>
				<th width="10">#</th>
				<th width="35%"><?php echo JText::_('RSFL_MIRROR_NAME'); ?></th>
				<th><?php echo JText::_('RSFL_MIRROR_URL'); ?></th>
				<th width="20"><?php echo JText::_('RSFL_MIRROR_DELETE'); ?></th>
			</tr>
			</thead>
	<?php
	foreach ($this->mirrors as $row)
	{ 
	?>
		<tr>
			<td><?php echo $row->IdMirror; ?></td>
			<td><a class="modal" rel="{size: {x: 700, y: 170}}" href="index.php?option=com_rsfiles&task=editmirror&tmpl=component&cid=<?php echo $row->IdMirror; ?>"><?php echo empty($row->MirrorName) ? JText::_('RSFL_NO_MIRROR') : $row->MirrorName ; ?></a></td>
			<td><a class="modal" rel="{ size: {x: 700, y: 170}}" href="index.php?option=com_rsfiles&task=editmirror&tmpl=component&cid=<?php echo $row->IdMirror; ?>"><?php echo $row->MirrorURL; ?></a></td>
			<td align="center"><a href="index.php?option=com_rsfiles&task=deletemirror&controller=files&cid=<?php echo $row->IdMirror; ?>&IdFile=<?php echo $this->data->FilePath; ?>"><img src="<?php echo JURI::root(); ?>administrator/components/com_rsfiles/assets/images/icons/delete.png" /></a></td>
		</tr>
	<?php
	}
	?>
		</table>
	</div>

<?php
//keep session alive while editing
JHTML::_('behavior.keepalive');
?>	
	
<?php echo $this->tabs->endPanel(); ?>

<?php echo $this->tabs->startPanel(JText::_('RSFL_SCREENSHOTS_FILES'),"screenshots-files"); ?>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
	<tr>
		<td valign="top">
			<table  class="adminform">
				<tr>
					<td>
						<label for="input1">
							<?php echo JText::_( 'RSFL_ADD_SCREENSHOTS' ).':'; ?>
						</label>
					</td>
					<td>
						<div id="screenshotsDiv">
						<input type="file" name="screenshots[]" size="40"/> <input type="button" onclick="javascript: submitbutton('apply')" value="Upload" />
						</div>
						<br/><a href="javascript:void();" onclick="newFile();return false;"><?php echo JText::_('RSFL_ADD_FILE_AGAIN');?></a>
					</td>
				</tr>
			</table>
<?php if(!empty($this->screenshots)) { ?>
			<div id="editcell1">
				<table class="adminlist">
					<thead>
						<tr>
							<th width="5">#</th>
							<th>
								<?php
									echo JText::_( 'RSFL_SCREENSHOT_NAME' ); 
								?>
							</th>
							<th width="100">
								<?php
									echo JText::_( 'RSFL_SCREENSHOT_DELETE' ); 
								?>
							</th>
						</tr>
					</thead>
					<tbody>
			<?php
			foreach($this->screenshots as $i => $screenshot)
			{
			?>
					<tr class="<?php echo "row$i"; ?>">
						<td><?php echo $screenshot->IdScreenshot; ?></td>
						<td><a href="<?php echo JURI::root(); ?>components/com_rsfiles/images/screenshots/<?php echo $screenshot->Path; ?>" target="_blank"><?php echo $screenshot->Path; ?></a></td>
						<td align="center"><a href="index.php?option=com_rsfiles&task=deletescreenshot&controller=files&cid=<?php echo $screenshot->IdScreenshot; ?>&IdFile=<?php echo $this->data->FilePath; ?>"><img src="<?php echo JURI::root().'administrator/components/com_rsfiles/assets/images/icons/delete.png'; ?>" title="Delete" alt="Delete file"></a></td>
					</tr>
			<?php
			}
			?>
					</tbody>
						</table>
		</div>	
<?php } ?>			
		</td>
	</tr>
</table>
<?php echo $this->tabs->endPanel(); ?>
<?php } ?>
<?php echo $this->tabs->endPane(); ?>

<?php echo JHTML::_( 'form.token' ); ?>
<input type="hidden" name="option" value="com_rsfiles" />
<input type="hidden" name="IdFile" value="<?php echo $this->data->IdFile; ?>" />
<input type="hidden" name="FilePath" value="<?php echo $this->data->FilePath; ?>" />
<input type="hidden" name="controller" value="files" />
<input type="hidden" name="view" value="files" />
<input type="hidden" name="task" value="editfile" />
</form>