/** * Template_Lite function plugin * */ function tpl_function_user_select($params, &$tpl) { $tpl->CI->load->helper('users'); return user_select(isset($params['selected']) ? $params['selected'] : array(), isset($params['max']) ? $params['max'] : 0, isset($params['var_name']) ? $params['var_name'] : 'id_user', $params['user_type'], isset($params['template']) ? $params['template'] : 'default', array_diff_key($params, array_flip(array('selected', 'max', 'var_name', 'user_type', 'template')))); }
public function display_fields($fields, $id, $container = null) { foreach ($fields as $field) { $field_container = !empty($field['container']) ? $field['container'] : null; if ($field_container == $container) { $field_name = !empty($field['name']) ? $field['name'] : null; $class = !empty($field['class']) ? $field['class'] : $field_name; $type = !empty($field['type']) ? $field['type'] : 'text'; $label = !empty($field['label']) ? $field['label'] : null; $rows = !empty($field['rows']) ? $field['rows'] : null; $info = !empty($field['info']) ? $field['info'] : null; $js = !empty($field['script']) ? $field['script'] : null; $video_display = !empty($field['video_display']) ? $field['video_display'] : false; echo '<div class="field ' . $class . '">' . PHP_EOL; if ($type == 'text') { echo $this->input_field_html($id, $field_name, $label, 'text'); } elseif ($type == 'url') { echo $this->input_field_html($id, $field_name, $label, 'url'); } elseif ($type == 'email') { echo $this->input_field_html($id, $field_name, $label, 'email'); } elseif ($type == 'date') { echo $this->input_field_html($id, $field_name, $label, 'date'); } elseif ($type == 'number') { $min = !empty($field['min']) ? $field['min'] : null; $max = !empty($field['max']) ? $field['max'] : null; $step = !empty($field['step']) ? $field['step'] : null; $default = !empty($field['default']) ? $field['default'] : null; $args = array('min' => $min, 'max' => $max, 'step' => $step, 'default' => $default); echo $this->input_field_html($id, $field_name, $label, 'number', $args); } elseif ($type == 'rich') { $rich_opts = array(); if (!empty($field['rows'])) { $rich_opts['rows'] = $field['rows']; } if (!empty($field['html'])) { $rich_opts['html'] = $field['html']; } if (!empty($field['media'])) { $rich_opts['media'] = $field['media']; } $this->richText_html($id, $field_name, $rich_opts); } elseif ($type == 'cta_btn') { echo $this->cta_button_hmtl($id, $field_name, $label); } elseif ($type == 'textarea') { echo $this->textarea_html($id, $field_name, $label, $rows); } elseif ($type == 'image' or $type == 'img' or $type == 'media_select') { $media_type = !empty($field['mime']) ? $field['mime'] : 'image'; $show = !empty($field['show']) ? $field['show'] : true; echo $this->mediaSelect($id, $field_name, $media_type, $label, $show); } elseif ($type == 'user') { user_select($id, $field_name); } elseif ($type == 'info') { $hr = isset($field['hr']) ? $field['hr'] : true; echo '<div class="info">' . PHP_EOL; echo '<p>' . $info . '</p>' . PHP_EOL; if ($hr != false) { echo '<hr>'; } echo '</div>' . PHP_EOL; } elseif ($type == 'form') { echo $this->select_form($id, $field_name); } elseif ($type == 'script') { echo '<script>' . PHP_EOL; echo $js; echo '</script>' . PHP_EOL; } elseif ($type == 'hidden') { $val = !empty($field['value']) ? $field['value'] : null; echo '<input type="hidden" name="' . $id . '[' . $field_name . ']' . '" value="' . $val . '" />' . PHP_EOL; } elseif ($type == 'content_select') { $post_type = !empty($field['post_type']) ? $field['post_type'] : 'all'; echo $this->content_selector_html($id, $field_name, $label, $post_type); } elseif ($type == 'gallery') { $this->the_gallery($id, $field_name, $label); } elseif ($type == 'map') { $meta = $this->meta; echo '<fieldset class="cta_button">'; echo '<legend><h4> Map </h4></legend>'; echo $this->input_field_html($id, 'latitude', 'Latitude: '); echo $this->input_field_html($id, 'longitude', 'Longitude: '); $args = array('min' => 1, 'max' => 19, 'step' => 1, 'default' => 9); echo $this->input_field_html($id, 'zoom', 'Zoom Level:', 'number', $args); echo '</fieldset>'; $longitude = !empty($meta[$id]['longitude']) ? $meta[$id]['longitude'] : null; $latitude = !empty($meta[$id]['latitude']) ? $meta[$id]['latitude'] : null; $zoom = !empty($meta[$id]['zoom']) ? $meta[$id]['zoom'] : 7; if ($longitude !== null and $latitude !== null) { echo '<img src="//maps.googleapis.com/maps/api/staticmap?center='; echo $latitude . ',' . $longitude; echo '&zoom=' . $zoom . '&size=400x400">'; } else { echo 'Map Error: longitiude or latitude NOT found'; } } echo '</div>' . PHP_EOL; } // end If - container check } // end - foreach loop }