本文整理汇总了PHP中form函数的典型用法代码示例。如果您正苦于以下问题:PHP form函数的具体用法?PHP form怎么用?PHP form使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了form函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postCategories
/**
* Update product categories
*
* @param FormRequest $request
* @return \Illuminate\Http\Response
*/
public function postCategories(FormRequest $request, $id)
{
if ($model = $this->validateEntity('product', $id)) {
form('edit_product_categories', ['entity' => $model])->handle($request);
}
return redirect()->back();
}
示例2: supplier_edit
/**
*/
function supplier_edit()
{
$_GET['id'] = intval($_GET['id']);
if (empty($_GET['id'])) {
return _e('Empty ID!');
}
$supplier_info = db()->query_fetch('SELECT * FROM ' . db('shop_suppliers') . ' WHERE id=' . $_GET['id']);
if (main()->is_post()) {
if (!$_POST['name']) {
_re('Product name must be filled');
}
if (!common()->_error_exists()) {
$sql_array = ['name' => $_POST['name'], 'url' => $_POST['url'] ?: common()->_propose_url_from_name($_POST['name']), 'desc' => $_POST['desc'], 'meta_keywords' => $_POST['meta_keywords'], 'meta_desc' => $_POST['meta_desc'], 'sort_order' => intval($_POST['sort_order'])];
module('manage_shop_revisions')->check_revision(__FUNCTION__, $_GET['id'], 'shop_suppliers');
db()->update('shop_suppliers', db()->es($sql_array), 'id=' . $_GET['id']);
module('manage_shop_revisions')->new_revision(__FUNCTION__, $_GET['id'], 'shop_suppliers');
common()->admin_wall_add(['shop supplier updated: ' . $_POST['name'], $_GET['id']]);
if (!empty($_FILES)) {
$man_id = $_GET['id'];
$this->_upload_image($man_id, $url);
}
}
return js_redirect('./?object=' . main()->_get('object') . '&action=suppliers');
}
$thumb_path = module('manage_shop')->supplier_img_dir . $supplier_info['url'] . '_' . $supplier_info['id'] . module('manage_shop')->THUMB_SUFFIX . '.jpg';
if (!file_exists($thumb_path)) {
$thumb_path = '';
} else {
$thumb_path = module('manage_shop')->supplier_img_webdir . $supplier_info['url'] . '_' . $supplier_info['id'] . module('manage_shop')->THUMB_SUFFIX . '.jpg';
}
$replace = ['name' => $supplier_info['name'], 'sort_order' => $supplier_info['sort_order'], 'desc' => $supplier_info['desc'], 'thumb_path' => $thumb_path, 'delete_image_url' => './?object=' . main()->_get('object') . '&action=delete_image&id=' . $supplier_info['id'], 'form_action' => './?object=' . main()->_get('object') . '&action=supplier_edit&id=' . $supplier_info['id'], 'back_url' => './?object=' . main()->_get('object') . '&action=suppliers'];
return form($replace)->text('name')->textarea('desc', 'Description')->text('url')->text('meta_keywords')->text('meta_desc')->save_and_back();
}
示例3: list_node_image_terms
function list_node_image_terms()
{
global $term_dir;
$files = file_scan_directory($term_dir, '.*_(full|summ).*');
if (!count($files)) {
print 'No node_images for terms; update script does not support node images.';
return;
}
$header = array(t('Term'), t('Image'), t('Migrate'), t('Delete'));
foreach ($files as $image) {
$image->tid = migrate_term_image_get_tid($image->name);
list($image->width, $image->height) = getimagesize($image->filename);
if ($image->height > 100) {
$image->height = $image->height / 2;
$image->width = $image->width / 2;
}
$img = "<img src='{$image->filename} ' width='{$image->width}' height='{$image->height}' />";
$term = taxonomy_get_term($image->tid);
$t_i_image = db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid = %d', $image->tid));
if ($t_i_image) {
$term->has_image = true;
}
unset($t_i_image);
$item = $term->name . '($image->name)';
$migrate = form_checkbox(NULL, "migrate][" . $image->name, 1, $term->has_image ? 0 : 1);
$delete = form_checkbox(NULL, "delete][" . $image->name, 1, $term->has_image ? 1 : 0);
$rows[] = array('data' => $item, $img, $migrate, $delete);
}
$table = theme('table', $header, $rows);
$table .= '<em>Checked rows do not have an existing taxonomy_image entry</em><br/>';
$form = form($table . form_submit('Migrate'));
print $form;
}
示例4: add
/**
*/
function add()
{
return form($a)->validate(['name' => 'trim|required'])->db_insert_if_ok(self::table, ['name', 'web_path', 'real_path'], [])->on_after_update(function () {
cache_del([self::table]);
common()->admin_wall_add(['site added: ' . $_POST['name'] . '', db()->insert_id()]);
})->text('name')->text('web_path')->text('real_path')->active_box()->save_and_back();
}
示例5: page_edit
/**
* The main Page editor panel.
*
* @param string|array $message The activity message
*/
function page_edit($message = '')
{
global $event, $step;
pagetop(gTxt('edit_pages'), $message);
extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
$name = sanitizeForPage(assert_string(gps('name')));
$newname = sanitizeForPage(assert_string(gps('newname')));
if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) {
$name = safe_field('page', 'txp_section', "name = 'default'");
} elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) {
$name = $newname;
}
$buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true);
if ($name) {
$buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions'));
} else {
$buttons .= hInput('savenew', 'savenew');
}
$html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html');
// Format of each entry is popTagLink -> array ( gTxt() string, class/ID).
$tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags'));
$tagbuild_links = '';
foreach ($tagbuild_items as $tb => $item) {
$tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]);
}
echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading'));
echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
示例6: GetAllComplaints
function GetAllComplaints($var, $gm)
{
global $tbl_list_complaint;
if ($var["serverindex"] == null || $var["serverindex"] == "") {
echo "<script src='/js/page.js'></script>\n";
echo "<script src='/js/checkbox.js'></script>\n";
form($var, $gm);
checkbox(true, true);
ReturnAndBack();
echo "</form>\n";
return eachServerFrame($var, $gm);
} else {
$serv_id = intval($var["serverindex"]);
}
global $page_main, $tbl_sys_msg;
$query_string = "select ua.ua_nMsgType, us.us_sName, c.c_sName, ua.ua_sErrorMsg, ua.ua_dtTime, ua.ua_uErrorCode from tbl_user_advice ua, tbl_char c, tbl_char_static cs, tbl_user_static us where ua.cs_uId = c.cs_uId and c.cs_uId = cs.cs_uId and cs.us_uId = us.us_uId order by ua_dtTime desc";
page($var, $query_string, 58, "Game", $serv_id, $result, $page, $desc);
echo "<table class='list_table'>\n";
echo "<tr><th class='type' style='width:60px;'>" . $page_main["category"] . "</th><th style='width:80px;'>" . $page_main["user_name"] . "</th><th style='width:80px;'>" . $page_main["role_name"] . "</th><th>" . $page_main["content"] . "</th><th style='width:40px;'>" . $tbl_sys_msg["status"] . "</th><th style='width:120px;'>" . $tbl_sys_msg["time"] . "</th></tr>\n";
while ($row = mysql_fetch_row($result)) {
printf("<tr><td>%s</td><td><input type='checkbox' flag='user' value='%s' onclick='Checkbox(this)' />%s</td><td><input type='checkbox' flag='role' value='%s' onclick='Checkbox(this)' />%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n", $tbl_list_complaint[$row[0]], $row[1], $row[1], $row[2], $row[2], $row[3], "-", $row[4]);
}
echo "</table>\n";
echo $page;
return true;
}
示例7: clean
function clean($message = '')
{
global $prefs;
extract($prefs);
pagetop("Cache Cleaner", ps("txp_token") === md5($lastmod) ? "Successful" : "Token expired. Please try again.");
if (ps("txp_token") === md5($lastmod)) {
echo "<div align=\"center\" style=\"margin-top:3em\">";
printf("Deleted %s files. Cache is clean.", '' . txp_flushdir(true));
echo "</div>";
}
echo "<div align=\"center\" style=\"margin-top:3em\">";
echo form(tag("Cache-Cleaner", "h3") . graf("Usually you don't need to do that. Cache is <b>automatically</b> cleared <br />1)\n\t\t\t\t after a certain amount of time <br />2) when a comment is posted, edited or moderated\n\t\t\t <br />3) after a page-template or form-tag is modified.<br />4) after template import.<br />5) after article update.<br /><br />" . fInput("hidden", "txp_token", md5($lastmod)) . fInput("submit", "clean_cache", "Clean all cached Files", "smallerbox") . eInput("cache") . sInput("clean"), " style=\"text-align:center\""));
echo tag("Cache Statistics", "h3");
global $path_to_site;
$count = array('size' => 0, 'num' => 0);
$txp_cache_dir = txpath . "/cache";
if (!empty($txp_cache_dir) and $fp = opendir($txp_cache_dir)) {
while (false !== ($file = readdir($fp))) {
if ($file[0] != ".") {
$count['size'] += filesize("{$txp_cache_dir}/{$file}");
++$count['num'];
}
}
closedir($fp);
printf("There are %d cache files with a total size of %d kb.", $count['num'], floor($count['size'] / 1000));
} else {
echo "Cache is empty.";
}
include $path_to_site . '/textpattern/lib/txp_cache/cache-config.php';
echo "</div>";
}
示例8: doLoginForm
/**
* Renders and outputs a login form.
*
* This function outputs a full HTML document,
* including <head> and footer.
*
* @param string|array $message The activity message
*/
function doLoginForm($message)
{
global $textarray_script, $event, $step;
include txpath . '/lib/txplib_head.php';
$event = 'login';
if (gps('logout')) {
$step = 'logout';
} elseif (gps('reset')) {
$step = 'reset';
}
pagetop(gTxt('login'), $message);
$stay = (cs('txp_login') and !gps('logout') ? 1 : 0);
$reset = gps('reset');
$name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1));
$out = array();
if ($reset) {
$out[] = hed(gTxt('password_reset'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), ' class="login-name"') . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish') . n) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1);
} else {
$out[] = hed(gTxt('login_to_textpattern'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), array('class' => 'login-name')) . graf(n . span(tag(gTxt('password'), 'label', array('for' => 'login_password')), array('class' => 'txp-label')) . n . span(fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), array('class' => 'txp-value')), array('class' => 'login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login') . n, array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish') . n) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot'));
if (gps('event')) {
$out[] = eInput(gps('event'));
}
}
echo form(tag(join('', $out), 'section', array('role' => 'region', 'class' => 'txp-login', 'aria-labelledby' => 'txp-login-heading')), '', '', 'post', '', '', 'login_form') . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>';
exit(0);
}
示例9: sec_section_list
function sec_section_list($message = '')
{
pagetop(gTxt('sections'), $message);
global $wlink;
$pageslist = safe_column("name", "txp_page", "1=1");
$styleslist = safe_column("name", "txp_css", "1=1");
$out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3));
$out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3));
$defrow = safe_row("page, css", "txp_section", "name like 'default'");
$out[] = form(tr(td(gTxt('default')) . td(startTable('edit', 'left', '') . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $defrow['page']) . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $defrow['css']) . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable()) . td()) . eInput('section') . sInput('section_save') . hInput('name', 'default'));
$rs = safe_rows_start("*", "txp_section", "name!='' order by name");
if ($rs) {
while ($a = nextRow($rs)) {
extract($a);
if ($name == 'default') {
continue;
}
$deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section');
$form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name);
$form = form($form);
$out[] = tr(td($name) . td($form) . td($deletelink));
}
}
echo startTable('list') . join('', $out) . endTable();
}
示例10: edit
/**
*/
function edit()
{
$replace = _class('admin_methods')->edit($this->_table);
$data = [];
if ($replace['linked_data']) {
$data = main()->get_data($replace['linked_data']);
} elseif ($replace['linked_table']) {
$q = db()->query('SELECT id, name FROM `' . db($replace['linked_table']) . '` ORDER BY name ASC');
while ($a = db()->fetch_assoc($q)) {
$data[$a['id']] = $a['name'];
}
} elseif ($replace['linked_method']) {
list($module, $method) = explode('.', trim($replace['linked_method']));
$module_obj = module($module);
if (method_exists($module_obj, $method)) {
$data = $module_obj->{$method}();
}
}
$form = form($replace);
$form->info('name');
if ($data) {
$form->select_box('value', $data);
} else {
$form->text('value');
}
$form->textarea('desc');
$form->save_and_back();
return $form;
}
示例11: _show_form
/**
* Login form
*/
function _show_form()
{
// Already logged in users not needed to login again
if (main()->USER_ID) {
return js_redirect($this->DEF_REDIRECT_URL);
}
// Default resirect after login
$_url_after_login = $this->DEF_REDIRECT_URL;
// Process special redirect format
if (!empty($_GET['go_url'])) {
if (false !== ($pos1 = strpos($_GET['go_url'], ';'))) {
$_GET['go_url'] = substr($_GET['go_url'], 0, $pos1) . '&action=' . substr($_GET['go_url'], $pos1 + 1);
}
$_url_after_login = './?object=' . str_replace(';', '&', $_GET['go_url']);
} elseif (conf('_force_login_go_url')) {
$_url_after_login = conf('_force_login_go_url');
}
if (strlen($_url_after_login) > 3 && !$_SESSION['user_go_url']) {
if (substr($_url_after_login, 0, 3) == './?') {
$_url_after_login = substr($_url_after_login, 3);
}
$_SESSION['user_go_url'] = $_url_after_login;
}
// To prevent multiple login forms displayed on one page
conf('_login_form_displayed', true);
return form(['form_action' => './?task=login'], ['class' => 'form-horizontal', 'legend' => 'Member Login', 'hide_empty' => 1])->validate(['__form_id__' => 'login_full_form', $this->LOGIN_FIELD => 'trim|required', 'password' => 'trim|required'])->login($this->LOGIN_FIELD, '', ['class' => 'input-medium', 'type' => $this->LOGIN_FIELD != 'login' ? $this->LOGIN_FIELD : 'text'])->password(['class' => 'input-medium'])->check_box('remember_me', '', ['no_label' => 1])->submit(['value' => 'Login', 'link_name' => 'Register', 'link_url' => './?object=register'])->container($this->oauth(['only_icons' => 1]), ['wide' => 0])->link('Retrieve lost password', './?object=get_pswd', ['class' => 'btn btn-mini btn-xs'])->hidden('action', null, ['value' => 'login']);
}
示例12: page_admin_images
function page_admin_images($act = "", $id = "")
{
requires_admin();
use_template("admin");
if ($act == "add") {
if (form_file_uploaded("file")) {
$fname = $_FILES["file"]['name'];
db_query("INSERT INTO images (link) VALUES ('')");
$id = db_last_id();
$fname = $id . "." . fileext($fname);
form_file_uploaded_move("file", "img/" . $fname);
db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
redir("admin/images");
}
form_start("", "post", " enctype='multipart/form-data' ");
form_file("Файл", "file");
form_submit("Загрузить", "submit");
form_end();
$o = form();
return $o;
}
if ($act == "del") {
$im = db_object_get("images", $id);
@unlink("../{$im->link}");
}
$o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
return $o;
}
示例13: _form
function _form($data)
{
$data_desc = $data ? 'Результат' : '';
$replace = [];
$_form = form($replace)->row_start(['desc' => ''])->submit('import', 'Импорт списка отделений')->check_box('confirm', false, ['desc' => 'подтверждение', 'no_label' => true])->row_end()->container($data, $data_desc);
return $_form;
}
示例14: postAddress
public function postAddress($number, FormRequest $request)
{
if (!form('shipment_address')->handle($request)) {
return redirect('cart/shipment/' . $number . '/address');
}
return redirect('checkout');
}
示例15: css_edit_raw
function css_edit_raw()
{
global $event, $step;
$default_name = safe_field('css', 'txp_section', "name = 'default'");
extract(gpsa(array('name', 'newname', 'copy', 'savenew')));
if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) {
$name = $default_name;
} elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) {
$name = $newname;
}
if (empty($name)) {
$buttons = '<div class="edit-title">' . gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>';
$thecss = gps('css');
} else {
$buttons = '<div class="edit-title">' . gTxt('you_are_editing_css') . sp . strong(htmlspecialchars($name)) . '</div>';
$thecss = fetch("css", 'txp_css', 'name', $name);
}
if (!empty($name)) {
$copy = '<span class="copy-as"><label for="copy-css">' . gTxt('copy_css_as') . '</label>' . sp . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-css') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>';
} else {
$copy = '';
}
$right = '<div id="content_switcher">' . hed(gTxt('all_stylesheets'), 2) . graf(sLink('css', 'pour', gTxt('create_new_css')), ' class="action-create smallerbox"') . css_list($name, $default_name) . '</div>';
echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit') . tr(td(form('<div id="main_content">' . $buttons . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy . '</div>', '', '', 'post', 'edit-form', '', 'style_form'), '', 'column') . tdtl($right, ' class="column"')) . endTable() . '</div>';
}