本文整理汇总了PHP中XoopsFormRadio::addOptionArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsFormRadio::addOptionArray方法的具体用法?PHP XoopsFormRadio::addOptionArray怎么用?PHP XoopsFormRadio::addOptionArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsFormRadio
的用法示例。
在下文中一共展示了XoopsFormRadio::addOptionArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: about_block_page_edit
function about_block_page_edit($options)
{
@(include dirname(dirname(__FILE__)) . "/xoops_version.php");
$page_handler =& xoops_getmodulehandler('page', 'about');
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('page_status', 1), 'AND');
$criteria->add(new Criteria('page_type', 1));
$criteria->setSort('page_order');
$criteria->setOrder('ASC');
$fields = array("page_id", "page_title", "page_image");
$pages = $page_handler->getAll($criteria, $fields, false);
$page_title = '';
foreach ($pages as $k => $v) {
$page_title = '<a href="' . XOOPS_URL . '/modules/' . $modversion['dirname'] . '/index.php?page_id=' . $k . '" target="_blank">' . $v['page_title'] . '</a>';
$options_page[$k] = empty($v['page_image']) ? $page_title : $page_title . '<img src="' . XOOPS_URL . '/modules/' . $modversion['dirname'] . '/images/picture.png' . '" />';
}
include_once dirname(dirname(__FILE__)) . '/include/xoopsformloader.php';
$form = new XoopsBlockForm();
$page_select = new XoopsFormRadio(_MI_ABOUT_BLOCKPAGE, 'options[0]', $options[0], '<br />');
$page_select->addOptionArray($options_page);
$form->addElement($page_select);
$form->addElement(new XoopsFormText(_MI_ABOUT_TEXT_LENGTH, 'options[1]', 5, 5, $options[1]));
$form->addElement(new XoopsFormText(_MI_ABOUT_VIEW_MORELINKTEXT, 'options[2]', 30, 50, $options[2]));
$form->addElement(new XoopsFormRadioYN(_MI_ABOUT_DOTITLEIMAGE, 'options[3]', $options[3]));
return $form->render();
}
示例2: SmartFormUrlLinkElement
function SmartFormUrlLinkElement($form_caption, $key, $object)
{
$this->XoopsFormElementTray($form_caption, ' ');
$this->addElement(new XoopsFormLabel('', '<br/>' . _CO_SOBJECT_URLLINK_URL));
$this->addElement(new SmartFormTextElement($object, 'url_' . $key));
$this->addElement(new XoopsFormLabel('', '<br/>' . _CO_SOBJECT_CAPTION));
$this->addElement(new SmartFormTextElement($object, 'caption_' . $key));
$this->addElement(new XoopsFormLabel('', '<br/>' . _CO_SOBJECT_DESC . '<br/>'));
$this->addElement(new XoopsFormTextArea('', 'desc_' . $key, $object->getVar('description')));
$this->addElement(new XoopsFormLabel('', '<br/>' . _CO_SOBJECT_URLLINK_TARGET));
$targ_val = $object->getVar('target');
$targetRadio = new XoopsFormRadio('', 'target_' . $key, $targ_val != '' ? $targ_val : '_blank');
$control = $object->getControl('target');
$targetRadio->addOptionArray($control['options']);
$this->addElement($targetRadio);
}
示例3: field_form
function field_form($fid = 0)
{
global $mediaschema, $field_types, $all_types;
if ($fid) {
$vals = $mediaschema->getField($fid);
} else {
$vals = array('fid' => 0, 'name' => '', 'label' => '', 'def' => '', 'type' => 'varchar(0)', 'weight' => 1);
}
if (preg_match('/^(\\w+)\\((\\d+)\\)/', $vals['type'], $d)) {
$type = $d[1];
$size = $d[2];
} else {
$type = $vals['type'];
$size = 0;
}
$form = new XoopsThemeForm($fid ? _AM_FIELDS_EDIT : _AM_FIELDS_NEW, 'FieldForm', 'fields.php');
$form->addElement(new XoopsFormHidden('fid', $vals['fid']));
$form->addElement(new XoopsFormText(_AM_FIELDS_LABEL, 'label', 40, 40, $vals['label']));
$fname = $vals['name'];
if (empty($fname) || preg_match('/^add/', $fname)) {
$types = $field_types;
if (empty($fname)) {
$types['keywords'] = _AM_TYPE_KEYWORD;
} else {
$form->addElement(new XoopsFormLabel(_AM_FIELDS_NAME, $fname));
}
$type_select = new XoopsFormRadio(_AM_FIELDS_TYPE, 'type', $type);
$type_select->addOptionArray($types);
$form->addElement($type_select);
$form->addElement(new XoopsFormText(_AM_FIELDS_SIZE, 'size', 4, 4, $size ? $size : 40));
} else {
$form->addElement(new XoopsFormLabel(_AM_FIELDS_NAME, $fname));
$form->addElement(new XoopsFormLabel(_AM_FIELDS_TYPE, $all_types[$type] . ($size ? " ({$size})" : '')));
}
if (!in_array($fname, array('ctime', 'mtime', 'hits', 'poster'))) {
if ($type == 'link') {
$form->addElement(new XoopsFormText(_AM_FIELDS_NUMBER, 'def', 4, 4, $vals['def']));
} else {
$form->addElement(new XoopsFormText(_AM_FIELDS_DEF, 'def', 40, 60, $vals['def']));
}
}
$form->addElement(new XoopsFormText(_AM_SORT_WEIGHT, 'weight', 4, 4, $vals['weight']));
$form->addElement(new XoopsFormButton('', 'field', _SUBMIT, 'submit'));
$form->display();
}
示例4: foreach
foreach ($items_range as $var => $title) {
$more = new XoopsFormText("", "{$var}_more", 10, 5, @$_POST["{$var}_more"]);
$less = new XoopsFormText("", "{$var}_less", 10, 5, @$_POST["{$var}_less"]);
$range_tray = new XoopsFormElementTray($title, " - ");
$range_tray->addElement($less);
$range_tray->addElement($more);
$form->addElement($range_tray);
unset($more, $less, $range_tray);
}
$mailok_radio = new XoopsFormRadio(_MA_USER_SHOWMAILOK, "user_mailok", empty($_POST["user_mailok"]) ? "both" : $_POST["user_mailok"]);
$mailok_radio->addOptionArray(array("mailok" => _MA_USER_MAILOK, "mailng" => _MA_USER_MAILNG, "both" => _MA_USER_BOTH));
$avatar_radio = new XoopsFormRadio(_MA_USER_HASAVATAR, "user_avatar", empty($_POST["user_avatar"]) ? "both" : $_POST["user_avatar"]);
$avatar_radio->addOptionArray(array("y" => _YES, "n" => _NO, "both" => _MA_USER_BOTH));
$level_radio = new XoopsFormRadio(_MA_USER_LEVEL, "level", @$_POST["level"]);
$levels = array(0 => _ALL, 1 => _MA_USER_LEVEL_ACTIVE, 2 => _MA_USER_LEVEL_INACTIVE, 3 => _MA_USER_LEVEL_DISABLED);
$level_radio->addOptionArray($levels);
$member_handler =& xoops_gethandler('member');
$groups = $member_handler->getGroupList();
$groups[0] = _ALL;
$group_select = new XoopsFormSelect(_MA_USER_GROUP, 'groups', @$_POST['groups'], 3, true);
$group_select->addOptionArray($groups);
$ranks = $rank_handler->getList();
$ranks[0] = _ALL;
$rank_select = new XoopsFormSelect(_MA_USER_RANK, 'rank', intval(@$_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);
示例5: XoopsFormElementTray
$msnm_tray = new XoopsFormElementTray(_AM_SYSTEM_USERS_MSNM, " ");
$msnm_tray->addElement($msnm_match);
$msnm_tray->addElement($msnm_text);
$location_text = new XoopsFormText(_AM_SYSTEM_USERS_LOCATIONC, "user_from", 30, 100);
$occupation_text = new XoopsFormText(_AM_SYSTEM_USERS_OCCUPATIONC, "user_occ", 30, 100);
$interest_text = new XoopsFormText(_AM_SYSTEM_USERS_INTERESTC, "user_intrest", 30, 100);
$lastlog_more = new XoopsFormText(_AM_SYSTEM_USERS_LASTLOGMORE, "user_lastlog_more", 10, 5);
$lastlog_less = new XoopsFormText(_AM_SYSTEM_USERS_LASTLOGLESS, "user_lastlog_less", 10, 5);
$reg_more = new XoopsFormText(_AM_SYSTEM_USERS_REGMORE, "user_reg_more", 10, 5);
$reg_less = new XoopsFormText(_AM_SYSTEM_USERS_REGLESS, "user_reg_less", 10, 5);
$posts_more = new XoopsFormText(_AM_SYSTEM_USERS_POSTSMORE, "user_posts_more", 10, 5);
$posts_less = new XoopsFormText(_AM_SYSTEM_USERS_POSTSLESS, "user_posts_less", 10, 5);
$mailok_radio = new XoopsFormRadio(_AM_SYSTEM_USERS_SHOWMAILOK, "user_mailok", "both");
$mailok_radio->addOptionArray(array("mailok" => _AM_SYSTEM_USERS_MAILOK, "mailng" => _AM_SYSTEM_USERS_MAILNG, "both" => _AM_SYSTEM_USERS_BOTH));
$type_radio = new XoopsFormRadio(_AM_SYSTEM_USERS_SHOWTYPE, "user_type", "actv");
$type_radio->addOptionArray(array("actv" => _AM_SYSTEM_USERS_ACTIVE, "inactv" => _AM_SYSTEM_USERS_INACTIVE, "both" => _AM_SYSTEM_USERS_BOTH));
$sort_select = new XoopsFormSelect(_AM_SYSTEM_USERS_SORT, "user_sort");
$sort_select->addOptionArray(array("uname" => _AM_SYSTEM_USERS_UNAME, "email" => _AM_SYSTEM_USERS_EMAIL, "last_login" => _AM_SYSTEM_USERS_LASTLOGIN, "user_regdate" => _AM_SYSTEM_USERS_REGDATE, "posts" => _AM_SYSTEM_USERS_POSTS));
$order_select = new XoopsFormSelect(_AM_SYSTEM_USERS_ORDER, "user_order");
$order_select->addOptionArray(array("ASC" => _AM_SYSTEM_USERS_ASC, "DESC" => _AM_SYSTEM_USERS_DESC));
$limit_text = new XoopsFormText(_AM_SYSTEM_USERS_LIMIT, "user_limit", 6, 2, 20);
$submit_button = new XoopsFormButton("", "user_submit", _SUBMIT, "submit");
$form = new XoopsThemeForm(_AM_SYSTEM_USERS_FINDUS, "uesr_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);
示例6: XoopsFormHidden
$form->addElement(new XoopsFormHidden('op', 'addfile'));
$form->addElement(new XoopsFormHidden('fct', 'images'));
$form->addElement(new XoopsFormButton('', 'img_button', _SUBMIT, 'submit'));
$form->display();
}
$form = new XoopsThemeForm(_MD_ADDIMGCAT, 'imagecat_form', 'admin.php', 'post', true);
$form->addElement(new XoopsFormText(_MD_IMGCATNAME, 'imgcat_name', 50, 255), true);
$form->addElement(new XoopsFormSelectGroup(_MD_IMGCATRGRP, 'readgroup', true, XOOPS_GROUP_ADMIN, 5, true));
$form->addElement(new XoopsFormSelectGroup(_MD_IMGCATWGRP, 'writegroup', true, XOOPS_GROUP_ADMIN, 5, true));
$form->addElement(new XoopsFormText(_IMGMAXSIZE, 'imgcat_maxsize', 10, 10, 50000));
$form->addElement(new XoopsFormText(_IMGMAXWIDTH, 'imgcat_maxwidth', 3, 4, 120));
$form->addElement(new XoopsFormText(_IMGMAXHEIGHT, 'imgcat_maxheight', 3, 4, 120));
$form->addElement(new XoopsFormText(_MD_IMGCATWEIGHT, 'imgcat_weight', 3, 4, 0));
$form->addElement(new XoopsFormRadioYN(_MD_IMGCATDISPLAY, 'imgcat_display', 1, _YES, _NO));
$storetype = new XoopsFormRadio(_MD_IMGCATSTRTYPE . '<br /><span style="color:#ff0000;">' . _MD_STRTYOPENG . '</span>', 'imgcat_storetype', 'file');
$storetype->addOptionArray(array('file' => _MD_ASFILE, 'db' => _MD_INDB));
$form->addElement($storetype);
$form->addElement(new XoopsFormHidden('op', 'addcat'));
$form->addElement(new XoopsFormHidden('fct', 'images'));
$form->addElement(new XoopsFormButton('', 'imgcat_button', _SUBMIT, 'submit'));
$form->display();
xoops_cp_footer();
exit;
}
if ($op == 'listimg') {
$imgcat_id = intval($imgcat_id);
if ($imgcat_id <= 0) {
redirect_header('admin.php?fct=images', 1);
}
$imgcat_handler = xoops_gethandler('imagecategory');
$imagecategory =& $imgcat_handler->get($imgcat_id);
示例7: keyword_form
function keyword_form($keyid = 0)
{
global $keywords, $nodetypes_select;
if ($keyid) {
$vals = $keywords->get($keyid);
} else {
$vals = array('keyid' => 0, 'name' => '', 'parent' => 0, 'relay' => 0, 'weight' => 1, 'nodetype' => 2, 'description' => '');
}
$form = new XoopsThemeForm($keyid ? _AM_KEYWORDS_EDIT : _AM_KEYWORDS_NEW, 'KeysForm', 'keywords.php');
$form->addElement(new XoopsFormHidden('keyid', $keyid));
$form->addElement(new XoopsFormText(_AM_KEYWORDS_NAME, 'name', 40, 128, $vals['name']));
$node_select = new XoopsFormRadio(_AM_KEYWORDS_NODETYPE, 'nodetype');
$node_select->addOptionArray($nodetypes_select);
$node_select->setValue($vals['nodetype']);
$form->addElement($node_select);
$parent_keys = new KeyFormSelect(_AM_KEYWORDS_PARENT, 'parent');
$keys = $keywords->getKeys(array(0, 1));
array_unshift($keys, array('keyid' => '', 'name' => _AM_KEY_NONE));
if ($keyid) {
unset($keys["key{$keyid}"]);
}
// remove self
$parent_keys->addOptions($keys);
$parent_keys->setValue($vals['parent']);
$form->addElement($parent_keys);
$relay_keys = new KeyFormSelect(_AM_KEYWORDS_RELAY, 'relay');
$relays = $keywords->getKeys(array(0, 2));
array_unshift($relays, array('keyid' => '', 'name' => _AM_KEY_NONE));
$relay_keys->addOptions($relays);
$relay_keys->setValue($vals['relay']);
$form->addElement($relay_keys);
$form->addElement(new XoopsFormText(_AM_SORT_WEIGHT, 'weight', 4, 4, $vals['weight']));
$form->addElement(new XoopsFormDhtmlTextArea(_AM_KEYWORDS_DESC, 'description', $vals['description']));
$form->addElement(new XoopsFormButton('', 'keys', _SUBMIT, 'submit'));
$form->display();
}
示例8: getEditElement
/**
* Returns a {@link XoopsFormElement} 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 XoopsFormElement
**/
function getEditElement($user, $profile)
{
$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;
}
}
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
switch ($this->getVar('field_type')) {
default:
case "autotext":
//autotext is not for editing
$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
break;
case "textbox":
$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case "textarea":
$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
break;
case "dhtml":
$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
break;
case "select":
$element = new XoopsFormSelect($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('', _NONE);
$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_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 XoopsFormSelect($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case "radio":
$element = new XoopsFormRadio($caption, $name, $value);
$element->addOptionArray($options);
break;
case "checkbox":
$element = new XoopsFormCheckBox($caption, $name, $value);
$element->addOptionArray($options);
break;
case "yesno":
$element = new XoopsFormRadioYN($caption, $name, $value);
break;
case "group":
$element = new XoopsFormSelectGroup($caption, $name, true, $value);
break;
case "group_multi":
$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
break;
case "language":
$element = new XoopsFormSelectLang($caption, $name, $value);
break;
case "date":
$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
break;
case "longdate":
$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
break;
case "datetime":
$element = new XoopsFormDatetime($caption, $name, 15, $value);
break;
case "list":
$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
break;
case "timezone":
$element = new XoopsFormSelectTimezone($caption, $name, $value);
$element->setExtra("style='width: 280px;'");
break;
case "rank":
$element = new XoopsFormSelect($caption, $name, $value);
include_once $GLOBALS['xoops']->path('class/xoopslists.php');
$ranks = XoopsLists::getUserRankList();
$element->addOption(0, "--------------");
$element->addOptionArray($ranks);
break;
case 'theme':
$element = new XoopsFormSelect($caption, $name, $value);
//.........这里部分代码省略.........
示例9: XoopsFormText
$msnm_tray->addElement($msnm_match);
$msnm_tray->addElement($msnm_text);
$location_text = new XoopsFormText(_AM_LOCATION, "user_from", 30, 100);
$occupation_text = new XoopsFormText(_AM_OCCUPATION, "user_occ", 30, 100);
$interest_text = new XoopsFormText(_AM_INTEREST, "user_intrest", 30, 100);
//$bio_text = new XoopsFormText(_AM_EXTRAINFO, "user_bio", 30, 100);
$lastlog_more = new XoopsFormText(_AM_LASTLOGMORE, "user_lastlog_more", 10, 5);
$lastlog_less = new XoopsFormText(_AM_LASTLOGLESS, "user_lastlog_less", 10, 5);
$reg_more = new XoopsFormText(_AM_REGMORE, "user_reg_more", 10, 5);
$reg_less = new XoopsFormText(_AM_REGLESS, "user_reg_less", 10, 5);
$posts_more = new XoopsFormText(_AM_POSTSMORE, "user_posts_more", 10, 5);
$posts_less = new XoopsFormText(_AM_POSTSLESS, "user_posts_less", 10, 5);
$mailok_radio = new XoopsFormRadio(_AM_SHOWMAILOK, "user_mailok", "both");
$mailok_radio->addOptionArray(array("mailok" => _AM_MAILOK, "mailng" => _AM_MAILNG, "both" => _AM_BOTH));
$type_radio = new XoopsFormRadio(_AM_SHOWTYPE, "user_type", "actv");
$type_radio->addOptionArray(array("actv" => _AM_ACTIVE, "inactv" => _AM_INACTIVE, "both" => _AM_BOTH));
$sort_select = new XoopsFormSelect(_AM_SORT, "user_sort");
$sort_select->addOptionArray(array("uname" => _AM_UNAME, "email" => _AM_EMAIL, "last_login" => _AM_LASTLOGIN, "user_regdate" => _AM_REGDATE, "posts" => _AM_POSTS));
$order_select = new XoopsFormSelect(_AM_ORDER, "user_order");
$order_select->addOptionArray(array("ASC" => _AM_ASC, "DESC" => _AM_DESC));
$limit_text = new XoopsFormText(_AM_LIMIT, "limit", 6, 2);
$fct_hidden = new XoopsFormHidden("fct", "findusers");
$op_hidden = new XoopsFormHidden("op", "submit");
$submit_button = new XoopsFormButton("", "user_submit", _SUBMIT, "submit");
$form = new XoopsThemeForm(_AM_FINDUS, "uesr_findform", "admin.php", 'post', true);
$form->addElement($uname_tray);
$form->addElement($name_tray);
$form->addElement($email_tray);
//$form->addElement($theme_select);
//$form->addElement($timezone_select);
$form->addElement($icq_tray);
示例10: constructElement
function constructElement($form_ele_id, $admin = false, $qcm)
{
global $xoopsUser, $xoopsModuleConfig, $separ, $myts;
$myts =& MyTextSanitizer::getInstance();
$id_form = $this->_ele->getVar('id_form');
$ele_caption = $this->_ele->getVar('ele_caption', 'e');
$ele_caption = preg_replace('/\\{null\\}/', '', $ele_caption);
$ele_caption = stripslashes($ele_caption);
$ele_value = $this->_ele->getVar('ele_value');
$e = $this->_ele->getVar('ele_type');
// required elements have a '*' after the text
$req = intval($this->_ele->getVar('ele_req'));
if ($req) {
$ele_caption = $ele_caption . ' *';
}
$ele_caption = $myts->displayTarea($ele_caption);
switch ($e) {
case 'text':
$ele_value[2] = eregi_replace("’", "'", $ele_value[2]);
$ele_value[2] = stripslashes($ele_value[2]);
$ele_value[2] = $myts->displayTarea($ele_value[2]);
if (!is_object($xoopsUser)) {
$ele_value[2] = preg_replace('/\\{NAME\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{name\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{UNAME\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{uname\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{EMAIL\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{email\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{MAIL\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{mail\\}/', '', $ele_value[2]);
$ele_value[2] = preg_replace('/\\{DATE\\}/', '', $ele_value[2]);
} elseif (!$admin) {
$ele_value[2] = preg_replace('/\\{NAME\\}/', $xoopsUser->getVar('name', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{name\\}/', $xoopsUser->getVar('name', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{UNAME\\}/', $xoopsUser->getVar('uname', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{uname\\}/', $xoopsUser->getVar('uname', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{MAIL\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{mail\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{EMAIL\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{email\\}/', $xoopsUser->getVar('email', 'e'), $ele_value[2]);
$ele_value[2] = preg_replace('/\\{DATE\\}/', date("d-m-Y"), $ele_value[2]);
}
$form_ele = new XoopsFormText($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], stripslashes($ele_value[2]));
break;
case 'textarea':
$ele_value[0] = stripslashes($ele_value[0]);
$ele_value[0] = $myts->displayTarea($ele_value[0]);
$form_ele = new XoopsFormTextArea($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], $ele_value[2]);
break;
case 'areamodif':
$ele_value[0] = stripslashes($ele_value[0]);
$ele_value[0] = $myts->displayTarea($ele_value[0]);
$form_ele = new XoopsFormLabel($ele_caption, $ele_value[0]);
break;
case 'select':
$selected = array();
$options = array();
$opt_count = 1;
while ($i = each($ele_value[2])) {
$options[$opt_count] = $myts->stripSlashesGPC($i['key']);
if ($i['value'] > 0) {
$selected[] = $opt_count;
}
$opt_count++;
}
if ($qcm == '1') {
$form_ele = new XoopsFormSelect($ele_caption, $form_ele_id, '', $ele_value[0], $ele_value[1]);
} else {
$form_ele = new XoopsFormSelect($ele_caption, $form_ele_id, $selected, $ele_value[0], $ele_value[1]);
}
if ($ele_value[1]) {
$this->_ele->setVar('ele_req', 0);
}
$form_ele->addOptionArray($options);
break;
case 'checkbox':
$selected = array();
$options = array();
$opt_count = 1;
while ($i = each($ele_value)) {
$options[$opt_count] = $myts->stripSlashesGPC($i['key']);
if ($i['value'] > 0) {
$selected[] = $opt_count;
}
$opt_count++;
}
switch ($xoopsModuleConfig['delimeter']) {
case 'br':
$form_ele = new XoopsFormElementTray($ele_caption, '<br />');
while ($o = each($options)) {
if ($qcm == '1') {
$t =& new XoopsFormCheckBox('', $form_ele_id . '[]');
} else {
$t =& new XoopsFormCheckBox('', $form_ele_id . '[]', $selected);
}
$t->addOption($o['key'], $o['value']);
$form_ele->addElement($t);
}
break;
default:
//.........这里部分代码省略.........
示例11: getEditElement
/**
* Returns a {@link XoopsFormElement} for editing the value of this field
*
* @param object $user {@link XoopsUser} object to edit the value of
*
* @return object
**/
function getEditElement(&$user)
{
$value = $user->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');
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;
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
switch ($this->getVar('field_type')) {
default:
case "autotext":
//autotext is not for editing
$element = new XoopsFormLabel($caption, $this->getOutputValue($user));
break;
case "textbox":
$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case "textarea":
$element = new XoopsFormTextArea($caption, $name, $value, 10, 50);
break;
case "dhtml":
$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50);
break;
case "select":
$element = new XoopsFormSelect($caption, $name, $value);
$element->addOptionArray($options);
break;
case "select_multi":
$element = new XoopsFormSelect($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case "radio":
$element = new XoopsFormRadio($caption, $name, $value);
$element->addOptionArray($options);
break;
case "checkbox":
$element = new XoopsFormCheckBox($caption, $name, $value);
$element->addOptionArray($options);
break;
case "yesno":
$element = new XoopsFormRadioYN($caption, $name, $value);
break;
case "group":
$element = new XoopsFormSelectGroup($caption, $name, true, $value);
break;
case "group_multi":
$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
break;
case "language":
$element = new XoopsFormSelectLang($caption, $name, $value);
break;
case "date":
$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
break;
// case "longdate":
// $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
// break;
// case "longdate":
// $element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace("-", "/", $value));
// break;
case "datetime":
$element = new XoopsFormDatetime($caption, $name, 15, $value);
break;
case "list":
$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
break;
case "timezone":
$element = new XoopsFormSelectTimezone($caption, $name, $value);
break;
case 'theme':
$element = new XoopsFormSelect($caption, $name, $value);
$element->addOption("0", _SITEDEFAULT);
$theme_list = XoopsLists::getThemesList();
foreach ($theme_list as $key => $val) {
if (!in_array($key, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
continue;
}
$element->addOption($key, $val);
}
/*
$handle = opendir(XOOPS_THEME_PATH.'/');
$dirlist = array();
while (false !== ($file = readdir($handle))) {
if (is_dir(XOOPS_THEME_PATH.'/'.$file) && !preg_match("/^[.]{1,2}$/",$file) && strtolower($file) != 'cvs') {
if (file_exists(XOOPS_THEME_PATH."/".$file."/theme.html") && in_array($file, $GLOBALS['xoopsConfig']['theme_set_allowed'])) {
$dirlist[$file]=$file;
//.........这里部分代码省略.........
示例12: getEditElement
/**
* Returns a {@link XoopsFormElement} 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 XoopsFormElement
**/
public function getEditElement($user, $profile)
{
$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;
}
}
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
switch ($this->getVar('field_type')) {
default:
case 'autotext':
//autotext is not for editing
$element = new XoopsFormLabel($caption, $this->getOutputValue($user, $profile));
break;
case 'textbox':
$element = new XoopsFormText($caption, $name, 35, $this->getVar('field_maxlength'), $value);
break;
case 'textarea':
$element = new XoopsFormTextArea($caption, $name, $value, 4, 30);
break;
case 'dhtml':
$element = new XoopsFormDhtmlTextArea($caption, $name, $value, 10, 30);
break;
case 'select':
$element = new XoopsFormSelect($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))) {
if (!array_key_exists('', $options)) {
$element->addOption('', _NONE);
$eltmsg = empty($caption) ? sprintf(_FORM_ENTER, $name) : sprintf(_FORM_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 XoopsFormSelect($caption, $name, $value, 5, true);
$element->addOptionArray($options);
break;
case 'radio':
$element = new XoopsFormRadio($caption, $name, $value);
$element->addOptionArray($options);
break;
case 'checkbox':
$element = new XoopsFormCheckBox($caption, $name, $value);
$element->addOptionArray($options);
break;
case 'yesno':
$element = new XoopsFormRadioYN($caption, $name, $value);
break;
case 'group':
$element = new XoopsFormSelectGroup($caption, $name, true, $value);
break;
case 'group_multi':
$element = new XoopsFormSelectGroup($caption, $name, true, $value, 5, true);
break;
case 'language':
$element = new XoopsFormSelectLang($caption, $name, $value);
break;
case 'date':
$element = new XoopsFormTextDateSelect($caption, $name, 15, $value);
break;
case 'longdate':
$element = new XoopsFormTextDateSelect($caption, $name, 15, str_replace('-', '/', $value));
break;
case 'datetime':
$element = new XoopsFormDatetime($caption, $name, 15, $value);
break;
case 'list':
$element = new XoopsFormSelectList($caption, $name, $value, 1, $options[0]);
break;
case 'timezone':
$element = new XoopsFormSelectTimezone($caption, $name, $value);
$element->setExtra("style='width: 280px;'");
break;
case 'rank':
$element = new XoopsFormSelect($caption, $name, $value);
include_once $GLOBALS['xoops']->path('class/xoopslists.php');
$ranks = XoopsLists::getUserRankList();
$element->addOption(0, '--------------');
$element->addOptionArray($ranks);
break;
case 'theme':
//.........这里部分代码省略.........
示例13: getControl
function getControl($controlName, $key)
{
switch ($controlName) {
case 'check':
include_once SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformcheckelement.php";
$control = $this->targetObject->getControl($key);
$controlObj = new SmartFormCheckElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
$controlObj->addOptionArray($control['options']);
return $controlObj;
break;
case 'color':
$control = $this->targetObject->getControl($key);
$controlObj = new XoopsFormColorPicker($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
return $controlObj;
break;
case 'radio':
$control = $this->targetObject->getControl($key);
$controlObj = new XoopsFormRadio($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
$controlObj->addOptionArray($control['options']);
return $controlObj;
break;
case 'label':
return new XoopsFormLabel($this->targetObject->vars[$key]['form_caption'], $this->targetObject->getVar($key));
break;
case 'textarea':
return $this->getTextArea($key);
case 'theme':
return $this->getThemeSelect($key, $this->targetObject->vars[$key]);
case 'theme_multi':
return $this->getThemeSelect($key, $this->targetObject->vars[$key], true);
break;
case 'timezone':
return new XoopsFormSelectTimezone($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key));
break;
case 'group':
return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
break;
case 'group_multi':
return new XoopsFormSelectGroup($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
break;
/*case 'user':
return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
break;*/
/*case 'user':
return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 1, false);
break;*/
case 'user_multi':
return new XoopsFormSelectUser($this->targetObject->vars[$key]['form_caption'], $key, false, $this->targetObject->getVar($key, 'e'), 5, true);
break;
case 'password':
return new XoopsFormPassword($this->targetObject->vars[$key]['form_caption'], $key, 50, 255, $this->targetObject->getVar($key, 'e'));
break;
case 'country':
return new XoopsFormSelectCountry($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getVar($key, 'e'));
break;
case 'urllink':
include_once SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformurllinkelement.php";
return new SmartFormUrlLinkElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getUrlLinkObj($key));
break;
case 'richfile':
include_once SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformrichfileelement.php";
return new SmartFormRichFileElement($this->targetObject->vars[$key]['form_caption'], $key, $this->targetObject->getFileObj($key));
break;
case 'section':
include_once SMARTOBJECT_ROOT_PATH . "class/form/elements/smartformsection.php";
return new SmartFormSection($key, $this->targetObject->vars[$key]['form_caption']);
break;
default:
$classname = "SmartForm" . ucfirst($controlName) . "Element";
if (!class_exists($classname)) {
if (file_exists(SMARTOBJECT_ROOT_PATH . "class/form/elements/" . strtolower($classname) . ".php")) {
include_once SMARTOBJECT_ROOT_PATH . "class/form/elements/" . strtolower($classname) . ".php";
} else {
// perhaps this is a control created by the module
$moduleName = $this->targetObject->handler->_moduleName;
$moduleFormElementsPath = $this->targetObject->handler->_modulePath . 'class/form/elements/';
$classname = ucfirst($moduleName) . ucfirst($controlName) . "Element";
$classFileName = strtolower($classname) . ".php";
if (file_exists($moduleFormElementsPath . $classFileName)) {
include_once $moduleFormElementsPath . $classFileName;
} else {
trigger_error($classname . " Not found", E_USER_WARNING);
return new XoopsFormLabel();
//Empty object
}
}
}
return new $classname($this->targetObject, $key);
break;
}
}
示例14: XoopsFormElementTray
$msnm_tray = new XoopsFormElementTray(_AM_SYSTEM_USERS_MSNM, ' ');
$msnm_tray->addElement($msnm_match);
$msnm_tray->addElement($msnm_text);
$location_text = new XoopsFormText(_AM_SYSTEM_USERS_LOCATIONC, 'user_from', 30, 100);
$occupation_text = new XoopsFormText(_AM_SYSTEM_USERS_OCCUPATIONC, 'user_occ', 30, 100);
$interest_text = new XoopsFormText(_AM_SYSTEM_USERS_INTERESTC, 'user_intrest', 30, 100);
$lastlog_more = new XoopsFormText(_AM_SYSTEM_USERS_LASTLOGMORE, 'user_lastlog_more', 10, 5);
$lastlog_less = new XoopsFormText(_AM_SYSTEM_USERS_LASTLOGLESS, 'user_lastlog_less', 10, 5);
$reg_more = new XoopsFormText(_AM_SYSTEM_USERS_REGMORE, 'user_reg_more', 10, 5);
$reg_less = new XoopsFormText(_AM_SYSTEM_USERS_REGLESS, 'user_reg_less', 10, 5);
$posts_more = new XoopsFormText(_AM_SYSTEM_USERS_POSTSMORE, 'user_posts_more', 10, 5);
$posts_less = new XoopsFormText(_AM_SYSTEM_USERS_POSTSLESS, 'user_posts_less', 10, 5);
$mailok_radio = new XoopsFormRadio(_AM_SYSTEM_USERS_SHOWMAILOK, 'user_mailok', 'both');
$mailok_radio->addOptionArray(array('mailok' => _AM_SYSTEM_USERS_MAILOK, 'mailng' => _AM_SYSTEM_USERS_MAILNG, 'both' => _AM_SYSTEM_USERS_BOTH));
$type_radio = new XoopsFormRadio(_AM_SYSTEM_USERS_SHOWTYPE, 'user_type', 'actv');
$type_radio->addOptionArray(array('actv' => _AM_SYSTEM_USERS_ACTIVE, 'inactv' => _AM_SYSTEM_USERS_INACTIVE, 'both' => _AM_SYSTEM_USERS_BOTH));
$sort_select = new XoopsFormSelect(_AM_SYSTEM_USERS_SORT, 'user_sort');
$sort_select->addOptionArray(array('uname' => _AM_SYSTEM_USERS_UNAME, 'email' => _AM_SYSTEM_USERS_EMAIL, 'last_login' => _AM_SYSTEM_USERS_LASTLOGIN, 'user_regdate' => _AM_SYSTEM_USERS_REGDATE, 'posts' => _AM_SYSTEM_USERS_POSTS));
$order_select = new XoopsFormSelect(_AM_SYSTEM_USERS_ORDER, 'user_order');
$order_select->addOptionArray(array('ASC' => _AM_SYSTEM_USERS_ASC, 'DESC' => _AM_SYSTEM_USERS_DESC));
$limit_text = new XoopsFormText(_AM_SYSTEM_USERS_LIMIT, 'user_limit', 6, 2, 20);
$submit_button = new XoopsFormButton('', 'user_submit', _SUBMIT, 'submit');
$form = new XoopsThemeForm(_AM_SYSTEM_USERS_FINDUS, '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);
示例15: XoopsThemeForm
/**
* Show Edit or New-create Form
*
* @param Openid_Context $record
* @param string $op
*/
function _showForm(&$record, $op)
{
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
$form = new XoopsThemeForm(_AD_OPENID_LANG_BUTTONS, 'openid_buttons', $this->_url, 'post', true);
$form->addElement(new XoopsFormHidden('controller', $this->_control));
$form->addElement(new XoopsFormHidden('op', $op));
$form->addElement(new XoopsFormText(_AD_OPENID_LANG_DESCRIPTION, 'description', 64, 255, $record->get4Show('description')));
$form->addElement(new XoopsFormText(_AD_OPENID_LANG_IMAGE, 'image', 64, 255, $record->get4Show('image')));
if ($op == 'save') {
$form->addElement(new XoopsFormHidden('id', $record->get4Show('id')));
$form->addElement(new XoopsFormHidden('type', $record->get4Show('type')));
} else {
$element = new XoopsFormRadio(_AD_OPENID_LANG_TYPE, 'type', $record->get4Show('type'));
$element->addOptionArray(array(_AD_OPENID_LANG_TYPE_SERVER, _AD_OPENID_LANG_TYPE_SINON));
$form->addElement($element);
}
$form->addElement(new XoopsFormText('OpenID Identifier', 'identifier', 64, 255, $record->get4Show('identifier')));
if ($record->get('type') !== '0') {
$form->addElement(new XoopsFormText(_AD_OPENID_LANG_RANGE, 'range', 10, 5, $record->get4Show('range')));
}
$form->addElement(new XoopsFormButton('', 'submit', 'OK', 'submit'));
echo $form->render();
}