コード例 #1
0
 /**
  * The default function
  *
  * Set up some variables and add them to the view file data
  */
 public function index()
 {
     /**
      * This part is the same as the previous example. For brevity comments are removed.
      */
     $content = '';
     TINA_MVC\include_helper('pagination');
     global $wpdb;
     $base_sql = 'SELECT ID AS `Database ID`, user_login AS `User Login`, display_name AS `Display Name` FROM ' . $wpdb->users;
     $count_sql = 'SELECT COUNT(ID) FROM ' . $wpdb->users;
     $P = new TINA_MVC\pagination('my_paginator');
     $P->set_count_from_sql($count_sql);
     $P->set_base_url(TINA_MVC\get_controller_url('page-test-3'));
     $P->filter_box_on_fields(array('User Login' => 'user_login', 'Display Name' => 'display_name', 'user_email' => 'user_email'));
     $P->set_base_sql($base_sql);
     $P->set_mid_range(9)->set_items_per_page(10)->set_default_sort_by('User Login')->set_default_sort_order('desc');
     /**
      * We will get the results and format custom HTML rows rather than allow
      * the pagination helper to give us a generic table. You should use escaped
      * HTML here.
      *
      * In this case we are just building some HTML. You would normally use a
      * view file instead of putting HTML in your page controller.
      */
     $rows = $P->get_sql_rows();
     // TINA_MVC\prd( $rows );
     /**
      * Iterate throught the results and build some HTML
      */
     foreach ($rows as $i => &$r) {
         if ($i % 2) {
             $bg = '#333';
             $fg = '#ccc';
         } else {
             $bg = '#ccc';
             $fg = '#333';
         }
         $r->{'Database ID'} = '<span style="color:' . $fg . ';background:' . $bg . '">' . $wpdb->escape($r->{'Database ID'}) . '</span>';
         $r->{'User Login'} = '<span style="color:' . $fg . ';background:' . $bg . '"><a href="#" title="' . $wpdb->escape($r->{'Display Name'}) . '">' . $r->{'User Login'} . '</a></span>';
         $r->{'A non-DB field (non-sortable)'} = '<span style="color:' . $fg . ';background:' . $bg . '"><a href="#" title="' . $wpdb->escape($r->{'Display Name'}) . '">' . $i . '</a></span>';
         /**
          * You can also unset() an entry here
          */
         // $r->{'Display Name'} = '<span style="color:'.$fg.';background:'.$bg.'">'.$wpdb->escape($r->{'Display Name'}).'</span>';
         unset($r->{'Display Name'});
     }
     /**
      * Set the rows, overriding the use of the html table helper
      */
     $P->set_html_rows($rows);
     /**
      * This will prevent the helper from adding sortable column HTML to the
      * column heading 'A non-DB field (non-sortable)'.
      *
      * You cannot sort on columns that do not come directly from the database.
      */
     $P->suppress_sort(array('A non-DB field (non-sortable)'));
     $this->set_post_title('Pagination');
     $this->set_post_content($P->get_html());
 }
コード例 #2
0
ファイル: my_profile_controller.php プロジェクト: RA2WP/RA2WP
 /**
  * Edit the users personal data
  *
  * @todo    do we need to implement the Wordpress 'password_reset' action hook
  */
 public function edit()
 {
     $current_user = $this->get_current_user();
     TINA_MVC\include_helper('form');
     $f = new TINA_MVC\form('edit_data_form');
     // $f_user_login = $f->add_field( 'user_login', 'text' );
     $f_user_email = $f->add_field('user_email', 'text')->set_default_value($current_user->user_email);
     $f_first_name = $f->add_field('first_name', 'text')->set_default_value($current_user->user_firstname);
     $f_last_name = $f->add_field('last_name', 'text')->set_default_value($current_user->user_lastname);
     $f_display_name = $f->add_field('display_name', 'text')->set_default_value($current_user->display_name);
     $f_current_password = $f->add_field('current_password', 'password')->add_validation(array('required' => NULL));
     $f_note = $f->add_text('f_note', "Leave 'New Password' blank to leave your password unchanged.");
     $f_new_password_1 = $f->add_field('new_password', 'password');
     $f_new_password_2 = $f->add_field('new_password_again', 'password');
     $f_submit = $f->add_field('submit', 'submit');
     $f_cancel = $f->add_field('cancel', 'submit');
     if ($f_cancel->get_posted_value()) {
         wp_redirect(TINA_MVC\get_controller_url('my-profile'));
         exit;
     }
     if ($data = $f->get_posted_data()) {
         $user_data = array();
         $error = 0;
         // check the password for edits...
         if (is_wp_error(wp_authenticate($current_user->user_login, $data['current_password']))) {
             $f_current_password->add_validation_error('Incorrect password.');
             $error++;
         }
         if ($data['user_email']) {
             if (!is_email($data['user_email'])) {
                 $f_user_email->add_validation_error("'" . $f_user_email->get_caption . "' is not a valid email address.");
                 $error++;
             }
             // make sure it isn't attached to another user...
             if ($test_user = get_user_by('email', $data['user_email'])) {
                 if ($test_user->ID != $current_user->ID) {
                     $f_user_email->add_validation_error('This email address belongs to another user.');
                     $error++;
                 }
             }
             if (!$error) {
                 $user_data['user_email'] = $data['user_email'];
             }
         }
         if ($data['first_name']) {
             $user_data['first_name'] = $data['first_name'];
         }
         if ($data['last_name']) {
             $user_data['last_name'] = $data['last_name'];
         }
         if ($data['display_name']) {
             $user_data['display_name'] = $data['display_name'];
         }
         if ($data['new_password'] or $data['new_password_again']) {
             if ($data['new_password'] != $data['new_password_again']) {
                 $f_new_password_1->add_validation_error('New passwords must match.');
                 $error++;
             } else {
                 $user_data['user_pass'] = $data['new_password'];
             }
         }
         if ($user_data and !$error) {
             $user_data['ID'] = $current_user->ID;
             wp_update_user($user_data);
             wp_redirect(TINA_MVC\get_controller_url('my-profile/index/saved'));
             exit;
         }
     }
     $this->add_var('edit_data_form', $f->render());
     $this->set_post_title('Editing Profile for ' . $current_user->user_login);
     $this->set_post_content($this->load_view('my_profile'));
 }
コード例 #3
0
 /**
  * Displays 'password reset sent' page
  *
  * Displayed after a user has sucessfuly requested a password reset
  */
 function password_reset_sent()
 {
     array_shift($this->request);
     // should be 'password_reset_sent'...
     if ($this->request and $this->request[0]) {
         $this->add_var_e('username', urldecode($this->request[0]));
         $this->set_post_content($this->load_view('registration_password_reset_sent'));
     } else {
         // was page called directly?
         wp_redirect(TINA_MVC\get_controller_url());
         exit;
     }
 }
コード例 #4
0
    die("Tut, tut. You wouldn't be trying to hack my site now would you?");
}
?>
Hi <?php 
echo esc_html($username);
?>
,

You (or someone else) requested a password reset for your account with <?php 
echo get_bloginfo('name', 'Display');
?>
.

If you did not request a password reset, then just ignore this email and nothing will happen. Otherwise click the following link to continue:
<?php 
echo TINA_MVC\get_controller_url('registration/password-reset-confirmation/' . urlencode($username) . '/' . urlencode($hash));
?>
.

If the above link doesn't work for you, then go to <?php 
echo TINA_MVC\get_controller_url('registration/password-reset-confirmation');
?>
 and use the following code to reset your password:
<?php 
echo $hash;
?>

Sincerely,
<?php 
echo get_bloginfo('name', 'Display');
echo site_url();
コード例 #5
0
ファイル: tina_mvc.php プロジェクト: RA2WP/RA2WP
 /**
  * Checks permalinks and returns an appropriate redirect url
  *
  * @param string $t the page name or path
  * @return string the url after checking permalinks
  */
 private function get_redirect_target($t = '')
 {
     if (get_option('permalink_structure')) {
         $t = TINA_MVC\get_controller_url($t, true);
     } else {
         // we need to find the page id...
         if ($page = get_page_by_path($t)) {
             $t = '?page_id=' . $page->ID;
         }
     }
     if (!$t) {
         return site_url();
     }
     return $t;
 }
コード例 #6
0
 /**
  * The default function
  *
  * Set up some variables and add them to the view file data
  */
 public function index()
 {
     $content = '';
     TINA_MVC\include_helper('pagination');
     global $wpdb;
     /**
      * We are using custom SQL here to demonstrate the use of the pager.
      *
      * Have a look at the Demo Data Creator plugin if you want to create many
      * dummy users for use with this example... or even better play with your own data
      *
      * The $base_sql is a properly escaped statement that will get you all the rows you want. ORDER BY and LIMIT clauses
      * are not set - they will be set automatically.
      *
      * Pay particular attention to the field names and their aliases. These are relevent when it comes to setting
      * sortable columns and a filter box (below).
      */
     $base_sql = 'SELECT ID AS `Database ID`, user_login AS `User Login`, display_name AS `Display Name` FROM ' . $wpdb->users;
     /**
      * A SQL statement to get the total number of rows returned in the above statement.
      */
     $count_sql = 'SELECT COUNT(ID) FROM ' . $wpdb->users;
     /**
      * The HTML table ID is set from the parameter you ppass to the constructor
      */
     $P = new TINA_MVC\pagination('my_paginator');
     $P->set_count_from_sql($count_sql);
     /**
      * The url required to get to the default table view
      */
     $P->set_base_url(TINA_MVC\get_controller_url('page-test-1'));
     /**
      * Set up the filter.
      *
      * This allows a user to search on various fields (even if they are not
      * selected for display). This will output a form at the top of the table
      * of results.
      * 
      * Parameter is array ( 'Display Name' => 'mysql_field_name' )
      *
      * These must match the field names and aliases in $base_sql
      */
     $P->filter_box_on_fields(array('User Login' => 'user_login', 'Display Name' => 'display_name', 'user_email' => 'user_email'));
     $P->set_base_sql($base_sql);
     /**
      * For the pagination links
      */
     $P->set_mid_range(9)->set_items_per_page(10)->set_default_sort_by('User Login')->set_default_sort_order('desc');
     /**
      * Grab the html.
      */
     $content = $P->get_html();
     /**
      * Sets the post title
      */
     $this->set_post_title('Testing Pagination');
     /**
      * Sets the post content. Note we are not using a view file for this example
      */
     $this->set_post_content($content);
 }
コード例 #7
0
 /**
  * The default function
  *
  * Set up some variables and add them to the view file data
  */
 public function index()
 {
     /**
      * This part is the same as the previous example. For brevity comments are removed.
      */
     $content = '';
     TINA_MVC\include_helper('pagination');
     global $wpdb;
     $base_sql = 'SELECT ID AS `Database ID`, user_login AS `User Login`, display_name AS `Display Name` FROM ' . $wpdb->users;
     $count_sql = 'SELECT COUNT(ID) FROM ' . $wpdb->users;
     $P = new TINA_MVC\pagination('my_paginator');
     $P->set_count_from_sql($count_sql);
     /**
      * OK, not quite the same. The base url is obviously different!
      */
     $P->set_base_url(TINA_MVC\get_controller_url('page-test-2'));
     $P->filter_box_on_fields(array('User Login' => 'user_login', 'Display Name' => 'display_name', 'user_email' => 'user_email'));
     $P->set_base_sql($base_sql);
     $P->set_mid_range(9)->set_items_per_page(10)->set_default_sort_by('User Login')->set_default_sort_order('desc');
     /**
      * We will get the results and format custom HTML rows rather than allow
      * the pagination helper to give us a generic table. You should use escaped
      * HTML here.
      */
     $rows = $P->get_sql_rows();
     // TINA_MVC\prd( $rows );
     /**
      * Iterate throught the results and build some HTML
      */
     foreach ($rows as $i => &$r) {
         //echo $r->{'User Login'};
         /**
          * We'll use this is the view file to produce the alternating row styles
          */
         $this->add_var('i', $i);
         /**
          * The row of data
          *
          * You need to be careful here if your array keys (or object variables) require escaping.
          */
         $this->add_var_e('r', $r);
         /**
          * The view file here is only a HTML snippet. It renders only one row.
          *
          * It is the first example of using a view snippet to produce output.
          *
          * In this case, the view file is used to render headings or rows based on the value of $view_file_part
          */
         $this->add_var('view_file_part', 'rows');
         $r = $this->load_view('page_test_2');
     }
     /**
      * Set the rows, overriding the use of the html table helper.
      *
      * This will also supress the table headings.
      */
     $P->set_html_rows($rows);
     /**
      * Set the table headings. This is optional.
      *
      * In this case, the view file is used to render headings or rows based on the value of $view_file_part
      */
     $this->add_var('view_file_part', 'headings');
     $P->set_html_headings($this->load_view('page_test_2'));
     /**
      * Grab the html.
      */
     $content = $P->get_html();
     /**
      * Sets the post title
      */
     $this->set_post_title('Testing Pagination 2');
     /**
      * Sets the post content. Note we are not using a view file for this example
      */
     $this->set_post_content($content);
 }