<?php
if (!defined('IN_CONTEXT')) die('access violation error!');
?>
<div class="content_title">
	<h3><?php _e($download_title); ?></h3>
</div>
<div class="space"></div>
<div class="content_toolbar">
	<a href="index.php?<?php echo Html::xuriquery('mod_download', 'admin_list'); ?>" title=""><?php _e('Back'); ?></a>
</div>
<div class="space"></div>
<div class="status_bar">
<?php if (Notice::get('mod_download/msg')) { ?>
	<span id="admindownfrm_stat" class="status"><?php echo Notice::get('mod_download/msg'); ?></span>
<?php } ?>
</div>
<div class="space"></div>
<?php
$download_form = new Form('index.php', 'downloadform', 'check_download_info');
$download_form->setEncType('multipart/form-data');
$download_form->p_open('mod_download', $next_action);
?>
<table id="downloadform_table" class="form_table" cellspacing="1">
    <tfoot>
        <tr>
            <td colspan="2">
            <?php
            echo Html::input('reset', 'reset', __('Reset'));
            echo Html::input('button', 'cancel', __('Cancel'), 'onclick="window.history.go(-1);"');
            echo Html::input('submit', 'submit', __('Save'));
            echo Html::input('hidden', 'download[id]', $curr_download->id);
            ?>
            </td>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td class="label"><?php _e('Language'); ?></td>
            <td class="entry">
            <?php
            echo Toolkit::switchText($curr_download->s_locale?$curr_download->s_locale:$mod_locale, 
                Toolkit::toSelectArray($langs, 'locale', 'name'));
            echo Html::input('hidden', 'download[s_locale]', 
           		$curr_download->s_locale?$curr_download->s_locale:$mod_locale);
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('Category'); ?></td>
            <td class="entry">
            <?php
            echo Html::select('download[download_category_id]', 
                $select_categories, 
                $curr_download->download_category_id);
            ?>
            &nbsp;<a href="index.php?<?php echo Html::uriquery('mod_download_category', 'admin_list'); ?>"><?php _e('Manage Categories'); ?></a>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('File'); ?></td>
            <td class="entry">
            <?php
            echo Html::input('file', 'download_file', '', 
                '', $download_form, 'RequiredTextbox', 
                __('Please select a download file to upload!'));
            ?>
			<BR />
			<?php _e('Supported file format'); ?>:<?php echo FILE_ALLOW_EXT;?>
			<BR />
			<?php _e('Upload size limit'); ?>:<?php echo ini_get('upload_max_filesize');?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('Description'); ?></td>
            <td class="entry">
            <?php
            echo Html::textarea('download[description]', $curr_download->description, 
                '', $download_form, 'RequiredTextbox', 
                __('Please input description!'));
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('Publish Time'); ?></td>
            <td class="entry">
            <?php
            $pub_start_time = $curr_download->pub_start_time?$curr_download->pub_start_time:-1;
            $value_0 = '';
            $value_1 = '';
            $value_t = '';
            if ($pub_start_time < 0) {
                $value_0 = 'checked="checked"';
            } else {
                $value_1 = 'checked="checked"';
                $value_t = date('Y-m-d H:i:s', $pub_start_time);
            }
            echo Html::input('radio', 'pub_start_time', '0', $value_0);
            _e('Immediately');
            echo Html::input('radio', 'pub_start_time', '1', $value_1);
            echo DatetimeInput::create('download[pub_start_time]', $download_form, $value_t);
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"><?php _e('End Publish Time'); ?></td>
            <td class="entry">
            <?php
            $pub_end_time = $curr_download->pub_end_time?$curr_download->pub_end_time:-1;
            $value_0 = '';
            $value_1 = '';
            $value_t = '';
            if ($pub_end_time < 0) {
                $value_0 = 'checked="checked"';
            } else {
                $value_1 = 'checked="checked"';
                $value_t = date('Y-m-d H:i:s', $pub_end_time);
            }
            echo Html::input('radio', 'pub_end_time', '1', $value_1);
            echo DatetimeInput::create('download[pub_end_time]', $download_form, $value_t);
            echo Html::input('radio', 'pub_end_time', '0', $value_0);
            _e('Never Expire');
            ?>
            </td>
        </tr>
        <tr>
            <td class="label"></td>
            <td class="entry">
            <?php
            echo Html::input('checkbox', 'download[published]', '1', 
                Toolkit::switchText($curr_download->published, 
                    array('0' => '', '1' => 'checked="checked"')));
            ?>
            &nbsp;<?php _e('Publish'); ?>
            </td>
        </tr>
        <tr>
            <td class="label"></td>
            <td class="entry">
            <?php
            echo Html::input('checkbox', 'ismemonly', '1');
            ?>
            &nbsp;<?php _e('Member only access'); ?>
            </td>
        </tr>
    </tbody>
</table>
<?php
$download_form->close();
$download_form->writeValidateJs();
?>