/**
 * Import ze souboru
 *
 * @package    IcingaEditor
 * @subpackage WebUI
 * @author     Vitex <*****@*****.**>
 * @copyright  2012 Vitex@hippy.cz (G)
 */
require_once 'includes/IEInit.php';
if ($oPage->isPosted()) {
    $importer = new IECommand();
    $success = 0;
    $cfgText = $oPage->getRequestValue('cfgtext');
    if ($cfgText) {
        $success += $importer->importText($cfgText, array('command_type' => $oPage->getRequestValue('type')));
    }
    if (isset($_FILES['cfgfile']['tmp_name']) && strlen(trim($_FILES['cfgfile']['tmp_name']))) {
        $success += $importer->importFile($_FILES['cfgfile']['tmp_name'], array('command_type' => $oPage->getRequestValue('type')));
    }
    if ($success) {
        $oPage->addStatusMessage(sprintf(_('Příkaz %s byl naimportován'), $importer->getName()), 'success');
    } else {
        $oPage->addStatusMessage(_('Příkaz nebyl naimportován'), 'warning');
    }
} else {
    $oPage->addStatusMessage(_('Zadejte konfigurační fragment příkazu, nebo zvolte soubor k importu'));
}
$oPage->addItem(new IEPageTop(_('Načtení příkazů ze souboru')));
$fileForm = new EaseTWBForm('CfgFileUp', null, 'POST', null, array('class' => 'form-horizontal', 'enctype' => 'multipart/form-data'));
$fileForm->addInput(new EaseHtmlTextareaTag('cfgtext', ''), _('konfigurační fragment'));