Example #1
0
    list($period, $from, $to, $days) = $matches;
    $days = explode(',', $days);
    // DAYS SELECT
    $sel = new MultipleSelect('days' . $z++);
    $sel->setElements($daynames);
    $sel->setElementsVal(array('1', '2', '3', '4', '5', '6', '7'));
    foreach ($days as $day) {
        $sel->setSelected(trim($day));
    }
    // Start hour
    $fields = array(new hourInputTpl('starthour[]'), new textTpl(_T('to', 'backuppc')), new hourInputTpl('endhour[]'), new textTpl(_T('on', 'backuppc')), $sel, new buttonTpl('removePeriod', _T('Remove', 'backuppc'), 'removePeriod'));
    $values = array(float2hhmm($from), '', float2hhmm($to), '', '');
    $f->add(new TrFormElement(_T('Do not backup from', 'backuppc'), new multifieldTpl($fields)), array("value" => $values, "required" => True));
}
// Add Period button
$addPeriodBtn = new buttonTpl('addPeriod', _T('Add exclusion', 'backuppc'));
$addPeriodBtn->setClass('btnPrimary');
$f->add(new TrFormElement('', $addPeriodBtn), array());
// If BackupProfile id is transmitten, we write it in the form
if ($ID) {
    $f->add(new HiddenTpl("id"), array("value" => $ID, "hide" => True));
} elseif (isset($profile['id'])) {
    $f->add(new HiddenTpl("id"), array("value" => $profile['id'], "hide" => True));
}
$f->pop();
$f->addValidateButton("bconfirm");
$f->display();
?>

<script src="modules/backuppc/lib/jquery.maskedinput-1.3.min.js"></script>
<script src="modules/backuppc/lib/jquery.multiselect.js"></script>
Example #2
0
if (!$package['sub_packages']) {
    $package['sub_packages'] = array(array('pid' => $papi_packages_pids[0], 'condition' => ''));
}
// SubPackages lists
for ($i = 0; $i < count($package['sub_packages']); $i++) {
    $package_select = new SelectItem('sub_packages[pids][]');
    $package_select->setElements($papi_packages_labels);
    $package_select->setElementsVal($papi_packages_pids);
    // Fields
    $fields = array($package_select, new InputTpl('sub_packages[conditions][]'), new buttonTpl('removeShare', _T('Remove'), 'removeShare'));
    $values = array($package['sub_packages'][$i]['pid'], $package['sub_packages'][$i]['condition'], '');
    $f->add(new TrFormElement(_T('Package', 'pkgs') . " (" . ($i + 1) . ')', new multifieldTpl($fields)), array("value" => $values, "required" => True));
}
print '<script type="text/javascript">window.pkg_count = ' . $i . ';</script>';
// Add Share button
$addShareBtn = new buttonTpl('addShare', _T('Add bundle', 'pkgs'));
$addShareBtn->setClass('btnPrimary');
$f->add(new TrFormElement('', $addShareBtn), array());
// If BackupProfile id is transmitten, we write it into the form
if ($ID) {
    $f->add(new HiddenTpl("id"), array("value" => $ID, "hide" => True));
} elseif (isset($profile['id'])) {
    $f->add(new HiddenTpl("id"), array("value" => $profile['id'], "hide" => True));
}
$f->pop();
$f->addValidateButton("bconfirm");
$f->display();
?>

<script type="text/javascript">
jQuery(function(){
    }
}
//  Check if credentials are active
$credentials_active = false;
if (isset($json['my_username'], $json['my_password'])) {
    $available = getAvailableAppstreamPackages();
    if ($available['detail'] != 'Invalid username/password') {
        $credential_active = true;
    }
}
// =============================================================
// My Credentials form
// =============================================================
if ($credential_active) {
    print '<h2><br/>' . _T('Your Account credentials are active', 'pkgs') . '</h2>';
    $edit_credentialBtn = new buttonTpl('edit_account', _T('Modify Account credentials', 'pkgs'));
    $edit_credentialBtn->display();
    $show_credentials = "0";
    print '<br/>';
} else {
    $show_credentials = "1";
    print '<h2><br/>' . _T('My Account credentials:', 'pkgs') . '</h2>';
}
print '<div id=\'credentials_form\'>';
$f = new ValidatingForm();
$f->push(new Table());
$f->add(new TrFormElement(_T('Username', 'pkgs'), new InputTpl('my_username')), array("value" => $json['my_username'], "required" => True));
$f->add(new TrFormElement(_T('Password', 'pkgs'), new PasswordTpl('my_password')), array("value" => $json['my_password'], "required" => True));
print "<input type = 'hidden' id = 'show_credentials' value = '{$show_credentials}'/>";
$f->addValidateButton("bconfirm");
$f->display();