本文整理汇总了PHP中XoopsFormCheckBox::addOptionArray方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsFormCheckBox::addOptionArray方法的具体用法?PHP XoopsFormCheckBox::addOptionArray怎么用?PHP XoopsFormCheckBox::addOptionArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsFormCheckBox
的用法示例。
在下文中一共展示了XoopsFormCheckBox::addOptionArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: topicsmanager
//.........这里部分代码省略.........
$imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'");
$imgtray->addElement($imageselect, false);
$imgtray->addElement(new XoopsFormLabel('', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />"));
$uploadfolder = sprintf(_AMS_AM_UPLOAD_WARNING, XOOPS_URL . "/modules/" . $xoopsModule->dirname() . '/images/topics');
$fileseltray = new XoopsFormElementTray('', '<br />');
$fileseltray->addElement(new XoopsFormFile(_AMS_AM_TOPIC_PICTURE, 'attachedfile', $xoopsModuleConfig['maxuploadsize']), false);
$fileseltray->addElement(new XoopsFormLabel($uploadfolder), false);
$imgtray->addElement($fileseltray);
$sform->addElement($imgtray);
//Forum linking
$module_handler =& xoops_gethandler('module');
$forum_module =& $module_handler->getByDirname('newbb');
if (is_object($forum_module) && $forum_module->getVar('version') >= 200) {
$forum_handler =& xoops_getmodulehandler('forum', 'newbb', true);
if (is_object($forum_handler)) {
$forums = $forum_handler->getForums();
if (count($forums) > 0) {
$forum_tree = new XoopsObjectTree($forums, 'forum_id', 'parent_forum');
$sform->addElement(new XoopsFormLabel(_AMS_AM_LINKEDFORUM, $forum_tree->makeSelBox('forum_id', 'forum_name', '--', $forum, true)));
}
}
}
//Banner
$sform->addElement(new XoopsFormDhtmlTextArea(_AMS_AM_TOPICBANNER, 'banner', $banner));
$inherit_checkbox = new XoopsFormCheckBox(_AMS_AM_BANNERINHERIT, 'banner_inherit', $banner_inherit);
$inherit_checkbox->addOption(1, _YES);
$sform->addElement($inherit_checkbox);
//Added in AMS 2.50 Final. Use News 1.62 permission style
//Enhance in AMS 3.0 Beta 1. Add default permission for approval=admin, submit=admin,User.
// Permissions
$member_handler =& xoops_gethandler('member');
$group_list =& $member_handler->getGroupList();
$gperm_handler =& xoops_gethandler('groupperm');
$group_type_ref =& $member_handler->getGroups(null, true);
$admin_list = array();
$user_list = array();
$full_list = array();
$admincount = 1;
$usercount = 1;
$fullcount = 1;
foreach (array_keys($group_type_ref) as $i) {
if ($group_type_ref[$i]->getVar('group_type') == 'Admin') {
$admin_list[$i] = $group_list[$i];
$admincount++;
$user_list[$i] = $group_list[$i];
$usercount++;
}
if ($group_type_ref[$i]->getVar('group_type') == 'User') {
$user_list[$i] = $group_list[$i];
$usercount++;
}
$full_list[$i] = $group_list[$i];
$fullcount++;
}
$admin_list = array_keys($admin_list);
$user_list = array_keys($user_list);
$full_list = array_keys($full_list);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('ams_approve', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $groups_ids);
} else {
// Creation mode
$groups_AMS_can_approve_checkbox = new XoopsFormCheckBox(_AMS_AM_APPROVEFORM, 'groups_AMS_can_approve[]', $admin_list);
}
$groups_AMS_can_approve_checkbox->addOptionArray($group_list);
$sform->addElement($groups_AMS_can_approve_checkbox);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('ams_submit', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $groups_ids);
} else {
// Creation mode
$groups_AMS_can_submit_checkbox = new XoopsFormCheckBox(_AMS_AM_SUBMITFORM, 'groups_AMS_can_submit[]', $user_list);
}
$groups_AMS_can_submit_checkbox->addOptionArray($group_list);
$sform->addElement($groups_AMS_can_submit_checkbox);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('ams_view', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $groups_ids);
} else {
// Creation mode
$groups_AMS_can_view_checkbox = new XoopsFormCheckBox(_AMS_AM_VIEWFORM, 'groups_AMS_can_view[]', $full_list);
}
$groups_AMS_can_view_checkbox->addOptionArray($group_list);
$sform->addElement($groups_AMS_can_view_checkbox);
// Submit buttons
$button_tray = new XoopsFormElementTray('', '');
$submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
$button_tray->addElement($submit_btn);
$sform->addElement($button_tray);
$sform->display();
}
示例2: CriteriaCompo
}
if (empty($modules)) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('hassearch', 1));
$criteria->add(new Criteria('isactive', 1));
if (!empty($available_modules)) {
$criteria->add(new Criteria('mid', "(".implode(',', $available_modules).")", 'IN'));
}
$db =& Database::getInstance();
$result = $db->query("SELECT mid FROM ".$db->prefix("search")." WHERE notshow!=0");
while (list($badmid) = $db->fetchRow($result)) {
$criteria->add(new Criteria('mid', $badmid, '!='));
}
$module_handler =& xoops_gethandler('module');
$mod_arr = $module_handler->getList($criteria);
$mods_checkbox->addOptionArray($mod_arr);
if( count($mod_arr) == 0){
$mods_checkbox = new XoopsFormLabel(_MD_SEARCHIN,_MD_UNABLE_TO_SEARCH);
}
}
else {
foreach ($modules as $mid => $module) {
if (!is_object($module)) continue;
$module_array[$mid] = $module->getVar('name');
}
$mods_checkbox->addOptionArray($module_array);
}
$search_form->addElement($mods_checkbox);
if( $xoopsModuleConfig['search_display_text'] == 1 ){
$search_form->addElement(new XoopsFormRadioYN(_MD_SHOW_CONTEXT, "showcontext", $showcontext));
}
示例3: foreach
$temp_queries = preg_split('/[\\s,]+/', mb_convert_kana($query, 's'));
foreach ($temp_queries as $q) {
$queries[] = addSlashes(trim($q));
}
} else {
$queries = array(addSlashes(trim($query)));
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
// create form
$search_form = new XoopsThemeForm(_SR_SEARCH, "search", "index.php", 'get');
$search_form->addElement(new XoopsFormText(_SR_KEYWORDS, "query", 30, 255, htmlspecialchars(stripslashes(implode(" ", $queries)), ENT_QUOTES)), true);
$type_select = new XoopsFormSelect(_SR_TYPE, "andor", $andor);
$type_select->addOptionArray(array("AND" => _SR_ALL, "OR" => _SR_ANY, "exact" => _SR_EXACT));
$search_form->addElement($type_select);
$mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $mids);
$mods_checkbox->addOptionArray($modules_name);
$search_form->addElement($mods_checkbox);
$search_form->addElement(new XoopsFormHidden("action", "results"));
$search_form->addElement(new XoopsFormHidden("page", "search"));
$search_form->addElement(new XoopsFormButton("", "submit", _SR_SEARCH, "submit"));
$search_form->display();
if ($action == 'results') {
echo '<div style="font-size:small">';
echo "<h3>" . _SR_SEARCHRESULTS . "</h3>";
echo _SR_KEYWORDS . ':';
if ($andor != 'exact') {
foreach ($queries as $q) {
echo ' <b>' . htmlspecialchars(stripslashes($q)) . '</b>';
}
} else {
echo ' "<b>' . htmlspecialchars(stripslashes($queries[0])) . '</b>"';
示例4: itemForm
function itemForm($action = false)
{
global $xoopsModuleConfig, $item_id;
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
include_once XOOPS_ROOT_PATH . "/modules/catalog/include/functions.render.php";
$category_handler = xoops_getmodulehandler('category', 'catalog');
$brand_handler = xoops_getmodulehandler('brand', 'catalog');
$pictures_handler = xoops_getmodulehandler('picture', 'catalog');
$country_handler = xoops_getmodulehandler('country', 'catalog');
$link_handler =& xoops_getmodulehandler('symbol', 'symbol');
$reseller_handler =& xoops_getmodulehandler('reseller', 'reseller');
$cat_handler =& xoops_getmodulehandler('category', 'catalog');
$greenep_handler = xoops_getmodulehandler('greenep', 'catalog');
$att_handler =& xoops_getmodulehandler('attachment', 'catalog');
$title = $this->isNew() ? _AM_CATALOG_ADDITEM : _AM_CATALOG_UPDATEITEM;
$format = empty($format) ? "e" : $format;
$form = new XoopsThemeForm($title, 'form', $action, 'post', true);
$form->setExtra("enctype=\"multipart/form-data\"");
if ($xoopsModuleConfig['display'] == 1) {
$countries =& $country_handler->getList();
$country_select = new XoopsFormSelect(_AM_CATALOG_BELONGCOUNTRY, "country_id", $this->getVar("country_id"));
$country_select->addOption('', _NONE);
$country_select->addOptionArray($countries);
$form->addElement($country_select, true);
$brand_select = new XoopsFormSelect(_AM_CATALOG_ITEMBRAND, "brand_id", $this->getVar("brand_id"));
$brand_select->addOption('', _NONE);
if ($this->getVar("country_id")) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('country_id', $this->getVar("country_id")));
$brands =& $brand_handler->getList($criteria);
unset($criteria);
$brand_select->addOptionArray($brands);
}
$form->addElement($brand_select, true);
}
//关联分类
$categories =& $category_handler->getTrees(0, "--");
$cat_options = array();
if ($categories) {
foreach ($categories as $id => $cat) {
$cat_options[$id] = $cat["prefix"] . $cat["cat_name"];
}
}
$cat_id = empty($_REQUEST['cat_id']) ? "" : $_REQUEST['cat_id'];
$cat_select = new XoopsFormSelect(_AM_CATALOG_ITEMCAT, "cat_id", $this->getVar("cat_id") != 0 ? $this->getVar("cat_id") : $cat_id);
$cat_select->addOption('', _AM_CATALOG_CHOICE);
$cat_select->addOptionArray($cat_options);
$form->addElement($cat_select, true);
/*
$form->addElement(new XoopsFormText(_AM_CATALOG_ITEMNAME, 'item_name', 60, 255, $this->getVar('item_name')), true);
$form->addElement(new XoopsFormDateTime("產品建立日期", 'create_time', 15, $this->getVar('create_time', $format)));
$form->addElement(new XoopsFormText(_AM_CATALOG_MADEIN, 'shop_price', 40, 60, $this->getVar('shop_price')));
$form->addElement(new XoopsFormText(_AM_CATALOG_ITEMPACK, 'item_repairtime', 40, 60, $this->getVar('item_repairtime')));
$form->addElement(new XoopsFormText(_AM_CATALOG_MAINFUNCTION, 'item_size', 100, 255, $this->getVar('item_size')));
$form->addElement(new XoopsFormText(_AM_CATALOG_SHOPPRICE, 'item_weight', 40, 60, $this->getVar('item_weight')));
*/
$form->addElement(new XoopsFormText('商品名稱', 'item_name', 60, 255, $this->getVar('item_name')), true);
$form->addElement(new XoopsFormDateTime("建立日期", 'create_time', 15, $this->getVar('create_time', $format)));
$form->addElement(new XoopsFormText('型號', 'item_repairtime', 40, 60, $this->getVar('item_repairtime')));
$form->addElement(new XoopsFormText('產品顏色', 'item_weight', 40, 60, $this->getVar('item_weight')));
$form->addElement(new XoopsFormText('外觀', 'shop_price', 40, 60, $this->getVar('shop_price')));
$form->addElement(new XoopsFormText('尺寸', 'item_weights', 40, 255, $this->getVar('item_weights')));
$form->addElement(new XoopsFormText('材質', 'item_size', 40, 60, $this->getVar('item_size')));
$form->addElement(new XoopsFormText('重量', 'item_weight2', 40, 255, $this->getVar('item_weight2')));
$form->addElement(new XoopsFormText('包裝', 'item_weightss', 40, 255, $this->getVar('item_weightss')));
$form->addElement(new XoopsFormText('附註', 'item_weightsss', 40, 255, $this->getVar('item_weightsss')));
/*
$criteria2 = new CriteriaCompo();
$criteria2->setSort('greenep_weight');
$criteria2->setOrder('ASC');
$greeneps =& $greenep_handler->getList($criteria2);
$greenep_select = new XoopsFormRadio('供應綠環保程度', "greenep_id", $this->getVar("greenep_id"));
$greenep_select->addOptionArray($greeneps);
$form->addElement($greenep_select);
*/
$format = empty($format) ? "e" : $format;
$form->addElement(new XoopsFormEditor(_AM_CATALOG_FUNCTIONDESC, "item_summary", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '150px', 'name' => 'item_summary', 'value' => $this->getVar('item_summary', $format)), false));
$form->addElement(new XoopsFormEditor(_AM_CATALOG_DETAILSPEC_DESC, "item_description", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '200px', 'name' => 'item_description', 'value' => $this->getVar('item_description', $format)), false));
$form->addElement(new XoopsFormEditor(_AM_CATALOG_AFTERSERVICE_DESC, "item_service", array('editor' => 'ckeditor', 'width' => '100%', 'height' => '200px', 'name' => 'item_service', 'value' => $this->getVar('item_service', $format)), false));
$links =& $link_handler->getList();
$link_select = new XoopsFormSelect(' ', "link_id", $this->getVar("link_id"));
$link_select->addOption('', _NONE);
$link_select->addOptionArray($links);
/*
$link_tray = new XoopsFormElementTray("環保標章選擇", " <br />");
$link_tray->addElement($link_select);
if ($this->getVar("link_id")) {
$link_obj =& $link_handler->get($this->getVar("link_id"));
$link_img = XOOPS_URL . "/uploads/symbol/" . $link_obj->getVar("link_image");
$link_tray->addElement(new XoopsFormLabel('','<span id="symbol_img"><img src="'.$link_img.'" /></span>'));
}
else {
$link_tray->addElement(new XoopsFormLabel('','<span id="symbol_img"></span>'));
}
$form->addElement($link_tray);
*/
/*
//.........这里部分代码省略.........
示例5: 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);
//.........这里部分代码省略.........
示例6: usercsv_form
function usercsv_form()
{
$form = new XoopsThemeForm(_AM_UCSV_EXPORT, 'index_form', basename(__FILE__), 'post', true);
$element = new XoopsFormCheckBox('', 'fields', null, ' ');
$element->addOptionArray(usercsv_getFormFields());
$ele_options = $element->getOptions();
$i = 0;
$option_ids = array();
foreach ($ele_options as $value => $name) {
$i++;
$option_ids[] = 'fields' . $i;
}
$option_ids_str = implode("', '", $option_ids);
$element2 = new XoopsFormLabel(_AM_UCSV_FIELDS, '
<div id="checkfields">' . $element->render() . '
<input name="usercsv_checkall" id="usercsv_checkall" value="" type="checkbox" onclick="var optionids = new Array(\'' . $option_ids_str . '\'); xoopsCheckAllElements(optionids, \'usercsv_checkall\');")>
' . _ALL . ' </div>');
$form->addElement($element2);
unset($element, $element2);
$tray = new XoopsFormElementTray('', '');
$tray->addElement(new XoopsFormButton('', 'usercsv_button', _SUBMIT, 'submit'));
$form->addElement($tray);
$form->addElement(new XoopsFormHidden('op', 'export'));
return $form->render();
}
示例7: 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:
//.........这里部分代码省略.........
示例8: getForm
/**
* @param bool $action
*
* @return XoopsThemeForm
*/
public function getForm($action = false)
{
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
}
if ($this->isNew()) {
$s_cat_value = '';
$a_mod_value = array();
$r_mod_value = array();
$r_block_value = array();
} else {
$sysperm_handler = xoops_getHandler('groupperm');
$s_cat_value = $sysperm_handler->getItemIds('system_admin', $this->getVar('groupid'));
$member_handler = xoops_getHandler('member');
$thisgroup = $member_handler->getGroup($this->getVar('groupid'));
$moduleperm_handler = xoops_getHandler('groupperm');
$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_getHandler('groupperm');
$r_block_value = $gperm_handler->getItemIds('block_read', $this->getVar('groupid'));
}
xoops_load('XoopsFormLoader');
xoops_load('XoopsLists');
include_once XOOPS_ROOT_PATH . '/modules/system/constants.php';
$title = $this->isNew() ? sprintf(_AM_SYSTEM_GROUPS_ADD) : sprintf(_AM_SYSTEM_GROUPS_EDIT);
$form = new XoopsThemeForm($title, 'groupform', $action, 'post', true);
$form->setExtra('enctype="multipart/form-data"');
$name_text = new XoopsFormText(_AM_SYSTEM_GROUPS_NAME, 'name', 30, 50, $this->getVar('name'));
$desc_text = new XoopsFormTextArea(_AM_SYSTEM_GROUPS_DESCRIPTION, 'desc', $this->getVar('description'));
$system_catids = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_SYSTEMRIGHTS, '');
$s_cat_checkbox_all = new XoopsFormCheckBox('', 'catbox', 1);
$s_cat_checkbox_all->addOption('allbox', _AM_SYSTEM_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 XoopsFormCheckBox('', 'system_catids', $s_cat_value);
$s_cat_checkbox->columns = 6;
$admin_dir = XOOPS_ROOT_PATH . '/modules/system/admin/';
$dirlist = XoopsLists::getDirListAsArray($admin_dir);
foreach ($dirlist as $file) {
include XOOPS_ROOT_PATH . '/modules/system/admin/' . $file . '/xoops_version.php';
if (!empty($modversion['category'])) {
if (xoops_getModuleOption('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 XoopsFormElementTray(_AM_SYSTEM_GROUPS_ACTIVERIGHTS, '');
$s_admin_checkbox_all = new XoopsFormCheckBox('', 'adminbox', 1);
$s_admin_checkbox_all->addOption('allbox', _AM_SYSTEM_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 XoopsFormCheckBox('', 'admin_mids[]', $a_mod_value);
$a_mod_checkbox->columns = 5;
$module_handler = xoops_getHandler('module');
$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->getList($criteria));
$admin_mids->addElement($a_mod_checkbox);
$read_mids = new XoopsFormElementTray(_AM_SYSTEM_GROUPS_ACCESSRIGHTS, '');
$s_mod_checkbox_all = new XoopsFormCheckBox('', 'readbox', 1);
$s_mod_checkbox_all->addOption('allbox', _AM_SYSTEM_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 XoopsFormCheckBox('', '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->getList($criteria));
$read_mids->addElement($r_mod_checkbox);
$criteria = new CriteriaCompo(new Criteria('isactive', 1));
$criteria->setSort('mid');
$criteria->setOrder('ASC');
$module_list = $module_handler->getList($criteria);
$module_list[0] = _AM_SYSTEM_GROUPS_CUSTOMBLOCK;
$block_handler = xoops_getHandler('block');
$blocks_obj = $block_handler->getObjects(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 XoopsFormElementTray(_AM_SYSTEM_GROUPS_BLOCKRIGHTS, '<br><br>');
$s_checkbox_all = new XoopsFormCheckBox('', 'blocksbox', 1);
$s_checkbox_all->addOption('allbox', _AM_SYSTEM_ALL);
$s_checkbox_all->setExtra(" onclick='xoopsCheckGroup(\"groupform\", \"blocksbox\" , \"read_bids[]\");' ");
$s_checkbox_all->setClass('xo-checkall');
$r_block_tray->addElement($s_checkbox_all);
//.........这里部分代码省略.........
示例9: topicsmanager
//.........这里部分代码省略.........
}
$sform = new XoopsThemeForm($formlabel, 'topicform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/index.php', 'post');
$sform->setExtra('enctype="multipart/form-data"');
$sform->addElement(new XoopsFormText(_AM_TOPICNAME, 'topic_title', 50, 255, $topic_title), true);
$editor = news_getWysiwygForm(_AM_TOPIC_DESCR, 'topic_description', $topic_description, 15, 60, 'hometext_hidden');
if ($editor) {
$sform->addElement($editor, false);
}
$sform->addElement(new XoopsFormHidden('op', $op), false);
$sform->addElement(new XoopsFormHidden('topic_id', $topic_id), false);
include_once XOOPS_ROOT_PATH . '/modules/news/class/class.newstopic.php';
$xt = new NewsTopic();
$sform->addElement(new XoopsFormLabel(_AM_PARENTTOPIC, $xt->MakeMyTopicSelBox(1, $parent, 'topic_pid', '', false)));
// Topic's color
// Code stolen to Zoullou, thank you Zoullou ;-)
$select_color = "\n<select name='topic_color' onchange='xoopsGetElementById(\"NewsColorSelect\").style.backgroundColor = \"#\" + this.options[this.selectedIndex].value;'>\n<option value='000000'>" . _AM_NEWS_COLOR . "</option>\n";
$color_values = array('000000', '000033', '000066', '000099', '0000CC', '0000FF', '003300', '003333', '003366', '0033CC', '0033FF', '006600', '006633', '006666', '006699', '0066CC', '0066FF', '009900', '009933', '009966', '009999', '0099CC', '0099FF', '00CC00', '00CC33', '00CC66', '00CC99', '00CCCC', '00CCFF', '00FF00', '00FF33', '00FF66', '00FF99', '00FFCC', '00FFFF', '330000', '330033', '330066', '330099', '3300CC', '3300FF', '333300', '333333', '333366', '333399', '3333CC', '3333FF', '336600', '336633', '336666', '336699', '3366CC', '3366FF', '339900', '339933', '339966', '339999', '3399CC', '3399FF', '33CC00', '33CC33', '33CC66', '33CC99', '33CCCC', '33CCFF', '33FF00', '33FF33', '33FF66', '33FF99', '33FFCC', '33FFFF', '660000', '660033', '660066', '660099', '6600CC', '6600FF', '663300', '663333', '663366', '663399', '6633CC', '6633FF', '666600', '666633', '666666', '666699', '6666CC', '6666FF', '669900', '669933', '669966', '669999', '6699CC', '6699FF', '66CC00', '66CC33', '66CC66', '66CC99', '66CCCC', '66CCFF', '66FF00', '66FF33', '66FF66', '66FF99', '66FFCC', '66FFFF', '990000', '990033', '990066', '990099', '9900CC', '9900FF', '993300', '993333', '993366', '993399', '9933CC', '9933FF', '996600', '996633', '996666', '996699', '9966CC', '9966FF', '999900', '999933', '999966', '999999', '9999CC', '9999FF', '99CC00', '99CC33', '99CC66', '99CC99', '99CCCC', '99CCFF', '99FF00', '99FF33', '99FF66', '99FF99', '99FFCC', '99FFFF', 'CC0000', 'CC0033', 'CC0066', 'CC0099', 'CC00CC', 'CC00FF', 'CC3300', 'CC3333', 'CC3366', 'CC3399', 'CC33CC', 'CC33FF', 'CC6600', 'CC6633', 'CC6666', 'CC6699', 'CC66CC', 'CC66FF', 'CC9900', 'CC9933', 'CC9966', 'CC9999', 'CC99CC', 'CC99FF', 'CCCC00', 'CCCC33', 'CCCC66', 'CCCC99', 'CCCCCC', 'CCCCFF', 'CCFF00', 'CCFF33', 'CCFF66', 'CCFF99', 'CCFFCC', 'CCFFFF', 'FF0000', 'FF0033', 'FF0066', 'FF0099', 'FF00CC', 'FF00FF', 'FF3300', 'FF3333', 'FF3366', 'FF3399', 'FF33CC', 'FF33FF', 'FF6600', 'FF6633', 'FF6666', 'FF6699', 'FF66CC', 'FF66FF', 'FF9900', 'FF9933', 'FF9966', 'FF9999', 'FF99CC', 'FF99FF', 'FFCC00', 'FFCC33', 'FFCC66', 'FFCC99', 'FFCCCC', 'FFCCFF', 'FFFF00', 'FFFF33', 'FFFF66', 'FFFF99', 'FFFFCC', 'FFFFFF');
foreach ($color_values as $color_value) {
if ($topic_color == $color_value) {
$selected = " selected='selected'";
} else {
$selected = '';
}
$select_color .= "<option" . $selected . " value='" . $color_value . "' style='background-color:#" . $color_value . ";color:#" . $color_value . ";'>#" . $color_value . "</option>\n";
}
$select_color .= "</select> \n<span id='NewsColorSelect'> </span>";
$sform->addElement(new XoopsFormLabel(_AM_NEWS_TOPIC_COLOR, $select_color));
// Sub menu ?
$sform->addElement(new XoopsFormRadioYN(_AM_SUB_MENU, 'submenu', $submenu, _YES, _NO));
$sform->addElement(new XoopsFormRadioYN(_AM_PUBLISH_FRONTPAGE, 'topic_frontpage', $topic_frontpage, _YES, _NO));
// Unused for this moment... sorry
//$sform->addElement(new XoopsFormText(_AM_NEWS_RSS_URL, 'topic_rssfeed', 50, 255, $topic_rssfeed), false);
// ********** Picture
$imgtray = new XoopsFormElementTray(_AM_TOPICIMG, '<br />');
$imgpath = sprintf(_AM_IMGNAEXLOC, 'modules/' . $xoopsModule->dirname() . '/images/topics/');
$imageselect = new XoopsFormSelect($imgpath, 'topic_imgurl', $topicimage);
$topics_array = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/modules/news/images/topics/');
foreach ($topics_array as $image) {
$imageselect->addOption("{$image}", $image);
}
$imageselect->setExtra("onchange='showImgSelected(\"image3\", \"topic_imgurl\", \"" . $uploadirectory . "\", \"\", \"" . XOOPS_URL . "\")'");
$imgtray->addElement($imageselect, false);
$imgtray->addElement(new XoopsFormLabel('', "<br /><img src='" . XOOPS_URL . "/" . $uploadirectory . "/" . $topicimage . "' name='image3' id='image3' alt='' />"));
$uploadfolder = sprintf(_AM_UPLOAD_WARNING, XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/images/topics');
$fileseltray = new XoopsFormElementTray('', '<br />');
$fileseltray->addElement(new XoopsFormFile(_AM_TOPIC_PICTURE, 'attachedfile', news_getmoduleoption('maxuploadsize')), false);
$fileseltray->addElement(new XoopsFormLabel($uploadfolder), false);
$imgtray->addElement($fileseltray);
$sform->addElement($imgtray);
// Permissions
$member_handler =& xoops_gethandler('member');
$group_list =& $member_handler->getGroupList();
$gperm_handler =& xoops_gethandler('groupperm');
$full_list = array_keys($group_list);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('news_approve', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $groups_ids);
} else {
// Creation mode
$groups_news_can_approve_checkbox = new XoopsFormCheckBox(_AM_APPROVEFORM, 'groups_news_can_approve[]', $full_list);
}
$groups_news_can_approve_checkbox->addOptionArray($group_list);
$sform->addElement($groups_news_can_approve_checkbox);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('news_submit', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $groups_ids);
} else {
// Creation mode
$groups_news_can_submit_checkbox = new XoopsFormCheckBox(_AM_SUBMITFORM, 'groups_news_can_submit[]', $full_list);
}
$groups_news_can_submit_checkbox->addOptionArray($group_list);
$sform->addElement($groups_news_can_submit_checkbox);
$groups_ids = array();
if ($topic_id > 0) {
// Edit mode
$groups_ids = $gperm_handler->getGroupIds('news_view', $topic_id, $xoopsModule->getVar('mid'));
$groups_ids = array_values($groups_ids);
$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $groups_ids);
} else {
// Creation mode
$groups_news_can_view_checkbox = new XoopsFormCheckBox(_AM_VIEWFORM, 'groups_news_can_view[]', $full_list);
}
$groups_news_can_view_checkbox->addOptionArray($group_list);
$sform->addElement($groups_news_can_view_checkbox);
// Submit buttons
$button_tray = new XoopsFormElementTray('', '');
$submit_btn = new XoopsFormButton('', 'post', $btnlabel, 'submit');
$button_tray->addElement($submit_btn);
$sform->addElement($button_tray);
$sform->display();
echo "<script type='text/javascript'>\n";
echo 'xoopsGetElementById("NewsColorSelect").style.backgroundColor = "#' . $topic_color . '";';
echo "</script>\n";
}
示例10: getForm
function getForm($action = false)
{
global $xoopsModuleConfig;
include_once XOOPS_ROOT_PATH . "/modules/portfolio/include/functions.render.php";
include_once XOOPS_ROOT_PATH . "/modules/portfolio/include/functions.php";
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
$service_handler = xoops_getmodulehandler('service', 'portfolio');
$cs_handler = xoops_getmodulehandler('cs', 'portfolio');
$images_handler = xoops_getmodulehandler('images', 'portfolio');
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
}
$title = $this->isNew() ? '添加案例' : '更新案例';
$format = empty($format) ? "e" : $format;
$status = $this->isNew() ? 1 : $this->getVar('case_status');
$form = new XoopsThemeForm($title, 'form', $action, 'post', true);
$form->setExtra("enctype=\"multipart/form-data\"");
//名称
$form->addElement(new XoopsFormText('案例名称', 'case_title', 60, 255, $this->getVar('case_title', $format)), true);
$form->addElement(new XoopsFormText('页面标题', 'case_menu_title', 60, 255, $this->getVar('case_menu_title', $format)));
//所属服务
$service_ids = array();
$cs = '';
if ($this->getVar('case_id')) {
$cs = $cs_handler->getServerIds(array($this->getVar('case_id')));
}
if (!empty($cs)) {
foreach ($cs as $k => $v) {
$service_ids[$v['service_id']] = $v['service_id'];
}
}
$services = $service_handler->getTrees(0, "--");
$service_options = array();
if (!empty($services)) {
foreach ($services as $id => $cat) {
$service_options[$id] = $cat["prefix"] . $cat["service_menu_name"];
}
}
$service_select = new XoopsFormCheckBox("所属服务", "service_ids", array_keys($service_ids));
$service_select->addOptionArray($service_options);
$form->addElement($service_select);
//题头图片
$case_image = new XoopsFormElementTray('题头图片', '', 'image');
if ($this->getVar('case_image')) {
$case_image->addElement(new XoopsFormLabel('', '<img width="100" src="' . XOOPS_URL . '/uploads/portfolio/' . $this->getVar('case_image') . '"><br><br>'));
$delete_check = new XoopsFormCheckBox('', 'delete_image');
$delete_check->addOption(1, _DELETE);
$case_image->addElement($delete_check);
$display = '从新上传将会覆盖现有文件';
} else {
$display = '';
}
$case_image->addElement(new XoopsFormFile('', 'case_image', 1024 * 1024 * 2));
$case_image->addElement(new XoopsFormLabel('', '允许上传的类型为jpeg,pjpeg,gif,png文件'));
$case_image->addElement(new XoopsFormLabel('', $display));
$form->addElement($case_image);
//案例相册
$gallery = new XoopsFormElementTray('案例相册', '', 'gallery');
if (!$this->isNew()) {
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('case_id', $this->getVar('case_id')));
$images = $images_handler->getAll($criteria, null, false, false);
if (!empty($images)) {
$list = '已有图片列表<input id="check" name="check" type="checkbox" onclick="xoopsCheckAll(\'form\',\'check\');" />全部';
$list .= '<ul class="ItemsList">';
foreach ($images as $k => $v) {
$list .= '<li>';
$list .= '
<img width=100 height="80" src="' . XOOPS_URL . '/uploads/portfolio/gallery/' . $v['image_file'] . '">
<div align="center">
<input type="checkbox" value="' . $v['image_id'] . '" name="del_image_ids[]">
名称: <input type="text" value="' . $v['image_title'] . '" maxlength="255" size="10" name="image_title[' . $v['image_id'] . ']"><br />
图片描述: <textarea cols="50" rows="5" name=image_desc[' . $v['image_id'] . ']">' . $v['image_desc'] . '</textarea>
</div>
';
$list .= '</li>';
}
$list .= '</ul>';
$gallery->addElement(new XoopsFormLabel('', $list));
$gallery->addElement(new XoopsFormLabel('', '<br style="clear: both;"/><br />(勾选图片提交后将被清除)'));
}
}
$gallery->addElement(new XoopsFormLabel('', '<div><a id="addMore" href="javascript:void(0);">添加相册内容</a></div>'));
$form->addElement($gallery);
//摘要
$form->addElement(new XoopsFormTextArea('案例摘要', 'case_summary', $this->getVar('case_summary'), 5, 100));
//案例介绍
$configs = array('editor' => 'fckeditor', 'width' => '100%', 'height' => '500px', 'value' => $this->getVar('case_description'));
$form->addElement(new XoopsFormEditor('案例介绍', 'case_description', $configs));
//模板选择
$templates = portfolio_getTemplateList("case");
if (count($templates) > 0) {
$template_select = new XoopsFormSelect("案例模板", "case_tpl", $this->getVar("case_tpl"));
$template_select->addOptionArray($templates);
$form->addElement($template_select);
}
//状态
$form->addElement(new XoopsFormRadioYN('是否显示', 'case_status', 1));
//创建时间
if ($this->isNew()) {
//.........这里部分代码省略.........
示例11: profile_getFieldForm
/**
* Get {@link XoopsThemeForm} for adding/editing fields
*
* @param object $field {@link ProfileField} object to get edit form for
* @param mixed $action URL to submit to - or false for $_SERVER['REQUEST_URI']
*
* @return object
*/
function profile_getFieldForm(&$field, $action = false)
{
if ($action === false) {
$action = $_SERVER['REQUEST_URI'];
}
$title = $field->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_FIELD) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_FIELD);
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
$form = new XoopsThemeForm($title, 'form', $action, 'post', true);
$form->addElement(new XoopsFormText(_PROFILE_AM_TITLE, 'field_title', 35, 255, $field->getVar('field_title', 'e')));
$form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'field_description', $field->getVar('field_description', 'e')));
if (!$field->isNew()) {
$fieldcat_id = $field->getVar('cat_id');
} else {
$fieldcat_id = 0;
}
$category_handler =& xoops_getmodulehandler('category');
$cat_select = new XoopsFormSelect(_PROFILE_AM_CATEGORY, 'field_category', $fieldcat_id);
$cat_select->addOption(0, _PROFILE_AM_DEFAULT);
$cat_select->addOptionArray($category_handler->getList());
$form->addElement($cat_select);
$form->addElement(new XoopsFormText(_PROFILE_AM_WEIGHT, 'field_weight', 10, 10, $field->getVar('field_weight', 'e')));
if ($field->getVar('field_config') || $field->isNew()) {
if (!$field->isNew()) {
$form->addElement(new XoopsFormLabel(_PROFILE_AM_NAME, $field->getVar('field_name')));
$form->addElement(new XoopsFormHidden('id', $field->getVar('field_id')));
} else {
$form->addElement(new XoopsFormText(_PROFILE_AM_NAME, 'field_name', 35, 255, $field->getVar('field_name', 'e')));
}
//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 XoopsFormSelect(_PROFILE_AM_TYPE, 'field_type', $field->getVar('field_type', 'e'));
$element_select->addOptionArray($fieldtypes);
$form->addElement($element_select);
switch ($field->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, XOBJ_DTYPE_UNICODE_ARRAY => _PROFILE_AM_UNICODE_ARRAY, XOBJ_DTYPE_UNICODE_TXTBOX => _PROFILE_AM_UNICODE_TXTBOX, XOBJ_DTYPE_UNICODE_TXTAREA => _PROFILE_AM_UNICODE_TXTAREA, XOBJ_DTYPE_UNICODE_EMAIL => _PROFILE_AM_UNICODE_EMAIL, XOBJ_DTYPE_UNICODE_URL => _PROFILE_AM_UNICODE_URL);
$type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
$type_select->addOptionArray($valuetypes);
$form->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, XOBJ_DTYPE_UNICODE_ARRAY => _PROFILE_AM_UNICODE_ARRAY, XOBJ_DTYPE_UNICODE_TXTBOX => _PROFILE_AM_UNICODE_TXTBOX, XOBJ_DTYPE_UNICODE_TXTAREA => _PROFILE_AM_UNICODE_TXTAREA, XOBJ_DTYPE_UNICODE_EMAIL => _PROFILE_AM_UNICODE_EMAIL, XOBJ_DTYPE_UNICODE_URL => _PROFILE_AM_UNICODE_URL);
$type_select = new XoopsFormSelect(_PROFILE_AM_VALUETYPE, 'field_valuetype', $field->getVar('field_valuetype', 'e'));
$type_select->addOptionArray($valuetypes);
$form->addElement($type_select);
break;
}
//$form->addElement(new XoopsFormRadioYN(_PROFILE_AM_NOTNULL, 'field_notnull', $field->getVar('field_notnull', 'e') ));
if ($field->getVar('field_type') == "select" || $field->getVar('field_type') == "select_multi" || $field->getVar('field_type') == "radio" || $field->getVar('field_type') == "checkbox") {
$options = $field->getVar('field_options');
if (count($options) > 0) {
$remove_options = new XoopsFormCheckBox(_PROFILE_AM_REMOVEOPTIONS, 'removeOptions');
$remove_options->columns = 3;
asort($options);
foreach (array_keys($options) as $key) {
$options[$key] .= "[{$key}]";
}
$remove_options->addOptionArray($options);
$form->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>";
$form->addElement(new XoopsFormLabel(_PROFILE_AM_ADDOPTION, $option_text));
}
}
if ($field->getVar('field_edit')) {
switch ($field->getVar('field_type')) {
case "textbox":
case "textarea":
case "dhtml":
$form->addElement(new XoopsFormText(_PROFILE_AM_MAXLENGTH, 'field_maxlength', 35, 35, $field->getVar('field_maxlength', 'e')));
$form->addElement(new XoopsFormTextArea(_PROFILE_AM_DEFAULT, 'field_default', $field->getVar('field_default', 'e')));
break;
case "checkbox":
case "select_multi":
$def_value = $field->getVar('field_default', 'e') != null ? unserialize($field->getVar('field_default', 'n')) : null;
$element = new XoopsFormSelect(_PROFILE_AM_DEFAULT, 'field_default', $def_value, 8, true);
$options = $field->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('', _NONE);
}
$element->addOptionArray($options);
$form->addElement($element);
break;
case "select":
//.........这里部分代码省略.........
示例12: isset
* @author Susheng Yang <ezskyyoung@gmail.com>
* @version $Id$
*/
include 'header.php';
xoops_cp_header();
loadModuleAdminMenu(1, "");
$op = isset($_REQUEST['op']) ? $_REQUEST['op'] : 'index';
switch ($op) {
default:
case "index":
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
$form = new XoopsThemeForm(_MI_TOOLS_INDEX, "updatecache", "index.php", "post", true);
$form->addElement(new XoopsFormLabel(_AM_TOOLS_TIP, _AM_TOOLS_TIPS));
$checkbox_options = array("updatexoopscache" => _AM_TOOLS_UPDATEXOOPSCACHE, "updatesmartycache" => _AM_TOOLS_UPDATESMARTYCACHE, "updatesmartycompile" => _AM_TOOLS_UPDATESMARTYCOMPILE);
$checkbox = new XoopsFormCheckBox(_AM_TOOLS_OPTIONS, "options", array_keys($checkbox_options));
$checkbox->addOptionArray($checkbox_options);
$form->addElement($checkbox);
$form->addElement(new XoopsFormHidden("op", "updatecache"));
$form->addElement(new XoopsFormHidden("step", "1"));
$form->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit"));
$form->display();
break;
case "updatecache":
if ($_REQUEST['step'] == 1) {
$options = implode('_', $_REQUEST['options']);
$url = XOOPS_URL . "/modules/tools/admin/index.php?op=updatecache&step=2&options={$options}";
$updating = _AM_TOOLS_UPDATING;
$msg = <<<EOF
\t<div class="loading" style="text-align:center">
<img src="../images/loader.gif" />
<p>{$updating}</P>
示例13: 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':
//.........这里部分代码省略.........
示例14: alumni_getSearchFrom
public function alumni_getSearchFrom($andor, $queries, $mids, $mid, $bycat)
{
$xoops = Xoops::getInstance();
$alumni = Alumni::getInstance();
// create form
parent::__construct(XoopsLocale::SEARCH, 'alumni', 'search.php', 'get');
// create form elements
$this->addElement(new XoopsFormText(XoopsLocale::KEYWORDS, 'query', 30, 255, htmlspecialchars(stripslashes(implode(' ', $queries)), ENT_QUOTES)), true);
$type_select = new XoopsFormSelect(XoopsLocale::TYPE, 'andor', $andor);
$type_select->addOptionArray(array('AND' => XoopsLocale::ALL_AND, 'OR' => XoopsLocale::ANY_OR, 'exact' => XoopsLocale::EXACT_MATCH));
$this->addElement($type_select);
$by_cat = Request::getInt('by_cat', 0);
$categoriesHandler = $xoops->getModuleHandler('category', 'alumni');
$search = Search::getInstance();
$module_id = $xoops->module->getVar('mid');
$groups = $xoops->isUser() ? $xoops->user->getGroups() : '3';
$alumni_ids = $alumni->getGrouppermHandler()->getItemIds('alumni_view', $groups, $module_id);
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('cid', '(' . implode(', ', $alumni_ids) . ')', 'IN'));
$criteria->setOrder($xoops->getModuleConfig('alumni_csortorder'));
$category_arr = $categoriesHandler->getall($criteria);
foreach (array_keys($category_arr) as $i) {
$cid = $category_arr[$i]->getVar('cid');
$pid = $category_arr[$i]->getVar('pid');
$title = $category_arr[$i]->getVar('title');
}
$categories = $alumni->getCategoryHandler()->getCategoriesForSearch();
$category_select = new XoopsFormSelect(AlumniLocale::L_ALUMNI_CATEGORIES, 'by_cat', $by_cat);
foreach ($categories as $cid => $title) {
$category_select->addOption('0', XoopsLocale::ALL);
$category_select->addOptionArray(array($cid => $title));
}
$this->addElement($category_select);
if (!empty($mids)) {
$mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mids);
} else {
$mods_checkbox = new XoopsFormCheckBox(XoopsLocale::SEARCH_IN, 'mids[]', $mid);
}
if (empty($modules)) {
$gperm_handler = $xoops->getHandlerGroupPermission();
$available_modules = $gperm_handler->getItemIds('module_read', $xoops->getUserGroups());
$available_plugins = Xoops\Module\Plugin::getPlugins('search');
$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 XoopsFormLabel(XoopsLocale::SEARCH_RULE, sprintf(XoopsLocale::EF_KEYWORDS_MUST_BE_GREATER_THAN, $search->getConfig('keyword_min'))));
}
$this->addElement(new XoopsFormHidden('action', 'results'));
$this->addElement(new XoopsFormHiddenToken('id'));
$this->addElement(new XoopsFormButton('', 'submit', XoopsLocale::SEARCH, 'submit'));
return $this;
}
示例15: XoopsThemeForm
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
// create form
$search_form = new XoopsThemeForm(_SR_SEARCH, "search_form", $_SERVER['PHP_SELF'], 'POST');
// create form elements
$search_form->addElement(new XoopsFormText(_SR_KEYWORDS, "query", 30, 255, htmlspecialchars(stripslashes(implode(" ", $queries)), ENT_QUOTES)), true);
$search_form->addElement(new XoopsFormText(_AMS_NW_USERNAME, "username", 30, 255, $username), false);
$type_select = new XoopsFormSelect(_SR_TYPE, "andor", $andor);
$type_select->addOptionArray(array("AND" => _SR_ALL, "OR" => _SR_ANY, "exact" => _SR_EXACT));
$search_form->addElement($type_select);
if (!empty($mids)) {
$mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $mids);
} else {
$mods_checkbox = new XoopsFormCheckBox(_SR_SEARCHIN, "mids[]", $xoopsModule->mid());
}
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('hassearch', 1));
$criteria->add(new Criteria('isactive', 1));
$module_handler =& xoops_gethandler('module');
$mods_checkbox->addOptionArray($module_handler->getList($criteria));
$search_form->addElement($mods_checkbox);
if ($xoopsConfigSearch['keyword_min'] > 0) {
$search_form->addElement(new XoopsFormLabel(_SR_SEARCHRULE, sprintf(_SR_KEYIGNORE, $xoopsConfigSearch['keyword_min'])));
}
$search_form->addElement(new XoopsFormHidden("op", "results"));
$search_form->addElement(new XoopsFormHidden('storyid', $article->storyid()));
$search_form->addElement(new XoopsFormButton("", "submit", _SR_SEARCH, "submit"));