Exemple #1
0
        new TrFormElement(_T('Default menu label', 'imaging'),
                          new InputTpl("default_m_label")),
        array("value" => $default_menu['default_name'])
    );
    $f->add(
            new TrFormElement(_T('Default menu timeout', 'imaging'),
                              new InputTpl("default_m_timeout")),
            array("value" => $default_menu['timeout'])
    );
    $f->pop();


    $f->add(new TitleElement(_T("Restoration options", "imaging")));
    $f->push(new Table());
    $possible_protocols = web_def_possible_protocols();
    $default_protocol = web_def_default_protocol();
    $protocols_choices = array();
    $protocols_values = array();

    /* translate possibles protocols */
    _T('nfs', 'imaging');
    _T('mtftp', 'imaging');
    foreach ($possible_protocols as $p) {
        if ($p['label']) {
            if ($p['label'] == $default_menu['protocol']) {
                $rest_selected = $p['imaging_uuid'];
            }
            if ($p['label'] == $default_protocol) {
                $p['label'] = _T($p['label'], 'imaging').' '._T('(default)', 'imaging');
            }
            $protocols_choices[$p['imaging_uuid']] = $p['label'];
Exemple #2
0
function expertModeDisplay($f, $has_profile, $type, $menu, $opts, $target, $real_target)
{
    if (!$has_profile) {
        $f->add(new TitleElement(sprintf(_T("%s menu parameters", "imaging"), $type == '' ? _T('Computer', 'imaging') : _T('Profile', 'imaging'))));
        $f->push(new Table());
        $f->add(new TrFormElement(_T('Default menu label', 'imaging'), new InputTpl("default_m_label")), array("value" => $menu['default_name']));
        $f->add(new TrFormElement(_T('Menu timeout', 'imaging'), new InputTpl("default_m_timeout")), array("value" => $menu['timeout']));
        foreach ($opts as $key => $str) {
            if ($menu[$key]) {
                $value = 'CHECKED';
            } else {
                $value = '';
            }
            $f->add(new TrFormElement($str, new CheckBoxTpl($key)), array("value" => $value));
        }
        $f->pop();
        $f->add(new TitleElement(_T("Restoration options", "imaging")));
        $f->push(new Table());
        $possible_protocols = web_def_possible_protocols();
        $default_protocol = web_def_default_protocol();
        $protocols_choices = array();
        $protocols_values = array();
        /* translate possibles protocols */
        _T('nfs', 'imaging');
        _T('tftp', 'imaging');
        _T('mtftp', 'imaging');
        foreach ($possible_protocols as $p) {
            if ($p['label']) {
                if ($p['label'] == $menu['protocol']) {
                    $rest_selected = $p['imaging_uuid'];
                }
                if ($p['label'] == $default_protocol) {
                    $p['label'] = _T($p['label'], 'imaging') . ' ' . _T('(default)', 'imaging');
                }
                $protocols_choices[$p['imaging_uuid']] = $p['label'];
                $protocols_values[$p['imaging_uuid']] = $p['imaging_uuid'];
            }
        }
        $rest_type = new RadioTpl("rest_type");
        $rest_type->setChoices($protocols_choices);
        $rest_type->setValues($protocols_values);
        $rest_type->setSelected($rest_selected);
        $f->add(new TrFormElement(_T("Restoration type", "imaging"), $rest_type));
        $f->add(new TrFormElement(_T("Restoration: MTFTP maximum waiting (in sec)", "imaging"), new InputTpl("rest_wait")), array("value" => $menu['mtftp_restore_timeout']));
        $f->pop();
        $f->add(new TitleElement(_T("Boot options", "imaging")));
        $f->push(new Table());
        $f->add(new TrFormElement(_T("Full path to the XPM displayed at boot", "imaging"), new InputTpl("boot_xpm")), array("value" => $menu['background_uri']));
        $f->add(new TrFormElement(_T("Message displayed during backup/restoration", "imaging"), new TextareaTpl("boot_msg")), array("value" => $menu['message']));
        /* $f->add(
               new TrFormElement(_T("Keyboard mapping (empty/fr)", "imaging"),
               new InputTpl("boot_keyboard")), array("value" => "")
           ); */
        $f->pop();
    } else {
        $f->add(new HiddenTpl("default_m_label"), array("value" => $menu['default_name'], "hide" => True));
        $f->add(new HiddenTpl("default_m_timeout"), array("value" => $menu['timeout'], "hide" => True));
        $possible_protocols = web_def_possible_protocols();
        foreach ($possible_protocols as $p) {
            if ($p['label'] && $p['label'] == $menu['protocol']) {
                $rest_selected = $p['imaging_uuid'];
                continue;
            }
        }
        $f->add(new HiddenTpl("rest_type"), array("value" => $rest_selected, "hide" => True));
        $f->add(new HiddenTpl("rest_wait"), array("value" => $menu['timeout'], "hide" => True));
        $f->add(new HiddenTpl("boot_xpm"), array("value" => $menu['background_uri'], "hide" => True));
        $f->add(new HiddenTpl("boot_msg"), array("value" => $menu['message'], "hide" => True));
        foreach ($opts as $key => $str) {
            if ($menu[$key]) {
                $value = 'CHECKED';
            } else {
                $value = '';
            }
            $f->add(new HiddenTpl($str), array("value" => $value, "hide" => True));
        }
    }
    /* $f->add(new TitleElement(_T("Administration options", "imaging")));
       $f->push(new Table());
       $f->add(
           new TrFormElement(_T("Password for adding a new client", "imaging"),
           new InputTpl("misc_passwd")), array("value" => "")
       );
       $f->pop();*/
    if ($type == '') {
        $f->add(new TitleElement(_T("Target options", "imaging")));
        $f->push(new Table());
        $local_kernel_parameters = web_def_kernel_parameters();
        $local_image_parameters = web_def_image_parameters();
        if (isset($real_target)) {
            if ($real_target != null) {
                $local_kernel_parameters = $real_target['kernel_parameters'];
                $local_image_parameters = $real_target['image_parameters'];
            }
            /* Make checkbox to force raw backup mode */
            if ($real_target != null && !empty($real_target['raw_mode'])) {
                $rawmode = "CHECKED";
            } else {
                $rawmode = "";
            }
        } else {
            if ($target != null) {
                $local_kernel_parameters = $target['kernel_parameters'];
                $local_image_parameters = $target['image_parameters'];
            }
            /* Make checkbox to force raw backup mode */
            if ($target != null && !empty($target['raw_mode'])) {
                $rawmode = "CHECKED";
            } else {
                $rawmode = "";
            }
        }
        $f->add(new TrFormElement(_T("Kernel parameters", "imaging"), new InputTpl("target_opt_kernel")), array("value" => $local_kernel_parameters));
        $f->add(new TrFormElement(_T("Image parameters", "imaging"), new InputTpl("target_opt_image")), array("value" => $local_image_parameters));
        $f->add(new TrFormElement(_T("Force raw backup mode", "imaging"), new CheckboxTpl("target_opt_raw_mode")), array("value" => $rawmode));
    } else {
        $f->add(new HiddenTpl('target_opt_kernel'), array("value" => $target != null ? $target['kernel_parameters'] : web_def_kernel_parameters(), "hide" => True));
        $f->add(new HiddenTpl('target_opt_image'), array("value" => $target != null ? $target['image_parameters'] : web_def_image_parameters(), "hide" => True));
        $f->add(new HiddenTpl('target_opt_raw_mode'), array("value" => $target != null ? $target['raw_mode'] : '', "hide" => True));
    }
}