Ticket #14: glotpress-profile.patch
| File glotpress-profile.patch, 2.9 KB (added by joostdevalk, 20 months ago) |
|---|
-
gp-templates/profile.php
1 <?php 2 gp_title( __('Profile < GlotPress') ); 3 gp_breadcrumb(array( __('Profile') )); 4 gp_tmpl_header(); 5 6 $per_page = 15; 7 8 if ( isset( $_COOKIE['gp_items_per_page'] ) ) 9 $per_page = (int) $_COOKIE['gp_items_per_page']; 10 11 ?> 12 <h2>Profile</h2> 13 <form method="post"> 14 <label for="per_page"><?php _e( "Number of items per page:" ); ?></label> 15 <input type="number" id="per_page" name="per_page" value="<?php echo $per_page ?>"/><br> 16 <input type="submit" value="<?php _e("Change Settings"); ?>"> 17 </form> 18 No newline at end of file -
gp-templates/header.php
22 22 if (GP::$user->logged_in()): 23 23 $user = GP::$user->current(); 24 24 25 printf( __('Hi, %s.'), $user->user_login);25 printf( __('Hi, %s.'), '<a href="'.gp_url( '/profile' ).'">'.$user->user_login.'</a>' ); 26 26 ?> 27 27 <a href="<?php echo gp_url('/logout')?>"><?php _e('Log out'); ?></a> 28 28 <?php else: ?> -
gp-includes/routes/profile.php
1 <?php 2 class GP_Route_Profile extends GP_Route_Main { 3 function profile_get() { 4 gp_tmpl_load( 'profile', array() ); 5 } 6 7 function profile_post() { 8 9 if ( isset( $_POST['per_page'] ) ) { 10 $per_page = (int) $_POST['per_page']; 11 setcookie( 'gp_items_per_page', $per_page, time()+60*60*24*365*11 ); 12 } 13 14 $this->redirect( gp_url( '/profile' ) ); 15 } 16 17 } -
gp-includes/thing.php
36 36 } 37 37 $this->set_static( 'static-vars-are-set', true ); 38 38 } 39 40 if ( isset( $_COOKIE['gp_items_per_page'] ) ) 41 $this->per_page = (int) $_COOKIE['gp_items_per_page']; 39 42 } 40 43 41 44 function get_static( $name, $default = null ) { -
gp-includes/router.php
44 44 'get:/login' => array('GP_Route_Login', 'login_get'), 45 45 'post:/login' => array('GP_Route_Login', 'login_post'), 46 46 'get:/logout' => array('GP_Route_Login', 'logout'), 47 48 'get:/profile' => array('GP_Route_Profile', 'profile_get'), 49 'post:/profile' => array('GP_Route_Profile', 'profile_post'), 47 50 48 51 "get:/$project/import-originals" => array('GP_Route_Project', 'import_originals_get'), 49 52 "post:/$project/import-originals" => array('GP_Route_Project', 'import_originals_post'),
