| [ Index ] |
PHP Cross Reference of GlotPress |
[Summary view] [Print] [Text view]
1 <?php 2 3 function gp_link_get( $url, $text, $attrs = array() ) { 4 $before = $after = ''; 5 foreach ( array('before', 'after') as $key ) { 6 if ( isset( $attrs[$key] ) ) { 7 $$key = $attrs[$key]; 8 unset( $attrs[$key] ); 9 } 10 } 11 $attributes = gp_html_attributes( $attrs ); 12 $attributes = $attributes? " $attributes" : ''; 13 // TODO: clean_url(), but make it allow [ and ] 14 return sprintf('%1$s<a href="%2$s"%3$s>%4$s</a>%5$s', $before, $url, $attributes, $text, $after ); 15 } 16 17 function gp_link() { 18 $args = func_get_args(); 19 echo call_user_func_array('gp_link_get', $args); 20 } 21 22 function gp_link_project_get( $project_or_path, $text, $attrs = array() ) { 23 $attrs = array_merge( array( 'title' => 'Project: '.$text ), $attrs ); 24 return gp_link_get( gp_url_project( $project_or_path ), $text, $attrs ); 25 } 26 27 function gp_link_project() { 28 $args = func_get_args(); 29 echo call_user_func_array('gp_link_project_get', $args); 30 } 31 32 function gp_link_project_edit_get( $project, $text = null, $attrs = array() ) { 33 if ( !GP::$user->current()->can( 'write', 'project', $project->id ) ) { 34 return ''; 35 } 36 $text = $text? $text : __( 'Edit' ); 37 return gp_link_get( gp_url_project( $project, '-edit' ), $text, gp_attrs_add_class( $attrs, 'action edit' ) ); 38 } 39 40 function gp_link_project_edit() { 41 $args = func_get_args(); 42 echo call_user_func_array('gp_link_project_edit_get', $args); 43 } 44 45 function gp_link_project_delete_get( $project, $text = false, $attrs = array() ) { 46 if ( !GP::$user->current()->can( 'write', 'project', $project->id ) ) { 47 return ''; 48 } 49 $text = $text? $text : __( 'Delete' ); 50 return gp_link_get( gp_url_project( $project, '-delete' ), $text, gp_attrs_add_class( $attrs, 'action delete' ) ); 51 } 52 53 function gp_link_project_delete() { 54 $args = func_get_args(); 55 echo call_user_func_array('gp_link_project_delete_get', $args); 56 } 57 58 function gp_link_home_get() { 59 return gp_link_get( gp_url( '/' ), __( 'Home' ), array( 'title' => __('Home Is Where The Heart Is') ) ); 60 } 61 62 function gp_link_home() { 63 $args = func_get_args(); 64 echo call_user_func_array('gp_link_home_get', $args); 65 } 66 67 function gp_link_login_get() { 68 return gp_link_get( gp_url( '/login' ), __( 'Login' ), array( 'title' => __('Sign into GlotPress') ) ); 69 } 70 71 function gp_link_login() { 72 $args = func_get_args(); 73 echo call_user_func_array('gp_link_login_get', $args); 74 } 75 76 function gp_link_set_edit_get( $set, $project, $text = false, $attrs = array() ) { 77 if ( !GP::$user->current()->can( 'write', 'project', $project->id ) ) { 78 return ''; 79 } 80 $text = $text? $text : __( 'Edit' ); 81 return gp_link_get( gp_url( gp_url_join( '/sets', $set->id, '-edit' ) ), $text, gp_attrs_add_class( $attrs, 'action edit' ) ); 82 } 83 84 function gp_link_set_edit() { 85 $args = func_get_args(); 86 echo call_user_func_array('gp_link_set_edit_get', $args); 87 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu May 24 03:59:35 2012 | Hosted by follow the white rabbit. |