<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category   Varien
 * @package    Varien_Object
 * @copyright  Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
 * @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php echo $this->template('install/header.phtml') ?>

<div class="page-head">
    <h3>Welcome to Magento's Installation Wizard!</h3>
</div>

<fieldset>
<?php if (!$this->controller()->isDownloaded()): ?>
    <p>You are now ready to continue the installation process by downloading the most up-to-date copy of the Magento software.</p>
    <form id="install_all" method="post" action="<?php echo $this->url('pearInstallAll') ?>" target="pear_iframe" onsubmit="return installAll()">
        <fieldset>
<?php else: ?>
    <p>There's an indication that Magento files already have been downloaded.</p>
    <p>If you feel that you have arrived to this page by mistake, please continue installation:</p>
    <button class="form-button" type="button" onclick="location.href='<?php echo $this->mageUrl() ?>'"><span>Continue Magento installation</span></button>
    <br/><br/><br/>
    <p>Alternatively, you could proceed with Re-Downloading all packages</p>
    <form id="reinstall_all" method="post" action="<?php echo $this->url('pearInstallAll') ?>&force=1" target="pear_iframe" onsubmit="return installAll(true)">
        <fieldset>
<?php endif; ?>

        <table cellspacing="0" class="form-list">
            <tr>
                <td class="label">Use custom permissions:</td>
                <td class="value">
                    <select onchange="useCustomPermissions(this)" id="use_custom_permissions_mode" name="use_custom_permissions_mode" style="width:150px;">
                        <option value="1" <?php if ($this->get('use_custom_permissions_mode')=='1'):?>selected="selected"<?php endif ?>>Yes</option>
                        <option value="0" <?php if ($this->get('use_custom_permissions_mode')=='0'):?>selected="selected"<?php endif ?>>No</option>
                    </select>
                </td>
            </tr>
        </table>
        <table cellspacing="0" class="form-list" id="use_custom_permissions_mode_panel" <?php if ($this->get('use_custom_permissions_mode')=='0'):?>style="display:none;"<?php endif ?>>
            <tr>
                <td class="label">Folders:</td>
                <td class="value">
                    <input id="mkdir_mode" name="mkdir_mode" value="<?php echo($this->get('mkdir_mode'));?>" style="width:50px;" type="text"></input>
                </td>
            </tr>
            <tr>
                <td class="label">Files:</td>
                <td class="value">
                    <input id="chmod_file_mode" name="chmod_file_mode" value="<?php echo($this->get('chmod_file_mode'));?>" style="width:50px;" type="text"></input>
                </td>
            </tr>
            <tr>
                <td class="label">Executable files:</td>
                <td class="value">
                    <input id="chmod_file_mode_executable" name="chmod_file_mode_executable" value="<?php echo($this->get('chmod_file_mode_executable'));?>" style="width:50px;" type="text"></input>
                </td>
            </tr>
        </table>

<?php if (!$this->controller()->isDownloaded()): ?>
            <button class="form-button" type="submit">Start the download process</button>
        </fielset>
    </form>
<?php else: ?>
            <button class="form-button" type="submit">Re-Download All Magento Core Packages</button>
        </fieldset>
    </form>
<?php endif; ?>
</fieldset>

<br/>
<?php echo $this->template('pear/iframe.phtml') ?>

<a name="pear_iframe_result"></a>
<div id="pear_iframe_success" style="display:none">
    <?php $this->set('messages', array('success'=>array(
       'Download completed. You can proceed with installation',
    ))) ?>
    <?php echo $this->template('messages.phtml') ?>

    <button class="form-button" type="button" onclick="location.href='<?php echo $this->mageUrl() ?>'"><span>Continue Magento installation</span></button>
</div>

<div id="pear_iframe_failure" style="display:none">
    <?php $this->set('messages', array('error'=>array('There was a problem during downloading of Magento packages. Please check the output frame for errors information and refresh the page to retry again.'))) ?>
    <?php echo $this->template('messages.phtml') ?>
    <button class="form-button" type="button" onclick="location.reload()"><span>Refresh</span></button>
</div>

<script>
function useCustomPermissions (element)
{
    if (element.value == '1') {
        disabledMode = 'block';
    } else {
        disabledMode = 'none';
    }
    document.getElementById('use_custom_permissions_mode_panel').style.display = disabledMode;
}
</script>

<script type="text/javascript">
function installAll(force)
{
    if (force) {
        if (!confirm("This will delete all files from core packages.\n\nAre you sure you wish to force re-install all Magento files?")) {
            return false;
        }
    }

    return onSubmit();
}
</script>

<?php echo $this->template('install/footer.phtml') ?>