Esempio n. 1
0
$opt_count = 0;
if (empty($addopt) && !empty($ele_id)) {
    $keys = array_keys($value);
    for ($i = 0; $i < count($keys); $i++) {
        $r = $value[$keys[$i]] ? $opt_count : null;
        $v = $myts->makeTboxData4PreviewInForm($keys[$i]);
        $options[] = addOption('ele_value[' . $opt_count . ']', $opt_count, $v, 'radio', $r);
        $opt_count++;
    }
} else {
    while ($v = each($ele_value)) {
        $v['value'] = $myts->makeTboxData4PreviewInForm($v['value']);
        if (!empty($v['value'])) {
            $r = $checked == $opt_count ? $opt_count : null;
            $options[] = addOption('ele_value[' . $opt_count . ']', $opt_count, $v['value'], 'radio', $r);
            $opt_count++;
        }
    }
    $addopt = empty($addopt) ? 2 : $addopt;
    for ($i = 0; $i < $addopt; $i++) {
        $options[] = addOption('ele_value[' . $opt_count . ']', $opt_count, '', 'radio');
        $opt_count++;
    }
}
$options[] = addOptionsTray();
$opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />');
$opt_tray->setDescription(_AM_ELE_OPT_DESC2);
for ($i = 0; $i < count($options); $i++) {
    $opt_tray->addElement($options[$i]);
}
$form->addElement($opt_tray);
Esempio n. 2
0
    $keys = array_keys($value);
    for ($i = 0; $i < count($keys); $i++) {
        $v = $myts->makeTboxData4PreviewInForm($keys[$i]);
        $options[] = addOption('ele_value[' . $opt_count . ']', 'checked[' . $opt_count . ']', $v, 'check', $value[$keys[$i]]);
        $opt_count++;
    }
} else {
    while ($v = each($ele_value)) {
        $v['value'] = $myts->makeTboxData4PreviewInForm($v['value']);
        if (!empty($v['value'])) {
            if (!isset($checked[$opt_count])) {
                $checked[$opt_count] = "";
            }
            $options[] = addOption('ele_value[' . $opt_count . ']', 'checked[' . $opt_count . ']', $v['value'], 'check', $checked[$v['key']]);
            $opt_count++;
        }
    }
    $addopt = empty($addopt) ? 2 : $addopt;
    for ($i = 0; $i < $addopt; $i++) {
        $options[] = addOption('ele_value[' . $opt_count . ']', 'checked[' . $opt_count . ']', '', 'check', '');
        $opt_count++;
    }
}
$add_opt = addOptionsTray();
$options[] = $add_opt;
$opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />');
$opt_tray->setDescription(_AM_ELE_OPT_DESC);
for ($i = 0; $i < count($options); $i++) {
    $opt_tray->addElement($options[$i]);
}
$form->addElement($opt_tray);
Esempio n. 3
0
 function adminUI($form, $value, $ele_id)
 {
     $myts =& MyTextSanitizer::getInstance();
     $options = array();
     $opt_count = 0;
     $addopt = $_POST['addopt'];
     if (!empty($ele_id)) {
         $keys = array_keys($value);
         for ($i = 0; $i < count($keys); $i++) {
             $r = $value[$keys[$i]] ? $opt_count : null;
             $v = $myts->makeTboxData4PreviewInForm($keys[$i]);
             $options[] = new xoopsFormText('', 'ele_value[' . $opt_count . ']', 40, 255, $v);
             // function in the admin/elements.php file
             $opt_count++;
         }
     }
     // added check below to add in blank rows that are unaccounted for above.
     // above code adds in all the options the user has typed in.  If there are blank rows on the form, this code will add in the appropriate amount, based on the 'rowcount' hidden element.
     // This code added by jwe 01/05/05
     if ($opt_count < $_POST['rowcount']) {
         for ($i = $opt_count; $i < $_POST['rowcount']; $i++) {
             $options[] = new xoopsFormText('', 'ele_value[' . $i . ']', 40, 255, '');
         }
         $opt_count = $_POST['rowcount'];
         // make the opt_count equal to the number of rows, since we've now brought the number back up to where it should be.
     }
     if (empty($addopt) and empty($ele_id)) {
         $addopt = 2;
     }
     for ($i = 0; $i < $addopt; $i++) {
         $options[] = new xoopsFormText('', 'ele_value[' . $opt_count . ']', 40, 255, '');
         $opt_count++;
     }
     // these two lines part of the jwe added code
     $rowcount = new XoopsFormHidden("rowcount", $opt_count);
     $form->addElement($rowcount);
     $opt_tray = new XoopsFormElementTray(_AM_ELE_OPT, '<br />');
     $opt_tray->setDescription(_AM_ELE_OPT_DESC_RANKORDERLISTS . '<br /><br />' . _AM_ELE_OPT_UITEXT);
     for ($i = 0; $i < count($options); $i++) {
         $opt_tray->addElement($options[$i]);
     }
     $opt_tray->addElement(addOptionsTray());
     $form->addElement($opt_tray);
     return $form;
 }