function form_block($name, $item, $value) { if (!$name || !$item) { return; } if (!isset($value) && $item['default_value']) { $value = $item['default_value']; } if ($item['hidden']) { $tr_class = 'class="myhide"'; } $title = $item['title']; if ($item['required']) { $title = '<span class="text-danger">*</span> ' . $title; } $html .= "<tr id='tr{$name}' {$tr_class}>"; $html .= "<td class='item-label'>{$title}</td><td>"; if ($item['type'] == 'group') { $html .= form_group_edit($name, '', $item['param']['options'], $value, $item['param']['placeholder']); } else { $html .= form_item($name, $value, $item); } $html .= "</td>"; $html .= "</tr>"; echo $html; }
public function test_input_text_simple() { $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Name">', trim(form_item($r)->text('name'))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Name">', trim(self::form_no_chain($r)->text('name'))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Name">', trim(self::form_no_chain($r)->text('name', ''))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Name">', trim(self::form_no_chain($r)->text('name', '', ['stacked' => 1]))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Name">', trim(self::form_no_chain($r)->text('name', '', ['stacked' => 1]))); $this->assertEquals('<span class="stacked-item"><input name="name" type="text" id="name" class="form-control" placeholder="Name">' . PHP_EOL . '</span>', trim(form('', ['no_form' => 1])->text('name', '', ['stacked' => 1]))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Desc">', trim(self::form_no_chain($r)->text('name', ['desc' => 'Desc']))); $this->assertEquals('<input name="name" type="text" id="name" class="form-control" placeholder="Desc">', trim(self::form_no_chain($r)->text('name', 'Desc'))); }
/** */ function _show_for_lang($lang) { $_GET['page'] = $lang; // Needed for html()->tree links $all = $this->_get_items($lang); $items = []; foreach ($all as $a) { $items[$a['id']] = ['parent_id' => $a['parent_id'], 'name' => _truncate($a['title'], 60, true, '...'), 'link' => url('/@object/edit/' . $a['id'] . '/@page'), 'active' => $a['active']]; } return html()->tree($items, ['form_action' => url('/@object/save/@id/@page'), 'draggable' => true, 'class_add' => 'no_hide_controls', 'back_link' => '', 'add_link' => url('/@object/add/@id/@page'), 'add_no_ajax' => true, 'no_expand' => true, 'opened_levels' => 10, 'show_controls' => function ($id, $item) { $form = form_item($item + ['add_link' => url('/@object/add/' . $id . '/@page'), 'edit_link' => url('/@object/edit/' . $id . '/@page'), 'delete_link' => url('/@object/delete/' . $id . '/@page'), 'active_link' => url('/@object/active/' . $id . '/@page')]); return implode(PHP_EOL, [$form->tbl_link_add(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_edit(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_delete(['hide_text' => 1, 'no_ajax' => 1]), $form->tbl_link_active()]); }]); }
function modal() { return _class('html')->modal(['inline' => 1, 'show_close' => 1, 'header' => 'Modal header', 'body' => '<p>Some body</p>', 'footer' => form_item()->save()]); }
function form_radios($title, $name, $value, $options, $description = 0) { if (count($options) > 0) { $output = ''; foreach ($options as $key => $choice) { $output .= form_radio($choice, $name, $key, $key == $value); } return form_item($title, $output, $description); } }
function login_page() { page_head("Login"); echo '<form role="form" action="hl.php" method="get"> <input type="hidden" name="action" value="login"> '; form_item("Authenticator:", "text", "auth", ""); form_submit_button("Submit"); page_tail(); }
/** * This pure-php method needed to greatly speedup page rendering time for 100+ items */ function _tree_items(&$data, $extra = []) { if ($extra['show_controls'] && !is_callable($extra['show_controls'])) { $r = ['edit_link' => isset($extra['edit_link']) ? $extra['edit_link'] : url('/@object/edit_item/%d/@page'), 'delete_link' => isset($extra['delete_link']) ? $extra['delete_link'] : url('/@object/delete_item/%d/@page'), 'clone_link' => isset($extra['clone_link']) ? $extra['clone_link'] : url('/@object/clone_item/%d/@page')]; $form_controls = form_item($r)->tbl_link_edit() . form_item($r)->tbl_link_delete() . form_item($r)->tbl_link_clone(); } $opened_levels = isset($extra['opened_levels']) ? $extra['opened_levels'] : 1; $is_draggable = isset($extra['draggable']) ? $extra['draggable'] : true; $keys = array_keys($data); $keys_counter = array_flip($keys); $items = []; $ul_opened = false; foreach ((array) $data as $id => $item) { $next_item = $data[$keys[$keys_counter[$id] + 1]]; $has_children = false; $close_li = 1; $close_ul = 0; if ($next_item) { if ($next_item['level'] > $item['level']) { $has_children = true; } $close_li = $item['level'] - $next_item['level'] + 1; if ($close_li < 0) { $close_li = 0; } } $expander_icon = ''; if ($has_children) { $expander_icon = $item['level'] >= $opened_levels ? 'icon-caret-right fa fa-caret-right' : 'icon-caret-down fa fa-caret-down'; } $content = ($item['icon_class'] ? '<i class="' . $item['icon_class'] . '"></i>' : '') . $item['name']; if ($item['link']) { $content = '<a href="' . $item['link'] . '">' . $content . '</a>'; } if (is_callable($extra['show_controls'])) { $func = $extra['show_controls']; $controls = $func($id, $item); } else { $controls = $extra['show_controls'] ? str_replace('%d', $id, $form_controls) : ''; } $badge = $item['badge'] ? ' <sup class="badge badge-' . ($item['class_badge'] ?: 'info') . '">' . $item['badge'] . '</sup>' : ''; $controls_style = 'float:right;' . ($extra['class_add'] != 'no_hide_controls' ? 'display:none;' : ''); $items[] = ' <li id="item_' . $id . '"' . (!$is_draggable ? ' class="not_draggable"' : '') . '> <div class="dropzone"></div> <dl> <a href="' . $item['link'] . '" class="expander"><i class="icon ' . $expander_icon . '"></i></a> ' . $content . $badge . ($is_draggable ? ' <span class="move" title="' . t('Move') . '"><i class="icon icon-move fa fa-arrows"></i></span>' : '') . ($controls ? '<div style="' . $controls_style . '" class="controls_over">' . $controls . '</div>' : '') . '</dl>'; if ($has_children) { $ul_opened = true; $items[] = PHP_EOL . '<ul class="' . ($item['level'] >= $opened_levels ? 'closed' : '') . '">' . PHP_EOL; } elseif ($close_li) { if ($ul_opened && !$has_children && $item['level'] != $next_item['level']) { $ul_opened = false; $close_ul = 1; } $tmp = str_repeat(PHP_EOL . ($close_ul ? '</li></ul>' : '</li>') . PHP_EOL, $close_li); if ($close_li > 1 && $close_ul) { $tmp = substr($tmp, 0, -strlen('</ul>' . PHP_EOL)) . PHP_EOL; } $items[] = $tmp; } } return $items; }
function generateConfirm($game, $edit) { if (!$this->can_edit) { error_exit("You do not have permission to edit this game"); } $dataInvalid = $this->isDataInvalid($edit); $s = new Spirit(); $home_spirit = $s->as_formbuilder(); $away_spirit = $s->as_formbuilder(); $win = variable_get('default_winning_score', 6); $lose = variable_get('default_losing_score', 0); switch ($edit['status']) { case 'home_default': $edit['home_score'] = "{$lose} (defaulted)"; $edit['away_score'] = $win; break; case 'away_default': $edit['home_score'] = $win; $edit['away_score'] = "{$lose} (defaulted)"; break; case 'forfeit': $edit['home_score'] = '0 (forfeit)'; $edit['away_score'] = '0 (forfeit)'; break; case 'normal': default: $home_spirit->bulk_set_answers($_POST['spirit_home']); $away_spirit->bulk_set_answers($_POST['spirit_away']); $dataInvalid .= $home_spirit->answers_invalid(); $dataInvalid .= $away_spirit->answers_invalid(); break; } if ($dataInvalid) { error_exit($dataInvalid . "<br>Please use your back button to return to the form, fix these errors, and try again"); } $output = para("You have made the changes below for the {$game->game_date} {$game->game_start} game between {$game->home_name} and {$game->away_name}. "); $output .= para("If this is correct, please click 'Submit' to continue. If not, use your back button to return to the previous page and correct the score."); $output .= form_hidden('edit[step]', 'perform'); $output .= form_hidden('edit[status]', $edit['status']); $output .= form_hidden('edit[home_score]', $edit['home_score']); $output .= form_hidden('edit[away_score]', $edit['away_score']); $score_group .= form_item("Home ({$game->home_name} [rated: {$game->rating_home}]) Score", $edit['home_score']); $score_group .= form_item("Away ({$game->away_name} [rated: {$game->rating_away}]) Score", $edit['away_score']); $output .= form_group("Scoring", $score_group); if ($edit['status'] == 'normal') { $output .= form_group("Spirit assigned to home ({$game->home_name})", $home_spirit->render_viewable()); $output .= $home_spirit->render_hidden('home'); $output .= form_group("Spirit assigned to away ({$game->away_name})", $away_spirit->render_viewable()); $output .= $away_spirit->render_hidden('away'); } $output .= para(form_submit('submit')); return form($output); }
function confirm(&$edit) { switch ($edit['type']) { case 'single': case 'oneset': case 'oneset_ratings_ladder': case 'blankset': case 'fullround': case 'halfroundstandings': case 'halfroundrating': break; default: error_exit("Please don't try to do that; it won't work, you fool"); break; } $output = "<p>The following information will be used to create your games:</p>"; $output .= form_hidden('edit[step]', 'perform'); $output .= form_hidden('edit[type]', $edit['type']); $output .= form_hidden('edit[startdate]', $edit['startdate']); $output .= form_hidden('edit[publish]', $edit['publish'] == 'yes' ? 'yes' : 'no'); $num_teams = count($this->league->teams) - count($edit['excludeTeamID']); $this->loadTypes($num_teams); $output .= form_item('What', $this->types[$edit['type']]); $output .= form_item('Start date', strftime("%A %B %d %Y", $edit['startdate'])); if (isset($edit['excludeTeamID'])) { $counter = 0; $excludes = ""; foreach ($edit['excludeTeamID'] as $teamid) { $excludes .= $this->league->teams[$teamid]->name . "<br>"; $output .= form_hidden("edit[excludeTeamID][{$counter}]", $teamid); $counter++; } $output .= form_item('Teams to exclude:', "<b>{$excludes}</b>"); } $output .= form_submit('Create Games', 'submit'); return form($output); }
<h1>İletişim</h1> Görüş ve önerilerinizi bizimle paylaşmanız sitemizin büyümesine ve aradığınız bilgi ve özelliklerin sitemizde yer almasına katkı sağlayacaktır. <hr /> <?php echo form_open(uri_string(), array('class' => 'yform full')); echo form_item('name', 'Adınız'); echo form_item('email', 'E-Posta Adresiniz'); echo form_item('message', 'Mesajınız', 'textarea', array('rows' => 10)); ?> <div class="actions"> <button type="submit" class="btn primary">Gönder</button> </div> <?php echo form_close();
?> <?php echo form_item('site_description', 'Anasayfa Description', 'textarea', array('rows' => 2, 'value' => set_value('site_description', get_option('site_description')))); ?> <?php echo form_item('site_keywords', 'Anasayfa Keywords', 'input', array('value' => set_value('site_keywords', get_option('site_keywords')))); ?> <?php echo form_item('google_verify', 'Google doğrulama kodu', 'input', array('value' => set_value('google_verify', get_option('google_verify')))); ?> </div> <div id="other" class="tab-pane"> <?php echo form_item('feedburner_username', 'Feedburner Kullanıcı Adı', 'input', array('value' => set_value('feedburner_username', get_option('feedburner_username')))); ?> <?php echo form_item('analytics_id', 'Google Analytics ID (UA-XXXXX-X)', 'input', array('value' => set_value('analytics_id', get_option('analytics_id')))); ?> <?php echo form_item('disqus', 'Disqus Hesabı', 'input', array('value' => set_value('disqus', get_option('disqus')))); ?> <?php echo form_item('disqus_api_key', 'Disqus API Key', 'input', array('value' => set_value('disqus_api_key', get_option('disqus_api_key')))); ?> </div> </div> <div class="actions"> <button type="submit" class="btn primary">Gönder</button> </div> <?php echo form_close();
echo form_fieldset_close(); ?> <?php echo form_fieldset('Yönetici Bilgileri'); ?> <?php echo form_item('name', 'İsim'); ?> <?php echo form_item('email', 'E-Posta'); ?> <?php echo form_item('password', 'Yeni Şifre', 'password'); ?> <?php echo form_item('confirm_password', 'Yeni Şifre Tekrarı', 'password'); ?> <?php echo form_hidden('permissions[:all:]', 1); ?> <?php echo form_fieldset_close(); ?> <div class="actions"> <button type="submit" class="btn primary">Gönder</button> </div> <?php echo form_close(); ?> <?php }
<?php return function () { return implode(PHP_EOL, [form_item()->country_box(['selected' => 'US', 'renderer' => 'div_box']), form_item()->language_box(['selected' => 'ru', 'renderer' => 'div_box']), form_item()->currency_box(['selected' => 'UAH', 'renderer' => 'div_box']), form_item()->timezone_box(['selected' => 'UTC', 'renderer' => 'div_box'])]); };
/** */ function balance() { $object =& $this->object; $action =& $this->action; $filter_name =& $this->filter_name; $filter =& $this->filter; $url =& $this->url; $user_id = (int) $_GET['user_id']; $account_id = (int) $_GET['account_id']; $url_back = url_admin('/@object'); $payment_api = _class('payment_api'); $payment_status = $payment_api->get_status(); // check id: user, operation if ($user_id > 0) { $user_info = user($user_id); if ($account_id > 0) { list($account_id, $account) = $payment_api->get_account__by_id(['account_id' => $account_id]); } else { list($account_id, $account) = $payment_api->account(['user_id' => $user_id]); } } else { common()->message_error('Не определен пользователь', ['translate' => false]); $form = form()->link('Назад', $url_back, ['class' => 'btn', 'icon' => 'fa fa-chevron-left']); return $form; } // prepare url $url_form_action = url_admin(['object' => $object, 'action' => $action, 'user_id' => $user_id, 'account_id' => $account_id]); $url_operation = url_admin(['object' => $object, 'action' => 'operation', 'user_id' => $user_id, 'account_id' => $account_id]); // prepare provider $providers = $payment_api->provider(['all' => true]); $items = []; foreach ($providers as $i => $item) { $items[$item['name']] = $item['title']; } $providers_form = $items; // prepare form $replace = ['amount' => null, 'user_id' => $user_id, 'provider_name' => 'administration', 'account_id' => $account_id, 'form_action' => $url_form_action, 'redirect_link' => $url_operation, 'back_link' => $url_back]; // $replace += $_POST + $data; $replace += $_POST; $form = form($replace, ['autocomplete' => 'off'])->validate(['amount' => 'trim|required|numeric|greater_than[0]', 'provider_name' => 'trim|required'])->on_validate_ok(function ($data, $extra, $rules) use(&$user_id, &$account_id, &$account) { $payment_api = _class('payment_api'); $provider_name = $_POST['provider_name']; $provider_name = empty($provider_name) ? 'administration' : $provider_name; $operation = $_POST['operation']; if ($operation == 'payment') { $provider_name = 'administration'; } $options = ['user_id' => $user_id, 'account_id' => $account_id, 'amount' => $_POST['amount'], 'operation_title' => $_POST['title'], 'operation' => $operation, 'provider_name' => $provider_name, 'is_balance_limit_lower' => false]; $result = $payment_api->transaction($options); if (!empty($result['form'])) { $form = $result['form'] . '<script>document.forms[0].submit();</script>'; echo $form; exit; } if ($result['status'] === true) { $message = 'message_success'; if (empty($account_id)) { $new_account = true; list($account_id, $account) = $payment_api->get_account(); } } else { $message = 'message_error'; } common()->{$message}($result['status_message'], ['translate' => false]); if (!$is_account) { $url = url_admin(['object' => $_GET['object'], 'action' => $_GET['action'], 'user_id' => $user_id, 'account_id' => $account_id]); return js_redirect($url); } })->float('amount', 'Сумма')->text('title', 'Название')->select_box('provider_name', $providers_form, ['show_text' => 1, 'desc' => 'Провайдер', 'tip' => 'Выбрать провайдера возможно только для пополнения. Списание возможно только от Администратора.'])->row_start(['desc' => 'Операция'])->submit('operation', 'deposition', ['desc' => 'Пополнить'])->submit('operation', 'payment', ['desc' => 'Списать', 'tip' => 'Списание возможно только от Администратора.'])->row_end(); if ($account_id > 0) { // fetch operations $operation_options = ['user_id' => $user_id, 'account_id' => $account_id, 'no_limit' => true, 'no_order_by' => true, 'sql' => true]; $sql = $this->_operation_sql($operation_options); if (empty($filter)) { $filter = ['order_by' => 'datetime_update', 'order_direction' => 'desc']; } // operations table $table = $this->_operation_table(['filter' => $filter, 'sql' => $sql, 'user_id' => $user_id, 'payment_status' => $payment_status, 'providers' => $providers]); } else { if (!$_POST['amount']) { common()->message_warning('Счет не определен', ['translate' => false]); } } $balance = ''; $currency_str = ''; $back = form_item()->link('Назад', $url_back, ['class' => 'btn', 'icon' => 'fa fa-chevron-left']); if ($account) { list($currency_id, $currency) = $payment_api->get_currency__by_id($account); $currency && ($currency_str = ' ' . $currency['short']); $balance = $account['balance']; } $user = user($user_id); $url_user = a('/members/edit/' . $user_id, $user['name']); $replace += ['user' => $user, 'url_user' => $url_user, 'balance' => ['amount' => $balance, 'currency' => $currency_str]]; $header = tpl()->parse('manage_payment/balance_header', $replace); $result = $header . $form . '<hr>' . $table; return $result; }
$("#sort tbody").sortable({ opacity: 0.6, cursor: "move", helper: fixHelper }); var fixHelper = function(e, ui) { ui.children().each(function() {$(this).width($(this).width());}); return ui; }; }); ', 'assets/js/jquery.ui.js'); $access_level = array('0' => 'Herkes', '1' => 'Üye Olmayanlar', '2' => 'Üyeler', '3' => 'Yöneticiler'); $target = array('' => 'Aynı Sayfada', 'blank' => 'Yeni Sayfada'); echo form_open_multipart($this->uri->uri_string()); echo form_item('title', 'Menü Adı', 'input', array('value' => set_value('title', isset($title) ? $title : ''))); echo form_item('slug', 'Menü Etiketi', 'input', array('value' => set_value('slug', isset($slug) ? $slug : ''))); ?> <table class="zebra-striped" id="sort"> <thead> <tr> <th>#</th> <th>Başlık</th> <th>Bağlantı</th> <th>Kimler Görebilir?</th> <th>Açılma Şekli</th> <th><a class="btn add" onclick="add_row();">Ekle</a></th> </tr> </thead> <tbody> <?php $i = 0;
<?php add_js_jquery('CKEDITOR.replace("content"); CKEDITOR.instances["content"].on("instanceReady", function(){ this.document.on("keyup", function(){CKEDITOR.instances.content.updateElement();}); this.document.on("paste", function(){CKEDITOR.instances.content.updateElement();}); }); ', 'assets/ckeditor/ckeditor.js'); echo form_open_multipart($this->uri->uri_string(), array('class' => 'yform full')); echo form_item('title', 'Sayfa başlığı', 'input', array('value' => set_value('title', isset($title) ? $title : ''))); echo form_item('content', 'Sayfa içeriği', 'textarea', array('rows' => 50, 'value' => set_value('content', isset($content) ? $content : ''))); echo form_item('meta_title', 'Meta title', 'input', array('value' => set_value('meta_title', isset($meta_title) ? $meta_title : ''))); echo form_item('meta_description', 'Meta description', 'textarea', array('rows' => 4, 'value' => set_value('meta_description', isset($meta_description) ? $meta_description : ''))); echo form_item('meta_keyword', 'Anahtar kelimeler', 'textarea', array('rows' => 4, 'value' => set_value('meta_keyword', isset($meta_keyword) ? $meta_keyword : ''))); ?> <div class="actions"> <button type="submit" class="btn primary">Gönder</button> </div> <?php echo form_close();
/** * Render for maintenance of the form. */ function render_maintenance() { // Remember the last sort order found, new question defaults to one past $sorder = 0; $output = form_hidden('edit[step]', 'confirm'); while (list(, $q) = each($this->_questions)) { $output .= question_render_maintenance($q); $sorder = $q->sorder; // assume they're in order } // Add a form group for adding a new element $element = form_textfield('Element name', "data[_new][name]", '', 60, 60, 'If this is blank, no new element will be added'); $element .= form_textarea('Element text', "data[_new][question]", '', 60, 5); $element .= form_textfield('Sort order', "data[_new][sorder]", $sorder + 1, 10, 10); $element .= form_checkbox('Required', "data[_new][required]", 1, false, 'Does this element require an answer? (Ignored for checkboxes, labels and descriptions)'); $type = form_radio('Text field', 'data[_new][type]', 'textfield', true, 'A single line of text'); $type .= form_radio('Text area', 'data[_new][type]', 'freetext', false, 'A 60x5 text box'); $type .= form_radio('Multiple choice', 'data[_new][type]', 'multiplechoice', false, 'Multiple choice, answers can be defined later.'); $type .= form_radio('Checkbox', 'data[_new][type]', 'checkbox', false, 'A true/false checkbox.'); $type .= form_radio('Label', 'data[_new][type]', 'label', false, 'Not a question, used for inserting a label anywhere (e.g. before a checkbox group).'); $type .= form_radio('Description', 'data[_new][type]', 'description', false, 'Not a question, a block of descriptive text.'); $element .= form_item('Element type', $type); $output .= form_group("Add a new element", $element); $output .= form_submit('Submit'); $output .= form_reset('Reset'); return form($output); }