/**
  * Get the html form for the filter box
  * @return string
  */
 private function get_filter_box_html()
 {
     if (empty($this->filtering)) {
         return '';
     }
     if (get_Post("{$this->filter_post_var}_clear")) {
         $search_term_escaped = '';
     } else {
         $search_term_escaped = esc_html_recursive($this->get_search_term($this->filter_post_var));
     }
     $html = '';
     $html .= '<FORM ACTION="' . $this->base_url . '#' . $this->get_id() . '" METHOD="post">';
     $html .= '<strong>Filter by ' . $this->list_of_filter_fields . ': </strong><br />';
     $html .= '<INPUT TYPE="TEXT" NAME="' . $this->filter_post_var . '" VALUE="' . $search_term_escaped . '" >';
     $html .= '<INPUT TYPE="SUBMIT" NAME="' . $this->filter_post_var . '_filter" VALUE="Filter">';
     $html .= '<INPUT TYPE="SUBMIT" NAME="' . $this->filter_post_var . '_clear" VALUE="Clear">';
     $html .= '</FORM>';
     return $html;
 }
示例#2
0
 /**
  * Add a variable to $this->template_vars
  *
  * Allows you to drop your template variables into an object for retrieval by
  * $this->load_vew()
  *
  * The key is added as a property of (object) $this->template_vars
  *
  * @param   string $key the object property name to use when adding data
  * @param   mixed $v variable to add
  * @param   boolean $esc whether to escape data or not
  * @return  boolean
  * @see $this->template_vars
  * @see $this->add_var_e()
  * @see $this->load_view()
  */
 public function add_var($key = NULL, $v = NULL, $esc = FALSE)
 {
     if (is_null($key)) {
         tina_mvc_error('$key parameter is required.');
     }
     if ($esc) {
         $v = esc_html_recursive($v);
     }
     $this->view_data["{$key}"] = $v;
 }
 /**
  * Builds the table and returns HTML ready to echo to the browser
  *
  * @return string The HTML table
  */
 public function get_html()
 {
     if (!empty($this->data)) {
         $this->html = "<table id=\"" . $this->get_id() . "\" class=\"tina_mvc_table\">";
         $this->html .= "<thead>";
         foreach ($this->data as &$row) {
             $this->html .= "<tr>";
             foreach ($row as $f_name => &$f_value) {
                 if ($this->do_not_esc_th) {
                     $this->html .= '<th>' . $f_name . '</th>';
                 } else {
                     $this->html .= '<th>' . esc_html_recursive($f_name) . '</th>';
                 }
             }
             $this->html .= "</tr>";
             break;
         }
         $this->html .= "</thead>";
         reset($this->data);
         $this->html .= "<tbody>";
         foreach ($this->data as &$row) {
             $this->html .= "<tr>";
             foreach ($row as $f_name => &$f_value) {
                 if ($this->do_not_esc_td) {
                     $this->html .= '<td>' . $f_value . '</td>';
                 } else {
                     $this->html .= '<td>' . esc_html_recursive($f_value) . '</td>';
                 }
             }
             $this->html .= "</tr>";
         }
         $this->html .= "</tbody>";
         $this->html .= '</table>';
         return $this->html;
     } else {
         return '';
     }
 }
示例#4
0
/**
 * Escape a data structure for rendering in a browser
 *
 * Recurses into arrays and objects
 * @param   mixed $data An array or object containing data to be escaped
 * @return  mixed The $escaped $data
 * @uses    ent2ncr() to escape non-XML entities
 */
function esc_html_recursive($data = FALSE)
{
    if (!$data) {
        return FALSE;
    }
    if (is_array($data) or is_object($data)) {
        foreach ($data as $key => &$value) {
            // $key = htmlentities($key,ENT_QUOTES);
            $key = esc_html($key);
            // $value = ent2ncr(htmlentities($data,ENT_QUOTES));
            $value = esc_html_recursive($value);
        }
    } else {
        $data = htmlentities($data, ENT_QUOTES);
    }
    return $data;
}