public function render_views($params) { $filename = isset($params['filename']) ? $params['filename'] : ''; $vars = isset($params['vars']) ? $params['vars'] : ''; //if (!isset($vars['fields']) || empty($vars['fields']) || !is_array($vars['fields'])) // return; $form_fields = ''; die('<pre>' . print_r($vars['fields'], true)); $this->ci->load->helper('form'); foreach ($vars['fields'] as $name => $opts) { switch (strtolower($opts['field_type'])) { case 'checkbox': $form_fields .= form_checkbox($name, 1); break; case 'date': $form_fields .= form_date(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'datetime': $form_fields .= form_datetime(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'dropdown': $options = isset($opts['options']) ? $opts['options'] : array(); $form_fields .= form_dropdown(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>"), $options); break; case 'email': $form_fields .= form_email(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'input': $form_fields .= form_input(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'month': $form_fields .= form_month(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'number': $form_fields .= form_number(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'range': $form_fields .= form_range(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; case 'textarea': $rows = 10; $cols = 40; $form_fields .= form_input(array('name' => $name, 'class' => 'input-xxlarge', 'value' => "<?php echo set_value('{$name}') ?>", 'rows' => $rows, 'cols' => $cols)); break; case 'url': $form_fields .= form_url(array('name' => $name, 'class' => 'input-xlarge', 'value' => "<?php echo set_value('{$name}') ?>")); break; } } //echo '<pre>'; //die(print_r($params)); $this->tpl = str_replace('{form_fields}', $form_fields, $this->tpl); }
function form_http($page = "index") { global $current_user; $vars = ""; $http = form_url() . '?pg=' . $page; $and = "&"; if (count($_GET) > 0) { foreach ($_GET as $n => $v) { if (!in_array($n, array('page'))) { $vars .= $and . $n . '=' . cc_urlencode($v); $and = "&"; } } } $and = "&"; $wp = array(); if (is_user_logged_in()) { $wp['login'] = $current_user->data->user_login; $wp['email'] = $current_user->data->user_email; $wp['first_name'] = isset($current_user->data->first_name) ? $current_user->data->first_name : $current_user->data->display_name; $wp['last_name'] = isset($current_user->data->last_name) ? $current_user->data->last_name : $current_user->data->display_name; $wp['roles'] = $current_user->roles; } $wp['lic'] = get_option('form_lic'); $wp['siteurl'] = home_url(); $wp['sitename'] = get_bloginfo('name'); $wp['pluginurl'] = FORM_URL; if (is_admin()) { $wp['mode'] = 'b'; $wp['pageurl'] = 'admin.php?page=form&'; } else { $wp['mode'] = 'f'; $wp['pageurl'] = form_home(); } $wp['time_format'] = get_option('time_format'); $wp['admin_email'] = get_option('admin_email'); $wp['key'] = get_option('form_key'); $wp['lang'] = get_option('form_lang'); // get_bloginfo('language'); $wp['client_version'] = FORM_VERSION; $vars .= $and . 'wp=' . urlencode(base64_encode(json_encode($wp))); if (isset($_SESSION['form']['http_referer'])) { $vars .= '&http_referer=' . cc_urlencode($_SESSION['form']['http_referer']); } if ($vars) { $http .= $vars; } return array($http, array('wp' => urlencode(base64_encode(json_encode($wp))))); }