<?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' );


// Get a new installer
$plg_installer = new JInstaller();

$plg_installer->install($this->parent->getPath('source').DS.'plg_system');
$db->setQuery("UPDATE #__plugins SET published=1 WHERE `element`='rsfiles' AND `folder`='system'");
$db->query();

$plg_installer->install($this->parent->getPath('source').DS.'plg_editor-xtd');
$db->setQuery("UPDATE #__plugins SET published=1 WHERE `element`='rsfiles' AND `folder`='editors-xtd'");
$db->query();


//check for the download directory
$db = JFactory::getDBO();
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
if(!is_dir(JPATH_ROOT.DS.'downloads'))
{ 
	JFolder::create(JPATH_ROOT.DS.'downloads');
}
	
	$db->setQuery("SELECT ConfigValue FROM #__rsfiles_config WHERE ConfigName = 'download_folder' ");
	$res = $db->loadResult();
	
	if(empty($res))
	{
		$db->setQuery("UPDATE #__rsfiles_config SET ConfigValue = '".$db->getEscaped(JPATH_ROOT.DS.'downloads')."' WHERE ConfigName = 'download_folder' ");
		$db->query();
	}

	$db->setQuery("DESCRIBE `#__rsfiles_files` ");
	$files_table = $db->loadObjectList();
	
	foreach ($files_table as $row)
	{
		if(!($row->Field == 'published'))
		{
			$db->setQuery("ALTER TABLE `#__rsfiles_files` ADD `published` INT( 2 ) NOT NULL DEFAULT '1'");
			$db->query();
		}
	}
	
?>
	
	<table class="adminlist">
	<thead>
		<tr>
			<th class="title" colspan="2"><?php echo JText::_('Extension'); ?></th>
			<th width="30%"><?php echo JText::_('Status'); ?></th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<td colspan="3"></td>
		</tr>
	</tfoot>
	<tbody>
		<tr class="row0">
			<td class="key" colspan="2"><?php echo 'RSFiles! '.JText::_('Component'); ?></td>
			<td><strong><?php echo JText::_('Installed'); ?></strong></td>
		</tr>
		<tr>
			<th><?php echo JText::_('Plugin'); ?></th>
			<th><?php echo JText::_('Group'); ?></th>
			<th></th>
		</tr>
		<tr class="row1">
			<td class="key">System - RSFiles! system plugin</td>
			<td class="key">system</td>
			<td><strong><?php echo JText::_('Installed'); ?></strong></td>
		</tr>
		<tr class="row0">
			<td class="key">Editors-xtd - RSFiles! button</td>
			<td class="key">editors-xtd</td>
			<td><strong><?php echo JText::_('Installed'); ?></strong></td>
		</tr>
	</tbody>
</table>
	
	<div align="left" width="100%">
 		<img src="../administrator/components/com_rsfiles/assets/images/imgs/rsfiles.jpg" alt="RSFiles! logo"/>
 	</div>
 	<br/>
	<table class="adminform">
		<tr>
			<td align="left">
			<strong>RSFiles! 1.0.0 Component for Joomla!</strong><br/>
			&copy; 2007-2009 by <a href="http://www.rsjoomla.com" target="_blank">http://www.rsjoomla.com</a><br/>
			All rights reserved.
			<br/><br/>
			This Joomla! Component has been released under GPL.<br/>
			<br/><br/>

			<b>Visit <a href="http://www.rsjoomla.com/" target="_blank">http://www.rsjoomla.com/</a> - for common issues, tech support, user manual, additional downloads and up to date knowledge base articles related to RSFiles!.</b><br/><br/>

			Thank you for using RSFiles!.
			<br/><br/>
			The rsjoomla.com team.
			<br/><br/>
			</td>
		</tr>
	</table><br/>
<br/><br/>
	<div align="left" width="100%"><b>RSFiles! 1.0.0 Installed</b></div>