/** * Get a {@link XoopsForm} object for creating/editing objects * @param mixed $action receiving page - defaults to $_SERVER['REQUEST_URI'] * @param mixed $title title of the form * * @return object */ function getForm($action = false, $title = false) { include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; if ($action == false) { $url_parts = parse_url($_SERVER['REQUEST_URI']); $action = $url_parts['path']; } if ($title == false) { $title = $this->isNew() ? _ADD : _EDIT; $title .= " " . _NL_AM_DISPATCH; } $form = new XoopsThemeForm($title, 'form', $action); if (!$this->isNew()) { $form->addElement(new XoopsFormHidden('id', $this->getVar('dispatch_id'))); } else { $this->assignVar('dispatch_time', $this->getNextDispatch()); } $form->addElement(new XoopsFormHidden('op', 'save')); $form->addElement(new XoopsFormHidden('nid', $this->getVar('newsletterid'))); $time = new XoopsFormDateTime(_NL_AM_TIME, 'dispatch_time', 15, $this->getVar('dispatch_time')); $time->_name = "dispatch_time"; //XOOPS 2.0.13.2 < fix for missing name attribute $form->addElement($time); $form->addElement(new XoopsFormText(_NL_AM_SUBJECT, 'dispatch_subject', 75, 255, $this->getVar('dispatch_subject', 'e'))); $status_radio = new XoopsFormRadio(_NL_AM_STATUS, 'dispatch_status', $this->getVar('dispatch_status')); $status_radio->addOption(0, _NL_AM_NOTREADY); $status_radio->addOption(1, _NL_AM_READY); $status_radio->addOption(2, _NL_AM_DISPATCHED); $form->addElement($status_radio); $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); return $form; }
/** * Get a {@link XoopsForm} object for creating/editing Spotlight articles * * @return object */ function getForm($action = false) { if ($action === false) { $action = $_SERVER['REQUEST_URI']; } $title = _AMS_AM_SPOTLIGHT; include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; include_once XOOPS_ROOT_PATH . "/modules/AMS/class/formimageselect.php"; $form = new XoopsThemeForm($title, 'spotlightform', $action); if (!$this->isNew()) { $form->addElement(new XoopsFormHidden('id', $this->getVar('spotlightid'))); } $mode_select = new XoopsFormRadio('', 'mode', $this->getVar('mode')); $mode_select->addOption(1, _AMS_AM_SPOT_LATESTARTICLE); $mode_select->addOption(2, _AMS_AM_SPOT_LATESTINTOPIC); $mode_select->addOption(3, _AMS_AM_SPOT_SPECIFICARTICLE); $mode_select->addOption(4, _AMS_AM_SPOT_CUSTOM); include_once XOOPS_ROOT_PATH . "/class/tree.php"; include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newstopic.php"; include_once XOOPS_ROOT_PATH . "/modules/AMS/class/class.newsstory.php"; $xt = new AmsTopic($GLOBALS['xoopsDB']->prefix("ams_topics")); $allTopics = $xt->getAllTopics(); $topic_obj_tree = new XoopsObjectTree($allTopics, 'topic_id', 'topic_pid'); $topic_select = new XoopsFormLabel(_AMS_AM_TOPIC, $topic_obj_tree->makeSelBox('topicid', 'topic_title', '--', $this->getVar('topicid'), false)); $topic_select->setDescription(_AMS_AM_SPOT_TOPIC_DESC); $article_select = new XoopsFormSelect(_AMS_AM_ARTICLE, 'storyid', $this->getVar('storyid')); $article_select->addOptionArray(AmsStory::getAllPublished($GLOBALS['xoopsModuleConfig']['spotlight_art_num'], 0, false, 0, 1, false)); $article_select->setDescription(_AMS_AM_SPOT_ARTICLE_DESC); $mode_tray = new XoopsFormElementTray(_AMS_AM_SPOT_MODE_SELECT); $mode_tray->addElement($mode_select); $showimage_select = new XoopsFormRadio(_AMS_AM_SPOT_SHOWIMAGE, 'showimage', $this->getVar('showimage')); $showimage_select->addOption(0, _AMS_AM_SPOT_SPECIFYIMAGE); $showimage_select->addOption(1, _AMS_AM_SPOT_TOPICIMAGE); $showimage_select->addOption(2, _AMS_AM_SPOT_AUTHORIMAGE); $showimage_select->addOption(3, _AMS_AM_SPOT_NOIMAGE); $showimage_select->setDescription(_AMS_AM_SPOT_SHOWIMAGE_DESC); $image_select = new XoopsFormImageSelect(_AMS_AM_SPOT_IMAGE, 'image', $this->getVar('image', 'e'), 70, 255); $autoteaser_select = new XoopsFormRadioYN(_AMS_AM_SPOT_AUTOTEASER, 'autoteaser', $this->getVar('autoteaser')); $teaser_text = new XoopsFormDhtmlTextArea(_AMS_AM_SPOT_TEASER, 'teaser', $this->getVar('teaser', 'e')); $maxlength_text = new XoopsFormText(_AMS_AM_SPOT_MAXLENGTH, 'maxlength', 10, 10, $this->getVar('maxlength')); $display_select = new XoopsFormRadioYN(_AMS_AM_SPOT_DISPLAY, 'display', $this->getVar('display')); $weight_text = new XoopsFormText(_AMS_AM_SPOT_WEIGHT, 'weight', 10, 10, $this->getVar('weight')); $form->addElement($mode_tray); $form->addElement($topic_select); $form->addElement($article_select); $form->addElement($showimage_select); $form->addElement($image_select); $form->addElement($autoteaser_select); $form->addElement($maxlength_text); $form->addElement($teaser_text); $form->addElement($display_select); $form->addElement($weight_text); $form->addElement(new XoopsFormHidden('op', 'save')); $form->addElement(new XoopsFormButton('', 'spotlightsubmit', _AMS_AM_SUBMIT, 'submit')); return $form; }
function _b_wp_archives_monthly_edit($options) { require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $optForm = new XoopsSimpleForm('Block Option Dummy Form', 'optionform', ''); $optFormType = new XoopsFormRadio('Month List Style:', 'options[0]', $options[0]); $optFormType->addOption(0, 'Simple List'); $optFormType->addOption(1, 'Dropdown List'); $optForm->addElement($optFormType); $optForm->addElement(new XoopsFormRadioYN('Listing with count:', 'options[1]', $options[1])); $optForm->addElement(new XoopsFormText('Custom Block Template File<br />(Default: wp_archives_monthly.html):', 'options[2]', 25, 50, $options[2])); $_wpTpl =& new WordPresTpl('theme'); $optForm->assign($_wpTpl); return $_wpTpl->fetch('wp_block_edit.html'); }
function _b_wp_recent_comments_edit($options) { require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $optForm = new XoopsSimpleForm('Block Option Dummy Form', 'optionform', ''); $optFormType = new XoopsFormRadio('Comment List Style:', 'options[0]', $options[0]); $optFormType->addOption(0, 'Standard'); $optFormType->addOption(1, 'Grouped by Article'); $optForm->addElement($optFormType); $optForm->addElement(new XoopsFormText('Comment List Count:', 'options[1]', 5, 5, $options[1])); $optForm->addElement(new XoopsFormRadioYN('Display RSS Icon:', 'options[2]', $options[2])); $optForm->addElement(new XoopsFormRadioYN('Display Posted Date:', 'options[3]', $options[3])); $optForm->addElement(new XoopsFormRadioYN('Show Comment Type:', 'options[4]', $options[4])); $optForm->addElement(new XoopsFormText('Custom Block Template File<br />(Default: wp_recent_comments.html):', 'options[5]', 25, 50, $options[5])); $_wpTpl =& new WordPresTpl('theme'); $optForm->assign($_wpTpl); return $_wpTpl->fetch('wp_block_edit.html'); }
function _b_wp_categories_edit($options) { require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; $optForm = new XoopsSimpleForm('Block Option Dummy Form', 'optionform', ''); $optFormType = new XoopsFormRadio('Category List Style:', 'options[0]', $options[0]); $optFormType->addOption(0, 'Simple List'); $optFormType->addOption(1, 'Dropdown List'); $optForm->addElement($optFormType); $optForm->addElement(new XoopsFormRadioYN('Listing with count:', 'options[1]', $options[1])); $optFormSort = new XoopsFormRadio('Sorting Key:', 'options[2]', $options[2]); $optFormSort->addOption('ID', 'ID'); $optFormSort->addOption('name', 'Name'); $optFormSort->addOption('description', 'Description'); $optForm->addElement($optFormSort); $optFormOrder = new XoopsFormRadio('Sorting Order:', 'options[3]', $options[3]); $optFormOrder->addOption('asc', 'Ascending'); $optFormOrder->addOption('desc', 'Descending'); $optForm->addElement($optFormOrder); $_wpTpl =& new WordPresTpl('theme'); $optForm->assign($_wpTpl); return $_wpTpl->fetch('wp_block_edit.html'); }
$mes = new XoopsFormRadio("Manual evaluation strategy:", "dataset[manualEvaluationStrategy]", "D"); $mes->addOption("D", "Evaluate a given document on all queries"); $mes->addOption("Q", "Evaluate all documents on a given query"); $formulario->addElement($mes); $formulario->insertBreak(); $formulario->addElement(new XoopsFormLabel("Select one of the scale method below:")); $escala1 = new XoopsFormRadio("", "dataset[modoEscala]", "1"); $escala1->addOption("1", "Standard relevance:"); $formulario->addElement($escala1); $formulario->addElement(new XoopsFormLabel('', "<blockquote>\r\n\t\t<input type=\"checkbox\" name=\"escala1_1\" value=\"S\"> No relevance<br>\r\n\t\t<input type=\"checkbox\" name=\"escala1_2\" value=\"S\"> Low relevance<br>\r\n\t\t<input type=\"checkbox\" name=\"escala1_3\" value=\"S\" checked> Medium relevance<br>\r\n\t\t<input type=\"checkbox\" name=\"escala1_4\" value=\"S\" checked> High relevance<br>\r\n\t\t</blockquote>")); $escala2 = new XoopsFormRadio("", "dataset[modoEscala]"); $escala2->addOption("2", "Score:"); $formulario->addElement($escala2); $formulario->addElement(new XoopsFormLabel('', "<blockquote>\r\n\t\t<input type=\"checkbox\" name=\"escala2_1\" value=\"S\"> 1<br>\r\n\t\t<input type=\"checkbox\" name=\"escala2_2\" value=\"S\"> 2<br>\r\n\t\t<input type=\"checkbox\" name=\"escala2_3\" value=\"S\"> 3<br>\r\n\t\t<input type=\"checkbox\" name=\"escala2_4\" value=\"S\" checked> 4<br>\r\n\t\t<input type=\"checkbox\" name=\"escala2_5\" value=\"S\" checked> 5<br>\r\n\t\t</blockquote>")); $escala3 = new XoopsFormRadio("", "dataset[modoEscala]"); $escala3->addOption("3", "Custom:"); $formulario->addElement($escala3); $tray1 = new XoopsFormElementTray("", "<br/>", "", "center"); $tray1->addElement(new XoopsFormLabel('', "<blockquote>")); for ($i = 0; $i < 10; $i++) { $traytmp = new XoopsFormElementTray(""); $namecheck = "check_{$i}"; ${$namecheck} = new XoopsFormCheckBox("", "escala3_{$i}"); ${$namecheck}->addOption("S", "{$i} - "); $traytmp->addElement(${$namecheck}); $traytmp->addElement(new XoopsFormText("", "dataset[escalap][{$i}]", 20, 20)); $nametray = "tray_{$i}"; ${$nametray} = $traytmp; $tray1->addElement(${$nametray}); } $tray1->addElement(new XoopsFormLabel('', "</blockquote>"));
$delete_attach_checkbox = new XoopsFormCheckBox(_MD_REMOVE, 'delete_tmp[]'); $url_prefix = str_replace(XOOPS_ROOT_PATH, XOOPS_URL, XOOPS_CACHE_PATH); foreach ($attachments_tmp as $key => $attachment) { $attach = ' <a href="' . $url_prefix . '/' . $attachment[0] . '" targe="_blank" >' . $attachment[1] . '</a>'; $delete_attach_checkbox->addOption($key, $attach); } $forum_form->addElement($delete_attach_checkbox); unset($delete_attach_checkbox); $attachments_tmp = base64_encode(serialize($attachments_tmp)); $forum_form->addElement(new XoopsFormHidden('attachments_tmp', $attachments_tmp)); } if ($xoopsModuleConfig['enable_karma'] || $xoopsModuleConfig['allow_require_reply']) { $view_require = $require_reply ? 'require_reply' : ($post_karma ? 'require_karma' : 'require_null'); $radiobox = new XoopsFormRadio(_MD_VIEW_REQUIRE, 'view_require', $view_require); if ($xoopsModuleConfig['allow_require_reply']) { $radiobox->addOption('require_reply', _MD_REQUIRE_REPLY); } if ($xoopsModuleConfig['enable_karma']) { $karmas = explode(',', $xoopsModuleConfig['karma_options']); $karmas = array_map("trim", $karmas); if (count($karmas) > 1) { foreach ($karmas as $karma) { $karma_array[strval($karma)] = intval($karma); } $karma_select = new XoopsFormSelect('', "post_karma", $post_karma); $karma_select->addOptionArray($karma_array); $radiobox->addOption('require_karma', _MD_REQUIRE_KARMA . $karma_select->render()); } } $radiobox->addOption('require_null', _MD_REQUIRE_NULL); }
$form = new XoopsThemeForm($form_name, "MainForm", "index.php"); // title $form->addElement(new XoopsFormText(_TC_LINKNAME, "title", 50, 255, htmlspecialchars($title, ENT_QUOTES))); // a file should be wrapped $address_select = new XoopsFormSelect(_TC_URL, "address", $address); $dir_handle = dir($wrap_path); while ($file = $dir_handle->read()) { if (is_file("{$wrap_path}/{$file}") && $file != 'index.php') { $address_select->addOption($file, htmlspecialchars($file, ENT_QUOTES)); } } $dir_handle->close(); $form->addElement($address_select); // base path for wrapping $wraproot_radio = new XoopsFormRadio(_TC_WRAPROOT, 'wraproot', $link); $wraproot_radio->addOption(TC_WRAPTYPE_NORMAL, sprintf(_TC_FMT_WRAPROOTTC, $mymodpath)); $wraproot_radio->addOption(TC_WRAPTYPE_CONTENTBASE, sprintf(_TC_FMT_WRAPROOTPAGE, $wrap_path)); $wraproot_radio->addOption(TC_WRAPTYPE_USEREWRITE, sprintf(_TC_FMT_WRAPBYREWRITE, $wrap_path)); $wraproot_radio->addOption(TC_WRAPTYPE_CHANGESRCHREF, sprintf(_TC_FMT_WRAPCHANGESRCHREF, $wrap_path)); $form->addElement($wraproot_radio); // options $option_tray = new XoopsFormElementTray(_OPTIONS, '<br />'); // visible $visible_checkbox = new XoopsFormCheckBox('', 'visible', $visible); $visible_checkbox->addOption(1, _TC_VISIBLE); $option_tray->addElement($visible_checkbox); // submenu $submenu_checkbox = new XoopsFormCheckBox('', 'submenu', $submenu); $submenu_checkbox->addOption(1, _TC_SUBMENU); $option_tray->addElement($submenu_checkbox); // comments
/** * Metagen * * Metagen is a system that can help you to have your page best indexed by search engines. * Except if you type meta keywords and meta descriptions yourself, the module will automatically create them. * From here you can also manage some other options like the maximum number of meta keywords to create and * the keywords apparition's order. */ function Metagen() { include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $cfg; xoops_cp_header(); $myts =& MyTextSanitizer::getInstance(); if (file_exists(XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php')) { include_once XOOPS_ROOT_PATH . '/modules/news/language/' . $xoopsConfig['language'] . '/main.php'; } else { include_once XOOPS_ROOT_PATH . '/modules/news/language/english/main.php'; } adminmenu(8); echo "<h1>" . _AM_NEWS_METAGEN . "</h1>"; echo _AM_NEWS_METAGEN_DESC . "<br /><br />"; // Metagen Options $registry = new news_registryfile('news_metagen_options.txt'); $content = ''; $content = $registry->getfile(); if (xoops_trim($content) != '') { list($keywordscount, $keywordsorder) = explode(',', $content); } else { $keywordscount = $cfg['meta_keywords_count']; $keywordsorder = $cfg['meta_keywords_order']; } $sform = new XoopsThemeForm(_OPTIONS, 'metagenoptions', XOOPS_URL . '/modules/news/admin/index.php', 'post'); $sform->addElement(new XoopsFormHidden('op', 'metagenoptions'), false); $sform->addElement(new XoopsFormText(_AM_NEWS_META_KEYWORDS_CNT, 'keywordscount', 4, 6, $keywordscount), true); $keywordsorder = new XoopsFormRadio(_AM_NEWS_META_KEYWORDS_ORDER, 'keywordsorder', $keywordsorder); $keywordsorder->addOption(0, _AM_NEWS_META_KEYWORDS_INTEXT); $keywordsorder->addOption(1, _AM_NEWS_META_KEYWORDS_FREQ1); $keywordsorder->addOption(2, _AM_NEWS_META_KEYWORDS_FREQ2); $sform->addElement($keywordsorder, false); $button_tray = new XoopsFormElementTray('', ''); $submit_btn = new XoopsFormButton('', 'post', _AM_MODIFY, 'submit'); $button_tray->addElement($submit_btn); $sform->addElement($button_tray); $sform->display(); // Blacklist $sform = new XoopsThemeForm(_AM_NEWS_BLACKLIST, 'metagenblacklist', XOOPS_URL . '/modules/news/admin/index.php', 'post'); $sform->addElement(new XoopsFormHidden('op', 'metagenblacklist'), false); // Remove words $remove_tray = new XoopsFormElementTray(_AM_NEWS_BLACKLIST); $remove_tray->setDescription(_AM_NEWS_BLACKLIST_DESC); $blacklist = new XoopsFormSelect('', 'blacklist', '', 5, true); $words = array(); $metablack = new news_blacklist(); $words = $metablack->getAllKeywords(); if (is_array($words) && count($words) > 0) { foreach ($words as $key => $value) { $blacklist->addOption($key, $value); } } $blacklist->setDescription(_AM_NEWS_BLACKLIST_DESC); $remove_tray->addElement($blacklist, false); $remove_btn = new XoopsFormButton('', 'go', _AM_DELETE, 'submit'); $remove_tray->addElement($remove_btn, false); $sform->addElement($remove_tray); // Add some words $add_tray = new XoopsFormElementTray(_AM_NEWS_BLACKLIST_ADD); $add_tray->setDescription(_AM_NEWS_BLACKLIST_ADD_DSC); $add_field = new XoopsFormTextArea('', 'keywords', '', 5, 70); $add_tray->addElement($add_field, false); $add_btn = new XoopsFormButton('', 'go', _AM_ADD, 'submit'); $add_tray->addElement($add_btn, false); $sform->addElement($add_tray); $sform->display(); }
} if (!empty($counts_module)) { $module_handler =& xoops_gethandler("module"); $module_list = $module_handler->getList(new Criteria("mid", "(" . implode(", ", array_keys($counts_module)) . ")", "IN")); } } $opform = new XoopsSimpleForm('', 'moduleform', xoops_getenv("PHP_SELF"), "get"); $tray = new XoopsFormElementTray(''); $mod_select = new XoopsFormSelect(_SELECT, 'modid', $modid); $mod_select->addOption(0, _ALL); foreach ($module_list as $module => $module_name) { $mod_select->addOption($module, $module_name . " (" . $counts_module[$module] . ")"); } $tray->addElement($mod_select); $status_select = new XoopsFormRadio("", 'status', $status); $status_select->addOption(-1, _ALL); $status_select->addOption(0, TAG_AM_ACTIVE); $status_select->addOption(1, TAG_AM_INACTIVE); $tray->addElement($status_select); $tray->addElement(new XoopsFormButton("", "submit", _SUBMIT, "submit")); $opform->addElement($tray); $opform->display(); $criteria = new CriteriaCompo(); $criteria->setSort("a"); $criteria->setOrder("ASC"); $criteria->setStart($start); $criteria->setLimit($limit); if ($status >= 0) { $criteria->add(new Criteria("o.tag_status", $status)); } if (!empty($modid)) {
function addOption($id1, $id2, $text, $type = 'check', $checked = null) { if (!isset($text)) { $text = ""; } $d = new XoopsFormText('', $id1, 40, 255, $text); if ($type == 'check') { $c = new XoopsFormCheckBox('', $id2, $checked); $c->addOption(1, ' '); } else { $c = new XoopsFormRadio('', 'checked', $checked); $c->addOption($id2, ' '); } $t = new XoopsFormElementTray(''); $t->addElement($c); $t->addElement($d); return $t; }
} $sform->addElement($checkbox); $sticky_confirmation = new XoopsFormRadio(_AM_NEWBB_PRUNE_STICKY, 'sticky', 1); $sticky_confirmation->addOption(1, _AM_NEWBB_PRUNE_YES); $sticky_confirmation->addOption(0, _AM_NEWBB_PRUNE_NO); $sform->addElement($sticky_confirmation); $digest_confirmation = new XoopsFormRadio(_AM_NEWBB_PRUNE_DIGEST, 'digest', 1); $digest_confirmation->addOption(1, _AM_NEWBB_PRUNE_YES); $digest_confirmation->addOption(0, _AM_NEWBB_PRUNE_NO); $sform->addElement($digest_confirmation); $lock_confirmation = new XoopsFormRadio(_AM_NEWBB_PRUNE_LOCK, 'lock', 0); $lock_confirmation->addOption(1, _AM_NEWBB_PRUNE_YES); $lock_confirmation->addOption(0, _AM_NEWBB_PRUNE_NO); $sform->addElement($lock_confirmation); $hot_confirmation = new XoopsFormSelect(_AM_NEWBB_PRUNE_HOT, 'hot', null, 1, false); $hot_confirmation->addOptionArray(array('0' => 0, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $sform->addElement($hot_confirmation); $sform->addElement($radiobox); $archive_confirmation = new XoopsFormRadio(_AM_NEWBB_PRUNE_ARCHIVE, 'archive', 1); $archive_confirmation->addOption(1, _AM_NEWBB_PRUNE_YES); $archive_confirmation->addOption(0, _AM_NEWBB_PRUNE_NO); $sform->addElement($archive_confirmation); $button_tray = new XoopsFormElementTray('', ''); $button_tray->addElement(new XoopsFormButton('', 'submit', _AM_NEWBB_PRUNE_SUBMIT, 'submit')); $button_tray->addElement(new XoopsFormButton('', 'reset', _AM_NEWBB_PRUNE_RESET, 'reset')); $sform->addElement($button_tray); $sform->display(); } echo "</td></tr></table>"; echo "</fieldset>"; xoops_cp_footer();
function renderFormSubmit($friend) { global $xoopsUser; /** * criteria fetch friendship to be edited */ $criteria_friend1 = new criteria('friend1_uid', $xoopsUser->getVar('uid')); $criteria_friend2 = new criteria('friend2_uid', $friend->getVar('uid')); $criteria_friendship = new criteriaCompo($criteria_friend1); $criteria_friendship->add($criteria_friend2); $friendships = $this->getObjects($criteria_friendship); $friendship = $friendships[0]; $form = new XoopsThemeForm(_MD_YOGURT_EDITFRIENDSHIP, "form_editfriendship", "editfriendship.php", "post", true); //$field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=../../uploads/".$friend->getVar('user_avatar')." />"); if ($friend->getVar('user_avatar') == "blank.gif") { $field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=images/noavatar.gif />"); } else { $field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=../../uploads/" . $friend->getVar('user_avatar') . " />"); } $field_friend_name = new XoopsFormLabel(_MD_YOGURT_FRIENDNAME, $friend->getVar('uname')); $field_friend_fan = new XoopsFormRadioYN(_MD_YOGURT_FAN, "fan", $friendship->getVar('fan'), '<img src="images/fans.gif" alt="' . _YES . '" title="' . _YES . '" />', '<img src="images/fansbw.gif" alt="' . _NO . '" title="' . _NO . '" />'); $field_friend_level = new XoopsFormRadio(_MD_YOGURT_LEVEL, "level", $friendship->getVar('level'), "<br />"); $field_friend_level->addOption("1", _MD_YOGURT_UNKNOWNACCEPTED); $field_friend_level->addOption("3", _MD_YOGURT_AQUAITANCE); $field_friend_level->addOption("5", _MD_YOGURT_FRIEND); $field_friend_level->addOption("7", _MD_YOGURT_BESTFRIEND); $field_friend_sexy = new XoopsFormRadio(_MD_YOGURT_SEXY, "hot", $friendship->getVar('hot')); $field_friend_sexy->addOption("1", '<img src="images/sexya.gif" alt="' . _MD_YOGURT_SEXYNO . '" title="' . _MD_YOGURT_SEXYNO . '" />'); $field_friend_sexy->addOption("2", '<img src="images/sexyb.gif" alt="' . _MD_YOGURT_SEXYYES . '" title="' . _MD_YOGURT_SEXYYES . '" />'); $field_friend_sexy->addOption("3", '<img src="images/sexyc.gif" alt="' . _MD_YOGURT_SEXYALOT . '" title="' . _MD_YOGURT_SEXYALOT . '" />'); $field_friend_trusty = new XoopsFormRadio(_MD_YOGURT_TRUSTY, "trust", $friendship->getVar('trust')); $field_friend_trusty->addOption("1", '<img src="images/trustya.gif" alt="' . _MD_YOGURT_TRUSTYNO . '" title="' . _MD_YOGURT_TRUSTYNO . '" />'); $field_friend_trusty->addOption("2", '<img src="images/trustyb.gif" alt="' . _MD_YOGURT_TRUSTYYES . '" title="' . _MD_YOGURT_TRUSTYYES . '" />'); $field_friend_trusty->addOption("3", '<img src="images/trustyc.gif" alt="' . _MD_YOGURT_TRUSTYALOT . '" title="' . _MD_YOGURT_TRUSTYALOT . '" />'); $field_friend_cool = new XoopsFormRadio(_MD_YOGURT_COOL, "cool", $friendship->getVar('cool')); $field_friend_cool->addOption("1", '<img src="images/coola.gif" alt="' . _MD_YOGURT_COOLNO . '" title="' . _MD_YOGURT_COOLNO . '" />'); $field_friend_cool->addOption("2", '<img src="images/coolb.gif" alt="' . _MD_YOGURT_COOLYES . '" title="' . _MD_YOGURT_COOLYES . '" />'); $field_friend_cool->addOption("3", '<img src="images/coolc.gif" alt="' . _MD_YOGURT_COOLALOT . '" title="' . _MD_YOGURT_COOLALOT . '" />'); $form->setExtra('enctype="multipart/form-data"'); $button_send = new XoopsFormButton("", "submit_button", _MD_YOGURT_UPDATEFRIEND, "submit"); $field_friend_friendid = new XoopsFormHidden("friend_uid", $friend->getVar('uid')); $field_friend_marker = new XoopsFormHidden("marker", "1"); $field_friend_friendshio_id = new XoopsFormHidden("friendship_id", $friendship->getVar('friendship_id')); $form->addElement($field_friend_friendid); $form->addElement($field_friend_friendshio_id); $form->addElement($field_friend_marker); $form->addElement($field_friend_avatar); $form->addElement($field_friend_name); $form->addElement($field_friend_level); $form->addElement($field_friend_fan); $form->addElement($field_friend_sexy); $form->addElement($field_friend_trusty); $form->addElement($field_friend_cool); $form->addElement($button_send); $form->display(); //If your server is php 4.4 }
function render($ele_value, $caption, $markupName, $isDisabled, $element, $entry_id) { global $myts; $myts =& MyTextSanitizer::getInstance(); $renderer =& new formulizeElementRenderer(); $ele_desc = $element->getVar('ele_desc', "f"); if (strstr($markupName, "de_")) { // display element uses a slightly different element name so it can be distinguished on subsequent page load from regular elements...THIS IS NOT TRUE/NECESSARY ANYMORE SINCE FORMULIZE 3, WHERE ALL ELEMENTS ARE DISPLAY ELEMENTS $true_ele_id = str_replace("de_" . $element->getVar('id_form') . "_" . $entry_id . "_", "", $markupName); } else { $true_ele_id = str_replace("ele_", "", $markupName); } $selected = ''; $disabledHiddenValue = ""; $options = array(); $opt_count = 1; while ($i = each($ele_value)) { $options[$opt_count] = constant($i['key']); $options[$opt_count] = $myts->stripSlashesGPC($options[$opt_count]); if ($i['value'] > 0) { $selected = $opt_count; } $opt_count++; } if ($element->getVar('ele_delim') != "") { $delimSetting = $element->getVar('ele_delim'); } $delimSetting =& $myts->undoHtmlSpecialChars($delimSetting); if ($delimSetting == "br") { $delimSetting = "<br />"; } $hiddenOutOfRangeValuesToWrite = array(); switch ($delimSetting) { case 'space': $form_ele1 = new XoopsFormRadio('', $markupName, $selected); $counter = 0; while ($o = each($options)) { $o = formulize_swapUIText($o, $element->getVar('ele_uitext')); $other = $renderer->optOther($o['value'], $markupName, $entry_id, $counter); if ($other != false) { $form_ele1->addOption($o['key'], _formulize_OPT_OTHER . $other); if ($o['key'] == $selected) { $disabledOutputText = _formulize_OPT_OTHER . $other; } } else { $o['value'] = get_magic_quotes_gpc() ? stripslashes($o['value']) : $o['value']; $form_ele1->addOption($o['key'], $o['value']); if ($o['key'] == $selected) { $disabledOutputText = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $counter++; } $form_ele1->setExtra("onchange=\"javascript:formulizechanged=1;\""); break; default: $form_ele1 = new XoopsFormElementTray('', $delimSetting); $counter = 0; while ($o = each($options)) { $o = formulize_swapUIText($o, $element->getVar('ele_uitext')); $t = new XoopsFormRadio('', $markupName, $selected); $other = $renderer->optOther($o['value'], $markupName, $entry_id, $counter); if ($other != false) { $t->addOption($o['key'], _formulize_OPT_OTHER . $other); if ($o['key'] == $selected) { $disabledOutputText = _formulize_OPT_OTHER . $other; } } else { $o['value'] = get_magic_quotes_gpc() ? stripslashes($o['value']) : $o['value']; $t->addOption($o['key'], $o['value']); if ($o['key'] == $selected) { $disabledOutputText = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $t->setExtra("onchange=\"javascript:formulizechanged=1;\""); $form_ele1->addElement($t); unset($t); $counter++; } break; } $renderedHoorvs = ""; if (count($hiddenOutOfRangeValuesToWrite) > 0) { foreach ($hiddenOutOfRangeValuesToWrite as $hoorKey => $hoorValue) { $thisHoorv = new xoopsFormHidden('formulize_hoorv_' . $true_ele_id . '_' . $hoorKey, $hoorValue); $renderedHoorvs .= $thisHoorv->render() . "\n"; unset($thisHoorv); } } if ($isDisabled) { $disabledHiddenValue = "<input type=hidden name=\"" . $markupName . "\" value=\"{$selected}\">\n"; $renderedElement = $disabledOutputText; // just text for disabled elements } else { $renderedElement = $form_ele1->render(); } $form_ele = new XoopsFormLabel($caption, "<nobr>{$renderedElement}</nobr>\n{$renderedHoorvs}\n{$disabledHiddenValue}\n"); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); return $form_ele; }
$form->addElement($form_xfn); $form->addElement(new XoopsFormTextArea(_LANG_WLA_SUB_NOTE, "link_notes", $link_notes, 10, 60)); $form_rating = new XoopsFormSelect(_LANG_WLA_SUB_RATE, "link_rating", $link_rating); $form_rating->setDescription(_LANG_WLA_CHECK_ZERO); for ($r = 0; $r < 10; $r++) { $form_rating->addOption($r, $r); } $form->addElement($form_rating); $form_target = new XoopsFormRadio(_LANG_WLA_SUB_TARGET, "link_target", $link_target); $form_target->setDescription(_LANG_WLA_CHECK_STRICT); $form_target->addOption('_blank', '_blank'); $form_target->addOption('_top', '_top'); $form_target->addOption('', "none"); $form->addElement($form_target); $form_visible = new XoopsFormRadio(_LANG_WLA_SUB_VISIBLE, "link_visible", $link_visible); $form_visible->addOption('Y', 'Yes'); $form_visible->addOption('N', 'No'); $form->addElement($form_visible); $form_category = new XoopsFormSelect(_LANG_WLA_SUB_CAT, "link_category", $link_category); $form_category->addOptionArray($category_options); $form->addElement($form_category); if ($form_id == 'addlink') { $form->addElement(new XoopsFormButton("", "submit", _LANG_WLA_BUTTON_TEXTNAME, "submit")); $form->addElement(new XoopsFormHidden("action", 'Add')); } else { if ($form_id == 'editlink') { $form_button = new XoopsFormElementTray(""); $form_button->addElement(new XoopsFormButton("", "submit", _LANG_WLM_SAVE_CHANGES, "submit")); $form_button->addElement(new XoopsFormButton("", "submit", _LANG_WLM_EDIT_CANCEL, "submit")); $form->addElement($form_button); $form->addElement(new XoopsFormHidden("action", 'editlink'));
## ## ## This program is distributed in the hope that it will be useful, ## ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## ## GNU General Public License for more details. ## ## ## ## 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 ## ############################################################################### ## URL: http://www.frxoops.org/ ## ## Project: Formulaire ## ############################################################################### if (!preg_match("/elements.php/", $_SERVER['PHP_SELF'])) { exit("Access Denied"); } if (!empty($ele_id)) { if ($value['_YES'] == 1) { $selected = '_YES'; } elseif ($value['_NO'] == 1) { $selected = '_NO'; } } if ($selected) { $options = new XoopsFormRadio(_AM_ELE_DEFAULT, 'ele_value', $selected); } else { $options = new XoopsFormRadio(_AM_ELE_DEFAULT, 'ele_value'); } $options->addOption('_YES', _YES); $options->addOption('_NO', _NO); $form->addElement($options);
} // Check checkout level if ($checkout_level == 1) { oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); } listCart(); $commande = $h_oledrion_commands->get($commend_id); $delivery_id = $commande->getVar('cmd_delivery_id'); $payments = $h_oledrion_payment->getThisDeliveryPayment($delivery_id); $sform = new XoopsThemeForm(_OLEDRION_PAYMENT_FORM, "informationfrm", OLEDRION_URL . 'checkout.php', 'post'); $sform->addElement(new XoopsFormHidden('op', 'save')); $sform->addElement(new XoopsFormHidden('action', 'payment')); $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); $payment_options = new XoopsFormRadio(_OLEDRION_SELECT_PAYMENT, 'payment_id'); foreach ($payments as $payment) { $payment_options->addOption($payment['payment_id'], oledrion_utils::paymentHtmlSelect($payment)); } $sform->addElement($payment_options, true); $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_CONFIRM, 'submit')); $sform = oledrion_utils::formMarkRequiredFields($sform); $xoopsTpl->assign('form', $sform->render()); // texte à afficher $registry = new oledrion_registryfile(); $text = $registry->getfile(OLEDRION_TEXTFILE6); $xoopsTpl->assign('text', xoops_trim($text)); break; // **************************************************************************************************************** // **************************************************************************************************************** case 'confirm': // Validation finale avant envoi sur la passerelle de paiement (ou arrêt) // ****************************************************************************************************************
function hypconfShowForm($config) { global $constpref, $mydirname, $mydirpath, $mytrustdirpath, $page, $xoopsConfig, $xoopsGTicket; if (!$config) { die('no configs'); } if (isset($config['error'])) { echo '<div class="error">' . join('</div><div class="error">', $config['error']) . '</div>'; unset($config['error']); } if (isset($config['contents'])) { echo $config['contents']; unset($config['contents']); } $underContents = ''; if (isset($config['underContents'])) { $underContents = $config['underContents']; unset($config['underContents']); } if ($config) { $count = count($config); include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; include_once dirname(dirname(__FILE__)) . '/class/formcheckbox.php'; if (!XC_CLASS_EXISTS('XoopsFormBreak')) { include_once dirname(dirname(__FILE__)) . '/class/formbreak.php'; } $form = new XoopsThemeForm(hypconf_constant($constpref . '_ADMENU_' . strtoupper($page)), 'pref_form', 'index.php'); $button_tray = new XoopsFormElementTray(""); for ($i = 0; $i < $count; $i++) { $description = defined($config[$i]['description']) ? constant($config[$i]['description']) : ''; //$title4tray = (!$description) ? hypconf_constant($config[$i]['title']) : hypconf_constant($config[$i]['title']).'<br /><br /><span style="font-weight:normal;">'.hypconf_constant($config[$i]['description']).'</span>'; // GIJ $title4tray = hypconf_constant($config[$i]['title']); $title = ''; // GIJ switch ($config[$i]['formtype']) { case 'textarea': (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); if ($config[$i]['valuetype'] == 'array') { // this is exceptional.. only when value type is arrayneed a smarter way for this $ele = $config[$i]['value'] != '' ? new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars(implode('|', $config[$i]['value'], _CHARSET)), 5, 50) : new XoopsFormTextArea($title, $config[$i]['name'], '', 5, 50); } else { $ele = new XoopsFormTextArea($title, $config[$i]['name'], $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET), 5, 50); $ele->setExtra('class="norich plain" spellcheck="false"'); } break; case 'select': $size = 1; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size); $options = $config[$i]['options']; $opcount = count($options); //var_dump($options); foreach ($options as $option) { if (isset($option['confop_value']) && isset($option['confop_name'])) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; } else { $optval = $optkey = $option; } $ele->addOption($optval, $optkey); } break; case 'select_multi': $size = 5; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], $size, true); $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'check': $ele = new HypconfFormCheckBox($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'radio': $ele = new XoopsFormRadio($title, $config[$i]['name'], $config[$i]['value']); if (!empty($config[$i]['width'])) { //$ele->setWidth($config[$i]['width']); } $options = $config[$i]['options']; foreach ($options as $option) { $optval = defined($option['confop_value']) ? hypconf_constant($option['confop_value']) : $option['confop_value']; $optkey = defined($option['confop_name']) ? hypconf_constant($option['confop_name']) : $option['confop_name']; $ele->addOption($optval, $optkey); } break; case 'yesno': $ele = new XoopsFormRadioYN($title, $config[$i]['name'], $config[$i]['value'], _YES, _NO); break; case 'password': $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormPassword($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); break; case 'label': $ele = new XoopsFormLabel($title, $description); $description = ''; break; case 'theme': case 'theme_multi': $ele = $config[$i]['formtype'] !== 'theme_multi' ? new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']) : new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value'], 5, true); $handle = opendir(XOOPS_THEME_PATH . '/'); $dirlist = array(); while (false !== ($file = readdir($handle))) { if (is_dir(XOOPS_THEME_PATH . '/' . $file) && !preg_match("/^\\..*\$/", $file) && strtolower($file) != 'cvs') { $dirlist[$file] = $file; } } closedir($handle); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); if (!empty($dirlist)) { asort($dirlist); $ele->addOptionArray($dirlist); } break; case 'tplset': $ele = new XoopsFormSelect($title, $config[$i]['name'], $config[$i]['value']); $tplset_handler =& xoops_gethandler('tplset'); $tplsetlist =& $tplset_handler->getList(); asort($tplsetlist); $ele->addOption('', hypconf_constant($constpref . '_NOT_SPECIFY')); foreach ($tplsetlist as $key => $name) { $ele->addOption($key, htmlspecialchars($name, ENT_QUOTES, _CHARSET)); } break; case 'textbox': default: $size = 50; if (!empty($config[$i]['size'])) { $size = $config[$i]['size']; } (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || ($myts =& MyTextSanitizer::getInstance()); $ele = new XoopsFormText($title, $config[$i]['name'], $size, 255, $myts->htmlspecialchars($config[$i]['value'], ENT_COMPAT, _CHARSET)); if ($config[$i]['valuetype'] === 'int') { $ele->setExtra(' style="text-align:right;"'); } break; } $ele_tray = new XoopsFormElementTray($title4tray, ''); $ele_tray->addElement($ele); $form->addElement($ele_tray); if ($description) { $form->insertBreak('<span style="font-weight:normal;">' . $description . '</span>', 'odd'); } unset($ele_tray); unset($ele); } $button_tray->addElement(new XoopsFormHidden('op', 'save')); $button_tray->addElement(new XoopsFormHidden('page', $page)); $xoopsGTicket->addTicketXoopsFormElement($button_tray, __LINE__, 1800, 'hypconf'); $button_tray->addElement(new XoopsFormButton('', 'button', _GO, 'submit')); $form->addElement($button_tray); $form->display(); } if ($underContents) { echo '<div>' . $underContents . '</div>'; } }
function constructElement($form_ele_id, $ele_value, $entry, $isDisabled = false, $screen = null) { if (strstr(getCurrentURL(), "printview.php")) { $isDisabled = true; // disabled all elements if we're on the printable view } global $xoopsUser, $xoopsModuleConfig, $separ, $myts; $myts =& MyTextSanitizer::getInstance(); // $form_ele_id contains the ele_id of the current link select box, but we have to remove "ele_" from the front of it. //print "form_ele_id: $form_ele_id<br>"; // debug code if (strstr($form_ele_id, "de_")) { // display element uses a slightly different element name so it can be distinguished on subsequent page load from regular elements...THIS IS NOT TRUE/NECESSARY ANYMORE SINCE FORMULIZE 3, WHERE ALL ELEMENTS ARE DISPLAY ELEMENTS $true_ele_id = str_replace("de_" . $this->_ele->getVar('id_form') . "_" . $entry . "_", "", $form_ele_id); $displayElementInEffect = true; } else { $true_ele_id = str_replace("ele_", "", $form_ele_id); $displayElementInEffect = false; } // added July 6 2005. if (!$xoopsModuleConfig['delimeter']) { // assume that we're accessing a form from outside the Formulize module, therefore the Formulize delimiter setting is not available, so we have to query for it directly. global $xoopsDB; $delimq = q("SELECT conf_value FROM " . $xoopsDB->prefix("config") . ", " . $xoopsDB->prefix("modules") . " WHERE " . $xoopsDB->prefix("modules") . ".mid=" . $xoopsDB->prefix("config") . ".conf_modid AND " . $xoopsDB->prefix("modules") . ".dirname=\"formulize\" AND " . $xoopsDB->prefix("config") . ".conf_name=\"delimeter\""); $delimSetting = $delimq[0]['conf_value']; } else { $delimSetting = $xoopsModuleConfig['delimeter']; } $customElementHasData = false; $id_form = $this->_ele->getVar('id_form'); $ele_caption = $this->_ele->getVar('ele_caption', 'e'); $ele_caption = preg_replace('/\\{SEPAR\\}/', '', $ele_caption); // $ele_caption = stripslashes($ele_caption); // next line commented out to accomodate passing of ele_value from index.php // $ele_value = $this->_ele->getVar('ele_value'); $ele_type = $this->_ele->getVar('ele_type'); // call the text sanitizer, first try to convert HTML chars, and if there were no conversions, then do a textarea conversion to automatically make links clickable $ele_caption = trans($ele_caption); $htmlCaption = htmlspecialchars_decode($myts->undoHtmlSpecialChars($ele_caption)); // do twice, because we need to handle &lt; and other stupid stuff...do first time through XOOPS myts just because it might be doing a couple extra things that are useful...can probably just use PHP's own filter twice, not too big a deal if ($htmlCaption == $ele_caption) { $ele_caption = $myts->displayTarea($ele_caption); } else { $ele_caption = $htmlCaption; } $ele_caption = $this->formulize_replaceCurlyBracketVariables($ele_caption, $entry, $id_form); // ele_desc added June 6 2006 -- jwe $ele_desc = $this->_ele->getVar('ele_desc', "f"); // the f causes no stupid reformatting by the ICMS core to take place // determine the entry owner if ($entry != "new") { $owner = getEntryOwner($entry, $id_form); } else { $owner = $xoopsUser ? $xoopsUser->getVar('uid') : 0; } // setup the previous entry UI if necessary -- this is an option that can be specified for certain screens $previousEntryUI = ""; if ($screen and $ele_type != "derived") { if ($screen->getVar('paraentryform') > 0) { $previousEntryUI = $this->formulize_setupPreviousEntryUI($screen, $true_ele_id, $ele_type, $owner, $displayElementInEffect, $entry, $this->_ele->getVar('ele_handle'), $this->_ele->getVar('id_form')); } } $form_handler = xoops_getmodulehandler('forms', 'formulize'); $formObject = $form_handler->get($id_form); switch ($ele_type) { case 'derived': if ($entry != "new") { $form_ele = new xoopsFormLabel($this->_ele->getVar('ele_caption'), formulize_numberFormat($ele_value[5], $this->_ele->getVar('ele_handle'))); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); } else { $form_ele = new xoopsFormLabel($this->_ele->getVar('ele_caption'), _formulize_VALUE_WILL_BE_CALCULATED_AFTER_SAVE); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); } break; case 'ib': if (get_magic_quotes_gpc()) { $ele_value[0] = stripslashes($ele_value[0]); } if (trim($ele_value[0]) == "") { $ele_value[0] = $ele_caption; } if (strstr($ele_value[0], "\$value=") or strstr($ele_value[0], "\$value =")) { $form_id = $id_form; $entry_id = $entry; $entryData = $this->formulize_getCachedEntryData($id_form, $entry); $creation_datetime = display($entryData, "creation_datetime"); $evalResult = eval($ele_value[0]); if ($evalResult === false) { $ele_value[0] = _formulize_ERROR_IN_LEFTRIGHT; } else { $ele_value[0] = $value; // value is supposed to be the thing set in the eval'd code } } $ele_value[0] = $this->formulize_replaceCurlyBracketVariables($ele_value[0], $entry, $id_form); $form_ele = $ele_value; // an array, item 0 is the contents of the break, item 1 is the class of the table cell (for when the form is table rendered) break; case 'text': $ele_value[2] = stripslashes($ele_value[2]); // $ele_value[2] = $myts->displayTarea($ele_value[2]); // commented by jwe 12/14/04 so that info displayed for viewing in a form box does not contain HTML formatting $ele_value[2] = getTextboxDefault($ele_value[2], $id_form, $entry); //if placeholder value is set if ($ele_value[11]) { $placeholder = $ele_value[2]; $ele_value[2] = ""; } if (!strstr(getCurrentURL(), "printview.php")) { // nmc 2007.03.24 - added $form_ele = new XoopsFormText($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], $ele_value[2]); } else { // nmc 2007.03.24 - added $form_ele = new XoopsFormLabel($ele_caption, formulize_numberFormat($ele_value[2], $this->_ele->getVar('ele_handle'))); // nmc 2007.03.24 - added } //if placeholder value is set if ($ele_value[11]) { $form_ele->setExtra("placeholder='" . $placeholder . "'"); } //if numbers-only option is set if ($ele_value[3]) { $form_ele->setExtra("class='numbers-only-textbox'"); } // if required unique option is set, create validation javascript that will ask the database if the value is unique or not if ($ele_value[9]) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $eltmsgUnique = empty($eltcaption) ? sprintf(_formulize_REQUIRED_UNIQUE, $eltname) : sprintf(_formulize_REQUIRED_UNIQUE, $eltcaption); if ($this->_ele->getVar('ele_req')) { // need to manually handle required setting, since only one validation routine can run for an element, so we need to include required checking in this unique checking routine, if the user selected required too $form_ele->customValidationCode[] = "\nif ( myform.{$eltname}.value == '' ) {\n"; $form_ele->customValidationCode[] = "window.alert(\"{$eltmsg}\");\n myform.{$eltname}.focus();\n return false;\n"; $form_ele->customValidationCode[] = "}\n"; } $form_ele->customValidationCode[] = "if(formulize_xhr_returned_check_for_unique_value != 'notreturned') {\n"; // a value has already been returned from xhr, so let's check that out... $form_ele->customValidationCode[] = "if(formulize_xhr_returned_check_for_unique_value != 'valuenotfound') {\n"; // request has come back, form has been resubmitted, but the check turned up postive, ie: value is not unique, so we have to halt submission , and reset the check for unique flag so we can check again when the user has typed again and is ready to submit $form_ele->customValidationCode[] = "window.alert(\"{$eltmsgUnique}\");\n"; $form_ele->customValidationCode[] = "formulize_xhr_returned_check_for_unique_value = 'notreturned'\n"; $form_ele->customValidationCode[] = "myform.{$eltname}.focus();\n return false;\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "} else {\n"; // do not submit the form, just send off the request, which will trigger a resubmission after setting the returned flag above to true so that we won't send again on resubmission $form_ele->customValidationCode[] = "\nvar formulize_xhr_params = []\n"; $form_ele->customValidationCode[] = "formulize_xhr_params[0] = myform.{$eltname}.value;\n"; $form_ele->customValidationCode[] = "formulize_xhr_params[1] = " . $this->_ele->getVar('ele_id') . ";\n"; $xhr_entry_to_send = is_numeric($entry) ? $entry : 0; $form_ele->customValidationCode[] = "formulize_xhr_params[2] = " . $xhr_entry_to_send . ";\n"; $form_ele->customValidationCode[] = "formulize_xhr_send('check_for_unique_value', formulize_xhr_params);\n"; $form_ele->customValidationCode[] = "return false;\n"; $form_ele->customValidationCode[] = "}\n"; } elseif ($this->_ele->getVar('ele_req') and !$isDisabled) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $form_ele->customValidationCode[] = "if (myform.{$eltname}.value == \"\") { window.alert(\"{$eltmsg}\"); myform.{$eltname}.focus(); return false; }"; } break; case 'textarea': $ele_value[0] = stripslashes($ele_value[0]); // $ele_value[0] = $myts->displayTarea($ele_value[0]); // commented by jwe 12/14/04 so that info displayed for viewing in a form box does not contain HTML formatting $ele_value[0] = getTextboxDefault($ele_value[0], $id_form, $entry); if (!strstr(getCurrentURL(), "printview.php") and !$isDisabled) { // nmc 2007.03.24 - added if (isset($ele_value['use_rich_text']) and $ele_value['use_rich_text']) { include_once XOOPS_ROOT_PATH . "/class/xoopsform/formeditor.php"; $form_ele = new XoopsFormEditor($ele_caption, 'FCKeditor', $editor_configs = array("name" => $form_ele_id, "value" => $ele_value[0]), $noHtml = false, $OnFailure = ""); $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $form_ele->customValidationCode[] = "\n var FCKGetInstance = FCKeditorAPI.GetInstance('{$form_ele_id}');\n"; $form_ele->customValidationCode[] = "var getText = FCKGetInstance.EditorDocument.body.innerHTML; \n"; $form_ele->customValidationCode[] = "var StripTag = getText.replace(/(<([^>]+)>)/ig,''); \n"; $form_ele->customValidationCode[] = "if(StripTag=='' || StripTag==' ') {\n"; $form_ele->customValidationCode[] = "window.alert(\"{$eltmsg}\");\n FCKGetInstance.Focus();\n return false;\n"; $form_ele->customValidationCode[] = "}\n"; $GLOBALS['formulize_fckEditors'] = true; } else { $form_ele = new XoopsFormTextArea($ele_caption, $form_ele_id, $ele_value[0], $ele_value[1], $ele_value[2]); } } else { // nmc 2007.03.24 - added $form_ele = new XoopsFormLabel($ele_caption, str_replace("\n", "<br>", undoAllHTMLChars($ele_value[0], ENT_QUOTES))); // nmc 2007.03.24 - added } break; case 'areamodif': if (strstr($ele_value[0], "\$value=") or strstr($ele_value[0], "\$value =")) { $form_id = $id_form; $entry_id = $entry; $entryData = $this->formulize_getCachedEntryData($id_form, $entry); $creation_datetime = display($entryData, "creation_datetime"); $evalResult = eval($ele_value[0]); if ($evalResult === false) { $ele_value[0] = _formulize_ERROR_IN_LEFTRIGHT; } else { $ele_value[0] = $value; // value is supposed to be the thing set in the eval'd code } } $ele_value[0] = $this->formulize_replaceCurlyBracketVariables($ele_value[0], $entry, $id_form); $form_ele = new XoopsFormLabel($ele_caption, $ele_value[0]); break; case 'select': if (is_string($ele_value[2]) and strstr($ele_value[2], "#*=:*")) { // new process for handling links...May 10 2008...new datastructure for formulize 3.0 $boxproperties = explode("#*=:*", $ele_value[2]); $sourceFid = $boxproperties[0]; $sourceHandle = $boxproperties[1]; $sourceEntryIds = explode(",", trim($boxproperties[2], ",")); // grab the user's groups and the module id global $regcode; if ($regcode) { // if we're dealing with a registration code, determine group membership based on the code $reggroupsq = q("SELECT reg_codes_groups FROM " . XOOPS_DB_PREFIX . "_reg_codes WHERE reg_codes_code=\"{$regcode}\""); $groups = explode("&8(%\$", $reggroupsq[0]['reg_codes_groups']); if ($groups[0] === "") { unset($groups); } // if a code has no groups associated with it, then kill the null value that will be in position 0 in the groups array. $groups[] = XOOPS_GROUP_USERS; $groups[] = XOOPS_GROUP_ANONYMOUS; } else { $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); } $module_id = getFormulizeModId(); global $xoopsDB; $pgroups = array(); // handle new linkscope option -- August 30 2006 $emptylist = false; if ($ele_value[3]) { $scopegroups = explode(",", $ele_value[3]); if (!in_array("all", $scopegroups)) { if ($ele_value[4]) { // limit by user's groups foreach ($groups as $gid) { // want to loop so we can get rid of reg users group simply if ($gid == XOOPS_GROUP_USERS) { continue; } if (in_array($gid, $scopegroups)) { $pgroups[] = $gid; } } } else { // just use scopegroups $pgroups = $scopegroups; } if (count($pgroups) == 0) { // specific scope was specified, and nothing found, so we should show nothing $emptylist = true; } } else { if ($ele_value[4]) { // all groups selected, but limiting by user's groups is turned on foreach ($groups as $gid) { // want to loop so we can get rid of reg users group simply if ($gid == XOOPS_GROUP_USERS) { continue; } $pgroups[] = $gid; } } else { // all groups should be used unset($pgroups); $allgroupsq = q("SELECT groupid FROM " . $xoopsDB->prefix("groups")); // . " WHERE groupid != " . XOOPS_GROUP_USERS); // use all groups now, if all groups are picked, with no restrictions on membership or anything, then use all groups foreach ($allgroupsq as $thisgid) { $pgroups[] = $thisgid['groupid']; } } } } // Note: OLD WAY: if no groups were found, then pguidq will be empty and so all entries will be shown, no restrictions // NEW WAY: if a specific group(s) was specified, and no match with the current user was found, then we return an empty list array_unique($pgroups); // remove duplicate groups from the list if ($ele_value[6] and count($pgroups) > 0) { $pgroupsfilter = " ("; $start = true; foreach ($pgroups as $thisPgroup) { if (!$start) { $pgroupsfilter .= " AND "; } $pgroupsfilter .= "EXISTS(SELECT 1 FROM " . $xoopsDB->prefix("formulize_entry_owner_groups") . " AS t2 WHERE t2.groupid={$thisPgroup} AND t2.fid={$sourceFid} AND t2.entry_id=t1.entry_id)"; $start = false; } $pgroupsfilter .= ")"; } elseif (count($pgroups) > 0) { $pgroupsfilter = " t2.groupid IN (" . formulize_db_escape(implode(",", $pgroups)) . ") AND t2.entry_id=t1.entry_id AND t2.fid={$sourceFid}"; } else { $pgroupsfilter = ""; } $sourceFormObject = $form_handler->get($sourceFid); list($conditionsfilter, $conditionsfilter_oom, $parentFormFrom) = buildConditionsFilterSQL($ele_value[5], $sourceFid, $entry, $owner, $formObject, "t1"); // if there is a restriction in effect, then add some SQL to reject options that have already been selected ?? $restrictSQL = ""; if ($ele_value[9]) { $t4_ele_value = $this->_ele->getVar('ele_value'); if ($t4_ele_value[1]) { // allows multiple selections $restrictSQL = " AND (\n\t\t\t\t\t\tNOT EXISTS (\n\t\t\t\t\t\tSELECT 1 FROM " . $xoopsDB->prefix("formulize_" . $formObject->getVar('form_handle')) . " AS t4 WHERE t4.`" . $this->_ele->getVar('ele_handle') . "` LIKE CONCAT( '%,', t1.`entry_id` , ',%' ) AND t4.entry_id != " . intval($entry); } else { $restrictSQL = " AND (\n NOT EXISTS (\n SELECT 1 FROM " . $xoopsDB->prefix("formulize_" . $formObject->getVar('form_handle')) . " AS t4 WHERE t4.`" . $this->_ele->getVar('ele_handle') . "` = t1.`entry_id` AND t4.entry_id != " . intval($entry); $restrictSQL .= $this->addEntryRestrictionSQL($ele_value[9], $id_form, $groups); // pass in the flag about restriction scope, and the form id, and the groups $restrictSQL .= " ) OR EXISTS (\n SELECT 1 FROM " . $xoopsDB->prefix("formulize_" . $formObject->getVar('form_handle')) . " AS t4 WHERE t4.`" . $this->_ele->getVar('ele_handle') . "` = t1.`entry_id` AND t4.entry_id = " . intval($entry); } $restrictSQL .= $this->addEntryRestrictionSQL($ele_value[9], $id_form, $groups); // pass in the flag about restriction scope, and the form id, and the groups $restrictSQL .= " ) OR EXISTS (\n\t\t\t\t\t\tSELECT 1 FROM " . $xoopsDB->prefix("formulize_" . $formObject->getVar('form_handle')) . " AS t4 WHERE t4.`" . $this->_ele->getVar('ele_handle') . "` LIKE CONCAT( '%,', t1.`entry_id` , ',%' ) AND t4.entry_id = " . intval($entry); $restrictSQL .= $this->addEntryRestrictionSQL($ele_value[9], $id_form, $groups); $restrictSQL .= ") )"; } static $cachedSourceValuesQ = array(); static $cachedSourceValuesAutocompleteFile = array(); static $cachedSourceValuesAutocompleteLength = array(); // setup the sort order based on ele_value[12], which is an element id number $sortOrder = $ele_value[15] == 2 ? " DESC" : "ASC"; if ($ele_value[12] == "none" or !$ele_value[12]) { $sortOrderClause = " ORDER BY t1.`{$sourceHandle}` {$sortOrder}"; } else { list($sortHandle) = convertElementIdsToElementHandles(array($ele_value[12]), $sourceFormObject->getVar('id_form')); $sortOrderClause = " ORDER BY t1.`{$sortHandle}` {$sortOrder}"; } // if no extra elements are selected for display as a form element, then display the linked element if (0 == count($ele_value[EV_MULTIPLE_FORM_COLUMNS]) or $ele_value[EV_MULTIPLE_FORM_COLUMNS][0] == 'none') { $linked_columns = array($boxproperties[1]); } else { $linked_columns = convertElementIdsToElementHandles($ele_value[EV_MULTIPLE_FORM_COLUMNS], $sourceFormObject->getVar('id_form')); // remove empty entries, which can happen if the "use the linked field selected above" option is selected $linked_columns = array_filter($linked_columns); } if (is_array($linked_columns)) { $select_column = "t1.`" . implode("`, t1.`", $linked_columns) . "`"; } else { $select_column = "t1.`{$linked_columns}`"; // in this case, it's just one linked column } // if there is a groups filter, then join to the group ownership table $extra_clause = ""; if ($pgroupsfilter) { $extra_clause = ", " . $xoopsDB->prefix("formulize_entry_owner_groups") . " AS t2 {$parentFormFrom} WHERE {$pgroupsfilter}"; } else { $extra_clause = " {$parentFormFrom} WHERE t1.entry_id>0"; } $sourceValuesQ = "SELECT t1.entry_id, " . $select_column . " FROM " . $xoopsDB->prefix("formulize_" . $sourceFormObject->getVar('form_handle')) . " AS t1" . $extra_clause . "{$conditionsfilter} {$conditionsfilter_oom} {$restrictSQL}" . "GROUP BY t1.entry_id {$sortOrderClause}"; if (!$isDisabled) { // set the default selections, based on the entry_ids that have been selected as the defaults, if applicable $hasNoValues = trim($boxproperties[2]) == "" ? true : false; $useDefaultsWhenEntryHasNoValue = $ele_value[14]; if (($entry == "new" or $useDefaultsWhenEntryHasNoValue and $hasNoValues) and (is_array($ele_value[13]) and count($ele_value[13]) > 0 or $ele_value[13])) { $defaultSelected = $ele_value[13]; } else { $defaultSelected = ""; } $form_ele = new XoopsFormSelect($ele_caption, $form_ele_id, $defaultSelected, $ele_value[0], $ele_value[1]); $form_ele->setExtra("onchange=\"javascript:formulizechanged=1;\" jquerytag='{$form_ele_id}'"); if ($ele_value[0] == 1) { // add the initial default entry, singular or plural based on whether the box is one line or not. $form_ele->addOption("none", _AM_FORMLINK_PICK); } } else { $disabledHiddenValue = array(); $disabledOutputText = array(); } if (!isset($cachedSourceValuesQ[$sourceValuesQ])) { $element_handler = xoops_getmodulehandler('elements', 'formulize'); $sourceElementObject = $element_handler->get($boxproperties[1]); if ($sourceElementObject->isLinked) { // need to jump one more level back to get value that this value is pointing at $sourceEleValue = $sourceElementObject->getVar('ele_value'); $originalSource = explode("#*=:*", $sourceEleValue[2]); include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php"; $data_handler = new formulizeDataHandler($originalSource[0]); } $reslinkedvaluesq = $xoopsDB->query($sourceValuesQ); if ($reslinkedvaluesq) { $linked_column_count = count($linked_columns); while ($rowlinkedvaluesq = $xoopsDB->fetchRow($reslinkedvaluesq)) { $linked_column_values = array(); foreach (range(1, $linked_column_count) as $linked_column_index) { if ($rowlinkedvaluesq[$linked_column_index] === "") { $linked_column_values[] = ""; } else { if ($sourceElementObject->isLinked) { $linked_value = prepvalues($rowlinkedvaluesq[$linked_column_index], $boxproperties[1], $rowlinkedvaluesq[0]); $linked_column_values[] = $linked_value[0]; } else { $linked_column_values[] = strip_tags(trim($rowlinkedvaluesq[$linked_column_index])); } } } $linkedElementOptions[$rowlinkedvaluesq[0]] = implode(" - ", $linked_column_values); } } $cachedSourceValuesQ[$sourceValuesQ] = $linkedElementOptions; /* ALTERED - 20100318 - freeform - jeff/julian - start */ if (!$isDisabled and $ele_value[8] == 1) { // write the possible values to a cached file so we can look them up easily when we need them, don't want to actually send them to the browser, since it could be huge, but don't want to replicate all the logic that has already gathered the values for us, each time there's an ajax request $cachedLinkedOptionsFileName = "formulize_linkedOptions_" . str_replace(".", "", microtime(true)); formulize_scandirAndClean(XOOPS_ROOT_PATH . "/cache/", "formulize_linkedOptions_"); $maxLength = 10; $the_values = array(); asort($linkedElementOptions); foreach ($linkedElementOptions as $id => $text) { $the_values[$id] = trans($text); $thisTextLength = strlen($text); $maxLength = $thisTextLength > $maxLength ? $thisTextLength : $maxLength; } file_put_contents(XOOPS_ROOT_PATH . "/cache/{$cachedLinkedOptionsFileName}", "<?php\n\${$cachedLinkedOptionsFileName} = " . var_export($the_values, true) . ";\n"); $cachedSourceValuesAutocompleteFile[$sourceValuesQ] = $cachedLinkedOptionsFileName; $cachedSourceValuesAutocompleteLength[$sourceValuesQ] = $maxLength; } } if ($boxproperties[2]) { $default_value = $boxproperties[2]; $default_value_user = $cachedSourceValuesQ[$sourceValuesQ][$boxproperties[2]]; } // if we're rendering an autocomplete box if (!$isDisabled and $ele_value[8] == 1) { $renderedComboBox = $this->formulize_renderQuickSelect($form_ele_id, $cachedSourceValuesAutocompleteFile[$sourceValuesQ], $default_value, $default_value_user, $cachedSourceValuesAutocompleteLength[$sourceValuesQ]); $form_ele = new xoopsFormLabel($ele_caption, $renderedComboBox); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); } elseif ($isDisabled) { $disabledOutputText[] = $default_value_user; } // only do this if we're rendering a normal element, that is not disabled if (!$isDisabled and $ele_value[8] == 0) { $form_ele->addOptionArray($cachedSourceValuesQ[$sourceValuesQ]); } // only do this if we're rendering a normal element (may be disabled) if ($ele_value[8] == 0) { foreach ($sourceEntryIds as $thisEntryId) { if (!$isDisabled) { $form_ele->setValue($thisEntryId); } else { $disabledName = $ele_value[1] ? $form_ele_id . "[]" : $form_ele_id; $disabledHiddenValue[] = "<input type=hidden name=\"{$disabledName}\" value=\"{$thisEntryId}\">"; $disabledOutputText[] = $cachedSourceValuesQ[$sourceValuesQ][$thisEntryId]; // the text value of the option(s) that are currently selected } } } if ($isDisabled) { $form_ele = new XoopsFormLabel($ele_caption, implode(", ", $disabledOutputText) . implode("\n", $disabledHiddenValue)); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); } elseif ($ele_value[8] == 0) { // this is a hack because the size attribute is private and only has a getSize and not a setSize, setting the size can only be done through the constructor $count = count($form_ele->getOptions()); $size = $ele_value[0]; $new_size = $count < $size ? $count : $size; $form_ele->_size = $new_size; } /* ALTERED - 20100318 - freeform - jeff/julian - stop */ } else { $selected = array(); $options = array(); $disabledOutputText = array(); $disabledHiddenValue = array(); $disabledHiddenValues = ""; // add the initial default entry, singular or plural based on whether the box is one line or not. if ($ele_value[0] == 1) { $options["none"] = _AM_FORMLINK_PICK; } // set opt_count to 1 if the box is NOT a multiple selection box. -- jwe 7/26/04 if ($ele_value[1]) { $opt_count = 0; } else { $opt_count = 1; } $hiddenOutOfRangeValuesToWrite = array(); while (is_array($ele_value[2]) and $i = each($ele_value[2])) { // handle requests for full names or usernames -- will only kick in if there is no saved value (otherwise ele_value will have been rewritten by the loadValues function in the form display // note: if the user is about to make a proxy entry, then the list of users displayed will be from their own groups, but not from the groups of the user they are about to make a proxy entry for. ie: until the proxy user is known, the choice of users for this list can only be based on the current user. This could lead to confusing or buggy situations, such as users being selected who are outside the groups of the proxy user (who will become the owner) and so there will be an invalid value stored for this element in the db. if ($i['key'] === "{FULLNAMES}" or $i['key'] === "{USERNAMES}") { // ADDED June 18 2005 to handle pulling in usernames for the user's group(s) if ($i['key'] === "{FULLNAMES}") { $nametype = "name"; } if ($i['key'] === "{USERNAMES}") { $nametype = "uname"; } if (isset($ele_value[2]['{OWNERGROUPS}'])) { $groups = $ele_value[2]['{OWNERGROUPS}']; } else { global $regcode; if ($regcode) { // if we're dealing with a registration code, determine group membership based on the code $reggroupsq = q("SELECT reg_codes_groups FROM " . XOOPS_DB_PREFIX . "_reg_codes WHERE reg_codes_code=\"{$regcode}\""); $groups = explode("&8(%\$", $reggroupsq[0]['reg_codes_groups']); if ($groups[0] === "") { unset($groups); } // if a code has no groups associated with it, then kill the null value that will be in position 0 in the groups array. $groups[] = XOOPS_GROUP_USERS; $groups[] = XOOPS_GROUP_ANONYMOUS; } else { global $xoopsUser; $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS); } } $pgroups = array(); $declaredUsersGroups = $groups; if ($ele_value[3]) { $scopegroups = explode(",", $ele_value[3]); if (!in_array("all", $scopegroups)) { $groups = $scopegroups; } else { // use all if (!$ele_value[4]) { // really use all (otherwise, we're just going with all user's groups, so existing value of $groups will be okay unset($groups); global $xoopsDB; $allgroupsq = q("SELECT groupid FROM " . $xoopsDB->prefix("groups")); // . " WHERE groupid != " . XOOPS_GROUP_USERS); // removed exclusion of registered users group March 18 2009, since it doesn't make sense in this situation. All groups should mean everyone, period. foreach ($allgroupsq as $thisgid) { $groups[] = $thisgid['groupid']; } } } } $namelist = gatherNames($groups, $nametype, $ele_value[6], $ele_value[5], $ele_value[4], $declaredUsersGroups); foreach ($namelist as $auid => $aname) { $options[$auid] = $aname; } } elseif ($i['key'] === "{SELECTEDNAMES}") { // loadValue in formDisplay will create a second option with this key that contains an array of the selected values $selected = $i['value']; } elseif ($i['key'] === "{OWNERGROUPS}") { // do nothing with this piece of metadata that gets set in loadValue, since it's used above } else { // regular selection list.... $options[$opt_count] = $myts->stripSlashesGPC($i['key']); if (strstr($i['key'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$opt_count] = str_replace(_formulize_OUTOFRANGE_DATA, "", $i['key']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } if ($i['value'] > 0) { $selected[] = $opt_count; } $opt_count++; } } $count = count($options); $size = $ele_value[0]; $final_size = $count < $size ? $count : $size; $form_ele1 = new XoopsFormSelect($ele_caption, $form_ele_id, $selected, $final_size, $ele_value[1]); $form_ele1->setExtra("onchange=\"javascript:formulizechanged=1;\" jquerytag='{$form_ele_id}'"); // must check the options for uitext before adding to the element -- aug 25, 2007 foreach ($options as $okey => $ovalue) { $options[$okey] = formulize_swapUIText($ovalue, $this->_ele->getVar('ele_uitext')); } $form_ele1->addOptionArray($options); if ($selected) { if (is_array($selected)) { $hiddenElementName = $ele_value[1] ? $form_ele1->getName() . "[]" : $form_ele1->getName(); foreach ($selected as $thisSelected) { $disabledOutputText[] = $options[$thisSelected]; $disabledHiddenValue[] = "<input type=hidden name=\"{$hiddenElementName}\" value=\"{$thisSelected}\">"; } } elseif ($ele_value[1]) { // need to keep [] in the hidden element name if multiple values are expected, even if only one is chosen $disabledOutputText[] = $options[$selected]; $disabledHiddenValue[] = "<input type=hidden name=\"" . $form_ele1->getName() . "[]\" value=\"{$selected}\">"; } else { $disabledOutputText[] = $options[$selected]; $disabledHiddenValue[] = "<input type=hidden name=\"" . $form_ele1->getName() . "\" value=\"{$selected}\">"; } } $renderedHoorvs = ""; if (count($hiddenOutOfRangeValuesToWrite) > 0) { foreach ($hiddenOutOfRangeValuesToWrite as $hoorKey => $hoorValue) { $thisHoorv = new xoopsFormHidden('formulize_hoorv_' . $true_ele_id . '_' . $hoorKey, $hoorValue); $renderedHoorvs .= $thisHoorv->render() . "\n"; unset($thisHoorv); } } if ($isDisabled) { $disabledHiddenValues = implode("\n", $disabledHiddenValue); // glue the individual value elements together into a set of values $renderedElement = implode(", ", $disabledOutputText); } elseif ($ele_value[8] == 1) { // autocomplete construction: make sure that $renderedElement is the final output of this chunk of code // write the possible values to a cached file so we can look them up easily when we need them, //don't want to actually send them to the browser, since it could be huge, //but don't want to replicate all the logic that has already gathered the values for us, each time there's an ajax request $cachedLinkedOptionsFileName = "formulize_Options_" . str_replace(".", "", microtime(true)); formulize_scandirAndClean(XOOPS_ROOT_PATH . "/cache/", "formulize_Options_"); $maxLength = 10; $the_values = array(); foreach ($options as $id => $text) { $the_values[$id] = trans($text); $thisTextLength = strlen($the_values[$id]); $maxLength = $thisTextLength > $maxLength ? $thisTextLength : $maxLength; } file_put_contents(XOOPS_ROOT_PATH . "/cache/{$cachedLinkedOptionsFileName}", "<?php\n\${$cachedLinkedOptionsFileName} = " . var_export($the_values, true) . ";\n"); $defaultSelected = is_array($selected) ? $selected[0] : $selected; $renderedComboBox = $this->formulize_renderQuickSelect($form_ele_id, $cachedLinkedOptionsFileName, $defaultSelected, $options[$defaultSelected], $maxLength); $form_ele2 = new xoopsFormLabel($ele_caption, $renderedComboBox); $renderedElement = $form_ele2->render(); } else { // normal element $renderedElement = $form_ele1->render(); } $form_ele = new XoopsFormLabel($ele_caption, "<nobr>{$renderedElement}</nobr>\n{$renderedHoorvs}\n{$disabledHiddenValues}\n"); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); } // end of if we have a link on our hands. -- jwe 7/29/04 // set required validation code if ($this->_ele->getVar('ele_req') and !$isDisabled) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); if ($ele_value[8] == 1) { // Has been edited in order to not allow the user to submit a form when "No match found" or "Choose an Option" is selected from the quickselect box. $form_ele->customValidationCode[] = "\nif ( myform.{$eltname}.value == '' || myform.{$eltname}.value == 'none' ) {\n window.alert(\"{$eltmsg}\");\n myform.{$eltname}_user.focus();\n return false;\n }\n"; } elseif ($ele_value[0] == 1) { $form_ele->customValidationCode[] = "\nif ( myform.{$eltname}.options[0].selected ) {\n window.alert(\"{$eltmsg}\");\n myform.{$eltname}.focus();\n return false;\n }\n"; } elseif ($ele_value[0] > 1) { $form_ele->customValidationCode[] = "selection = false;\n"; $form_ele->customValidationCode[] = "\nfor(i=0;i<myform.{$eltname}.options.length;i++) {\n"; $form_ele->customValidationCode[] = "if(myform.{$eltname}.options[i].selected) {\n"; $form_ele->customValidationCode[] = "selection = true;\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "if(selection == false) { window.alert(\"{$eltmsg}\");\n myform.{$eltname}.focus();\n return false;\n }\n"; } } if ($isDisabled) { $isDisabled = false; // disabled stuff handled here in element, so don't invoke generic disabled handling below (which is only for textboxes and their variations) } break; case 'checkbox': $selected = array(); $options = array(); $disabledHiddenValue = array(); $disabledHiddenValues = ""; $disabledOutputText = array(); $opt_count = 1; while ($i = each($ele_value)) { $options[$opt_count] = $myts->stripSlashesGPC($i['key']); if ($i['value'] > 0) { $selected[] = $opt_count; $disabledHiddenValue[] = "<input type=hidden name=\"" . $form_ele_id . "[]\" value=\"{$opt_count}\">"; } $opt_count++; } if ($this->_ele->getVar('ele_delim') != "") { $delimSetting = $this->_ele->getVar('ele_delim'); } $delimSetting =& $myts->undoHtmlSpecialChars($delimSetting); if ($delimSetting == "br") { $delimSetting = "<br />"; } $hiddenOutOfRangeValuesToWrite = array(); switch ($delimSetting) { case 'space': $form_ele1 = new XoopsFormCheckBox($ele_caption, $form_ele_id, $selected); $counter = 0; // counter used for javascript that works with 'Other' box while ($o = each($options)) { $o = formulize_swapUIText($o, $this->_ele->getVar('ele_uitext')); $other = $this->optOther($o['value'], $form_ele_id, $entry, $counter, true); if ($other != false) { $form_ele1->addOption($o['key'], _formulize_OPT_OTHER . $other); if (in_array($o['key'], $selected)) { $disabledOutputText[] = _formulize_OPT_OTHER . $other; } } else { $form_ele1->addOption($o['key'], $o['value']); if (in_array($o['key'], $selected)) { $disabledOutputText[] = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $counter++; } $form_ele1->setExtra(" onchange=\"javascript:formulizechanged=1;\" jquerytag=\"{$form_ele_id}\" "); break; default: $form_ele1 = new XoopsFormElementTray($ele_caption, $delimSetting); $counter = 0; // counter used for javascript that works with 'Other' box while ($o = each($options)) { $o = formulize_swapUIText($o, $this->_ele->getVar('ele_uitext')); $other = $this->optOther($o['value'], $form_ele_id, $entry, $counter, true); $t = new XoopsFormCheckBox('', $form_ele_id . '[]', $selected, $delimSetting); if ($other != false) { $t->addOption($o['key'], _formulize_OPT_OTHER . $other); if (in_array($o['key'], $selected)) { $disabledOutputText[] = _formulize_OPT_OTHER . $other; } } else { $t->addOption($o['key'], $o['value']); if (in_array($o['key'], $selected)) { $disabledOutputText[] = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $t->setExtra(" onchange=\"javascript:formulizechanged=1;\" jquerytag=\"{$form_ele_id}\" "); $form_ele1->addElement($t); unset($t); $counter++; } break; } $renderedHoorvs = ""; if (count($hiddenOutOfRangeValuesToWrite) > 0) { foreach ($hiddenOutOfRangeValuesToWrite as $hoorKey => $hoorValue) { $thisHoorv = new xoopsFormHidden('formulize_hoorv_' . $true_ele_id . '_' . $hoorKey, $hoorValue); $renderedHoorvs .= $thisHoorv->render() . "\n"; unset($thisHoorv); } } if ($isDisabled) { $disabledHiddenValues = implode("\n", $disabledHiddenValue); // glue the individual value elements together into a set of values $renderedElement = implode(", ", $disabledOutputText); } else { $renderedElement = $form_ele1->render(); } $form_ele = new XoopsFormLabel($ele_caption, "{$renderedElement}\n{$renderedHoorvs}\n{$disabledHiddenValues}\n"); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); if ($this->_ele->getVar('ele_req') and !$isDisabled) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $form_ele->customValidationCode[] = "selection = true;\n"; $form_ele->customValidationCode[] = "checkboxes = \$('[jquerytag={$eltname}]:checked');\n"; // need to use this made up attribute here, because there is no good way to select the checkboxes using the name or anything else that XOOPS/Impress is giving us!! $form_ele->customValidationCode[] = "if(checkboxes.length == 0) { window.alert(\"{$eltmsg}\");\n \$('[jquerytag={$eltname}]').focus();\n return false;\n }\n"; } if ($isDisabled) { $isDisabled = false; // disabled stuff handled here in element, so don't invoke generic disabled handling below (which is only for textboxes and their variations) } break; case 'radio': case 'yn': $selected = ''; $disabledHiddenValue = ""; $options = array(); $opt_count = 1; while ($i = each($ele_value)) { switch ($ele_type) { case 'radio': $options[$opt_count] = $myts->stripSlashesGPC($i['key']); $options[$opt_count] = $myts->displayTarea($options[$opt_count]); break; case 'yn': $options[$opt_count] = constant($i['key']); $options[$opt_count] = $myts->stripSlashesGPC($options[$opt_count]); break; } if ($i['value'] > 0) { $selected = $opt_count; } $opt_count++; } if ($this->_ele->getVar('ele_delim') != "") { $delimSetting = $this->_ele->getVar('ele_delim'); } $delimSetting =& $myts->undoHtmlSpecialChars($delimSetting); if ($delimSetting == "br") { $delimSetting = "<br />"; } $hiddenOutOfRangeValuesToWrite = array(); switch ($delimSetting) { case 'space': $form_ele1 = new XoopsFormRadio('', $form_ele_id, $selected); $counter = 0; while ($o = each($options)) { $o = formulize_swapUIText($o, $this->_ele->getVar('ele_uitext')); $other = $this->optOther($o['value'], $form_ele_id, $entry, $counter); if ($other != false) { $form_ele1->addOption($o['key'], _formulize_OPT_OTHER . $other); if ($o['key'] == $selected) { $disabledOutputText = _formulize_OPT_OTHER . $other; } } else { $o['value'] = get_magic_quotes_gpc() ? stripslashes($o['value']) : $o['value']; $form_ele1->addOption($o['key'], $o['value']); if ($o['key'] == $selected) { $disabledOutputText = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $counter++; } $form_ele1->setExtra("onchange=\"javascript:formulizechanged=1;\""); break; default: $form_ele1 = new XoopsFormElementTray('', $delimSetting); $counter = 0; while ($o = each($options)) { $o = formulize_swapUIText($o, $this->_ele->getVar('ele_uitext')); $t = new XoopsFormRadio('', $form_ele_id, $selected); $other = $this->optOther($o['value'], $form_ele_id, $entry, $counter); if ($other != false) { $t->addOption($o['key'], _formulize_OPT_OTHER . "</label><label>{$other}"); // epic hack to terminate radio button's label so it doesn't include the clickable 'other' box!! if ($o['key'] == $selected) { $disabledOutputText = _formulize_OPT_OTHER . $other; } } else { $o['value'] = get_magic_quotes_gpc() ? stripslashes($o['value']) : $o['value']; $t->addOption($o['key'], $o['value']); if ($o['key'] == $selected) { $disabledOutputText = $o['value']; } if (strstr($o['value'], _formulize_OUTOFRANGE_DATA)) { $hiddenOutOfRangeValuesToWrite[$o['key']] = str_replace(_formulize_OUTOFRANGE_DATA, "", $o['value']); // if this is an out of range value, grab the actual value so we can stick it in a hidden element later } } $t->setExtra("onchange=\"javascript:formulizechanged=1;\""); $form_ele1->addElement($t); unset($t); $counter++; } break; } $renderedHoorvs = ""; if (count($hiddenOutOfRangeValuesToWrite) > 0) { foreach ($hiddenOutOfRangeValuesToWrite as $hoorKey => $hoorValue) { $thisHoorv = new xoopsFormHidden('formulize_hoorv_' . $true_ele_id . '_' . $hoorKey, $hoorValue); $renderedHoorvs .= $thisHoorv->render() . "\n"; unset($thisHoorv); } } if ($isDisabled) { $disabledHiddenValue = "<input type=hidden name=\"" . $form_ele_id . "\" value=\"{$selected}\">\n"; $renderedElement = $disabledOutputText; // just text for disabled elements } else { $renderedElement = $form_ele1->render(); } $form_ele = new XoopsFormLabel($ele_caption, "{$renderedElement}\n{$renderedHoorvs}\n{$disabledHiddenValue}\n"); $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); if ($this->_ele->getVar('ele_req') and !$isDisabled) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); $form_ele->customValidationCode[] = "selection = false;\n"; $form_ele->customValidationCode[] = "if(myform.{$eltname}.length) {\n"; $form_ele->customValidationCode[] = "for(var i=0;i<myform.{$eltname}.length;i++){\n"; $form_ele->customValidationCode[] = "if(myform.{$eltname}[i].checked){\n"; $form_ele->customValidationCode[] = "selection = true;\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "}\n"; $form_ele->customValidationCode[] = "if(selection == false) { window.alert(\"{$eltmsg}\");\n myform.{$eltname}.focus();\n return false;\n }\n"; } if ($isDisabled) { $isDisabled = false; // disabled stuff handled here in element, so don't invoke generic disabled handling below (which is only for textboxes and their variations) } break; case 'date': // if there's no value (ie: it's blank) ... OR it's the default value because someone submitted a date field without actually specifying a date, that last part added by jwe 10/23/04 if ($ele_value[0] == "" or $ele_value[0] == "YYYY-mm-dd") { $form_ele = new XoopsFormTextDateSelect($ele_caption, $form_ele_id, 15, ""); $form_ele->setExtra(" onchange=\"javascript:formulizechanged=1;\" jquerytag=\"{$form_ele_id}\" "); } else { $form_ele = new XoopsFormTextDateSelect($ele_caption, $form_ele_id, 15, getDateElementDefault($ele_value[0])); $form_ele->setExtra(" onchange=\"javascript:formulizechanged=1;\" jquerytag=\"{$form_ele_id}\" "); } // end of check to see if the default setting is for real // added validation code - sept 5 2007 - jwe if ($this->_ele->getVar('ele_req') and !$isDisabled) { $eltname = $form_ele_id; $eltcaption = $ele_caption; $eltmsg = empty($eltcaption) ? sprintf(_FORM_ENTER, $eltname) : sprintf(_FORM_ENTER, $eltcaption); $eltmsg = str_replace('"', '\\"', stripslashes($eltmsg)); // parseInt() is used to determine if the element value contains a number // Date.parse() would be better, except that it will fail for dd-mm-YYYY format, ie: 22-11-2013 $form_ele->customValidationCode[] = "\nif (isNaN(parseInt(myform.{$eltname}.value))) {\n window.alert(\"{$eltmsg}\");\n myform.{$eltname}.focus();\n return false;\n }\n"; } if (!$isDisabled) { $limit_past = (isset($ele_value["date_limit_past"]) and $ele_value["date_limit_past"] != ""); $limit_future = (isset($ele_value["date_limit_future"]) and $ele_value["date_limit_future"] != ""); if ($limit_past or $limit_future) { $reference_date = time(); if ("new" != $entry) { $entryData = $this->formulize_getCachedEntryData($id_form, $entry); $reference_date = strtotime(display($entryData, "creation_date")); } if ($limit_past) { $form_ele->setExtra(" min-date='" . date("Y-m-d", strtotime("-" . max(0, intval($ele_value["date_past_days"])) . " days", $reference_date)) . "' "); } if ($limit_future) { $form_ele->setExtra(" max-date='" . date("Y-m-d", strtotime("+" . max(0, intval($ele_value["date_future_days"])) . " days", $reference_date)) . "' "); } $form_ele->setExtra(" onchange=\"javascript:formulizechanged=1;check_date_limits('{$form_ele_id}');\" onclick=\"javascript:check_date_limits('{$form_ele_id}');\" onblur=\"javascript:check_date_limits('{$form_ele_id}');\" jquerytag=\"{$form_ele_id}\" "); } else { $form_ele->setExtra(" onchange=\"javascript:formulizechanged=1;\" jquerytag=\"{$form_ele_id}\" "); } } break; case 'sep': //$ele_value[0] = $myts->displayTarea($ele_value[0]); $ele_value[0] = $myts->xoopsCodeDecode($ele_value[0]); $form_ele = new XoopsFormLabel($ele_caption, $ele_value[0]); break; case 'upload': $form_ele = new XoopsFormFile($ele_caption, $form_ele_id, $ele_value[1]); break; /* * Hack by F�lix<INBOX International> * Adding colorpicker form element */ /* * Hack by F�lix<INBOX International> * Adding colorpicker form element */ case 'colorpick': if ($ele_value[0] == "") { //print "Bad date"; $form_ele = new XoopsFormColorPicker($ele_caption, $form_ele_id, ""); } else { //print "good date"; $form_ele = new XoopsFormColorPicker($ele_caption, $form_ele_id, $ele_value[0]); } // end of check to see if the default setting is for real break; /* * End of Hack by F�lix<INBOX International> * Adding colorpicker form element */ /* * End of Hack by F�lix<INBOX International> * Adding colorpicker form element */ default: if (file_exists(XOOPS_ROOT_PATH . "/modules/formulize/class/" . $ele_type . "Element.php")) { $elementTypeHandler = xoops_getmodulehandler($ele_type . "Element", "formulize"); $form_ele = $elementTypeHandler->render($ele_value, $ele_caption, $form_ele_id, $isDisabled, $this->_ele, $entry, $screen); // $ele_value as passed in here, $caption, name that we use for the element in the markup, flag for whether it's disabled or not, element object, entry id number that this element belongs to, $screen is the screen object that was passed in, if any // if form_ele is an array, then we want to treat it the same as an "insertbreak" element, ie: it's not a real form element object if (is_object($form_ele)) { if (!$isDisabled and ($this->_ele->getVar('ele_req') or $this->_ele->alwaysValidateInputs) and $this->_ele->hasData) { // if it's not disabled, and either a declared required element according to the webmaster, or the element type itself always forces validation... $form_ele->customValidationCode = $elementTypeHandler->generateValidationCode($ele_caption, $form_ele_id, $this->_ele, $entry); } $form_ele->setDescription(html_entity_decode($ele_desc, ENT_QUOTES)); $isDisabled = false; // the render method must handle providing a disabled output, so as far as the rest of the logic here goes, the element is not disabled but should be rendered as is $baseCustomElementObject = $elementTypeHandler->create(); if ($baseCustomElementObject->hasData) { $customElementHasData = true; } } } else { return false; } break; } // end element-type case if (is_object($form_ele) and !$isDisabled and $this->_ele->hasData) { if ($previousEntryUI) { $previousEntryUIRendered = " " . $previousEntryUI->render(); } else { $previousEntryUIRendered = ""; } // $ele_type is the type value...only put in a cue for certain kinds of elements, and definitely not for blank subforms if (substr($form_ele_id, 0, 9) != "desubform" and ($ele_type == "text" or $ele_type == "textarea" or $ele_type == "select" or $ele_type == "radio" or $ele_type == "checkbox" or $ele_type == "date" or $ele_type == "colorpick" or $ele_type == "yn" or $customElementHasData)) { $elementCue = "\n<input type=\"hidden\" id=\"decue_" . trim($form_ele_id, "de_") . "\" name=\"decue_" . trim($form_ele_id, "de_") . "\" value=1>\n"; } else { $elementCue = ""; } $form_ele->setExtra(" onchange=\"javascript:formulizechanged=1;\""); // reuse caption, put two spaces between element and previous entry UI $form_ele_new = new xoopsFormLabel($form_ele->getCaption(), $form_ele->render() . $previousEntryUIRendered . $elementCue); $form_ele_new->formulize_element = $this->_ele; if ($ele_desc != "") { $ele_desc = html_entity_decode($ele_desc, ENT_QUOTES); $ele_desc = $myts->makeClickable($ele_desc); $form_ele_new->setDescription($ele_desc); } $form_ele_new->setName($form_ele_id); // need to set this as the name, in case it is required and then the name will be picked up by any "required" checks that get done and used in the required validation javascript for textboxes if (!empty($form_ele->customValidationCode)) { $form_ele_new->customValidationCode = $form_ele->customValidationCode; } if ($form_ele->isRequired()) { $form_ele_new->setRequired(); } return $form_ele_new; } elseif (is_object($form_ele) and $isDisabled and $this->_ele->hasData) { // element is disabled $form_ele = $this->formulize_disableElement($form_ele, $ele_type, $ele_desc); return $form_ele; } else { // form ele is not an object...and/or has no data. Happens for IBs and for non-interactive elements, like grids. return $form_ele; } }
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // ------------------------------------------------------------------------ // if (!defined("XOOPS_ROOT_PATH")) { die("XOOPS root path not defined"); } include_once XOOPS_ROOT_PATH . "/class/xoopslists.php"; include XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $cform = new XoopsThemeForm(_CM_POSTCOMMENT, "commentform", "postcomment.php", "post", true); if (!preg_match("/^re:/i", $subject)) { $subject = "Re: " . xoops_substr($subject, 0, 56); } $cform->addElement(new XoopsFormText(_CM_TITLE, 'subject', 50, 255, $subject), true); $icons_radio = new XoopsFormRadio(_MESSAGEICON, 'icon', $icon); $subject_icons = XoopsLists::getSubjectsList(); foreach ($subject_icons as $iconfile) { $icons_radio->addOption($iconfile, '<img src="' . XOOPS_URL . '/images/subject/' . $iconfile . '" alt="" />'); } $cform->addElement($icons_radio); $cform->addElement(new XoopsFormDhtmlTextArea(_CM_MESSAGE, 'message', $message, 10, 50), true); $option_tray = new XoopsFormElementTray(_OPTIONS, '<br />'); if ($xoopsUser) { if ($xoopsConfig['anonpost'] == 1) { $noname_checkbox = new XoopsFormCheckBox('', 'noname', $noname); $noname_checkbox->addOption(1, _POSTANON); $option_tray->addElement($noname_checkbox); } if ($xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { $nohtml_checkbox = new XoopsFormCheckBox('', 'nohtml', $nohtml); $nohtml_checkbox->addOption(1, _DISABLEHTML); $option_tray->addElement($nohtml_checkbox); }
$sform->addElement($checkbox); $sticky_confirmation = new XoopsFormRadio(_AM_XFORUM_PRUNE_STICKY, 'sticky', 1); $sticky_confirmation->addOption(1, _AM_XFORUM_PRUNE_YES); $sticky_confirmation->addOption(0, _AM_XFORUM_PRUNE_NO); $sform->addElement($sticky_confirmation); $digest_confirmation = new XoopsFormRadio(_AM_XFORUM_PRUNE_DIGEST, 'digest', 1); $digest_confirmation->addOption(1, _AM_XFORUM_PRUNE_YES); $digest_confirmation->addOption(0, _AM_XFORUM_PRUNE_NO); $sform->addElement($digest_confirmation); $lock_confirmation = new XoopsFormRadio(_AM_XFORUM_PRUNE_LOCK, 'lock', 0); $lock_confirmation->addOption(1, _AM_XFORUM_PRUNE_YES); $lock_confirmation->addOption(0, _AM_XFORUM_PRUNE_NO); $sform->addElement($lock_confirmation); $hot_confirmation = new XoopsFormSelect(_AM_XFORUM_PRUNE_HOT, 'hot', null, 1, false); $hot_confirmation->addOptionArray(array('0' => 0, '5' => 5, '10' => 10, '15' => 15, '20' => 20, '25' => 25, '30' => 30)); $sform->addElement($hot_confirmation); $sform->addElement($radiobox); $archive_confirmation = new XoopsFormRadio(_AM_XFORUM_PRUNE_ARCHIVE, 'archive', 1); $archive_confirmation->addOption(1, _AM_XFORUM_PRUNE_YES); $archive_confirmation->addOption(0, _AM_XFORUM_PRUNE_NO); $sform->addElement($archive_confirmation); $button_tray = new XoopsFormElementTray('', ''); $button_tray->addElement(new XoopsFormButton('', 'submit', _AM_XFORUM_PRUNE_SUBMIT, 'submit')); $button_tray->addElement(new XoopsFormButton('', 'reset', _AM_XFORUM_PRUNE_RESET, 'reset')); $sform->addElement($button_tray); $sform->display(); } echo "</td></tr></table>"; echo "</fieldset>"; echo chronolabs_inline(false); xoops_cp_footer();
function createDataTypeUI($ele_type, $element, $id_form, $ele_encrypt) { // data type controls ... added May 31 2009, jwe // only do it for existing elements where the datatype choice is relevant // do not do it for encrypted elements $renderedUI = ""; // check if there's a special class file for this element type, and if so, instantiate an element object of that kind, so we can check if it needs a datatype UI or not $customTypeNeedsUI = false; if (file_exists(XOOPS_ROOT_PATH . "/modules/formulize/class/" . $ele_type . "Element.php")) { $customTypeHandler = xoops_getmodulehandler($ele_type . "Element", 'formulize'); $customTypeObject = $customTypeHandler->create(); $customTypeNeedsUI = $customTypeObject->needsDataType; } if (($ele_type == "text" or $ele_type == "textarea" or $ele_type == "select" or $ele_type == "radio" or $ele_type == "checkbox" or $ele_type == "derived" or $customTypeNeedsUI) and !$ele_encrypt) { if ($element) { $defaultTypeInformation = $element->getDataTypeInformation(); $defaultType = $defaultTypeInformation['dataType']; $defaultTypeSize = $defaultTypeInformation['dataTypeSize']; //print "defaultType: $defaultType<br>"; //print "defaultTypeSize: $defaultTypeSize<br>"; $renderedUI .= "<input type='hidden' name='element_default_datatype' value='{$defaultType}'>\n"; $renderedUI .= "<input type='hidden' name='element_default_datatypesize' value='{$defaultTypeSize}'>\n"; } else { $defaultType = 'text'; $defaultTypeSize = ''; } // setup the UI for the options... $dataTypeTray = new XoopsFormElementTray(_AM_FORM_DATATYPE_CONTROLS, '<br>'); $dataTypeTray->setDescription(_AM_FORM_DATATYPE_CONTROLS_DESC); $textType = new XoopsFormRadio('', 'element_datatype', $defaultType); $textDataTypeLabel = (!$element and $ele_type == 'text') ? _AM_FORM_DATATYPE_TEXT_NEWTEXT : _AM_FORM_DATATYPE_TEXT; $textType->addOption('text', $textDataTypeLabel); $intType = new XoopsFormRadio('', 'element_datatype', $defaultType); $intType->addOption('int', _AM_FORM_DATATYPE_INT); $decimalType = new XoopsFormRadio('', 'element_datatype', $defaultType); $decimalTypeSizeDefault = ($defaultTypeSize and $defaultType == "decimal") ? $defaultTypeSize : 2; $decimalTypeSize = new XoopsFormText('', 'element_datatype_decimalsize', 2, 2, $decimalTypeSizeDefault); $decimalTypeSize->setExtra(" style=\"width: 2em;\" "); // style to force width necessary to compensate for silly forced 60% textbox widths in ICMS admin side $decimalType->addOption('decimal', _AM_FORM_DATATYPE_DECIMAL1 . $decimalTypeSize->render() . _AM_FORM_DATATYPE_DECIMAL2); $varcharType = new XoopsFormRadio('', 'element_datatype', $defaultType); $varcharTypeSizeDefault = ($defaultTypeSize and $defaultType == 'varchar') ? $defaultTypeSize : 255; $varcharTypeSize = new XoopsFormText('', 'element_datatype_varcharsize', 3, 3, $varcharTypeSizeDefault); $varcharTypeSize->setExtra(" style=\"width: 3em;\" "); $varcharType->addOption('varchar', _AM_FORM_DATATYPE_VARCHAR1 . $varcharTypeSize->render() . _AM_FORM_DATATYPE_VARCHAR2); $charType = new XoopsFormRadio('', 'element_datatype', $defaultType); $charTypeSizeDefault = ($defaultTypeSize and $defaultType == 'char') ? $defaultTypeSize : 255; $charTypeSize = new XoopsFormText('', 'element_datatype_charsize', 3, 3, $charTypeSizeDefault); $charTypeSize->setExtra(" style=\"width: 3em;\" "); $charType->addOption('char', _AM_FORM_DATATYPE_CHAR1 . $charTypeSize->render() . _AM_FORM_DATATYPE_CHAR2); if ($defaultType != "text" and $defaultType != "int" and $defaultType != "decimal" and $defaultType != "varchar" and $defaultType != "char") { $otherType = new XoopsFormRadio('', 'element_datatype', $defaultType); $otherType->addOption($defaultType, _AM_FORM_DATATYPE_OTHER . $defaultType); $dataTypeTray->addElement($otherType); } $dataTypeTray->addElement($textType); $dataTypeTray->addElement($intType); $dataTypeTray->addElement($decimalType); $dataTypeTray->addElement($varcharType); $dataTypeTray->addElement($charType); $renderedUI .= $dataTypeTray->render(); } return $renderedUI; }
$giorni_asta = new XoopsFormSelect("Durata dell'asta?", "giorni_asta"); $giorni_asta->addOption("10", "10 giorni"); $giorni_asta->addOption("7", "7 giorni"); $giorni_asta->addOption("5", "5 giorni"); $giorni_asta->addOption("1", "1 giorno"); /* $cat_link = new XoopsFormLabel( "<a href='javascript:location.href=\"viewcat.php?cid=\"+document.uploadphoto.cid.value;'>"._GO."</a>" ) ; $cat_tray = new XoopsFormElementTray( _ALBM_PHOTOCAT , ' ' ) ; $cat_tray->addElement( $cat_select ) ; $cat_tray->addElement( $cat_link ) ; */ //$desc_tarea = new XoopsFormDhtmlTextArea( _ALBM_PHOTODESC , "desc_text" , $myts->makeTareaData4Edit( $photo['description'] ) , 10 , 50 ) ; $desc_tarea = new XoopsFormTextArea(_ALBM_PHOTODESC, "desc_text", $myts->makeTareaData4Edit($photo['description']), 10, 50); $file_form = new XoopsFormFile(_ALBM_SELECTFILE, "photofile", $myalbum_fsize); $file_form->setExtra("size='30'"); if ($myalbum_canrotate) { $rotate_radio = new XoopsFormRadio(_ALBM_RADIO_ROTATETITLE, 'rotate', 'rot0'); $rotate_radio->addOption('rot0', _ALBM_RADIO_ROTATE0 . " "); $rotate_radio->addOption('rot90', "<img src='images/icon_rotate90.gif' alt='" . _ALBM_RADIO_ROTATE90 . "' title='" . _ALBM_RADIO_ROTATE90 . "' /> "); $rotate_radio->addOption('rot180', "<img src='images/icon_rotate180.gif' alt='" . _ALBM_RADIO_ROTATE180 . "' title='" . _ALBM_RADIO_ROTATE180 . "' /> "); $rotate_radio->addOption('rot270', "<img src='images/icon_rotate270.gif' alt='" . _ALBM_RADIO_ROTATE270 . "' title='" . _ALBM_RADIO_ROTATE270 . "' /> "); } $op_hidden = new XoopsFormHidden("op", "submit"); $counter_hidden = new XoopsFormHidden("fieldCounter", 1); $preview_hidden = new XoopsFormHidden("preview_name", htmlspecialchars($preview_name), ENT_QUOTES); $submit_button = new XoopsFormButton("", "submit", _SUBMIT, "submit"); $preview_button = new XoopsFormButton("", "preview", _PREVIEW, "submit"); $reset_button = new XoopsFormButton("", "reset", _CANCEL, "reset"); $submit_tray = new XoopsFormElementTray(''); //riga qui sotto commentata da slyss //if( $caller != 'imagemanager' ) $submit_tray->addElement( $preview_button ) ; $submit_tray->addElement($submit_button); $submit_tray->addElement($reset_button);
/** * Get {@link XoopsThemeForm} for editing a user * * @param object $user {@link XoopsUser} to edit * * @return object */ function getUserForm(&$user, $action = false) { global $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsUser; if ($action === false) { $action = $_SERVER['REQUEST_URI']; } include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php"; $title = $user->isNew() ? _PROFILE_AM_ADDUSER : _PROFILE_MA_EDITPROFILE; $form = new XoopsThemeForm($title, 'userinfo', $action, 'post', true); if ($user->isNew() || $xoopsUser->isAdmin()) { $elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_NICKNAME, 'loginname', 25, 255, $user->getVar('loginname', 'e')), 'required' => 1); } else { $elements[0][] = array('element' => new XoopsFormLabel(_PROFILE_MA_NICKNAME, $user->getVar('loginname')), 'required' => 0); } $weights[0][] = 0; $elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_DISPLAYNAME, 'uname', 25, 75, $user->getVar('uname', 'e')), 'required' => 1); $weights[0][] = 0; $elements[0][] = array('element' => new XoopsFormText(_PROFILE_MA_REALNAME, 'name', 25, 75, $user->getVar('name', 'e')), 'required' => 0); $weights[0][] = 0; $email_tray = new XoopsFormElementTray(_PROFILE_MA_EMAIL, '<br />'); if ($user->isNew() || $xoopsModuleConfig['allow_chgmail'] == 1 || $xoopsUser->isAdmin()) { $email_text = new XoopsFormText('', 'email', 30, 60, $user->getVar('email')); } else { $email_text = new XoopsFormLabel('', $user->getVar('email')); } $email_tray->addElement($email_text, $user->isNew() || $xoopsModuleConfig['allow_chgmail'] == 1); $elements[0][] = array('element' => $email_tray, 'required' => 0); $weights[0][] = 0; if ($xoopsUser->isAdmin() && $user->getVar('uid') != $xoopsUser->getVar('uid')) { //If the user is an admin and is editing someone else $pwd_text = new XoopsFormPassword('', 'password', 10, 32); $pwd_text2 = new XoopsFormPassword('', 'vpass', 10, 32); $pwd_tray = new XoopsFormElementTray(_PROFILE_MA_PASSWORD . '<br />' . _PROFILE_MA_TYPEPASSTWICE); $pwd_tray->addElement($pwd_text); $pwd_tray->addElement($pwd_text2); $elements[0][] = array('element' => $pwd_tray, 'required' => 0); //cannot set an element tray required $weights[0][] = 0; $level_radio = new XoopsFormRadio(_PROFILE_MA_ACTIVEUSER, 'level', $user->getVar('level')); $level_radio->addOption(1, _PROFILE_MA_ACTIVE); $level_radio->addOption(0, _PROFILE_MA_INACTIVE); $level_radio->addOption(-1, _PROFILE_MA_DISABLED); $elements[0][] = array('element' => $level_radio, 'required' => 0); $weights[0][] = 0; } $elements[0][] = array('element' => new XoopsFormHidden('uid', $user->getVar('uid')), 'required' => 0); $weights[0][] = 0; $elements[0][] = array('element' => new XoopsFormHidden('op', 'save'), 'required' => 0); $weights[0][] = 0; if ($xoopsUser && $xoopsUser->isAdmin()) { $xoopsModule->loadLanguage("admin"); $rank_select = new XoopsFormSelect(_PROFILE_AM_RANK, "rank", $user->getVar('rank')); $ranklist = XoopsLists::getUserRankList(); if (count($ranklist) > 0) { $rank_select->addOption(0, _PROFILE_AM_NSRA); $rank_select->addOption(0, "--------------"); $rank_select->addOptionArray($ranklist); } else { $rank_select->addOption(0, _PROFILE_AM_NSRID); } $elements[0][] = array('element' => $rank_select, 'required' => 0); $weights[0][] = 0; $gperm_handler =& xoops_gethandler('groupperm'); //If user has admin rights on groups include_once XOOPS_ROOT_PATH . "/modules/system/constants.php"; if ($gperm_handler->checkRight("system_admin", XOOPS_SYSTEM_GROUP, $xoopsUser->getGroups(), 1)) { //add group selection $group_select = new XoopsFormSelectGroup(_PROFILE_AM_GROUP, 'groups', false, $user->getGroups(), 5, true); $elements[0][] = array('element' => $group_select, 'required' => 0); $weights[0][] = 0; } } // Dynamic fields $profile_handler =& xoops_gethandler('profile'); // Get fields $fields =& $profile_handler->loadFields(); // Get ids of fields that can be edited $gperm_handler =& xoops_gethandler('groupperm'); $editable_fields = $gperm_handler->getItemIds('profile_edit', $xoopsUser->getGroups(), $xoopsModule->getVar('mid')); $profile_fieldcat_handler =& xoops_getmodulehandler('fieldcategory'); /* @var $profile_fieldcat_handler ProfileFieldCategoryHandler */ $profile_cat_handler =& xoops_getmodulehandler('category'); /* @var $profile_cat_handler ProfileCategoryHandler */ $fieldcats =& $profile_fieldcat_handler->getObjects(null, true); if (count($fieldcats) > 0) { foreach (array_keys($fieldcats) as $i) { $catids[] = $fieldcats[$i]->getVar('catid'); } $categories =& $profile_cat_handler->getObjects(new Criteria('catid', "(" . implode(',', array_unique($catids)) . ")", "IN"), true, false); } $fieldcat_handler =& xoops_getmodulehandler('fieldcategory'); $fieldcats =& $fieldcat_handler->getObjects(null, true); foreach (array_keys($fields) as $i) { if (in_array($fields[$i]->getVar('fieldid'), $editable_fields)) { $fieldinfo['element'] = $fields[$i]->getEditElement($user); $fieldinfo['required'] = $fields[$i]->getVar('field_required'); if (isset($fieldcats[$fields[$i]->getVar('fieldid')])) { $key = $fieldcats[$fields[$i]->getVar('fieldid')]->getVar('catid'); } else { $key = 0; } $elements[$key][] = $fieldinfo; $weights[$key][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? intval($fieldcats[$fields[$i]->getVar('fieldid')]->getVar('field_weight')) : 1; } } ksort($elements); foreach (array_keys($elements) as $k) { array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]); $title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _PROFILE_MA_DEFAULT; $form->insertBreak($title, 'head'); foreach (array_keys($elements[$k]) as $i) { $form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']); } } $form->addElement(new XoopsFormButton('', 'submit', _PROFILE_MA_SAVECHANGES, 'submit')); return $form; }
/** * prepare HTML for output * * @return string */ function render() { $ret = ""; $formObject = new XoopsFormRadio('', 'rrule_freq', $this->_rrule_freq); $formObject->addOption('none', _MD_EXTCAL_NO_RECCUR_EVENT); $ret .= $formObject->render(); $ret .= "<br /><br /><fieldset><legend>" . _MD_EXTCAL_RECCUR_POLICY . "</legend><fieldset><legend>"; $formObject = new XoopsFormRadio('', 'rrule_freq', $this->_rrule_freq); $formObject->addOption('daily', _MD_EXTCAL_DAILY); $ret .= $formObject->render(); $ret .= "</legend>" . _MD_EXTCAL_DURING . " "; $formObject = new XoopsFormText('', 'rrule_daily_interval', 3, 2, $this->_rrule_daily_interval); $ret .= $formObject->render(); $ret .= " " . _MD_EXTCAL_DAYS . "</fieldset><br /><fieldset><legend>"; $formObject = new XoopsFormRadio('', 'rrule_freq', $this->_rrule_freq); $formObject->addOption('weekly', _MD_EXTCAL_WEEKLY); $ret .= $formObject->render(); $ret .= "</legend>" . _MD_EXTCAL_DURING . " "; $formObject = new XoopsFormText('', 'rrule_weekly_interval', 3, 2, $this->_rrule_weekly_interval); $ret .= $formObject->render(); $ret .= " " . _MD_EXTCAL_WEEKS . "<br />"; $formObject = new XoopsFormCheckBox('', 'rrule_weekly_bydays'); $formObject->addOption('MO', 'Mo '); $formObject->addOption('TU', 'Tu '); $formObject->addOption('WE', 'We '); $formObject->addOption('TH', 'Th '); $formObject->addOption('FR', 'Fr '); $formObject->addOption('SA', 'Sa '); $formObject->addOption('SU', 'Su '); $ret .= $formObject->render(); $ret .= "</fieldset><br /><fieldset><legend>"; $formObject = new XoopsFormRadio('', 'rrule_freq', $this->_rrule_freq); $formObject->addOption('monthly', _MD_EXTCAL_MONTHLY); $ret .= $formObject->render(); $ret .= "</legend>" . _MD_EXTCAL_DURING . " "; $formObject = new XoopsFormText('', 'rrule_monthly_interval', 3, 2, $this->_rrule_monthly_interval); $ret .= $formObject->render(); $ret .= " " . _MD_EXTCAL_MONTH . ", " . _MD_EXTCAL_ON . " "; $formObject = new XoopsFormSelect('', 'rrule_monthly_byday', $this->_rrule_weekly_bydays); $formObject->addOption('', ' '); $formObject->addOption('1MO', _MD_EXTCAL_1_MO); $formObject->addOption('1TU', _MD_EXTCAL_1_TU); $formObject->addOption('1WE', _MD_EXTCAL_1_WE); $formObject->addOption('1TH', _MD_EXTCAL_1_TH); $formObject->addOption('1FR', _MD_EXTCAL_1_FR); $formObject->addOption('1SA', _MD_EXTCAL_1_SA); $formObject->addOption('1SU', _MD_EXTCAL_1_SU); $formObject->addOption('2MO', _MD_EXTCAL_2_MO); $formObject->addOption('2TU', _MD_EXTCAL_2_TU); $formObject->addOption('2WE', _MD_EXTCAL_2_WE); $formObject->addOption('2TH', _MD_EXTCAL_2_TH); $formObject->addOption('2FR', _MD_EXTCAL_2_FR); $formObject->addOption('2SA', _MD_EXTCAL_2_SA); $formObject->addOption('2SU', _MD_EXTCAL_2_SU); $formObject->addOption('3MO', _MD_EXTCAL_3_MO); $formObject->addOption('3TU', _MD_EXTCAL_3_TU); $formObject->addOption('3WE', _MD_EXTCAL_3_WE); $formObject->addOption('3TH', _MD_EXTCAL_3_TH); $formObject->addOption('3FR', _MD_EXTCAL_3_FR); $formObject->addOption('3SA', _MD_EXTCAL_3_SA); $formObject->addOption('3SU', _MD_EXTCAL_3_SU); $formObject->addOption('4MO', _MD_EXTCAL_4_MO); $formObject->addOption('4TU', _MD_EXTCAL_4_TU); $formObject->addOption('4WE', _MD_EXTCAL_4_WE); $formObject->addOption('4TH', _MD_EXTCAL_4_TH); $formObject->addOption('4FR', _MD_EXTCAL_4_FR); $formObject->addOption('4SA', _MD_EXTCAL_4_SA); $formObject->addOption('4SU', _MD_EXTCAL_4_SU); $formObject->addOption('-1MO', _MD_EXTCAL_LAST_MO); $formObject->addOption('-1TU', _MD_EXTCAL_LAST_TU); $formObject->addOption('-1WE', _MD_EXTCAL_LAST_WE); $formObject->addOption('-1TH', _MD_EXTCAL_LAST_TH); $formObject->addOption('-1FR', _MD_EXTCAL_LAST_FR); $formObject->addOption('-1SA', _MD_EXTCAL_LAST_SA); $formObject->addOption('-1SU', _MD_EXTCAL_LAST_SU); $ret .= $formObject->render(); $ret .= " " . _MD_EXTCAL_OR_THE . " "; $formObject = new XoopsFormText('', 'rrule_bymonthday', 3, 2, $this->_rrule_bymonthday); $ret .= $formObject->render(); $ret .= " " . _MD_EXTCAL_DAY_NUM_MONTH . "</fieldset><br /><fieldset><legend>"; $formObject = new XoopsFormRadio('', 'rrule_freq', $this->_rrule_freq); $formObject->addOption('yearly', 'Yearly'); $ret .= $formObject->render(); $ret .= "</legend>" . _MD_EXTCAL_DURING . " "; $formObject = new XoopsFormText('', 'rrule_yearly_interval', 3, 2, $this->_rrule_yearly_interval); $ret .= $formObject->render(); $ret .= ' ' . _MD_EXTCAL_YEARS . '<br />'; $formObject = new ExtcalFormRRuleCheckBox('', 'rrule_yearly_bymonths', $this->_rrule_yearly_bymonths); $formObject->addOption('1', 'Jan'); $formObject->addOption('2', 'Fev'); $formObject->addOption('3', 'Mar'); $formObject->addOption('4', 'Apr'); $formObject->addOption('5', 'Mai'); $formObject->addOption('6', 'Jun'); $formObject->addOption('7', 'Jul'); $formObject->addOption('8', 'Agu'); $formObject->addOption('9', 'Sep'); $formObject->addOption('10', 'Oct'); $formObject->addOption('11', 'Nov'); $formObject->addOption('12', 'Dec'); $ret .= $formObject->render(); $ret .= '<br />'; $formObject = new XoopsFormSelect('', 'rrule_yearly_byday', $this->_rrule_yearly_byday); $formObject->addOption('', _MD_EXTCAL_SAME_ST_DATE); $formObject->addOption('1MO', _MD_EXTCAL_1_MO); $formObject->addOption('1TU', _MD_EXTCAL_1_TU); $formObject->addOption('1WE', _MD_EXTCAL_1_WE); $formObject->addOption('1TH', _MD_EXTCAL_1_TH); $formObject->addOption('1FR', _MD_EXTCAL_1_FR); $formObject->addOption('1SA', _MD_EXTCAL_1_SA); $formObject->addOption('1SU', _MD_EXTCAL_1_SU); $formObject->addOption('2MO', _MD_EXTCAL_2_MO); $formObject->addOption('2TU', _MD_EXTCAL_2_TU); $formObject->addOption('2WE', _MD_EXTCAL_2_WE); $formObject->addOption('2TH', _MD_EXTCAL_2_TH); $formObject->addOption('2FR', _MD_EXTCAL_2_FR); $formObject->addOption('2SA', _MD_EXTCAL_2_SA); $formObject->addOption('2SU', _MD_EXTCAL_2_SU); $formObject->addOption('3MO', _MD_EXTCAL_3_MO); $formObject->addOption('3TU', _MD_EXTCAL_3_TU); $formObject->addOption('3WE', _MD_EXTCAL_3_WE); $formObject->addOption('3TH', _MD_EXTCAL_3_TH); $formObject->addOption('3FR', _MD_EXTCAL_3_FR); $formObject->addOption('3SA', _MD_EXTCAL_3_SA); $formObject->addOption('3SU', _MD_EXTCAL_3_SU); $formObject->addOption('4MO', _MD_EXTCAL_4_MO); $formObject->addOption('4TU', _MD_EXTCAL_4_TU); $formObject->addOption('4WE', _MD_EXTCAL_4_WE); $formObject->addOption('4TH', _MD_EXTCAL_4_TH); $formObject->addOption('4FR', _MD_EXTCAL_4_FR); $formObject->addOption('4SA', _MD_EXTCAL_4_SA); $formObject->addOption('4SU', _MD_EXTCAL_4_SU); $formObject->addOption('-1MO', _MD_EXTCAL_LAST_MO); $formObject->addOption('-1TU', _MD_EXTCAL_LAST_TU); $formObject->addOption('-1WE', _MD_EXTCAL_LAST_WE); $formObject->addOption('-1TH', _MD_EXTCAL_LAST_TH); $formObject->addOption('-1FR', _MD_EXTCAL_LAST_FR); $formObject->addOption('-1SA', _MD_EXTCAL_LAST_SA); $formObject->addOption('-1SU', _MD_EXTCAL_LAST_SU); $ret .= $formObject->render(); $ret .= "</fieldset></fieldset>"; return $ret; }
// ------------------------------------------------------------------------ // // This program is free software; you can redistribute it and/or modify // // it under the terms of the GNU General Public License as published by // // the Free Software Foundation; either version 2 of the License, or // // (at your option) any later version. // // // // You may not change or alter any portion of this comment or credits // // of supporting developers from this source code or any supporting // // source code which is considered copyrighted (c) material of the // // original comment or credit authors. // // // // This program is distributed in the hope that it will be useful, // // but WITHOUT ANY WARRANTY; without even the implied warranty of // // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // // GNU General Public License for more details. // // // // 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"; $sform = new XoopsThemeForm(_AMS_NW_RATEARTICLE, "ratingform", XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/ratefile.php'); $sform->setExtra('enctype="multipart/form-data"'); $sform->addElement(new XoopsFormHidden('storyid', $article->storyid)); $rating_select = new XoopsFormRadio(_AMS_NW_RATE, 'rating', 0); for ($i = 1; $i <= 10; $i++) { $rating_select->addOption($i); } $sform->addElement($rating_select, true); $sform->addElement(new XoopsFormButton('', 'submit', _AMS_NW_SUBMITRATING, 'submit')); $sform->assign($xoopsTpl);
/** * Get {@link XoopsThemeForm} for editing a user * * @param object $user {@link XoopsUser} to edit * * @return object */ function profile_getUserForm(&$user, $profile = null, $action = false) { if ($action === false) { $action = $_SERVER['REQUEST_URI']; } if (empty($GLOBALS['xoopsConfigUser'])) { $config_handler =& xoops_gethandler('config'); $GLOBALS['xoopsConfigUser'] = $config_handler->getConfigsByCat(XOOPS_CONF_USER); } include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); $title = $user->isNew() ? _PROFILE_AM_ADDUSER : _US_EDITPROFILE; $form = new XoopsThemeForm($title, 'userinfo', $action, 'post', true); $profile_handler =& xoops_getmodulehandler('profile'); // Dynamic fields if (!$profile) { $profile_handler =& xoops_getmodulehandler('profile', 'profile'); $profile = $profile_handler->get($user->getVar('uid')); } // Get fields $fields = $profile_handler->loadFields(); // Get ids of fields that can be edited $gperm_handler =& xoops_gethandler('groupperm'); $editable_fields = $gperm_handler->getItemIds('profile_edit', $GLOBALS['xoopsUser']->getGroups(), $GLOBALS['xoopsModule']->getVar('mid')); if ($user->isNew() || $GLOBALS['xoopsUser']->isAdmin()) { $elements[0][] = array('element' => new XoopsFormText(_US_NICKNAME, 'uname', 25, $GLOBALS['xoopsUser']->isAdmin() ? 60 : $GLOBALS['xoopsConfigUser']['maxuname'], $user->getVar('uname', 'e')), 'required' => 1); $email_text = new XoopsFormText('', 'email', 30, 60, $user->getVar('email')); } else { $elements[0][] = array('element' => new XoopsFormLabel(_US_NICKNAME, $user->getVar('uname')), 'required' => 0); $email_text = new XoopsFormLabel('', $user->getVar('email')); } $email_tray = new XoopsFormElementTray(_US_EMAIL, '<br />'); $email_tray->addElement($email_text, $user->isNew() || $GLOBALS['xoopsUser']->isAdmin() ? 1 : 0); $weights[0][] = 0; $elements[0][] = array('element' => $email_tray, 'required' => 0); $weights[0][] = 0; if ($GLOBALS['xoopsUser']->isAdmin() && $user->getVar('uid') != $GLOBALS['xoopsUser']->getVar('uid')) { //If the user is an admin and is editing someone else $pwd_text = new XoopsFormPassword('', 'password', 10, 32); $pwd_text2 = new XoopsFormPassword('', 'vpass', 10, 32); $pwd_tray = new XoopsFormElementTray(_US_PASSWORD . '<br />' . _US_TYPEPASSTWICE); $pwd_tray->addElement($pwd_text); $pwd_tray->addElement($pwd_text2); $elements[0][] = array('element' => $pwd_tray, 'required' => 0); //cannot set an element tray required $weights[0][] = 0; $level_radio = new XoopsFormRadio(_PROFILE_MA_USERLEVEL, 'level', $user->getVar('level')); $level_radio->addOption(1, _PROFILE_MA_ACTIVE); $level_radio->addOption(0, _PROFILE_MA_INACTIVE); //$level_radio->addOption(-1, _PROFILE_MA_DISABLED); $elements[0][] = array('element' => $level_radio, 'required' => 0); $weights[0][] = 0; } $elements[0][] = array('element' => new XoopsFormHidden('uid', $user->getVar('uid')), 'required' => 0); $weights[0][] = 0; $elements[0][] = array('element' => new XoopsFormHidden('op', 'save'), 'required' => 0); $weights[0][] = 0; $cat_handler = xoops_getmodulehandler('category'); $categories = array(); $all_categories = $cat_handler->getObjects(null, true, false); $count_fields = count($fields); foreach (array_keys($fields) as $i) { if (in_array($fields[$i]->getVar('field_id'), $editable_fields)) { // Set default value for user fields if available if ($user->isNew()) { $default = $fields[$i]->getVar('field_default'); if ($default !== '' && $default !== null) { $user->setVar($fields[$i]->getVar('field_name'), $default); } } if ($profile->getVar($fields[$i]->getVar('field_name'), 'n') === null) { $default = $fields[$i]->getVar('field_default', 'n'); $profile->setVar($fields[$i]->getVar('field_name'), $default); } $fieldinfo['element'] = $fields[$i]->getEditElement($user, $profile); $fieldinfo['required'] = $fields[$i]->getVar('field_required'); $key = @$all_categories[$fields[$i]->getVar('cat_id')]['cat_weight'] * $count_fields + $fields[$i]->getVar('cat_id'); $elements[$key][] = $fieldinfo; $weights[$key][] = $fields[$i]->getVar('field_weight'); $categories[$key] = @$all_categories[$fields[$i]->getVar('cat_id')]; } } if ($GLOBALS['xoopsUser'] && $GLOBALS['xoopsUser']->isAdmin()) { xoops_loadLanguage('admin', 'profile'); $gperm_handler =& xoops_gethandler('groupperm'); //If user has admin rights on groups include_once $GLOBALS['xoops']->path('modules/system/constants.php'); if ($gperm_handler->checkRight('system_admin', XOOPS_SYSTEM_GROUP, $GLOBALS['xoopsUser']->getGroups(), 1)) { //add group selection $group_select = new XoopsFormSelectGroup(_US_GROUPS, 'groups', false, $user->getGroups(), 5, true); $elements[0][] = array('element' => $group_select, 'required' => 0); //set as latest; $weights[0][] = $count_fields + 1; } } ksort($elements); foreach (array_keys($elements) as $k) { array_multisort($weights[$k], SORT_ASC, array_keys($elements[$k]), SORT_ASC, $elements[$k]); $title = isset($categories[$k]) ? $categories[$k]['cat_title'] : _PROFILE_MA_DEFAULT; $desc = isset($categories[$k]) ? $categories[$k]['cat_description'] : ""; $form->addElement(new XoopsFormLabel("<h3>{$title}</h3>", $desc), false); foreach (array_keys($elements[$k]) as $i) { $form->addElement($elements[$k][$i]['element'], $elements[$k][$i]['required']); } } $form->addElement(new XoopsFormHidden('uid', $user->getVar('uid'))); $form->addElement(new XoopsFormButton('', 'submit', _US_SAVECHANGES, 'submit')); return $form; }
$imgsel->addOptionArray($images_array); $image->addElement($imgsel); if ($id != '' && $affimg == '1') { $imgaff = new XoopsFormCheckBox(" " . _FORM_DISPLAY, 'affimg', 1); $imgaff->addOption(1, ' '); } else { $imgaff = new XoopsFormCheckBox(" " . _FORM_DISPLAY, 'affimg'); $imgaff->addOption(1, ' '); } $image->addElement($imgaff); if ($id != '') { $ordre_form = new XoopsFormRadio(_FORM_ORDER, 'ordre', $ordre); } else { $ordre_form = new XoopsFormRadio(_FORM_ORDER, 'ordre', 'tit'); } $ordre_form->addOption('tit', _FORM_DTIT); $ordre_form->addOption('img', _FORM_DIMG); $email_form = new XoopsFormText(_FORM_EMAIL, 'email', 30, 255, $email); $select_form_group_perm = new XoopsFormSelectGroup(_FORM_GROUP, 'groupe', true, $tab2[$i], 4, false); for ($i = 0; $i < $m; $i++) { if ($id != '' && $tab[$i] == $groupe) { $select_form_group_perm = new XoopsFormSelectGroup(_FORM_GROUP, 'groupe', true, $groupe, 4, false); } } $select_form_group_perm->addOption(' ', _FORM_NO_GROUP); if ($id != '' && $admin == '1') { $admin_form = new XoopsFormCheckBox(_FORM_ADMIN, 'admin', 1); $admin_form->addOption(1, ' '); } else { $admin_form = new XoopsFormCheckBox(_FORM_ADMIN, 'admin'); $admin_form->addOption(1, ' ');
unset($element); break; case "language": $element = new XoopsFormSelectLang($fields[$i]->getVar('field_title'), $fields[$i]->getVar('field_name'), null, 6); $searchform->addElement($element); unset($element); break; } } asort($sortby_arr); $sortby_arr = array_merge(array("" => _NONE, "uname" => _US_NICKNAME, "email" => _US_EMAIL), $sortby_arr); $sortby_select = new XoopsFormSelect(_PROFILE_MA_SORTBY, 'sortby'); $sortby_select->addOptionArray($sortby_arr); $searchform->addElement($sortby_select); $order_select = new XoopsFormRadio(_PROFILE_MA_ORDER, 'order', 0); $order_select->addOption(0, _ASCENDING); $order_select->addOption(1, _DESCENDING); $searchform->addElement($order_select); $limit_text = new XoopsFormText(_PROFILE_MA_PERPAGE, 'limit', 15, 10, $limit_default); $searchform->addElement($limit_text); $searchform->addElement(new XoopsFormHidden('op', 'results')); $searchform->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); $searchform->assign($GLOBALS['xoopsTpl']); $GLOBALS['xoopsTpl']->assign('page_title', _PROFILE_MA_SEARCH); //added count user $member_handler =& xoops_gethandler('member'); $acttotal = $member_handler->getUserCount(new Criteria('level', 0, '>')); $total = sprintf(_PROFILE_MA_ACTUS, "<span style='color:#ff0000;'>{$acttotal}</span>"); $GLOBALS['xoopsTpl']->assign('total_users', $total); break; case "results":
$editor_configs['height'] = '400px'; // default value = 400px if ($wysiwyg_is_exist == 1) { $sform->addElement(new XoopsFormEditor($editor_configs['caption'], $editor, $editor_configs, $story->nohtml(), null)); } elseif ($wysiwyg_is_exist == 2) { $sform->addElement(new XoopsFormWysiwygTextArea($editor_configs['caption'], $editor_configs['name'], $editor_configs['value'], $editor_configs['width'], $editor_configs['height'], 'hiddenHometext')); } elseif ($wysiwyg_is_exist == 3) { $sform->addElement(new XoopsFormWysiwygTextArea($editor_configs, 'hiddenBodytext')); } else { $sform->addElement(new XoopsFormDhtmlTextArea($editor_configs['caption'], $editor_configs['name'], $editor_configs['value'], $editor_configs['rows'], $editor_configs['cols'], 'hiddenBodytext')); } $sform->addElement(new XoopsFormLabel('', '* ' . _MULTIPLE_PAGE_GUIDE), false); $sform->addElement(new XoopsFormTextArea(_AMS_NW_BANNER, 'banner', $myts->htmlSpecialChars($story->banner))); if ($edit && !isset($_GET['approve'])) { $change_radio = new XoopsFormRadio(_AMS_NW_MAJOR, 'change', $story->change); $change_radio->addOption(0, _AMS_NW_NOVERSIONCHANGE); $change_radio->addOption(1, _AMS_NW_VERSION); $change_radio->addOption(2, _AMS_NW_REVISION); $change_radio->addOption(3, _AMS_NW_MINOR); $change_radio->addOption(4, _AMS_NW_AUTO); $change_radio->setDescription(_AMS_NW_VERSIONDESC); $change_radio->setValue(4); $sform->addElement($change_radio); $sform->addElement(new XoopsFormRadioYN(_AMS_NW_SWITCHAUTHOR . " (" . $story->uname . ")", 'newauthor', 0)); } // Manage upload(s) $allowupload = false; switch ($xoopsModuleConfig['uploadgroups']) { case 1: //Submitters and Approvers $allowupload = true;