function select_ajax($dir = NULL) { if (!is_numeric($dir)) { $dir = $select_ajax_segment = fuel_uri_string(1, NULL, TRUE); $dirs = $this->model->get_dirs(); foreach ($dirs as $key => $d) { if ($d == $dir) { $dir = $key; break; } } } $this->load->helper('array'); $this->load->helper('form'); $this->load->library('form_builder'); $this->model->add_filters(array('group_id' => $dir)); $options = options_list($this->model->list_items(), 'name', 'name'); $preview = '<div id="asset_preview"></div>'; $field_values['asset_folder']['value'] = $dir; $fields['asset_select'] = array('value' => '', 'label' => 'Select', 'type' => 'select', 'options' => $options, 'after_html' => $preview); $this->form_builder->css_class = 'asset_select'; $this->form_builder->submit_value = null; $this->form_builder->use_form_tag = false; $this->form_builder->set_fields($fields); $this->form_builder->display_errors = false; $this->form_builder->set_field_values($field_values); $vars['form'] = $this->form_builder->render(); $this->load->view('assets/assets_select_ajax', $vars); }
function form_fields($values = array()) { $fields = parent::form_fields(); $CI =& get_instance(); // navigation group if (empty($CI->navigation_groups_model)){ $CI->load->module_model(FUEL_FOLDER, 'navigation_groups_model'); } $CI->load->helper('array'); $group_options = options_list($CI->navigation_groups_model->find_all_array()); $group_values = array_keys($group_options); $group_value = (!empty($group_values)) ? $group_values[0] : 1; $fields['group_id'] = array( 'type' => 'select', 'options' => $group_options, 'class' => 'add_edit navigation_group', 'comment' => 'The grouping of items you want to associate this navigation item to' ); if (count($group_options) == 0) { $fields['group_id']['displayonly'] = TRUE; } if (empty($CI->pages_model)) { $CI->load->module_model(FUEL_FOLDER, 'pages_model'); } $this->load->helper('array'); $parent_group = (!empty($values['group_id'])) ? $values['group_id'] : $group_value; $where['group_id'] = $parent_group; if (!empty($values['id'])) { $where['id !='] = $values['id']; $where['parent_id !='] = $values['id']; } $parent_options = $this->options_list('id', 'nav_key', $where); $fields['parent_id']['label'] = lang('navigation_model_parent_id'); $fields['parent_id']['type'] = 'select'; $fields['parent_id']['options'] = $parent_options; $fields['parent_id']['first_option'] = array('0' => 'None'); $yes = lang('form_enum_option_yes'); $no = lang('form_enum_option_no'); $fields['hidden']['options'] = array('yes' => $yes, 'no' => $no); return $fields; }
public function select($dir = NULL) { if (!is_numeric($dir)) { $dir = fuel_uri_string(1, NULL, TRUE); $dirs = $this->fuel->assets->dirs(); foreach ($dirs as $key => $d) { if ($d == $dir) { $dir = $key; break; } } } $value = ''; if ($this->session->flashdata('uploaded_post')) { $uploaded_post = $this->session->flashdata('uploaded_post'); if (isset($uploaded_post)) { $subfolder = trim(preg_replace('#^' . preg_quote($dir) . '(.*)#', '$1', $uploaded_post['asset_folder']), '/'); if (!empty($subfolder)) { $subfolder = $subfolder . '/'; } $value = $subfolder . $uploaded_post['uploaded_file_name']; } } else { $value = $this->input->get_post('selected', TRUE); } $this->js_controller_params['method'] = 'select'; $this->js_controller_params['folder'] = $dir; $this->load->helper('array'); $this->load->library('form_builder'); $this->model->add_filters(array('group_id' => $dir)); $order = $this->input->get_post('order', TRUE); if ($order == 'last_updated') { $by = 'desc'; } else { $order = 'name'; $by = 'asc'; } $options = options_list($this->model->list_items(NULL, 0, $order, $by), 'name', 'name'); $redirect_to = uri_safe_encode(fuel_uri(fuel_uri_string(), TRUE)); // added back to make it refresh $preview = ' OR <a href="' . fuel_url('assets/inline_create?asset_folder=' . urlencode($dir) . '&redirect_to=' . $redirect_to) . '" class="btn_field">Upload</a><div id="asset_preview"></div>'; $field_values['asset_folder']['value'] = $dir; $fields['asset_select'] = array('value' => $value, 'label' => lang('assets_select_action'), 'type' => 'select', 'options' => $options, 'after_html' => $preview); if (isset($_GET['width'])) { $fields['width'] = array('value' => $this->input->get_post('width', TRUE), 'label' => lang('form_label_width'), 'size' => 5, 'row_class' => 'img_only'); } if (isset($_GET['height'])) { $fields['height'] = array('value' => $this->input->get_post('height', TRUE), 'label' => lang('form_label_height'), 'size' => 5, 'row_class' => 'img_only'); } if (isset($_GET['alt'])) { $fields['alt'] = array('value' => $this->input->get_post('alt', TRUE), 'label' => lang('form_label_alt'), 'row_class' => 'img_only'); } if (isset($_GET['align'])) { $alignment_options = array('' => '', 'left' => 'left', 'right' => 'right', 'middle' => 'middle', 'top' => 'top', 'bottom' => 'bottom'); $fields['align'] = array('value' => $this->input->get_post('align', TRUE), 'label' => lang('form_label_align'), 'type' => 'select', 'options' => $alignment_options, 'row_class' => 'img_only'); } if (isset($_GET['class'])) { $fields['class'] = array('value' => $this->input->get_post('class', TRUE), 'label' => lang('form_label_class'), 'size' => 6, 'row_class' => 'img_only'); } $this->form_builder->css_class = 'asset_select'; $this->form_builder->submit_value = NULL; $this->form_builder->use_form_tag = FALSE; $this->form_builder->set_fields($fields); $this->form_builder->display_errors = FALSE; $this->form_builder->set_field_values($field_values); $vars['form'] = $this->form_builder->render_divs(); $this->fuel->admin->set_inline(TRUE); $crumbs = array('' => $this->module_name, lang('assets_select_action')); //$this->fuel->admin->set_panel_display('notification', FALSE); $this->fuel->admin->set_titlebar($crumbs); $this->fuel->admin->render('modal_select', $vars); }
function form_fields($values = array()) { $fields = parent::form_fields(); $CI =& get_instance(); // navigation group if (empty($CI->navigation_groups_model)) { $CI->load->module_model(FUEL_FOLDER, 'navigation_groups_model'); } $CI->load->helper('array'); $group_options = options_list($CI->navigation_groups_model->find_all_array()); $group_values = array_keys($group_options); $group_value = !empty($group_values) ? $group_values[0] : 1; $fields['group_id'] = array('label' => 'Navigation Group', 'type' => 'select', 'options' => $group_options, 'class' => 'add_edit navigation_group', 'comment' => 'The grouping of items you want to associate this navigation item to'); if (count($group_options) == 0) { $fields['group_id']['displayonly'] = TRUE; } if (empty($CI->pages_model)) { $CI->load->module_model(FUEL_FOLDER, 'pages_model'); } $this->load->helper('array'); $parent_options = $this->options_list('id', 'nav_key'); $fields['parent_id']['label'] = 'Parent'; $fields['parent_id']['type'] = 'select'; $fields['parent_id']['options'] = $parent_options; $fields['parent_id']['first_option'] = array('0' => 'None'); $fields['published']['label_layout'] = 'left'; return $fields; }