public function getSearchFrom($andor, $queries, $mids, $mid) { $xoops = Xoops::getInstance(); $search = Search::getInstance(); // create form parent::__construct(_MD_SEARCH, 'search', 'index.php', 'get'); // create form elements $this->addElement(new Xoops\Form\Text(_MD_SEARCH_KEYWORDS, 'query', 30, 255, htmlspecialchars(stripslashes($this->queryArrayToString($queries)), ENT_QUOTES)), true); $type_select = new Xoops\Form\Select(_MD_SEARCH_TYPE, 'andor', $andor); $type_select->addOptionArray(array('AND' => _MD_SEARCH_ALL, 'OR' => _MD_SEARCH_ANY)); $this->addElement($type_select); if (!empty($mids)) { $mods_checkbox = new Xoops\Form\Checkbox(_MD_SEARCH_SEARCHIN, 'mids[]', $mids); } else { $mods_checkbox = new Xoops\Form\Checkbox(_MD_SEARCH_SEARCHIN, 'mids[]', $mid); } if (empty($modules)) { $gperm_handler = $xoops->getHandlerGroupperm(); $available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups()); $available_plugins = \Xoops\Module\Plugin::getPlugins('search'); //todo, would be nice to have the module ids availabe also $criteria = new CriteriaCompo(); $criteria->add(new Criteria('dirname', "('" . implode("','", array_keys($available_plugins)) . "')", 'IN')); if (isset($available_modules) && !empty($available_modules)) { $criteria->add(new Criteria('mid', '(' . implode(',', $available_modules) . ')', 'IN')); } $module_handler = $xoops->getHandlerModule(); $mods_checkbox->addOptionArray($module_handler->getNameList($criteria)); } else { /* @var $module XoopsModule */ $module_array = array(); foreach ($modules as $mid => $module) { $module_array[$mid] = $module->getVar('name'); } $mods_checkbox->addOptionArray($module_array); } $this->addElement($mods_checkbox); if ($search->getConfig('keyword_min') > 0) { $this->addElement(new Xoops\Form\Label(_MD_SEARCH_SEARCHRULE, sprintf(_MD_SEARCH_KEYIGNORE, $search->getConfig('keyword_min')))); } $this->addElement(new Xoops\Form\Hidden('action', 'results')); $this->addElement(new Xoops\Form\Token('id')); $this->addElement(new Xoops\Form\Button('', 'submit', _MD_SEARCH, 'submit')); return $this; }
/** * __construct * * @param XoopsUser|XoopsObject &$obj user object */ public function __construct(XoopsUser $obj) { $xoops = Xoops::getInstance(); if ($obj->isNew()) { //Add user $uid_value = ""; $uname_value = ""; $name_value = ""; $email_value = ""; $email_cbox_value = 0; $url_value = ""; $timezone_value = $xoops->getConfig('default_TZ'); $icq_value = ""; $aim_value = ""; $yim_value = ""; $msnm_value = ""; $location_value = ""; $occ_value = ""; $interest_value = ""; $sig_value = ""; $sig_cbox_value = 0; $bio_value = ""; $rank_value = 0; $mailok_value = 0; $form_title = SystemLocale::ADD_USER; $form_isedit = false; $groups = array(FixedGroups::USERS); } else { //Edit user $uid_value = $obj->getVar("uid", "E"); $uname_value = $obj->getVar("uname", "E"); $name_value = $obj->getVar("name", "E"); $email_value = $obj->getVar("email", "E"); $email_cbox_value = $obj->getVar("user_viewemail") ? 1 : 0; $url_value = $obj->getVar("url", "E"); $timezone_value = $obj->getVar("timezone_offset"); $icq_value = $obj->getVar("user_icq", "E"); $aim_value = $obj->getVar("user_aim", "E"); $yim_value = $obj->getVar("user_yim", "E"); $msnm_value = $obj->getVar("user_msnm", "E"); $location_value = $obj->getVar("user_from", "E"); $occ_value = $obj->getVar("user_occ", "E"); $interest_value = $obj->getVar("user_intrest", "E"); $sig_value = $obj->getVar("user_sig", "E"); $sig_cbox_value = $obj->getVar("attachsig") == 1 ? 1 : 0; $bio_value = $obj->getVar("bio", "E"); $rank_value = $obj->getVar('rank'); $mailok_value = $obj->getVar('user_mailok', 'E'); $form_title = sprintf(SystemLocale::F_UPDATE_USER, $obj->getVar("uname")); $form_isedit = true; $groups = array_values($obj->getGroups()); } //Affichage du formulaire parent::__construct($form_title, "form_user", "admin.php", "post", true); $this->addElement(new Xoops\Form\Text(XoopsLocale::USER_NAME, "username", 4, 25, $uname_value), true); $this->addElement(new Xoops\Form\Text(XoopsLocale::NAME, "name", 5, 60, $name_value)); $email_tray = new Xoops\Form\ElementTray(XoopsLocale::EMAIL, "<br />"); $email_text = new Xoops\Form\Text("", "email", 5, 60, $email_value); $email_tray->addElement($email_text, true); $email_cbox = new Xoops\Form\Checkbox("", "user_viewemail", $email_cbox_value); $email_cbox->addOption(1, XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL); $email_tray->addElement($email_cbox); $this->addElement($email_tray, true); $this->addElement(new Xoops\Form\Text(XoopsLocale::WEB_URL, "url", 5, 100, $url_value)); $this->addElement(new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, "timezone_offset", $timezone_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::ICQ, "user_icq", 3, 15, $icq_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::AIM, "user_aim", 3, 18, $aim_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::YIM, "user_yim", 3, 25, $yim_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::MSNM, "user_msnm", 3, 100, $msnm_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::LOCATION, "user_from", 5, 100, $location_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::OCCUPATION, "user_occ", 5, 100, $occ_value)); $this->addElement(new Xoops\Form\Text(XoopsLocale::INTEREST, "user_intrest", 5, 150, $interest_value)); $sig_tray = new Xoops\Form\ElementTray(XoopsLocale::SIGNATURE, "<br />"); $sig_tarea = new Xoops\Form\TextArea("", "user_sig", $sig_value, 5, 5); $sig_tray->addElement($sig_tarea); $sig_cbox = new Xoops\Form\Checkbox("", "attachsig", $sig_cbox_value); $sig_cbox->addOption(1, XoopsLocale::ALWAYS_ATTACH_MY_SIGNATURE); $sig_tray->addElement($sig_cbox); $this->addElement($sig_tray); $this->addElement(new Xoops\Form\TextArea(XoopsLocale::EXTRA_INFO, "bio", $bio_value, 5, 5)); $ranklist = $xoops->service('userrank')->getAssignableUserRankList()->getValue(); if ($ranklist !== null) { $rank_select = new Xoops\Form\Select(XoopsLocale::RANK, "rank", $rank_value); $rank_select->addOption(0, "--------------"); if (count($ranklist) > 0) { $rank_select->addOptionArray($ranklist); } $this->addElement($rank_select); } else { $this->addElement(new Xoops\Form\Hidden("rank", $rank_value)); } // adding a new user requires password fields if (!$form_isedit) { $this->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, "password", 3, 32), true); $this->addElement(new Xoops\Form\Password(XoopsLocale::RETYPE_PASSWORD, "pass2", 3, 32), true); } else { $this->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, "password", 3, 32)); $this->addElement(new Xoops\Form\Password(XoopsLocale::RETYPE_PASSWORD, "pass2", 3, 32)); } $this->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::ONLY_USERS_THAT_ACCEPT_EMAIL, 'user_mailok', $mailok_value)); //Groups administration addition XOOPS 2.0.9: Mith $gperm_handler = $xoops->getHandlerGroupPermission(); $group_select = array(); //If user has admin rights on groups if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, $xoops->user->getGroups(), 1)) { //add group selection $group_select[] = new Xoops\Form\SelectGroup(XoopsLocale::GROUPS, 'groups', false, $groups, 5, true); } else { //add each user groups foreach ($groups as $key => $group) { $group_select[] = new Xoops\Form\Hidden('groups[' . $key . ']', $group); } } foreach ($group_select as $group) { $this->addElement($group); unset($group); } $this->addElement(new Xoops\Form\Hidden("fct", "users")); $this->addElement(new Xoops\Form\Hidden("op", "users_save")); $this->addElement(new Xoops\Form\Button("", "submit", XoopsLocale::A_SUBMIT, "submit")); if (!empty($uid_value)) { $this->addElement(new Xoops\Form\Hidden("uid", $uid_value)); } }
/** * @param PublisherCategory $obj */ public function __construct(PublisherCategory $obj) { $xoops = Xoops::getInstance(); $publisher = Publisher::getInstance(); $member_handler = $xoops->getHandlerMember(); $userGroups = $member_handler->getGroupList(); parent::__construct(_AM_PUBLISHER_CATEGORY, "form", $xoops->getEnv('PHP_SELF')); $this->setExtra('enctype="multipart/form-data"'); // Category $criteria = new Criteria(null); $criteria->setSort('weight'); $criteria->setOrder('ASC'); $categories = $publisher->getCategoryHandler()->getObjects($criteria); $mytree = new XoopsObjectTree($categories, "categoryid", "parentid"); $cat_select = $mytree->makeSelBox('parentid', 'name', '--', $obj->getVar('parentid'), true); $this->addElement(new Xoops\Form\Label(_AM_PUBLISHER_PARENT_CATEGORY_EXP, $cat_select)); // Name $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY, 'name', 50, 255, $obj->getVar('name', 'e')), true); // Description $this->addElement(new Xoops\Form\TextArea(_AM_PUBLISHER_COLDESCRIPT, 'description', $obj->getVar('description', 'e'), 7, 60)); // EDITOR $groups = $xoops->getUserGroups(); $gperm_handler = $publisher->getGrouppermHandler(); $module_id = $publisher->getModule()->mid(); $allowed_editors = PublisherUtils::getEditors($gperm_handler->getItemIds('editors', $groups, $module_id)); $nohtml = false; if (count($allowed_editors) > 0) { $editor = @$_POST['editor']; if (!empty($editor)) { PublisherUtils::setCookieVar('publisher_editor', $editor); } else { $editor = PublisherUtils::getCookieVar('publisher_editor'); if (empty($editor) && $xoops->isUser()) { $editor = $xoops->user->getVar('publisher_editor'); // Need set through user profile } } $editor = empty($editor) || !in_array($editor, $allowed_editors) ? $publisher->getConfig('submit_editor') : $editor; $form_editor = new Xoops\Form\SelectEditor($this, 'editor', $editor, $nohtml, $allowed_editors); $this->addElement($form_editor); } else { $editor = $publisher->getConfig('submit_editor'); } $editor_configs = array(); $editor_configs['rows'] = $publisher->getConfig('submit_editor_rows') == '' ? 35 : $publisher->getConfig('submit_editor_rows'); $editor_configs['cols'] = $publisher->getConfig('submit_editor_cols') == '' ? 60 : $publisher->getConfig('submit_editor_cols'); $editor_configs['width'] = $publisher->getConfig('submit_editor_width') == '' ? "100%" : $publisher->getConfig('submit_editor_width'); $editor_configs['height'] = $publisher->getConfig('submit_editor_height') == '' ? "400px" : $publisher->getConfig('submit_editor_height'); $editor_configs['name'] = 'header'; $editor_configs['value'] = $obj->getVar('header', 'e'); $text_header = new Xoops\Form\Editor(_AM_PUBLISHER_CATEGORY_HEADER, $editor, $editor_configs, $nohtml, $onfailure = null); $text_header->setDescription(_AM_PUBLISHER_CATEGORY_HEADER_DSC); $this->addElement($text_header); // IMAGE $image_array = XoopsLists::getImgListAsArray(PublisherUtils::getImageDir('category')); $image_select = new Xoops\Form\Select('', 'image', $obj->image()); //$image_select -> addOption ('-1', '---------------'); $image_select->addOptionArray($image_array); $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/' . PUBLISHER_DIRNAME . '/images/category/' . "\", \"\", \"" . \XoopsBaseConfig::get('url') . "\")'"); $image_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_IMAGE, ' '); $image_tray->addElement($image_select); $image_tray->addElement(new Xoops\Form\Label('', "<br /><br /><img src='" . PublisherUtils::getImageDir('category', false) . $obj->image() . "' name='image3' id='image3' alt='' />")); $image_tray->setDescription(_AM_PUBLISHER_IMAGE_DSC); $this->addElement($image_tray); // IMAGE UPLOAD //$max_size = 5000000; $file_box = new Xoops\Form\File(_AM_PUBLISHER_IMAGE_UPLOAD, "image_file"); $file_box->setExtra("size ='45'"); $file_box->setDescription(_AM_PUBLISHER_IMAGE_UPLOAD_DSC); $this->addElement($file_box); // Short url $text_short_url = new Xoops\Form\Text(_AM_PUBLISHER_CATEGORY_SHORT_URL, 'short_url', 50, 255, $obj->getVar('short_url', 'e')); $text_short_url->setDescription(_AM_PUBLISHER_CATEGORY_SHORT_URL_DSC); $this->addElement($text_short_url); // Meta Keywords $text_meta_keywords = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_KEYWORDS, 'meta_keywords', $obj->getVar('meta_keywords', 'e'), 7, 60); $text_meta_keywords->setDescription(_AM_PUBLISHER_CATEGORY_META_KEYWORDS_DSC); $this->addElement($text_meta_keywords); // Meta Description $text_meta_description = new Xoops\Form\TextArea(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION, 'meta_description', $obj->getVar('meta_description', 'e'), 7, 60); $text_meta_description->setDescription(_AM_PUBLISHER_CATEGORY_META_DESCRIPTION_DSC); $this->addElement($text_meta_description); // Weight $this->addElement(new Xoops\Form\Text(_AM_PUBLISHER_COLPOSIT, 'weight', 4, 4, $obj->getVar('weight'))); // Added by skalpa: custom template support //todo, check this $this->addElement(new Xoops\Form\Text("Custom template", 'template', 50, 255, $obj->getVar('template', 'e')), false); // READ PERMISSIONS $groups_read_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_READ, 'groups_read[]', $obj->getGroups_read()); foreach ($userGroups as $group_id => $group_name) { $groups_read_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_read_checkbox); // SUBMIT PERMISSIONS $groups_submit_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT, 'groups_submit[]', $obj->getGroups_submit()); $groups_submit_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_SUBMIT_DSC); foreach ($userGroups as $group_id => $group_name) { $groups_submit_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_submit_checkbox); // MODERATION PERMISSIONS $groups_moderation_checkbox = new Xoops\Form\Checkbox(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR, 'groups_moderation[]', $obj->getGroups_moderation()); $groups_moderation_checkbox->setDescription(_AM_PUBLISHER_PERMISSIONS_CAT_MODERATOR_DSC); foreach ($userGroups as $group_id => $group_name) { $groups_moderation_checkbox->addOption($group_id, $group_name); } $this->addElement($groups_moderation_checkbox); $moderator = new Xoops\Form\SelectUser(_AM_PUBLISHER_CATEGORY_MODERATOR, 'moderator', true, $obj->getVar('moderator', 'e'), 1, false); $moderator->setDescription(_AM_PUBLISHER_CATEGORY_MODERATOR_DSC); $this->addElement($moderator); $cat_tray = new Xoops\Form\ElementTray(_AM_PUBLISHER_SCATEGORYNAME, '<br /><br />'); for ($i = 0; $i < $this->_subCatsCount; ++$i) { if ($i < (isset($_POST['scname']) ? sizeof($_POST['scname']) : 0)) { $subname = isset($_POST['scname']) ? $_POST['scname'][$i] : ''; } else { $subname = ''; } $cat_tray->addElement(new Xoops\Form\Text('', 'scname[' . $i . ']', 50, 255, $subname)); } $t = new Xoops\Form\Text('', 'nb_subcats', 3, 2); $l = new Xoops\Form\Label('', sprintf(_AM_PUBLISHER_ADD_OPT, $t->render())); $b = new Xoops\Form\Button('', 'submit_subcats', _AM_PUBLISHER_ADD_OPT_SUBMIT, 'submit'); if (!$obj->getVar('categoryid')) { $b->setExtra('onclick="this.form.elements.op.value=\'addsubcats\'"'); } else { $b->setExtra('onclick="this.form.elements.op.value=\'mod\'"'); } $r = new Xoops\Form\ElementTray(''); $r->addElement($l); $r->addElement($b); $cat_tray->addElement($r); $this->addElement($cat_tray); $this->addElement(new Xoops\Form\Hidden('categoryid', $obj->getVar('categoryid'))); $this->addElement(new Xoops\Form\Hidden('nb_sub_yet', $this->_subCatsCount)); // Action buttons tray $button_tray = new Xoops\Form\ElementTray('', ''); // No ID for category -- then it's new category, button says 'Create' if (!$obj->getVar('categoryid')) { $button_tray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_CREATE, 'submit')); $butt_clear = new Xoops\Form\Button('', '', _AM_PUBLISHER_CLEAR, 'reset'); $button_tray->addElement($butt_clear); $butt_cancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $this->addElement($button_tray); } else { $button_tray->addElement(new Xoops\Form\Button('', 'addcategory', _AM_PUBLISHER_MODIFY, 'submit')); $butt_cancel = new Xoops\Form\Button('', '', _AM_PUBLISHER_CANCEL, 'button'); $butt_cancel->setExtra('onclick="history.go(-1)"'); $button_tray->addElement($butt_cancel); $this->addElement($button_tray); } }
/** * __construct * * @param XoopsGroup|XoopsObject &$obj group object */ public function __construct(XoopsGroup &$obj) { $xoops = Xoops::getInstance(); if ($obj->isNew()) { $s_cat_value = ''; $a_mod_value = array(); $r_mod_value = array(); $r_block_value = array(); } else { $sysperm_handler = $xoops->getHandlerGroupperm(); $s_cat_value = $sysperm_handler->getItemIds('system_admin', $obj->getVar('groupid')); $member_handler = $xoops->getHandlerMember(); $thisgroup = $member_handler->getGroup($obj->getVar('groupid')); $moduleperm_handler = $xoops->getHandlerGroupperm(); $a_mod_value = $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid')); $r_mod_value = $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid')); $gperm_handler = $xoops->getHandlerGroupperm(); $r_block_value = $gperm_handler->getItemIds('block_read', $obj->getVar('groupid')); } include_once $xoops->path('/modules/system/constants.php'); $title = $obj->isNew() ? SystemLocale::ADD_NEW_GROUP : SystemLocale::EDIT_GROUP; parent::__construct($title, "groupform", 'admin.php', "post", true); $this->setExtra('enctype="multipart/form-data"'); $name_text = new Xoops\Form\Text(SystemLocale::GROUP_NAME, "name", 4, 50, $obj->getVar('name')); $desc_text = new Xoops\Form\TextArea(SystemLocale::GROUP_DESCRIPTION, "desc", $obj->getVar('description')); $system_catids = new Xoops\Form\ElementTray(SystemLocale::SYSTEM_ADMIN_RIGHTS, ''); $s_cat_checkbox_all = new Xoops\Form\Checkbox('', "catbox", 1); $s_cat_checkbox_all->addOption('allbox', XoopsLocale::ALL); $s_cat_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"catbox\" , \"system_catids[]\");' "); $s_cat_checkbox_all->setClass('xo-checkall'); $system_catids->addElement($s_cat_checkbox_all); $s_cat_checkbox = new Xoops\Form\Checkbox('', "system_catids", $s_cat_value); //$s_cat_checkbox->columns = 6; $admin_dir = \XoopsBaseConfig::get('root-path') . '/modules/system/admin/'; $dirlist = XoopsLists::getDirListAsArray($admin_dir); foreach ($dirlist as $file) { include \XoopsBaseConfig::get('root-path') . '/modules/system/admin/' . $file . '/xoops_version.php'; if (!empty($modversion['category'])) { if ($xoops->getModuleConfig('active_' . $file, 'system') == 1) { $s_cat_checkbox->addOption($modversion['category'], $modversion['name']); } } unset($modversion); } unset($dirlist); $system_catids->addElement($s_cat_checkbox); $admin_mids = new Xoops\Form\ElementTray(SystemLocale::MODULE_ADMIN_RIGHTS, ''); $s_admin_checkbox_all = new Xoops\Form\Checkbox('', "adminbox", 1); $s_admin_checkbox_all->addOption('allbox', XoopsLocale::ALL); $s_admin_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"adminbox\" , \"admin_mids[]\");' "); $s_admin_checkbox_all->setClass('xo-checkall'); $admin_mids->addElement($s_admin_checkbox_all); $a_mod_checkbox = new Xoops\Form\Checkbox('', "admin_mids[]", $a_mod_value); //$a_mod_checkbox->columns = 5; $module_handler = $xoops->getHandlerModule(); $criteria = new CriteriaCompo(new Criteria('hasadmin', 1)); $criteria->add(new Criteria('isactive', 1)); $criteria->add(new Criteria('dirname', 'system', '<>')); $a_mod_checkbox->addOptionArray($module_handler->getNameList($criteria)); $admin_mids->addElement($a_mod_checkbox); $read_mids = new Xoops\Form\ElementTray(SystemLocale::MODULE_ACCESS_RIGHTS, ''); $s_mod_checkbox_all = new Xoops\Form\Checkbox('', "readbox", 1); $s_mod_checkbox_all->addOption('allbox', XoopsLocale::ALL); $s_mod_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"readbox\" , \"read_mids[]\");' "); $s_mod_checkbox_all->setClass('xo-checkall'); $read_mids->addElement($s_mod_checkbox_all); $r_mod_checkbox = new Xoops\Form\Checkbox('', "read_mids[]", $r_mod_value); //$r_mod_checkbox->columns = 5; $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); $r_mod_checkbox->addOptionArray($module_handler->getNameList($criteria)); $read_mids->addElement($r_mod_checkbox); $criteria = new CriteriaCompo(new Criteria('isactive', 1)); $criteria->setSort("mid"); $criteria->setOrder("ASC"); $module_list = $module_handler->getNameList($criteria); $module_list[0] = SystemLocale::CUSTOM_BLOCK; $block_handler = $xoops->getHandlerBlock(); $blocks_obj = $block_handler->getDistinctObjects(new Criteria("mid", "('" . implode("', '", array_keys($module_list)) . "')", "IN"), true); $blocks_module = array(); foreach (array_keys($blocks_obj) as $bid) { $title = $blocks_obj[$bid]->getVar("title"); $blocks_module[$blocks_obj[$bid]->getVar('mid')][$blocks_obj[$bid]->getVar('bid')] = empty($title) ? $blocks_obj[$bid]->getVar("name") : $title; } ksort($blocks_module); $r_block_tray = new Xoops\Form\ElementTray(SystemLocale::BLOCK_ACCESS_RIGHTS, "<br /><br />"); $s_checkbox_all = new Xoops\Form\Checkbox('', "blocksbox", 1); $s_checkbox_all->addOption('allbox', XoopsLocale::ALL); $s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' "); $s_checkbox_all->setClass('xo-checkall'); $r_block_tray->addElement($s_checkbox_all); foreach (array_keys($blocks_module) as $mid) { $new_blocks_array = array(); foreach ($blocks_module[$mid] as $key => $value) { $new_blocks_array[$key] = "<a href='" . \XoopsBaseConfig::get('url') . "/modules/system/admin.php?fct=blocksadmin&op=edit&bid={$key}' " . "title='ID: {$key}' rel='external'>{$value}</a>"; } $r_block_checkbox = new Xoops\Form\Checkbox('<strong>' . $module_list[$mid] . '</strong><br />', "read_bids[]", $r_block_value); //$r_block_checkbox->columns = 5; $r_block_checkbox->addOptionArray($new_blocks_array); $r_block_tray->addElement($r_block_checkbox); unset($r_block_checkbox); } if (!$obj->isNew()) { $this->addElement(new Xoops\Form\Hidden('g_id', $obj->getVar('groupid'))); $this->addElement(new Xoops\Form\Hidden("op", "groups_save_update")); } else { $this->addElement(new Xoops\Form\Hidden("op", "groups_save_add")); } $this->addElement(new Xoops\Form\Hidden('fct', 'groups')); $this->addElement($name_text, true); $this->addElement($desc_text); $this->addElement($system_catids); $this->addElement($admin_mids); $this->addElement($read_mids); $this->addElement($r_block_tray); $this->addElement(new Xoops\Form\Button("", "submit", XoopsLocale::A_SUBMIT, "submit")); }
/** * @param AlumniCategory|XoopsObject $obj */ public function __construct(AlumniCategory &$obj) { $xoops = Xoops::getInstance(); $moduleDirName = basename(dirname(__DIR__)); $admin_lang = '_AM_' . strtoupper($moduleDirName); $title = $obj->isNew() ? sprintf(AlumniLocale::ADD_CAT) : sprintf(AlumniLocale::EDIT_CAT); parent::__construct($title, 'form', false, 'post', true); include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $this->setExtra('enctype="multipart/form-data"'); include_once XOOPS_ROOT_PATH . '/class/tree.php'; $categoryHandler = $xoops->getModuleHandler('category', 'alumni'); $arr = $categoryHandler->getall(); $mytree = new XoopsObjectTree($arr, 'cid', 'pid'); $this->addElement(new Xoops\Form\Label(AlumniLocale::CATEGORY_PID, $mytree->makeSelBox('pid', 'title', '-', $obj->getVar('pid'), true))); $this->addElement(new Xoops\Form\Text(AlumniLocale::CATEGORY_TITLE, 'title', 50, 255, $obj->getVar('title')), true); if ($obj->isNew()) { $default_img = 'default.gif'; } else { $default_img = str_replace('alumni/', '', $obj->getVar('img', 'e')); } $img = $obj->getVar("img") ? $obj->getVar("img") : 'default.gif'; $imgtray_img = new Xoops\Form\ElementTray(AlumniLocale::IMGCAT, '<br />'); $img_path = \XoopsBaseConfig::get('root-path') . '/modules/alumni/images/cat'; $imgpath_img = sprintf(AlumniLocale::FORMIMAGE_PATH, $img_path); $imageselect_img = new Xoops\Form\Select(sprintf(XoopsLocale::F_FILE_EXISTS_IN, $img_path . '/'), 'img', $img); $image_array_img = XoopsLists::getImgListAsArray($img_path); $imageselect_img->addOption("{$default_img}", $default_img); foreach ($image_array_img as $image_img) { $imageselect_img->addOption("{$image_img}", $image_img); } $alumni_upload_url = \XoopsBaseConfig::get('url') . '/modules/alumni/images/cat'; $imageselect_img->setExtra("onchange='showImgSelected(\"image_img\", \"img\", \"\", \"\", \"" . $alumni_upload_url . "\")'"); $imgtray_img->addElement($imageselect_img, false); $imgtray_img->addElement(new Xoops\Form\Label('', "<br /><img src='" . $alumni_upload_url . "/" . $img . "' name='image_img' id='image_img' alt='' />")); $fileseltray_category_img = new Xoops\Form\ElementTray('<br />', '<br />'); $fileseltray_category_img->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, "img"), false); $fileseltray_category_img->addElement(new Xoops\Form\Label(''), false); $imgtray_img->addElement($fileseltray_category_img); $this->addElement($imgtray_img); $this->addElement(new Xoops\Form\Text(AlumniLocale::ORDER, 'ordre', 4, 4, $obj->getVar('ordre')), false); $this->addElement(new Xoops\Form\Label(AlumniLocale::IFSCHOOL, '')); $photo_old = $obj->getVar('scphoto') ? $obj->getVar('scphoto') : ''; $uploadirectory_photo = XOOPS_ROOT_PATH . "/modules/{$moduleDirName}/photos/school_photos"; $imgtray_photo = new Xoops\Form\ElementTray(AlumniLocale::SCPHOTO, '<br />'); $imgpath_photo = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo); $fileseltray_photo = new Xoops\Form\ElementTray('', '<br />'); $fileseltray_photo->addElement(new XoopsFormFile(AlumniLocale::FORMUPLOAD, 'scphoto', $xoops->getModuleConfig('alumni_photomax')), false); if ($photo_old) { $fileseltray_photo->addElement(new Xoops\Form\Label(AlumniLocale::SELECTED_PHOTO, '<a href="../photos/school_photos/' . $photo_old . '">' . $photo_old . '</a>', false)); $imgtray_checkbox = new Xoops\Form\Checkbox('', 'del_photo', 0); $imgtray_checkbox->addOption(1, AlumniLocale::DELPICT); $fileseltray_photo->addElement($imgtray_checkbox); } $imgtray_photo->addElement($fileseltray_photo); $this->addElement($imgtray_photo); $this->addElement(new Xoops\Form\Hidden('photo_old', $photo_old)); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCADDRESS, 'scaddress', 50, 255, $obj->getVar('scaddress')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCADDRESS2, 'scaddress2', 50, 255, $obj->getVar('scaddress2')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCCITY, 'sccity', 50, 255, $obj->getVar('sccity')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCSTATE, 'scstate', 50, 255, $obj->getVar('scstate')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCZIP, 'sczip', 50, 255, $obj->getVar('sczip')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCPHONE, 'scphone', 50, 255, $obj->getVar('scphone')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCFAX, 'scfax', 50, 255, $obj->getVar('scfax')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCMOTTO, 'scmotto', 50, 255, $obj->getVar('scmotto')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::SCURL, 'scurl', 50, 255, $obj->getVar('scurl')), false); $this->addElement(new Xoops\Form\Hidden('op', 'save_category')); $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); }
$fromemail = $xoops->getConfig('from') ? $xoops->getConfig('from') : $xoops->user->getVar("email", "E"); $femail_text = new Xoops\Form\Text(_AM_MAILUSERS_MAILFMAIL, "mail_fromemail", 30, 255, $fromemail); $subject_caption = _AM_MAILUSERS_MAILSUBJECT . "<br /><br /><span style='font-size:x-small;font-weight:bold;'>" . _AM_MAILUSERS_MAILTAGS . "</span><br /><span style='font-size:x-small;font-weight:normal;'>" . _AM_MAILUSERS_MAILTAGS2 . "</span>"; $subject_text = new Xoops\Form\Text($subject_caption, "mail_subject", 50, 255); $body_caption = _AM_MAILUSERS_MAILBODY . "<br /><br /><span style='font-size:x-small;font-weight:bold;'>" . _AM_MAILUSERS_MAILTAGS . "</span><br /><span style='font-size:x-small;font-weight:normal;'>" . _AM_MAILUSERS_MAILTAGS1 . "<br />" . _AM_MAILUSERS_MAILTAGS2 . "<br />" . _AM_MAILUSERS_MAILTAGS3 . "<br />" . _AM_MAILUSERS_MAILTAGS4 . "</span>"; $editor_configs = array(); $editor_configs["name"] = "mail_body"; $editor_configs["value"] = ''; $editor_configs["rows"] = 20; $editor_configs["cols"] = 100; $editor_configs["width"] = "100%"; $editor_configs["height"] = "400px"; $editor_configs["editor"] = $xoops->getModuleConfig('mailusers_editor'); $body_text = new Xoops\Form\Editor($body_caption, "mail_body", $editor_configs); //$body_text = new Xoops\Form\TextArea($body_caption, "mail_body", "", 10); $to_checkbox = new Xoops\Form\Checkbox(_AM_MAILUSERS_SENDTO, "mail_send_to", "mail"); $to_checkbox->addOption("mail", _AM_MAILUSERS_EMAIL); $to_checkbox->addOption("pm", _AM_MAILUSERS_PM); $start_hidden = new Xoops\Form\Hidden("mail_start", 0); $op_hidden = new Xoops\Form\Hidden("op", "send"); $submit_button = new Xoops\Form\Button("", "mail_submit", XoopsLocale::A_SEND, "submit"); $form->addElement($fname_text); $form->addElement($femail_text); $form->addElement($subject_text); $form->addElement($body_text); $form->addElement($to_checkbox); $form->addElement($op_hidden); $form->addElement($start_hidden); $form->addElement($submit_button); $form->setRequired($subject_text); $form->setRequired($body_text);
/** * @param ProfileField|XoopsObject $obj */ public function __construct(ProfileField $obj) { $xoops = Xoops::getInstance(); $title = $obj->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD); parent::__construct($title, 'form', '', 'post', true); $this->addElement(new Xoops\Form\Text(_PROFILE_AM_TITLE, 'field_title', 5, 255, $obj->getVar('field_title', 'e')), true); $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $obj->getVar('field_description', 'e'), 5, 5)); if (!$obj->isNew()) { $fieldcat_id = $obj->getVar('cat_id'); } else { $fieldcat_id = 0; } $category_handler = $xoops->getModuleHandler('category'); $cat_select = new Xoops\Form\Select(_PROFILE_AM_CATEGORY, 'field_category', $fieldcat_id); $cat_select->addOption(0, _PROFILE_AM_DEFAULT); $cat_select->addOptionArray($category_handler->getList()); $this->addElement($cat_select); $weight = new Xoops\Form\Text(_PROFILE_AM_WEIGHT, 'field_weight', 1, 10, $obj->getVar('field_weight', 'e'), ''); $weight->setPattern('^\\d+$', _PROFILE_AM_ERROR_WEIGHT); $this->addElement($weight, true); if ($obj->getVar('field_config') || $obj->isNew()) { if (!$obj->isNew()) { $this->addElement(new Xoops\Form\Label(_PROFILE_AM_NAME, $obj->getVar('field_name'))); $this->addElement(new Xoops\Form\Hidden('id', $obj->getVar('field_id'))); } else { $this->addElement(new Xoops\Form\Text(_PROFILE_AM_NAME, 'field_name', 5, 255, $obj->getVar('field_name', 'e')), true); } //autotext and theme left out of this one as fields of that type should never be changed (valid assumption, I think) $fieldtypes = array('checkbox' => _PROFILE_AM_CHECKBOX, 'date' => _PROFILE_AM_DATE, 'datetime' => _PROFILE_AM_DATETIME, 'longdate' => _PROFILE_AM_LONGDATE, 'group' => _PROFILE_AM_GROUP, 'group_multi' => _PROFILE_AM_GROUPMULTI, 'language' => _PROFILE_AM_LANGUAGE, 'radio' => _PROFILE_AM_RADIO, 'select' => _PROFILE_AM_SELECT, 'select_multi' => _PROFILE_AM_SELECTMULTI, 'textarea' => _PROFILE_AM_TEXTAREA, 'dhtml' => _PROFILE_AM_DHTMLTEXTAREA, 'textbox' => _PROFILE_AM_TEXTBOX, 'timezone' => _PROFILE_AM_TIMEZONE, 'yesno' => _PROFILE_AM_YESNO); $element_select = new Xoops\Form\Select(_PROFILE_AM_TYPE, 'field_type', $obj->getVar('field_type', 'e')); $element_select->addOptionArray($fieldtypes); $this->addElement($element_select); switch ($obj->getVar('field_type')) { case "textbox": $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER); $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e'), 5, 5); $type_select->addOptionArray($valuetypes); $this->addElement($type_select); break; case "select": case "radio": $valuetypes = array(XOBJ_DTYPE_ARRAY => _PROFILE_AM_ARRAY, XOBJ_DTYPE_EMAIL => _PROFILE_AM_EMAIL, XOBJ_DTYPE_INT => _PROFILE_AM_INT, XOBJ_DTYPE_FLOAT => _PROFILE_AM_FLOAT, XOBJ_DTYPE_DECIMAL => _PROFILE_AM_DECIMAL, XOBJ_DTYPE_TXTAREA => _PROFILE_AM_TXTAREA, XOBJ_DTYPE_TXTBOX => _PROFILE_AM_TXTBOX, XOBJ_DTYPE_URL => _PROFILE_AM_URL, XOBJ_DTYPE_OTHER => _PROFILE_AM_OTHER); $type_select = new Xoops\Form\Select(_PROFILE_AM_VALUETYPE, 'field_valuetype', $obj->getVar('field_valuetype', 'e')); $type_select->addOptionArray($valuetypes); $this->addElement($type_select); break; } //$this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_NOTNULL, 'field_notnull', $obj->getVar('field_notnull', 'e') )); if ($obj->getVar('field_type') == "select" || $obj->getVar('field_type') == "select_multi" || $obj->getVar('field_type') == "radio" || $obj->getVar('field_type') == "checkbox") { $options = $obj->getVar('field_options'); if (count($options) > 0) { $remove_options = new Xoops\Form\Checkbox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions'); //$remove_options->columns = 3; asort($options); foreach (array_keys($options) as $key) { $options[$key] .= "[{$key}]"; } $remove_options->addOptionArray($options); $this->addElement($remove_options); } $option_text = "<table cellspacing='1'><tr><td class='width20'>" . _PROFILE_AM_KEY . "</td><td>" . _PROFILE_AM_VALUE . "</td></tr>"; for ($i = 0; $i < 3; ++$i) { $option_text .= "<tr><td><input type='text' name='addOption[{$i}][key]' id='addOption[{$i}][key]' size='15' /></td><td><input type='text' name='addOption[{$i}][value]' id='addOption[{$i}][value]' size='35' /></td></tr>"; $option_text .= "<tr height='3px'><td colspan='2'> </td></tr>"; } $option_text .= "</table>"; $this->addElement(new Xoops\Form\Label(_PROFILE_AM_ADDOPTION, $option_text)); } } if ($obj->getVar('field_edit')) { switch ($obj->getVar('field_type')) { case "textbox": case "textarea": case "dhtml": $this->addElement(new Xoops\Form\Text(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 5, 5, $obj->getVar('field_maxlength', 'e'))); $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; case "checkbox": case "select_multi": $def_value = $obj->getVar('field_default', 'e') != null ? unserialize($obj->getVar('field_default', 'n')) : null; $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true); $options = $obj->getVar('field_options'); asort($options); // 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); } $element->addOptionArray($options); $this->addElement($element); break; case "select": case "radio": $def_value = $obj->getVar('field_default', 'e') != null ? $obj->getVar('field_default') : null; $element = new Xoops\Form\Select(_PROFILE_AM_DEFAULT, 'field_default', $def_value); $options = $obj->getVar('field_options'); asort($options); // 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); } $element->addOptionArray($options); $this->addElement($element); break; case "date": $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e'))); break; case "longdate": $this->addElement(new Xoops\Form\DateSelect(_PROFILE_AM_DEFAULT, 'field_default', 2, strtotime($obj->getVar('field_default', 'e')))); break; case "datetime": $this->addElement(new Xoops\Form\DateTime(_PROFILE_AM_DEFAULT, 'field_default', 2, $obj->getVar('field_default', 'e'))); break; case "yesno": $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; case "timezone": $this->addElement(new Xoops\Form\SelectTimeZone(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; case "language": $this->addElement(new Xoops\Form\SelectLanguage(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; case "group": $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, $obj->getVar('field_default', 'e'))); break; case "group_multi": $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_DEFAULT, 'field_default', true, unserialize($obj->getVar('field_default', 'n')), 5, true)); break; case "theme": $this->addElement(new Xoops\Form\SelectTheme(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; case "autotext": $this->addElement(new Xoops\Form\TextArea(_PROFILE_AM_DEFAULT, 'field_default', $obj->getVar('field_default', 'e'))); break; } } $groupperm_handler = $xoops->getHandlerGroupperm(); $searchable_types = array('textbox', 'select', 'radio', 'yesno', 'date', 'datetime', 'timezone', 'language'); if (in_array($obj->getVar('field_type'), $searchable_types)) { $search_groups = $groupperm_handler->getGroupIds('profile_search', $obj->getVar('field_id'), $xoops->module->getVar('mid')); $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_SEARCH, 'profile_search', true, $search_groups, 5, true)); } if ($obj->getVar('field_edit') || $obj->isNew()) { if (!$obj->isNew()) { //Load groups $editable_groups = $groupperm_handler->getGroupIds('profile_edit', $obj->getVar('field_id'), $xoops->module->getVar('mid')); } else { $editable_groups = array(); } $this->addElement(new Xoops\Form\SelectGroup(_PROFILE_AM_PROF_EDITABLE, 'profile_edit', false, $editable_groups, 5, true)); $this->addElement(new Xoops\Form\RadioYesNo(_PROFILE_AM_REQUIRED, 'field_required', $obj->getVar('field_required', 'e'))); $regstep_select = new Xoops\Form\Select(_PROFILE_AM_PROF_REGISTER, 'step_id', $obj->getVar('step_id', 'e')); $regstep_select->addOption(0, XoopsLocale::NO); $regstep_handler = $xoops->getModuleHandler('regstep'); $regstep_select->addOptionArray($regstep_handler->getList()); $this->addElement($regstep_select); } $this->addElement(new Xoops\Form\Hidden('op', 'save')); $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); }
/** * @param PagePage_content|XoopsObject $obj */ public function __construct(PagePage_content $obj) { $helper = Page::getInstance(); $xoops = $helper->xoops(); $xoops->theme()->addStylesheet('modules/page/css/styles.css'); $title = $obj->isNew() ? PageLocale::A_ADD_CONTENT : PageLocale::A_EDIT_CONTENT; parent::__construct($title, 'form', 'content.php', 'post', true, 'raw'); $tabTray = new Xoops\Form\TabTray('', 'uniqueid'); /** * Main */ $tab1 = new Xoops\Form\Tab(PageLocale::TAB_MAIN, 'main'); //Author // if ($helper->isUserAdmin()) { $content_author = $obj->isNew() ? $xoops->user->getVar('uid') : $obj->getVar('content_author'); $tab1->addElement(new Xoops\Form\SelectUser(XoopsLocale::AUTHOR, 'content_author', true, $content_author, 1, false), true); // } //date $tab1->addElement(new Xoops\Form\DateTime(XoopsLocale::DATE, 'content_create', $obj->getVar('content_create'))); //title $tab1->addElement(new Xoops\Form\Text(XoopsLocale::TITLE, 'content_title', 12, 255, $obj->getVar('content_title'), ''), true); // editor $editor_configs = array(); $editor_configs['editor'] = $helper->getConfig('page_editor'); $editor_configs['rows'] = 12; $editor_configs['cols'] = 12; //short text $editor_configs['name'] = 'content_shorttext'; $editor_configs['value'] = $obj->getVar('content_shorttext', 'e'); $tab1->addElement(new Xoops\Form\Editor(XoopsLocale::SHORT_TEXT, 'content_shorttext', $editor_configs), true); //text $editor_configs['name'] = 'content_text'; $editor_configs['value'] = $obj->getVar('content_text', 'e'); $text = new Xoops\Form\Editor(XoopsLocale::TEXT, 'content_text', $editor_configs); $text->setDescription(PageLocale::CONTENT_TEXT_DESC); $tab1->addElement($text, false); //Weight $weight = new Xoops\Form\Text(XoopsLocale::WEIGHT, 'content_weight', 1, 5, $obj->getVar('content_weight'), ''); $weight->setPattern('^\\d+$', PageLocale::E_WEIGHT); $tab1->addElement($weight, true); $tabTray->addElement($tab1); /** * Metas */ $tab2 = new Xoops\Form\Tab(PageLocale::TAB_METAS, 'metas'); //content_mkeyword $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_KEYWORDS, 'content_mkeyword', $obj->getVar('content_mkeyword'), 1, 11, PageLocale::CONTENT_META_KEYWORDS_DSC)); //content_mdescription $tab2->addElement(new Xoops\Form\TextArea(PageLocale::CONTENT_META_DESCRIPTION, 'content_mdescription', $obj->getVar('content_mdescription'), 5, 11)); $tabTray->addElement($tab2); /** * Options */ $tab3 = new Xoops\Form\Tab(PageLocale::TAB_OPTIONS, 'options'); //Options $content_option = $obj->getOptions(); $checkbox = new Xoops\Form\Checkbox(XoopsLocale::OPTIONS, 'content_option', $content_option, false); $checkbox->setDescription(PageLocale::CONTENT_OPTIONS_DSC); foreach ($obj->options as $option) { $checkbox->addOption($option, \Xoops\Locale::translate('L_CONTENT_DO' . strtoupper($option), 'page')); } $tab3->addElement($checkbox); //maindisplay $tab3->addElement(new Xoops\Form\RadioYesNo(PageLocale::Q_ON_MAIN_PAGE, 'content_maindisplay', $obj->getVar('content_maindisplay'))); //active $tab3->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::ACTIVE, 'content_status', $obj->getVar('content_status'))); $tabTray->addElement($tab3); /** * Permissions */ if ($helper->isUserAdmin()) { $tab4 = new Xoops\Form\Tab(PageLocale::TAB_PERMISSIONS, 'permissions'); //permissions $group_list = $xoops->getHandlerMember()->getGroupList(); $full_list = array_keys($group_list); if (!$obj->isNew()) { $module_id = $helper->getModule()->getVar('mid', 'n'); $groups_ids_view = $helper->getGrouppermHandler()->getGroupIds('page_view_item', $obj->getVar('content_id'), $module_id); $groups_ids_view = array_values($groups_ids_view); $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $groups_ids_view, false); } else { $groups_can_view_checkbox = new Xoops\Form\Checkbox(PageLocale::CONTENT_SELECT_GROUPS, 'groups_view_item[]', $full_list, false); } $groups_can_view_checkbox->addOptionArray($group_list); $tab4->addElement($groups_can_view_checkbox); $tabTray->addElement($tab4); } $this->addElement($tabTray); $this->addElement(new Xoops\Form\Hidden('content_id', $obj->getVar('content_id'))); /** * Buttons */ $buttonTray = new Xoops\Form\ElementTray('', ''); $buttonTray->addElement(new Xoops\Form\Hidden('op', 'save')); $buttonSubmit = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit'); $buttonSubmit->setClass('btn btn-success'); $buttonTray->addElement($buttonSubmit); $buttonReset = new Xoops\Form\Button('', 'reset', XoopsLocale::A_RESET, 'reset'); $buttonReset->setClass('btn btn-warning'); $buttonTray->addElement($buttonReset); $buttonCancel = new Xoops\Form\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button'); $buttonCancel->setExtra("onclick='javascript:history.go(-1);'"); $buttonCancel->setClass('btn btn-danger'); $buttonTray->addElement($buttonCancel); $this->addElement($buttonTray); }
/** * Get {@link Xoops\Form\ThemeForm} for registering new users * * @param XoopsUser $user * @param $profile * @param null $step * @return Xoops\Form\ThemeForm */ function profile_getRegisterForm(XoopsUser $user, $profile, $step = null) { $xoops = Xoops::getInstance(); $action = $_SERVER['REQUEST_URI']; $step_no = $step['step_no']; $use_token = $step['step_no'] > 0 ? true : false; $reg_form = new Xoops\Form\ThemeForm($step['step_name'], 'regform', $action, 'post', $use_token); if ($step['step_desc']) { $reg_form->addElement(new Xoops\Form\Label('', $step['step_desc'])); } if ($step_no == 1) { //$uname_size = $GLOBALS['xoopsConfigUser']['maxuname'] < 35 ? $GLOBALS['xoopsConfigUser']['maxuname'] : 35; $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', 5, $xoops->getConfig('maxuname'), $user->getVar('uname', 'e')), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Text(XoopsLocale::EMAIL, 'email', 5, 255, $user->getVar('email', 'e')), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Password(XoopsLocale::PASSWORD, 'pass', 5, 32, ''), 'required' => true); $weights[0][] = 0; $elements[0][] = array('element' => new Xoops\Form\Password(XoopsLocale::VERIFY_PASSWORD, 'vpass', 5, 32, ''), 'required' => true); $weights[0][] = 0; } // Dynamic fields /* @var $profile_handler ProfileProfileHandler */ $profile_handler = \Xoops::getModuleHelper('profile')->getHandler('profile'); $fields = $profile_handler->loadFields(); $_SESSION['profile_required'] = array(); $weights = array(); /* @var ProfileField $field */ foreach ($fields as $field) { if ($field->getVar('step_id') == $step['step_id']) { $fieldinfo['element'] = $field->getEditElement($user, $profile); //assign and check (=) if ($fieldinfo['required'] = $field->getVar('field_required')) { $_SESSION['profile_required'][$field->getVar('field_name')] = $field->getVar('field_title'); } $key = $field->getVar('cat_id'); $elements[$key][] = $fieldinfo; $weights[$key][] = $field->getVar('field_weight'); } } ksort($elements); foreach (array_keys($elements) as $k) { array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]); foreach (array_keys($elements[$k]) as $i) { $reg_form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']); } } //end of Dynamic User fields $myts = MyTextSanitizer::getInstance(); if ($step_no == 1 && $xoops->getConfig('reg_dispdsclmr') != 0 && $xoops->getConfig('reg_disclaimer') != '') { $disc_tray = new Xoops\Form\ElementTray(XoopsLocale::DISCLAIMER, '<br />'); $disc_text = new Xoops\Form\Label("", "<div class=\"pad5\">" . $myts->displayTarea($xoops->getConfig('reg_disclaimer'), 1) . "</div>"); $disc_tray->addElement($disc_text); $agree_chk = new Xoops\Form\Checkbox('', 'agree_disc'); $agree_chk->addOption(1, XoopsLocale::I_AGREE_TO_THE_ABOVE); $disc_tray->addElement($agree_chk); $reg_form->addElement($disc_tray); } if ($step_no == 1) { $reg_form->addElement(new Xoops\Form\Captcha(), true); } $reg_form->addElement(new Xoops\Form\Hidden('uid', $user->getVar('uid'))); $reg_form->addElement(new Xoops\Form\Hidden('step', $step_no)); $reg_form->addElement(new Xoops\Form\Button('', 'submitButton', XoopsLocale::A_SUBMIT, 'submit')); return $reg_form; }
$radio_inline->addOption(3, 'Radio Inline 3'); $radio_inline->setDescription('Description Radio Inline'); $tab2->addElement($radio_inline, false); $radio = new Xoops\Form\Radio('Radio', 'radio', 2, false); $radio->addOption(1, 'Radio 1'); $radio->addOption(2, 'Radio 2'); $radio->addOption(3, 'Radio 3'); $radio->setDescription('Description Radio'); $tab2->addElement($radio, false); $checkbox_inline = new Xoops\Form\Checkbox('Checkbox Inline', 'checkbox_inline', 1, true); $checkbox_inline->addOption(1, 'Checkbox Inline 1'); $checkbox_inline->addOption(2, 'Checkbox Inline 2'); $checkbox_inline->addOption(3, 'Checkbox Inline 3'); $checkbox_inline->setDescription('Description Checkbox Inline'); $tab3->addElement($checkbox_inline, true); $checkbox = new Xoops\Form\Checkbox('Checkbox', 'checkbox', 2, false); $checkbox->addOption(1, 'Checkbox 1'); $checkbox->addOption(2, 'Checkbox 2'); $checkbox->addOption(3, 'Checkbox 3'); $checkbox->setDescription('Description Checkbox'); $tab3->addElement($checkbox, true); $label = new Xoops\Form\Label('Label', 'label', 'label'); $label->setDescription('Description Label'); $tab3->addElement($label, true); $color = new Xoops\Form\ColorPicker('Color', 'color'); $color->setDescription('Description Color'); $tab3->addElement($color, true); $file = new Xoops\Form\File('File', 'file'); $file->setDescription('Description File'); $tab3->addElement($file, true); $select = new Xoops\Form\Select('Select', 'select', '', 1, false);
$form->addElement($email_tray); $url_text = new Xoops\Form\Text(XoopsLocale::WEBSITE, 'url', 30, 100, $xoops->user->getVar('url', 'E')); $form->addElement($url_text); $timezone_select = new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, 'timezone', $xoops->user->getVar('timezone')); $icq_text = new Xoops\Form\Text(XoopsLocale::ICQ, 'user_icq', 15, 15, $xoops->user->getVar('user_icq', 'E')); $aim_text = new Xoops\Form\Text(XoopsLocale::AIM, 'user_aim', 18, 18, $xoops->user->getVar('user_aim', 'E')); $yim_text = new Xoops\Form\Text(XoopsLocale::YIM, 'user_yim', 25, 25, $xoops->user->getVar('user_yim', 'E')); $msnm_text = new Xoops\Form\Text(XoopsLocale::MSNM, 'user_msnm', 30, 100, $xoops->user->getVar('user_msnm', 'E')); $location_text = new Xoops\Form\Text(XoopsLocale::LOCATION, 'user_from', 30, 100, $xoops->user->getVar('user_from', 'E')); $occupation_text = new Xoops\Form\Text(XoopsLocale::OCCUPATION, 'user_occ', 30, 100, $xoops->user->getVar('user_occ', 'E')); $interest_text = new Xoops\Form\Text(XoopsLocale::INTEREST, 'user_intrest', 30, 150, $xoops->user->getVar('user_intrest', 'E')); $sig_tray = new Xoops\Form\ElementTray(XoopsLocale::SIGNATURE, '<br />'); $sig_tarea = new Xoops\Form\DhtmlTextArea('', 'user_sig', $xoops->user->getVar('user_sig', 'E')); $sig_tray->addElement($sig_tarea); $sig_cbox_value = $xoops->user->getVar('attachsig') ? 1 : 0; $sig_cbox = new Xoops\Form\Checkbox('', 'attachsig', $sig_cbox_value); $sig_cbox->addOption(1, XoopsLocale::ALWAYS_ATTACH_MY_SIGNATURE); $sig_tray->addElement($sig_cbox); $bio_tarea = new Xoops\Form\TextArea(XoopsLocale::EXTRA_INFO, 'bio', $xoops->user->getVar('bio', 'E')); $pwd_text = new Xoops\Form\Password('', 'password'); $pwd_text2 = new Xoops\Form\Password('', 'vpass'); $pwd_tray = new Xoops\Form\ElementTray(XoopsLocale::PASSWORD . '<br />' . XoopsLocale::TYPE_NEW_PASSWORD_TWICE_TO_CHANGE_IT); $pwd_tray->addElement($pwd_text); $pwd_tray->addElement($pwd_text2); $mailok_radio = new Xoops\Form\RadioYesNo(XoopsLocale::Q_RECEIVE_OCCASIONAL_EMAIL_NOTICES_FROM_ADMINISTRATORS, 'user_mailok', $xoops->user->getVar('user_mailok')); $uid_hidden = new Xoops\Form\Hidden('uid', $xoops->user->getVar('uid')); $op_hidden = new Xoops\Form\Hidden('op', 'saveuser'); $submit_button = new Xoops\Form\Button('', 'submit', XoopsLocale::SAVE_CHANGES, 'submit'); $form->addElement($timezone_select); $form->addElement($icq_text); $form->addElement($aim_text);
/** * @param AlumniCategory|XoopsObject $obj */ public function __construct(AlumniListing &$obj) { $xoops = Xoops::getInstance(); if ($xoops->getModuleConfig('alumni_moderated') == '1') { $title = $obj->isNew() ? sprintf(AlumniLocale::ADD_MOD) : sprintf(AlumniLocale::EDIT_MOD); } else { $title = $obj->isNew() ? sprintf(AlumniLocale::ADD_LISTING) : sprintf(AlumniLocale::EDIT_LISTING); } parent::__construct($title, 'form', false, 'post', true); $this->setExtra('enctype="multipart/form-data"'); $member_handler = $xoops->getHandlerMember(); $userGroups = $member_handler->getGroupList(); $lid = Request::getInt('lid', 0); if (isset($lid)) { $lid = $lid; } $this->addElement(new Xoops\Form\Label(AlumniLocale::SUBMITTER, $xoops->user->uname())); $categoryHandler = $xoops->getmodulehandler('category', 'alumni'); $categories = $categoryHandler->getObjects(); $mytree = new XoopsObjectTree($categories, 'cid', 'pid'); if ($obj->isNew()) { $this_cid = Request::getInt('cid', 0); } else { $this_cid = $obj->getVar('cid'); } $categories_Handler = $xoops->getmodulehandler('category', 'alumni'); $categories = $categories_Handler->getObjects(); $mytree = new XoopsObjectTree($categories, 'cid', 'pid'); $category_select = $mytree->makeSelBox('cid', 'title', '--', $this_cid, true); $this->addElement(new Xoops\Form\Label(AlumniLocale::SCHOOL, $category_select), true); $cat_name = ''; $categories_Handler = $xoops->getModuleHandler('category', 'alumni'); $catObj = $categories_Handler->get($obj->getVar('cid')); $cat_name = $catObj->getVar('title'); $this->addElement(new Xoops\Form\Hidden('school', $cat_name)); $this->addElement(new Xoops\Form\Text(AlumniLocale::NAME_2, 'name', 50, 255, $obj->getVar('name')), true); $this->addElement(new Xoops\Form\Text(AlumniLocale::MNAME_2, 'mname', 50, 255, $obj->getVar('mname')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::LNAME_2, 'lname', 50, 255, $obj->getVar('lname')), true); $this->addElement(new Xoops\Form\Text(AlumniLocale::CLASS_OF_2, 'year', 50, 255, $obj->getVar('year')), true); $this->addElement(new Xoops\Form\Text(AlumniLocale::STUDIES_2, 'studies', 50, 255, $obj->getVar('studies')), false); $activities = $obj->getVar('activities', 'e') ? $obj->getVar('activities', 'e') : ''; $editor_configs = array(); $editor_configs['name'] = 'activities'; $editor_configs['value'] = $activities; $editor_configs['editor'] = $xoops->getModuleConfig('alumni_form_options'); $editor_configs['rows'] = 6; $editor_configs['cols'] = 8; $this->addElement(new Xoops\Form\Editor(AlumniLocale::ACTIVITIES, 'activities', $editor_configs), false); $extrainfo = $obj->getVar('extrainfo', 'e') ? $obj->getVar('extrainfo', 'e') : ''; $editor_configs = array(); $editor_configs['name'] = 'extrainfo'; $editor_configs['value'] = $extrainfo; $editor_configs['editor'] = $xoops->getModuleConfig('alumni_form_options'); $editor_configs['rows'] = 6; $editor_configs['cols'] = 8; $this->addElement(new Xoops\Form\Editor(AlumniLocale::EXTRAINFO, 'extrainfo', $editor_configs), false); $photo_old = $obj->getVar('photo') ? $obj->getVar('photo') : ''; $uploadirectory_photo = XOOPS_ROOT_PATH . "/modules/alumni/photos/grad_photo"; $imgtray_photo = new Xoops\Form\ElementTray(AlumniLocale::GRAD_PHOTO, '<br />'); $imgpath_photo = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo); $fileseltray_photo = new Xoops\Form\ElementTray('', '<br />'); $fileseltray_photo->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, 'photo', $xoops->getModuleConfig('alumni_photomax')), false); if ($photo_old) { $fileseltray_photo->addElement(new Xoops\Form\Label(AlumniLocale::PHOTO2, '<a href="photos/grad_photo/' . $photo_old . '">' . $photo_old . '</a>', false)); $imgtray_checkbox = new Xoops\Form\Checkbox('', 'del_photo', 0); $imgtray_checkbox->addOption(1, AlumniLocale::DELPICT); $fileseltray_photo->addElement($imgtray_checkbox); } $imgtray_photo->addElement($fileseltray_photo); $this->addElement($imgtray_photo); $this->addElement(new Xoops\Form\Hidden('photo_old', $photo_old)); $photo2_old = $obj->getVar('photo2') ? $obj->getVar('photo2') : ''; $uploadirectory_photo2 = XOOPS_ROOT_PATH . "/modules/alumni/photos/now_photo"; $imgtray_photo2 = new Xoops\Form\ElementTray(AlumniLocale::NOW_PHOTO, '<br />'); $imgpath_photo2 = sprintf(AlumniLocale::FORMIMAGE_PATH, $uploadirectory_photo2); $fileseltray_photo2 = new Xoops\Form\ElementTray('', '<br />'); $fileseltray_photo2->addElement(new Xoops\Form\File(AlumniLocale::FORMUPLOAD, 'photo2', $xoops->getModuleConfig('alumni_photomax')), false); if ($photo2_old) { $fileseltray_photo2->addElement(new Xoops\Form\Label(AlumniLocale::PHOTO2, '<a href="photos/now_photo/' . $photo2_old . '">' . $photo2_old . '</a>', false)); $imgtray_checkbox2 = new Xoops\Form\Checkbox('', 'del_photo2', 0); $imgtray_checkbox2->addOption(1, AlumniLocale::DELPICT); $fileseltray_photo2->addElement($imgtray_checkbox2); } $imgtray_photo2->addElement($fileseltray_photo2); $this->addElement($imgtray_photo2); $this->addElement(new Xoops\Form\Hidden('photo2_old', $photo2_old)); $this->addElement(new Xoops\Form\Text(AlumniLocale::EMAIL_2, 'email', 50, 255, $obj->getVar('email')), true); $this->addElement(new Xoops\Form\Text(AlumniLocale::OCC_2, 'occ', 50, 255, $obj->getVar('occ')), false); $this->addElement(new Xoops\Form\Text(AlumniLocale::TOWN_2, 'town', 50, 255, $obj->getVar('town')), false); if ($xoops->user->isAdmin()) { $this->addElement(new Xoops\Form\RadioYesNo(AlumniLocale::APPROVE_2, 'valid', $obj->getVar('valid'), XoopsLocale::YES, XoopsLocale::NO)); } if ($xoops->getModuleConfig('alumni_use_captcha') == '1') { $this->addElement(new Xoops\Form\Captcha()); } $this->addElement(new Xoops\Form\Hidden('security', $xoops->security()->createToken())); if (isset($_REQUEST['date'])) { $this->addElement(new Xoops\Form\Hidden('date', $_REQUEST['date'])); } else { $this->addElement(new XoopsFormHidden('date', time())); } $this->addElement(new Xoops\Form\Hidden('submitter', $xoops->user->uname())); $this->addElement(new Xoops\Form\Hidden('usid', $xoops->user->uid())); $this->addElement(new Xoops\Form\Hidden('op', 'save_listing')); $this->addElement(new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit')); }
/** * @param CommentsComment $obj */ public function __construct(CommentsComment $obj) { $xoops = Xoops::getInstance(); $helper = $xoops->getModuleHelper('comments'); $module = $xoops->getModuleById($obj->getVar('modid')); if (!is_object($module)) { $xoops->redirect(\XoopsBaseConfig::get('url'), 1, XoopsLocale::E_NO_ACCESS_PERMISSION); } $dirname = $module->getVar('dirname'); // create form if ($xoops->isAdminSide) { $url = $helper->url("admin/comment_post.php"); } else { $url = $helper->url("comment_post.php"); } parent::__construct(_MD_COMMENTS_POSTCOMMENT, "commentform", $url, "post", true); switch ($xoops->getModuleConfig('com_rule', $dirname)) { case Comments::APPROVE_ALL: $rule_text = _MD_COMMENTS_COMAPPROVEALL; break; case Comments::APPROVE_USER: $rule_text = _MD_COMMENTS_COMAPPROVEUSER; break; case Comments::APPROVE_ADMIN: default: $rule_text = _MD_COMMENTS_COMAPPROVEADMIN; break; } $this->addElement(new Xoops\Form\Label(_MD_COMMENTS_COMRULES, $rule_text)); $this->addElement(new Xoops\Form\Text(_MD_COMMENTS_TITLE, 'com_title', 50, 255, $obj->getVar('title', 'e')), true); $iconsRadio = new Xoops\Form\Radio(XoopsLocale::MESSAGE_ICON, 'com_icon', $obj->getVar('icon', 'e')); \Xoops\Core\Lists\SubjectIcon::setOptionsArray($iconsRadio); $this->addElement($iconsRadio); // editor $editor = $helper->getConfig('com_editor'); if (class_exists('Xoops\\Form\\Editor')) { $configs = array('name' => 'com_text', 'value' => $obj->getVar('text', 'e'), 'rows' => 25, 'cols' => 90, 'width' => '100%', 'height' => '400px', 'editor' => $editor); $this->addElement(new Xoops\Form\Editor(_MD_COMMENTS_MESSAGE, 'com_text', $configs, false, $onfailure = 'textarea')); } else { $this->addElement(new Xoops\Form\DhtmlTextArea(_MD_COMMENTS_MESSAGE, 'com_text', $obj->getVar('text', 'e'), 10, 50), true); } $option_tray = new Xoops\Form\ElementTray(XoopsLocale::OPTIONS, '<br />'); $buttonTray = new Xoops\Form\ElementTray('', ' '); if ($xoops->isUser()) { if ($xoops->getModuleConfig('com_anonpost', $dirname)) { $noname = $obj->getVar('noname', 'e') ? 1 : 0; $noname_checkbox = new Xoops\Form\Checkbox('', 'com_noname', $noname); $noname_checkbox->addOption(1, XoopsLocale::POST_ANONYMOUSLY); $option_tray->addElement($noname_checkbox); } if (false != $xoops->user->isAdmin($obj->getVar('modid'))) { // show status change box when editing (comment id is not empty) if ($obj->getVar('id', 'e')) { $status_select = new Xoops\Form\Select(_MD_COMMENTS_STATUS, 'com_status', $obj->getVar('status', 'e')); $status_select->addOptionArray(array(Comments::STATUS_PENDING => _MD_COMMENTS_PENDING, Comments::STATUS_ACTIVE => _MD_COMMENTS_ACTIVE, Comments::STATUS_HIDDEN => _MD_COMMENTS_HIDDEN)); $this->addElement($status_select); $buttonTray->addElement(new Xoops\Form\Button('', 'com_dodelete', XoopsLocale::A_DELETE, 'submit')); } if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) { $html_checkbox = new Xoops\Form\Checkbox('', 'com_dohtml', $obj->getVar('dohtml', 'e')); $html_checkbox->addOption(1, _MD_COMMENTS_DOHTML); $option_tray->addElement($html_checkbox); } } } if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) { //Yeah, what? } $smiley_checkbox = new Xoops\Form\Checkbox('', 'com_dosmiley', $obj->getVar('domsiley', 'e')); $smiley_checkbox->addOption(1, _MD_COMMENTS_DOSMILEY); $option_tray->addElement($smiley_checkbox); $xcode_checkbox = new Xoops\Form\Checkbox('', 'com_doxcode', $obj->getVar('doxcode', 'e')); $xcode_checkbox->addOption(1, _MD_COMMENTS_DOXCODE); $option_tray->addElement($xcode_checkbox); if (isset($editor) && in_array($editor, array('textarea', 'dhtmltextarea'))) { $br_checkbox = new Xoops\Form\Checkbox('', 'com_dobr', $obj->getVar('dobr', 'e')); $br_checkbox->addOption(1, _MD_COMMENTS_DOAUTOWRAP); $option_tray->addElement($br_checkbox); } else { $this->addElement(new Xoops\Form\Hidden('com_dohtml', 1)); $this->addElement(new Xoops\Form\Hidden('com_dobr', 0)); } $this->addElement($option_tray); if (!$xoops->isUser()) { $this->addElement(new Xoops\Form\Captcha()); } $this->addElement(new Xoops\Form\Hidden('com_modid', $obj->getVar('modid', 'e'))); $this->addElement(new Xoops\Form\Hidden('com_pid', $obj->getVar('pid', 'e'))); $this->addElement(new Xoops\Form\Hidden('com_rootid', $obj->getVar('rootid', 'e'))); $this->addElement(new Xoops\Form\Hidden('com_id', $obj->getVar('id', 'e'))); $this->addElement(new Xoops\Form\Hidden('com_itemid', $obj->getVar('itemid', 'e'))); $this->addElement(new Xoops\Form\Hidden('com_order', Request::getInt('com_order', $helper->getUserConfig('com_order')))); $this->addElement(new Xoops\Form\Hidden('com_mode', Request::getString('com_mode', $helper->getUserConfig('com_mode')))); // add module specific extra params if (!$xoops->isAdminSide) { /* @var $plugin CommentsPluginInterface */ $plugin = \Xoops\Module\Plugin::getPlugin($dirname, 'comments'); if (is_array($extraParams = $plugin->extraParams())) { foreach ($extraParams as $extra_param) { // This routine is included from forms accessed via both GET and POST if (isset($_POST[$extra_param])) { $hidden_value = $_POST[$extra_param]; } else { if (isset($_GET[$extra_param])) { $hidden_value = $_GET[$extra_param]; } else { $hidden_value = ''; } } $this->addElement(new Xoops\Form\Hidden($extra_param, $hidden_value)); } } } $buttonTray->addElement(new Xoops\Form\Button('', 'com_dopreview', XoopsLocale::A_PREVIEW, 'submit')); $buttonTray->addElement(new Xoops\Form\Button('', 'com_dopost', _MD_COMMENTS_POSTCOMMENT, 'submit')); $this->addElement($buttonTray); return $this; }
$email_text = new Xoops\Form\Text('', 'email', 25, 60, $myts->htmlSpecialChars($email)); $email_option = new Xoops\Form\Checkbox('', 'user_viewemail', $user_viewemail); $email_option->addOption(1, XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL); $email_tray->addElement($email_text, true); $email_tray->addElement($email_option); $reg_form = new Xoops\Form\ThemeForm(XoopsLocale::USER_REGISTRATION, 'userinfo', 'register.php', 'post', true); $uname_size = $xoopsConfigUser['maxuname'] < 25 ? $xoopsConfigUser['maxuname'] : 25; $reg_form->addElement(new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', $uname_size, $uname_size, $myts->htmlSpecialChars($uname)), true); $reg_form->addElement($email_tray); $reg_form->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, 'pass', 32, 64, $myts->htmlSpecialChars($pass)), true); $reg_form->addElement(new Xoops\Form\Password(XoopsLocale::VERIFY_PASSWORD, 'vpass', 32, 64, $myts->htmlSpecialChars($vpass)), true); $reg_form->addElement(new Xoops\Form\Text(XoopsLocale::WEBSITE, 'url', 25, 255, $myts->htmlSpecialChars($url))); $tzselected = $timezone != '' ? $timezone : $xoopsConfig['default_TZ']; $reg_form->addElement(new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, 'timezone', $tzselected)); //$reg_form->addElement($avatar_tray); $reg_form->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::Q_RECEIVE_OCCASIONAL_EMAIL_NOTICES_FROM_ADMINISTRATORS, 'user_mailok', $user_mailok)); if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') { $disc_tray = new Xoops\Form\ElementTray(XoopsLocale::DISCLAIMER, '<br />'); $disc_text = new Xoops\Form\TextArea('', 'disclaimer', $xoopsConfigUser['reg_disclaimer'], 15, 80); $disc_text->set('readonly', 'readonly'); $disc_tray->addElement($disc_text); $agree_chk = new Xoops\Form\Checkbox('', 'agree_disc', $agree_disc); $agree_chk->addOption(1, XoopsLocale::I_AGREE_TO_THE_ABOVE); $eltname = $agree_chk->getName(); $eltmsg = str_replace('"', '\\"', stripslashes(sprintf(XoopsLocale::F_ENTER, XoopsLocale::I_AGREE_TO_THE_ABOVE))); $agree_chk->addCustomValidationCode("if ( myform.{$eltname}.checked == false ) { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }"); $disc_tray->addElement($agree_chk, true); $reg_form->addElement($disc_tray); } $reg_form->addElement(new Xoops\Form\Hidden('op', 'newuser')); $reg_form->addElement(new Xoops\Form\Button('', 'submitButton', XoopsLocale::A_SUBMIT, 'submit'));
$email_text = new Xoops\Form\Text('', 'email', 25, 60, $myts->htmlSpecialChars($email)); $email_option = new Xoops\Form\Checkbox('', 'user_viewemail', $user_viewemail); $email_option->addOption(1, XoopsLocale::ALLOW_OTHER_USERS_TO_VIEW_EMAIL); $email_tray->addElement($email_text, true); $email_tray->addElement($email_option); $reg_form = new Xoops\Form\ThemeForm(XoopsLocale::USER_REGISTRATION, 'userinfo', 'register.php', 'post', true); $uname_size = $xoopsConfigUser['maxuname'] < 25 ? $xoopsConfigUser['maxuname'] : 25; $reg_form->addElement(new Xoops\Form\Text(XoopsLocale::USERNAME, 'uname', $uname_size, $uname_size, $myts->htmlSpecialChars($uname)), true); $reg_form->addElement($email_tray); $reg_form->addElement(new Xoops\Form\Password(XoopsLocale::PASSWORD, 'pass', 10, 32, $myts->htmlSpecialChars($pass)), true); $reg_form->addElement(new Xoops\Form\Password(XoopsLocale::VERIFY_PASSWORD, 'vpass', 10, 32, $myts->htmlSpecialChars($vpass)), true); $reg_form->addElement(new Xoops\Form\Text(XoopsLocale::WEBSITE, 'url', 25, 255, $myts->htmlSpecialChars($url))); $tzselected = $timezone_offset != '' ? $timezone_offset : $xoopsConfig['default_TZ']; $reg_form->addElement(new Xoops\Form\SelectTimeZone(XoopsLocale::TIME_ZONE, 'timezone_offset', $tzselected)); //$reg_form->addElement($avatar_tray); $reg_form->addElement(new Xoops\Form\RadioYesNo(XoopsLocale::Q_RECEIVE_OCCASIONAL_EMAIL_NOTICES_FROM_ADMINISTRATORS, 'user_mailok', $user_mailok)); if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') { $disc_tray = new Xoops\Form\ElementTray(XoopsLocale::DISCLAIMER, '<br />'); $disc_text = new Xoops\Form\TextArea('', 'disclaimer', $xoopsConfigUser['reg_disclaimer'], 15, 80); $disc_text->setExtra('readonly="readonly"'); $disc_tray->addElement($disc_text); $agree_chk = new Xoops\Form\Checkbox('', 'agree_disc', $agree_disc); $agree_chk->addOption(1, XoopsLocale::I_AGREE_TO_THE_ABOVE); $eltname = $agree_chk->getName(); $eltmsg = str_replace('"', '\\"', stripslashes(sprintf(XoopsLocale::F_ENTER, XoopsLocale::I_AGREE_TO_THE_ABOVE))); $agree_chk->customValidationCode[] = "if ( myform.{$eltname}.checked == false ) { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }"; $disc_tray->addElement($agree_chk, true); $reg_form->addElement($disc_tray); } $reg_form->addElement(new Xoops\Form\Hidden('op', 'newuser')); $reg_form->addElement(new Xoops\Form\Button('', 'submitButton', XoopsLocale::A_SUBMIT, 'submit'));
/** * 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; }