function generate() { $form_name = $_POST['form_name']; $label = $_POST['element_name']; $element_id = $_POST['elemet_type']; $form_id = key_exists('form_id', $_POST) ? $_POST['form_id'] : 0; $options = $_POST['options']; if ($form_id == 0) { //insert form $query_form = "insert into form values('','{$form_name}')"; if (!mysql_query($query_form)) { die('Error:' . mysql_error()); } else { $form_id = mysql_insert_id(); } } //insert form elements $query_elem = "insert into form_element values('','{$form_id}','{$element_id}','{$label}','{$options}')"; if (!mysql_query($query_elem)) { die('Error:' . mysql_error()); } else { $_SESSION['form_id'] = $form_id; $_SESSION['form_name'] = $form_name; render_form($form_id); } }
function b_ccenter_form_show($options) { global $xoopsUser, $xoopsDB, $xoopsTpl; $cond = "active"; if (is_object($xoopsUser)) { $conds = array(); foreach ($xoopsUser->getGroups() as $gid) { $conds[] = "grpperm LIKE '%|{$gid}|%'"; } if ($conds) { $cond .= " AND (" . join(' OR ', $conds) . ")"; } } else { $cond .= " AND grpperm LIKE '%|" . XOOPS_GROUP_ANONYMOUS . "|%'"; } if (!empty($options[0])) { $cond .= ' AND formid=' . intval($options[0]); } $res = $xoopsDB->query("SELECT * FROM " . FORMS . " WHERE {$cond} ORDER BY weight,formid"); if (!$res || $xoopsDB->getRowsNum($res) == 0) { return array(); } $form = $xoopsDB->fetchArray($res); $myts =& MyTextSanitizer::getInstance(); $items = get_form_attribute($form['defs']); assign_form_widgets($items); $form['items'] =& $items; $form['action'] = 'index.php?form=' . $form['formid']; $template = render_form($form, 'form'); return array('content' => $xoopsTpl->fetch('db:' . $template)); }
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL_STATIC; ?> css/datatable.css" /> <h2>Add User Account</h2> <?php render_form($schema, $user, 'admin/save-user');
</td> <td> <fieldset> <h3><?php echo $_lang['role_config_management']; ?> </h3> <?php echo render_form('logs', $_lang['role_view_logs']); echo render_form('settings', $_lang['role_edit_settings']); echo render_form('file_manager', $_lang['role_file_manager']); echo render_form('bk_manager', $_lang['role_bk_manager']); echo render_form('manage_metatags', $_lang['role_manage_metatags']); echo render_form('import_static', $_lang['role_import_static']); echo render_form('export_static', $_lang['role_export_static']); echo render_form('remove_locks', $_lang['role_remove_locks']); ?> </fieldset> </td> </tr> </table> <input type="submit" name="save" style="display:none"> </form> </div> </div> <?php function render_form($name, $label, $status = '')
<h2>Create an App</h2> <?php render_form($schema, $app, 'dashboard/developer/create-app');
$path = ini_get('include_path'); $path = $path_extra . PATH_SEPARATOR . $path; ini_set('include_path', $path); require_once "Auth/OpenID.php"; /** * Data. */ $store_types = array("Filesystem" => "Auth_OpenID_FileStore", "MySQL" => "Auth_OpenID_MySQLStore", "PostgreSQL" => "Auth_OpenID_PostgreSQLStore", "SQLite" => "Auth_OpenID_SQLiteStore"); /** * Main. */ $messages = array(); session_start(); init_session(); if (!check_session() || isset($_GET['add_openid'])) { render_form(); } else { print generate_config(isset($_GET['download'])); } /** * Functions. */ function check_url($url) { return Auth_OpenID::normalizeUrl($url) !== null; } function build_url() { $port = $_SERVER['SERVER_PORT'] == 80 ? null : $_SERVER['SERVER_PORT']; $parts = explode("/", $_SERVER['SERVER_PROTOCOL']); $scheme = strtolower($parts[0]);
assign_form_widgets($items); } $cust = $form['custom']; $form['items'] =& $items; $action = "index.php?form=" . $form['formid']; if (!empty($form['priuser'])) { $action .= '&uid=' . $form['priuser']['uid']; } $form['action'] = $action; $title = htmlspecialchars($form['title'], ENT_QUOTES); $breadcrumbs->set($title, "index.php?form={$id}"); include XOOPS_ROOT_PATH . "/header.php"; $xoopsTpl->assign('errors', $errors); $xoopsTpl->assign('xoops_pagetitle', $title); $breadcrumbs->assign(); $xoopsOption['template_main'] = render_form($form, $op); if ($cust != _CC_TPL_FULL) { include XOOPS_ROOT_PATH . "/footer.php"; } else { echo $xoopsTpl->fetch('db:' . $xoopsOption['template_main']); } function store_message($items, $form) { global $xoopsUser, $xoopsDB, $xoopsModuleConfig; $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0; $store = $form['store']; if ($store == _DB_STORE_NONE) { $showaddr = true; // no store to need show address } else { $showaddr = get_attr_value(null, 'notify_with_email');
render_form($schema, $a_user, 'admin/save-user', false, function ($schema, $data) { if (count($schema['groups']['enum']) > 0) { ?> <div class="form-group row"> <label for="auth">Groups</label> <div> <?php $data['groups'] = explode(', ', $data['groups']); if (count($schema['groups']['enum']) == 0) { echo '<i>No user groups defined.</i>'; } foreach ($schema['groups']['enum'] as $id => $title) { ?> <label><input type="checkbox" name="groups[<?php echo $id; ?> ]"<?php echo in_array($id, $data['groups']) ? ' checked' : ''; ?> /><?php echo $title; ?> </label> <?php } ?> </div> </div> <?php } ?> <div class="form-group row"> <label for="auth">Access Control</label> <table class="ACL"> <tr> <th>Module</th> <th>Full Access</th> <th>View</th> <th>Add</th> <th>Edit</th> <th>Delete</th> </tr> <?php $data['auth'] = array_merge(json_decode(PUBLIC_MODULES, true), json_decode($data['auth'], true)); foreach ($schema['auth']['enum'] as $module) { renderACLRow('', $module, $data['auth'], 0); } ?> </table> </div> <?php });
?> </h2> <?php render_form($schema, $a_user, 'admin/save-group', false, function ($schema, $data) { ?> <div class="form-group row"> <label for="auth">Access Control</label> <table class="ACL"> <tr> <th>Module</th> <th>Full Access</th> <th>View</th> <th>Add</th> <th>Edit</th> <th>Delete</th> </tr> <?php $data['auth'] = array_merge(json_decode(PUBLIC_MODULES, true), json_decode($data['auth'], true)); foreach ($schema['auth']['enum'] as $module) { renderACLRow('', $module, $data['auth'], 0); } ?> </table> </div> <?php }); // function renderACLRow($path, $module, $data, $indent) { $acl = isset($data[$path . $module[0]]) ? $data[$path . $module[0]] : array();
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL_STATIC; ?> css/datatable.css" /> <h2>My Account</h2> <?php render_form($schema, $user, 'user'); ?> <br/> <h3>Recently used devices</h3> <?php render_table($logins_schema, $logins, 'logins'); ?> <style>table.table-striped tr td img {width:24px;}</style>
<br/><br/> <?php render_table($schema, $blog, 'tbl-blog'); ?> <?php if ($pages > 1) { for ($i = 1; $i < $pages + 1; $i++) { ?> <a class="button<?php echo $i == $page ? ' current' : ''; ?> " href="<?php echo BASE_URL; ?> admin/blog/<?php echo $i; ?> "><?php echo $i; ?> </a> <?php } } ?> <?php } else { render_form($schema, $article, 'user/blog/edit/' . $article['id']); }
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL_STATIC; ?> css/datatable.css" /> <h2>Static Pages</h2> <?php if (!isset($page)) { render_table($schema, $pages, 'tbl-pages'); } else { render_form($schema, $content, 'admin/pages/' . $content['slug']); ?> <style>iframe#content_ifr{height:300px !important; width:99.8% !important;}</style><?php }
<link rel="stylesheet" type="text/css" href="<?php echo BASE_URL_STATIC; ?> css/datatable.css" /> <h2>Static Pages</h2> <?php if (!isset($page)) { render_table($schema, $pages, 'tbl-users'); } else { render_form($schema, $content, 'admin/page/' . $content['stub']); }
render_table($schema, $news, 'tbl-news'); ?> <?php if ($pages > 1) { for ($i = 1; $i < $pages + 1; $i++) { ?> <a class="button<?php echo $i == $page ? ' current' : ''; ?> " href="<?php echo BASE_URL; ?> dashboard/index/<?php echo $i; ?> "><?php echo $i; ?> </a> <?php } } ?> <?php } else { render_form($schema, $article, 'dashboard'); ?> <style>iframe#content_ifr{height:300px !important; width:99.8% !important;}</style><?php }
function build_form($formid = 0) { global $xoopsDB, $xoopsUser, $myts, $fields, $xoopsConfig, $xoopsModuleConfig, $xoopsTpl; include_once dirname(dirname(__FILE__)) . "/language/" . $xoopsConfig['language'] . '/main.php'; if (isset($_POST['formid'])) { $data = array(); $fields[] = 'priuid'; $fields[] = 'cgroup'; foreach ($fields as $name) { $data[$name] = $myts->stripSlashesGPC($_POST[$name]); } $data['optvars'] = post_optvars(); $data['grpperm'] = $_POST['grpperm']; $formid = intval($_POST['formid']); // form preview get_attr_value($data['optvars']); // set default values $items = get_form_attribute($data['defs']); assign_form_widgets($items); if ($_POST['preview']) { echo "<h2>" . _PREVIEW . " : " . htmlspecialchars($data['title'], ENT_QUOTES) . "</h2>\n"; echo "<div class='preview'>\n"; $data['action'] = ''; $data['check_script'] = ""; $data['items'] =& $items; if (empty($xoopsTpl)) { $xoopsTpl = new XoopsTpl(); } $out = $xoopsTpl->fetch('db:' . render_form($data, 'form')); echo preg_replace('/type=["\']submit["\']/', 'type="submit" disabled="disabled"', $out); echo "</div>\n<hr size='5'/>\n"; } } elseif ($formid) { $res = $xoopsDB->query('SELECT * FROM ' . FORMS . " WHERE formid={$formid}"); $data = $xoopsDB->fetchArray($res); $data['grpperm'] = explode('|', trim($data['grpperm'], '|')); } else { $data = array('title' => '', 'description' => '', 'defs' => '', 'store' => 1, 'custom' => 0, 'weight' => 0, 'active' => 1, 'priuid' => $xoopsUser->getVar('uid'), 'cgroup' => XOOPS_GROUP_ADMIN, 'optvars' => '', 'grpperm' => array(XOOPS_GROUP_USERS)); } $form = new XoopsThemeForm($formid ? _AM_FORM_EDIT : _AM_FORM_NEW, 'myform', 'index.php'); $form->addElement(new XoopsFormHidden('formid', $formid)); $form->addElement(new XoopsFormText(_AM_FORM_TITLE, 'title', 35, 80, $data['title']), true); if (!empty($data['mtime'])) { $form->addElement(new XoopsFormLabel(_AM_FORM_MTIME, formatTimestamp($data['mtime']))); } $desc = new XoopsFormElementTray(_AM_FORM_DESCRIPTION, "<br/>"); $description = $data['description']; $editor = get_attr_value(null, 'use_fckeditor'); if ($editor) { $desc->addElement(new XoopsFormTextArea('', 'description', $description, 10, 60)); } else { $desc->addElement(new XoopsFormDhtmlTextArea('', 'description', $description, 10, 60)); } if (!$editor) { $button = new XoopsFormButton('', 'ins_tpl', _AM_INS_TEMPLATE); $button->setExtra("onClick=\"myform.description.value += defsToString();\""); $desc->addElement($button); } $error = check_form_tags($data['custom'], $data['defs'], $description); if ($error) { $desc->addElement(new XoopsFormLabel('', "<div style='color:red;'>{$error}</div>")); } $form->addElement($desc); $custom = new XoopsFormSelect(_AM_FORM_CUSTOM, 'custom', $data['custom']); $custom->setExtra(' onChange="myform.ins_tpl.disabled = (this.value==0||this.value==4);"'); $custom_type = unserialize_vars(_AM_CUSTOM_DESCRIPTION); if ($editor) { unset($custom_type[0]); } $custom->addOptionArray($custom_type); $form->addElement($custom); $grpperm = new XoopsFormSelectGroup(_AM_FORM_ACCEPT_GROUPS, 'grpperm', true, $data['grpperm'], 4, true); $grpperm->setDescription(_AM_FORM_ACCEPT_GROUPS_DESC); $form->addElement($grpperm); $defs_tray = new XoopsFormElementTray(_AM_FORM_DEFS); $defs_tray->addElement(new XoopsFormTextArea('', 'defs', $data['defs'], 10, 60)); $defs_tray->addElement(new XoopsFormLabel('', '<div id="itemhelper" style="display:none; white-space:nowrap;"> ' . _AM_FORM_LAB . ' <input name="xelab" size="10"> <input type="checkbox" name="xereq" title="' . _AM_FORM_REQ . '"> <select name="xetype"> <option value="text">text</option> <option value="checkbox">checkbox</option> <option value="radio">radio</option> <option value="textarea">textarea</option> <option value="select">select</option> <option value="const">const</option> <option value="hidden">hidden</option> <option value="mail">mail</option> <option value="file">file</option> </select> <input name="xeopt" size="30" /> <button onClick="return addFieldItem();">' . _AM_FORM_ADD . '</button> </div>')); $defs_tray->setDescription(_AM_FORM_DEFS_DESC); $form->addElement($defs_tray); $member_handler =& xoops_gethandler('member'); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $options = array(); foreach ($groups as $k => $v) { $options[-$k] = sprintf(_CC_FORM_PRIM_GROUP, $v); } $options[0] = _AM_FORM_PRIM_NONE; $priuid = new MyFormSelect(_AM_FORM_PRIM_CONTACT, 'priuid', $data['priuid']); $priuid->addOptionArray($options); $priuid->addOptionUsers($data['cgroup']); $priuid->setDescription(_AM_FORM_PRIM_DESC); $form->addElement($priuid); $cgroup = new XoopsFormSelect('', 'cgroup', $data['cgroup']); $cgroup->setExtra(' onChange="setSelectUID(\'priuid\', 0);"'); $cgroup->addOption(0, _AM_FORM_CGROUP_NONE); $groups = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!=')); $cgroup->addOptionArray($groups); $cgroup_tray = new XoopsFormElementTray(_AM_FORM_CONTACT_GROUP); $cgroup_tray->addElement($cgroup); $cgroup_tray->addElement(new XoopsFormLabel('', '<noscript><input type="submit" name="chggrp" id="chggrp" value="' . _AM_CHANGE . '"/></noscript>')); $form->addElement($cgroup_tray); $store = new XoopsFormSelect(_AM_FORM_STORE, 'store', $data['store']); $store->addOptionArray(unserialize_vars(_CC_STORE_MODE, 1)); $form->addElement($store); $form->addElement(new XoopsFormRadioYN(_AM_FORM_ACTIVE, 'active', $data['active'])); $form->addElement(new XoopsFormText(_AM_FORM_WEIGHT, 'weight', 2, 8, $data['weight'])); $items = get_form_attribute(_CC_OPTDEFS, _AM_OPTVARS_LABEL, 'optvar'); $vars = unserialize_vars($data['optvars']); $others = ""; foreach ($items as $k => $item) { $name = $item['name']; if (isset($vars[$name])) { $items[$k]['default'] = $vars[$name]; unset($vars[$name]); } } $val = ""; foreach ($vars as $i => $v) { $val .= "{$i}={$v}\n"; } $items[$k]['default'] = $val; assign_form_widgets($items); $varform = ""; foreach ($items as $item) { $br = $item['type'] == "textarea" ? "<br/>" : ""; $class = $item['default'] ? ' class="changed"' : ''; $varform .= "<div><span{$class}>" . $item['label'] . "</span>: {$br}" . $item['input'] . "</div>"; } $ck = empty($data['optvars']) ? "" : " checked='checked'"; $optvars = new XoopsFormLabel(_AM_FORM_OPTIONS, "<script type='text/javascript'>document.write(\"<input type='checkbox' id='optshow' onChange='toggle(this);'{$ck}/> " . _AM_OPTVARS_SHOW . "\");</script><div id='optvars'" . ($ck ? '' : ' style="display:none;"') . ">{$varform}</div>"); $form->addElement($optvars); $submit = new XoopsFormElementTray(''); $submit->addElement(new XoopsFormButton('', 'formdefs', _SUBMIT, 'submit')); $submit->addElement(new XoopsFormButton('', 'preview', _PREVIEW, 'submit')); $form->addElement($submit); echo "<a name='form'></a><style>.changed {font-weight: bold;}</style>"; $form->display(); if ($editor) { $base = XOOPS_URL . "/common/fckeditor"; global $xoopsTpl; echo "<script type='text/javascript' src='{$base}/fckeditor.js'></script>\n"; $editor = "var ccFCKeditor = new FCKeditor('description', '100%', '350', '{$editor}');\nccFCKeditor.BasePath = '{$base}/';\nccFCKeditor.ReplaceTextarea();"; } echo '<script language="JavaScript">' . $priuid->renderSupportJS(false) . ' // display only JavaScript enable xoopsGetElementById("itemhelper").style.display = "block"; ' . $editor . ' function toggle(a) { xoopsGetElementById("optvars").style.display = a.checked?"block":"none"; } togle(xoopsGetElementById("optshow")); function addFieldItem() { var myform = window.document.myform; var item=myform.xelab.value; if (item == "") { alert("' . _AM_FORM_LABREQ . '"); myform.xelab.focus(); return false; } if (myform.xereq.checked) item += "*"; var ty = myform.xetype.value; var ov = myform.xeopt.value; item += ","+ty; if (ty != "text" && ty != "textarea" && ty != "file" && ty != "mail" && ov == "") { alert(ty+": ' . _AM_FORM_OPTREQ . '"); myform.xeopt.focus(); return false; } if (ov != "") item += ","+ov; opts = myform.defs; if (opts.value!="" && !opts.value.match(/[\\n\\r]$/)) item = "\\n"+item; opts.value += item; myform.xelab.value = ""; // clear old value myform.xeopt.value = ""; return false; // always return false } function defsToString() { value = window.document.myform.defs.value; ret = ""; lines = value.split("\\n"); conf = "' . _MD_CONF_LABEL . '"; for (i in lines) { lab = lines[i].replace(/,.*$/, ""); if (lab.match(/^\\s*#/)) { ret += "[desc]<div>"+lines[i].replace(/^\\s*#/, "")+"</div>[/desc]\\n"; } else if (lab != "") { ret += "<div>"+lab+": {"+lab.replace(/\\*?$/,"")+"}</div>\\n"; if (lines[i].match(/^[^,]+,\\s*mail/i)) { lab = conf.replace(/%s/, lab); ret += "[desc]<div>"+lab+": {"+lab.replace(/\\*?$/,"")+"}</div>[/desc]\\n"; } } } return "<form {FORM_ATTR}>\\n"+ret+ "<p>{SUBMIT} {BACK}</p>\\n</form>\\n{CHECK_SCRIPT}"; } fvalue = document.myform.custom.value; document.myform.ins_tpl.disabled = (fvalue==0 || fvalue==4); </script> '; }