예제 #1
0
        $form->addInput('label', 'Label', $field->label);
        $form->addDropdown('type', 'Type', UserDataField::getTypes(), $field->type);
        switch ($field->type) {
            case UserDataField::RADIO:
                for ($i = 1; $i < 6; $i++) {
                    $opt = 'opt_' . $i;
                    $val = UserDataFieldOption::get($field->id, $opt);
                    $form->addInput($opt, 'Option ' . $i, $val);
                }
                break;
            case UserDataField::AVATAR:
                for ($i = 1; $i < 6; $i++) {
                    $opt = 'avatar_' . $i;
                    $val = UserDataFieldOption::get($field->id, $opt);
                    if ($val) {
                        $img = new XhtmlComponentImage();
                        $img->src = getThumbUrl($val);
                        $form->add($img, 'Existing picture ' . $i);
                        //                $form->addCheckbox('remove_'.$f->id, 'Remove photo');
                    }
                    $form->addFile($opt, 'Avatar ' . $i, $val);
                }
                break;
        }
        $form->addSubmit('Save');
        $form->setHandler('editSubmit');
        echo $form->render();
        break;
    default:
        echo 'No handler for view ' . $this->owner;
}
예제 #2
0
    if ($session->id) {
        dp('HACK user ' . $session->name . ' (' . $session->id . ') tried to login user ' . $p['usr']);
        return false;
    }
    if ($session->login($p['usr'], $p['pwd'])) {
        $session->showStartPage();
    }
    return true;
}
$form = new XhtmlForm('login');
$form->cssTable('');
$u_img = new XhtmlComponentImage();
$u_img->src = $page->getRelativeCoreDevUrl() . 'gfx/icon_user.png';
$i = new XhtmlComponentInput();
$i->name = 'usr';
$form->add($i, t('Username'), $u_img);
$p_img = new XhtmlComponentImage();
$p_img->src = $page->getRelativeCoreDevUrl() . 'gfx/icon_keys.png';
$i = new XhtmlComponentPassword();
$i->name = 'pwd';
$form->add($i, t('Password'), $p_img);
$form->addSubmit('Log in', 'font-weight:bold');
$form->setFocus('usr');
$form->onSubmit('return check_login(this);');
$form->setHandler(__NAMESPACE__ . '\\loginHandler');
echo $form->render();
$header->registerJsFunction('function show_login_form()' . '{' . ($show_reg_div ? 'hide_el("' . $reg_div . '");' : '') . ($show_recover_div ? 'hide_el("' . $recover_div . '");' : '') . 'show_el("' . $login_div . '");' . '}');
if ($show_reg_div) {
    $header->registerJsFunction('function show_reg_form()' . '{' . 'hide_el("' . $login_div . '");' . 'show_el("' . $reg_div . '");' . '}');
    $x = new XhtmlComponentButton();
    $x->onClick('return show_reg_form();');