function table_torch_nav() { $CI =& get_instance(); $tables = $CI->config->item('table_torch_tables'); $prefs = $tables[TORCH_TABLE]; $extra_links = $CI->config->item('table_torch_extra_nav_links'); if (isset($_SERVER['HTTP_REFERER'])) { $refer = $_SERVER['HTTP_REFERER']; } else { $refer = torch_url(array()); } $str = "<ul id=\"navHeader\">\n"; if (TORCH_METHOD == 'edit' or TORCH_METHOD == 'add') { $str .= "<li class=\"backLink\"><a href=\"{$refer}\">" . $CI->lang->line('table_torch_back_to_listing') . "</a></li>\n"; } else { if (TORCH_METHOD == 'listing' and $prefs['add'] == TRUE) { $str .= "<li class=\"backLink\">\n" . anchor(torch_url(array('table' => TORCH_TABLE, 'action' => 'add'), FALSE), $CI->lang->line('table_torch_add_new_link')) . "</li>\n"; } } foreach ($tables as $key => $table) { if ($key == TORCH_TABLE) { $class = 'active'; } else { $class = ''; } $label = ucwords(plural(table_torch_title($key))); $url = torch_url(array('table' => $key, 'action' => 'listing')); $str .= "<li><a href=\"{$url}\" class=\"{$class}\">{$label}</a></li>\n"; } foreach ($extra_links as $url => $label) { $str .= "<li>" . anchor($url, $label) . "</li>\n"; } return $str . "\n</ul>\n"; }
function table_torch_form_open() { $CI =& get_instance(); $str = ''; if (TORCH_METHOD == 'add') { $str .= form_open(torch_url(array('action' => 'insert', 'table' => TORCH_TABLE), FALSE)); } else { $str .= form_open(torch_url(array('action' => 'update', 'table' => TORCH_TABLE), FALSE)); } $str .= "\n<div class=\"formContainer\">\n"; return $str; }
protected function _table_data($offset = 0) { $tables = $this->CI->config->item('table_torch_tables'); $prefs = $tables[TORCH_TABLE]; $humanize = $this->CI->config->item('table_torch_humanize_fields'); $paginate_prefs = $this->CI->config->item('table_torch_pagination_settings'); $limit = $paginate_prefs['per_page']; $funct = $this->CI->config->item('table_torch_function'); $rows = $this->CI->table_torch_model->get_listing($this->url_vals, $limit, $offset); for ($i = 0; $i < count($rows); $i++) { $row = $rows[$i]; $actions = ''; if ($prefs['edit']) { $actions .= anchor(torch_url(array('action' => 'edit', 'table' => TORCH_TABLE, 'key' => $row[PRIMARY_KEY]), FALSE), 'Edit', array('class' => 'actionLink', 'id' => 'editLink')); } if ($prefs['delete']) { $confirm = $this->CI->lang->line('table_torch_delete_confirm'); $actions .= anchor(torch_url(array('action' => 'delete', 'table' => TORCH_TABLE, 'key' => $row[PRIMARY_KEY]), FALSE), 'Delete', array('onclick' => "return confirm('{$confirm}')", 'class' => 'actionLink')); } $tmp['actions'] = $actions; foreach ($rows[$i] as $key => $value) { if (!empty($prefs['formats'][$key])) { $value = $prefs['formats'][$key]($value, $key, TORCH_TABLE); } elseif (!empty($funct)) { $value = $funct($value); } $tmp[$key] = $value; } $rows[$i] = $tmp; } $headers[0] = $this->CI->lang->line('table_torch_actions'); $desc = $this->CI->table_torch_model->describe_table(); $org_vals = $this->url_vals; foreach ($desc as $row) { $class = ''; $prefix = ''; if ($org_vals['sort_field'] == $row['Field']) { if ($org_vals['sort_dir'] == 'ASC') { $class = 'desc'; $prefix = '▼ '; $this->url_vals['sort_dir'] = 'DESC'; } else { $class = 'asc'; $prefix = '▲ '; $this->url_vals['sort_dir'] = 'ASC'; } } else { $this->url_vals['sort_dir'] = 'ASC'; } $this->url_vals['sort_field'] = $row['Field']; $fieldname = $row['Field']; if ($humanize) { $fieldname = humanize($fieldname); } array_push($headers, anchor(torch_url($this->url_vals, FALSE), $prefix . $fieldname, array('class' => $class))); } $this->url_vals = $org_vals; $this->CI->table->set_heading($headers); return $rows; }
<?php echo form_open(torch_url(array('action' => 'search', 'table' => TORCH_TABLE), FALSE), array('id' => 'searchForm')); echo form_hidden('table', TORCH_TABLE); foreach ($url_params as $key => $value) { if (!empty($value)) { echo form_hidden($key, $value); } } echo form_dropdown('search_field', $options, $url_params['search_field']); echo form_input('keyword', $url_params['keyword']); echo form_submit('submit', $this->lang->line('table_torch_search')); echo anchor(torch_url(array('action' => 'listing', 'table' => TORCH_TABLE), FALSE), $this->lang->line('table_torch_clear_search')); echo form_close();