/** * Return the complete HTML * * Navigation links appear before and after the table * * @return string */ public function get_html() { if (!$this->custom_html_rows) { $this->build_sql(); } if (empty($this->custom_html_rows_are_strings) or empty($this->custom_html_rows)) { // we'll just use the table helper to format a table include_helper('table'); $table = new table('sample_table'); // we need to change the headings to add the html links for sorting... if ($this->sql_results) { foreach ($this->sql_results as &$row) { $new_row = new \stdClass(); foreach ($row as $fname => $val) { $other_order = 'asc'; $current_order = ' '; // sorting? if ($this->sort_by == $fname) { if ($this->sort_ord == 'asc') { $current_order = ' ↑'; $other_order = 'desc'; } else { $current_order = ' ↓'; $other_order = 'asc'; } } if (!$this->suppress_sort and !in_array($fname, $this->do_not_allow_sort_on_these_columns)) { $key = '<a href="' . $this->base_url . '1/0/' . 'sort-' . urlencode($fname) . '-' . $other_order . '#' . $this->pager_id . '">' . esc_html_recursive($fname) . '</a>'; $key .= "<span style=\"width:2em;\">{$current_order}</span>"; } else { $key = esc_html_recursive($fname); } $new_row->{$key} = $val; } break; } $this->sql_results[0] = $new_row; reset($this->sql_results); $table->set_data($this->sql_results); $table->do_not_esc_th(TRUE); $table->do_not_esc_td(TRUE); $html_results = $table->get_html(); } else { $html_results = ''; } } else { // we have custom HTML ready to go $html_results = ''; if (!empty($this->custom_html_headings)) { $html_results .= $this->custom_html_headings; } foreach ($this->sql_results as $row) { $html_results .= $row . "\r\n"; } } $html = ''; // default if ($html_results) { $html = '<div id="' . $this->get_id() . '">' . "\r\n"; $html .= $this->get_filter_box_html(); $html .= parent::display_pages(); $html .= $html_results; $html .= parent::display_pages(); $html .= "\r\n</div>"; } return $html; }
/** * Displays and processes a login form * * Used if a user is not authorised to view. Forces a login * * @return Boolean TRUE if user passed authentication */ private function do_login() { include_helper('form'); $f = new form('login_form'); $f_user_login = $f->add_field('user_login', 'text')->add_validation(array('required' => NULL)); $f_password = $f->add_field('user_password', 'password')->add_validation(array('required' => NULL)); $f_remember_me = $f->add_field('remember', 'checkbox'); $f_submit = $f->add_field('wp_submit', 'submit', $label = 'Login'); if ($credentials = $f->get_posted_data()) { // form was submitted successfully $u = wp_signon($credentials, false); if (!is_wp_error($u)) { return TRUE; // we are logged in and done ... } else { $f->add_error('The username and/or password is incorrect.'); } } // if we got here we are not authenticated - display the form... // if there is a _do_login view we will use it... $login_form = $f->render(); $this->CONTROLLER->add_var('login_form', $login_form); $this->CONTROLLER->set_post_title('Login to Continue'); $this->CONTROLLER->set_post_content($this->CONTROLLER->load_view('tina_mvc_do_login')); return FALSE; }