/** * @param BannersBannerclient $obj */ public function __construct(BannersBannerClient $obj) { $title = $obj->isNew() ? sprintf(_AM_BANNERS_CLIENTS_ADD) : sprintf(_AM_BANNERS_CLIENTS_EDIT); parent::__construct($title, 'form', 'clients.php', 'post', true); $this->addElement(new Xoops\Form\Text(_AM_BANNERS_CLIENTS_NAME, 'name', 5, 255, $obj->getVar('bannerclient_name')), true); // date if ($obj->isNew()) { $user = '******'; } else { if ($obj->getVar('bannerclient_uid') == 0) { $user = '******'; } else { $user = '******'; } } $uname = new Xoops\Form\ElementTray(_AM_BANNERS_CLIENTS_UNAME, ''); $type = new Xoops\Form\Radio('', 'user', $user); $options = array('N' => _AM_BANNERS_CLIENTS_UNAME_NO, 'Y' => _AM_BANNERS_CLIENTS_UNAME_YES); $type->addOptionArray($options); $uname->addElement($type); $uname->addElement(new Xoops\Form\SelectUser('', 'uid', false, $obj->getVar('bannerclient_uid'), 1, false)); $this->addElement($uname); $this->addElement(new Xoops\Form\TextArea(_AM_BANNERS_CLIENTS_EXTRAINFO, 'extrainfo', $obj->getVar('bannerclient_extrainfo'), 5, 5), false); if (!$obj->isNew()) { $this->addElement(new Xoops\Form\Hidden('cid', $obj->getVar('bannerclient_cid'))); } $this->addElement(new Xoops\Form\Hidden('op', 'save')); $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); }
/** * @param ImagesCategory|XoopsObject $obj */ public function __construct(ImagesCategory $obj) { $xoops = Xoops::getInstance(); $perm_handler = $xoops->getHandlerGroupperm(); if ($obj->isNew()) { $title = _AM_IMAGES_CAT_ADD; $read = FixedGroups::ADMIN; $write = FixedGroups::ADMIN; } else { $title = _AM_IMAGES_CAT_EDIT; $read = $perm_handler->getGroupIds('imgcat_read', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid')); $write = $perm_handler->getGroupIds('imgcat_write', $obj->getVar('imgcat_id'), $xoops->module->getVar('mid')); } parent::__construct($title, 'imagecat_form', $xoops->getEnv('PHP_SELF'), 'post', true); $tabtray = new Xoops\Form\TabTray('', 'uniqueid', $xoops->getModuleConfig('jquery_theme', 'system')); $tab1 = new Xoops\Form\Tab(_MI_IMAGES_CATEGORIES, 'tabid-1'); $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_NAME, 'imgcat_name', 50, 255, $obj->getVar('imgcat_name')), true); $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_SIZE, 'imgcat_maxsize', 2, 8, $obj->getVar('imgcat_maxsize'))); $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_WIDTH, 'imgcat_maxwidth', 1, 4, $obj->getVar('imgcat_maxwidth'))); $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_CAT_HEIGHT, 'imgcat_maxheight', 1, 4, $obj->getVar('imgcat_maxheight'))); $tab1->addElement(new Xoops\Form\Text(_AM_IMAGES_WEIGHT, 'imgcat_weight', 1, 5, $obj->getVar('imgcat_weight'))); $tab1->addElement(new Xoops\Form\RadioYesNo(_AM_IMAGES_CAT_DISPLAY, 'imgcat_display', $obj->getVar('imgcat_display'))); if ($obj->isNew()) { $store = new Xoops\Form\Radio(_AM_IMAGES_CAT_STR_TYPE . '<div class="red">' . _AM_IMAGES_CAT_STR_TYOPENG . '</div>', 'imgcat_storetype', 'file'); $store->addOptionArray(array('file' => _AM_IMAGES_CAT_ASFILE, 'db' => _AM_IMAGES_CAT_INDB)); $tab1->addElement($store); } else { $store = array('db' => _AM_IMAGES_CAT_INDB, 'file' => _AM_IMAGES_CAT_ASFILE); $tab1->addElement(new Xoops\Form\Label(_AM_IMAGES_CAT_STR_TYPE, $store[$obj->getVar('imgcat_storetype')])); $this->addElement(new Xoops\Form\Hidden('imgcat_storetype', $obj->getVar('imgcat_storetype'))); } $tab2 = new Xoops\Form\Tab(_MI_IMAGES_PERMISSIONS, 'tabid-2'); $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_READ_GRP, 'readgroup', true, $read, 5, true)); $tab2->addElement(new Xoops\Form\SelectGroup(_AM_IMAGES_CAT_WRITE_GRP, 'writegroup', true, $write, 5, true)); $tabtray->addElement($tab1); $tabtray->addElement($tab2); $this->addElement($tabtray); $this->addElement(new Xoops\Form\Hidden('imgcat_id', $obj->getVar('imgcat_id'))); /** * Buttons */ $button_tray = new Xoops\Form\ElementTray('', ''); $button_tray->addElement(new Xoops\Form\Hidden('op', 'save')); $button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'); $button->setClass('btn btn-success'); $button_tray->addElement($button); $button_2 = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset'); $button_2->setClass('btn btn-warning'); $button_tray->addElement($button_2); $button_3 = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button'); $button_3->setExtra("onclick='javascript:history.go(-1);'"); $button_3->setClass('btn btn-danger'); $button_tray->addElement($button_3); $this->addElement($button_tray); }
$msnm_tray = new Xoops\Form\ElementTray(XoopsLocale::MSNM, " "); $msnm_tray->addElement($msnm_match); $msnm_tray->addElement($msnm_text); $location_text = new Xoops\Form\Text(XoopsLocale::LOCATION_CONTAINS, "user_from", 30, 100); $occupation_text = new Xoops\Form\Text(XoopsLocale::OCCUPATION_CONTAINS, "user_occ", 30, 100); $interest_text = new Xoops\Form\Text(XoopsLocale::INTEREST_CONTAINS, "user_intrest", 30, 100); $lastlog_more = new Xoops\Form\Text(SystemLocale::LAST_LOGIN_GREATER_THAN_X, "user_lastlog_more", 10, 5); $lastlog_less = new Xoops\Form\Text(SystemLocale::LAST_LOGIN_LESS_THAN_X, "user_lastlog_less", 10, 5); $reg_more = new Xoops\Form\Text(SystemLocale::REGISTRATION_DATE_GREATER_THAN_X, "user_reg_more", 10, 5); $reg_less = new Xoops\Form\Text(SystemLocale::REGISTRATION_DATE_LESS_THAN_X, "user_reg_less", 10, 5); $posts_more = new Xoops\Form\Text(SystemLocale::POSTS_NUMBER_GREATER_THAN_X, "user_posts_more", 10, 5); $posts_less = new Xoops\Form\Text(SystemLocale::POSTS_NUMBER_LESS_THAN_X, "user_posts_less", 10, 5); $mailok_radio = new Xoops\Form\Radio(XoopsLocale::TYPE_OF_USERS_TO_SHOW, "user_mailok", "both"); $mailok_radio->addOptionArray(array("mailok" => XoopsLocale::ONLY_USERS_THAT_ACCEPT_EMAIL, "mailng" => XoopsLocale::ONLY_USERS_THAT_DO_NOT_ACCEPT_EMAIL, "both" => XoopsLocale::ALL_USERS)); $type_radio = new Xoops\Form\Radio(XoopsLocale::TYPE_OF_USERS_TO_SHOW, "user_type", "both"); $type_radio->addOptionArray(array("actv" => SystemLocale::ONLY_ACTIVE_USERS, "inactv" => SystemLocale::ONLY_INACTIVE_USERS, "both" => XoopsLocale::ALL_USERS)); $sort_select = new Xoops\Form\Select(XoopsLocale::SORT_BY, "user_sort", 'uname'); $sort_select->addOptionArray(array("uname" => XoopsLocale::USER_NAME, "email" => XoopsLocale::EMAIL, "last_login" => XoopsLocale::LAST_LOGIN, "user_regdate" => XoopsLocale::REGISTRATION_DATE, "posts" => XoopsLocale::COMMENTS_POSTS)); $order_select = new Xoops\Form\Select(XoopsLocale::ORDER, "user_order", 'ASC'); $order_select->addOptionArray(array("ASC" => XoopsLocale::ASCENDING, "DESC" => XoopsLocale::DESCENDING)); $limit_text = new Xoops\Form\Text(XoopsLocale::NUMBER_OF_RESULTS_PER_PAGE, "user_limit", 6, 2, 20); $submit_button = new Xoops\Form\Button("", "user_submit", XoopsLocale::A_SUBMIT, "submit"); $form = new Xoops\Form\ThemeForm(XoopsLocale::FIND_USERS, "user_findform", "admin.php?fct=users", 'post', true); $form->addElement($uname_tray); $form->addElement($name_tray); $form->addElement($email_tray); $form->addElement($group_select); $form->addElement($icq_tray); $form->addElement($aim_tray); $form->addElement($yim_tray); $form->addElement($msnm_tray);
foreach ($items_range as $var => $title) { $more = new Xoops\Form\Text("", "{$var}_more", 10, 5, @$_POST["{$var}_more"]); $less = new Xoops\Form\Text("", "{$var}_less", 10, 5, @$_POST["{$var}_less"]); $range_tray = new Xoops\Form\ElementTray($title, " - "); $range_tray->addElement($less); $range_tray->addElement($more); $form->addElement($range_tray); unset($more, $less, $range_tray); } $mailok_radio = new Xoops\Form\Radio(XoopsLocale::TYPE_OF_USERS_TO_SHOW, "user_mailok", empty($_POST["user_mailok"]) ? "both" : $_POST["user_mailok"]); $mailok_radio->addOptionArray(array("mailok" => XoopsLocale::ONLY_USERS_THAT_ACCEPT_EMAIL, "mailng" => XoopsLocale::ONLY_USERS_THAT_DO_NOT_ACCEPT_EMAIL, "both" => XoopsLocale::ALL)); $avatar_radio = new Xoops\Form\Radio(XoopsLocale::HAS_AVATAR, "user_avatar", empty($_POST["user_avatar"]) ? "both" : $_POST["user_avatar"]); $avatar_radio->addOptionArray(array("y" => XoopsLocale::YES, "n" => XoopsLocale::NO, "both" => XoopsLocale::ALL)); $level_radio = new Xoops\Form\Radio(XoopsLocale::LEVEL, "level", @$_POST["level"]); $levels = array(0 => XoopsLocale::ALL, 1 => XoopsLocale::ACTIVE, 2 => XoopsLocale::INACTIVE, 3 => XoopsLocale::DISABLED); $level_radio->addOptionArray($levels); $member_handler = $xoops->getHandlerMember(); $groups = $member_handler->getGroupList(); $groups[0] = XoopsLocale::ALL; $group_select = new Xoops\Form\Select(XoopsLocale::GROUP, 'groups', @$_POST['groups'], 3, true); $group_select->addOptionArray($groups); $ranks = $xoops->service('userrank')->getAssignableUserRankList()->getValue(); $ranks[0] = XoopsLocale::ALL; $rank_select = new Xoops\Form\Select(XoopsLocale::RANK, 'rank', (int) @$_POST['rank']); $rank_select->addOptionArray($ranks); $form->addElement($url_text); $form->addElement($location_text); $form->addElement($occupation_text); $form->addElement($interest_text); $form->addElement($mailok_radio); $form->addElement($avatar_radio);
/** * Returns a {@link Xoops\Form\Element} for editing the value of this field * * @param XoopsUser $user {@link XoopsUser} object to edit the value of * @param ProfileProfile $profile {@link ProfileProfile} object to edit the value of * * @return Xoops\Form\Element **/ public function getEditElement(XoopsUser $user, ProfileProfile $profile) { $xoops = Xoops::getInstance(); $value = in_array($this->getVar('field_name'), $this->getUserVars()) ? $user->getVar($this->getVar('field_name'), 'e') : $profile->getVar($this->getVar('field_name'), 'e'); $caption = $this->getVar('field_title'); $caption = defined($caption) ? constant($caption) : $caption; $name = $this->getVar('field_name', 'e'); $options = $this->getVar('field_options'); if (is_array($options)) { //asort($options); foreach (array_keys($options) as $key) { $optval = defined($options[$key]) ? constant($options[$key]) : $options[$key]; $optkey = defined($key) ? constant($key) : $key; unset($options[$key]); $options[$optkey] = $optval; } } switch ($this->getVar('field_type')) { default: case "autotext": //autotext is not for editing $element = new Xoops\Form\Label($caption, $this->getOutputValue($user, $profile)); break; case "textbox": $element = new Xoops\Form\Text($caption, $name, 35, $this->getVar('field_maxlength'), $value); break; case "textarea": $element = new Xoops\Form\TextArea($caption, $name, $value, 4, 30); break; case "dhtml": $element = new Xoops\Form\DhtmlTextArea($caption, $name, $value, 10, 30); break; case "select": $element = new Xoops\Form\Select($caption, $name, $value); // If options do not include an empty element, then add a blank option to prevent any default selection if (!in_array('', array_keys($options))) { $element->addOption('', XoopsLocale::NONE); $eltmsg = empty($caption) ? sprintf(XoopsLocale::F_ENTER, $name) : sprintf(XoopsLocale::F_ENTER, $caption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $element->customValidationCode[] = "\nvar hasSelected = false; var selectBox = myform.{$name};" . "for (i = 0; i < selectBox.options.length; i++ ) { if ( selectBox.options[i].selected == true && selectBox.options[i].value != '' ) { hasSelected = true; break; } }" . "if ( !hasSelected ) { window.alert(\"{$eltmsg}\"); selectBox.focus(); return false; }"; } $element->addOptionArray($options); break; case "select_multi": $element = new Xoops\Form\Select($caption, $name, $value, 5, true); $element->addOptionArray($options); break; case "radio": $element = new Xoops\Form\Radio($caption, $name, $value); $element->addOptionArray($options); break; case "checkbox": $element = new Xoops\Form\Checkbox($caption, $name, $value); $element->addOptionArray($options); break; case "yesno": $element = new Xoops\Form\RadioYesNo($caption, $name, $value); break; case "group": $element = new Xoops\Form\SelectGroup($caption, $name, true, $value); break; case "group_multi": $element = new Xoops\Form\SelectGroup($caption, $name, true, $value, 5, true); break; case "language": $element = new Xoops\Form\SelectLanguage($caption, $name, $value); break; case "date": $element = new Xoops\Form\DateSelect($caption, $name, 15, $value); break; case "longdate": $element = new Xoops\Form\DateSelect($caption, $name, 15, str_replace("-", "/", $value)); break; case "datetime": $element = new Xoops\Form\DateTime($caption, $name, 15, $value); break; case "timezone": $element = new Xoops\Form\SelectTimeZone($caption, $name, $value); $element->setExtra("style='width: 280px;'"); break; case "rank": $ranklist = $xoops->service('userrank')->getAssignableUserRankList()->getValue(); if ($ranklist !== null) { $element = new Xoops\Form\Select($caption, $name, $value); $element->addOption(0, "--------------"); $element->addOptionArray($ranklist); } else { $element = new Xoops\Form\Hidden($name, $value); } break; case 'theme': $element = new Xoops\Form\Select($caption, $name, $value); $element->addOption("0", _PROFILE_MA_SITEDEFAULT); $handle = opendir(\XoopsBaseConfig::get('themes-path') . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(\XoopsBaseConfig::get('themes-path') . '/' . $file) && !preg_match("/^[.]{1,2}\$/", $file) && strtolower($file) != 'cvs') { if (XoopsLoad::fileExists(\XoopsBaseConfig::get('themes-path') . "/" . $file . "/theme.html") && in_array($file, $xoops->getConfig('theme_set_allowed'))) { $dirlist[$file] = $file; } } } closedir($handle); if (!empty($dirlist)) { asort($dirlist); $element->addOptionArray($dirlist); } break; } if ($this->getVar('field_description') != "") { $element->setDescription($this->getVar('field_description')); } return $element; }