Changeset 504332
- Timestamp:
- 02/13/2012 02:59:58 PM (14 years ago)
- Location:
- sfce-create-event/trunk
- Files:
-
- 4 edited
-
readme.txt (modified) (1 diff)
-
sfce-create-event.php (modified) (4 diffs)
-
sfce-settings-page.php (modified) (4 diffs)
-
sfce_create_event_post.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sfce-create-event/trunk/readme.txt
r401798 r504332 5 5 Tags: Simple Facebook Connect, Facebook, event, SFC, create 6 6 Requires at least: 2.7 7 Tested up to: 3. 1.38 Stable tag: 3.96.37 Tested up to: 3.3.1 8 Stable tag:4.0.1 9 9 10 10 Create Facebook events automatically when you create Wordpress posts. This plugin requires the Simple Facebook Connect plugin by Otto. -
sfce-create-event/trunk/sfce-create-event.php
r401798 r504332 1 1 <?php 2 2 /* 3 Plugin Name: SFCe - Create Event4 Version: 3.96.33 Plugin Name: SFCe - Graph API Create Event 4 Version: 4.00.1 5 5 Author: Roger Howorth 6 6 Author URI: http://www.thehypervisor.com 7 7 Plugin URI: http://www.thehypervisor.com/simple-facebook-connect-extensions 8 Description: Adds a PHP function to create a Facebook event. Requires Simple Facebook Connect plugin by Otto.8 Description: Adds a PHP function to create a Facebook event. 9 9 License: http://www.gnu.org/licenses/gpl.html 10 10 … … 31 31 */ 32 32 33 include_once('sfce-invite-people.php'); 33 add_action("plugins_loaded", "sfce_graph_create_event_init"); 34 add_action("admin_menu", "sfce_graph_create_event_init"); 34 35 35 add_action("plugins_loaded", "sfce_create_event_init"); 36 add_action("admin_menu", "sfce_create_event_init"); 37 38 function sfce_create_event_init() { 36 function sfce_graph_create_event_init() { 39 37 $plugin_dir = dirname(plugin_basename(__FILE__)); 40 38 load_plugin_textdomain( 'sfce-create-event', null, $plugin_dir . '/languages/'); … … 48 46 // See Notes section for possible arguments - http://wiki.developers.facebook.com/index.php/Events.create 49 47 $num_args = func_num_args(); 50 if ( $num_args <> '1' ) 51 wp_die(__('You must pass the correct arguments as an array to sfce_create_event when you invoke the function. See plugin readme for more details.', 'sfce-create-event')); 48 if ( $num_args <> '1' ) wp_die(__('You must pass the correct arguments as an array to sfce_create_event when you invoke the function. See plugin readme for more details.', 'sfce-create-event')); 52 49 $args = func_get_arg(0); 50 53 51 // Make Facebook event 54 // Check if the post is published before creating fb event, disable this line for testing55 // if ( $args['post_id']->post_status == "draft" ) return $args['post_id'];52 // Check if the post is published before creating fb event, disable this line for testing 53 //if ( $args['post_id']->post_status == "draft" ) return $args['post_id']; 56 54 57 // load Facebook platform 58 $fboptions = get_option('sfc_options'); 59 $options = get_option('sfce_event_options'); 55 // load Facebook ID etc 56 $fboptions = get_option('sfc_options'); 60 57 61 include_once WP_PLUGIN_DIR . '/simple-facebook-connect/facebook-platform/facebook.php'; 62 $fb=new Facebook($fboptions['api_key'], $fboptions['app_secret']); 63 $fb_user = $fb->user; 64 if ( empty ($fb_user)) { 65 //$about = $fb->api_client->users_getInfo($fb_user,'about_me'); 66 // Not loggged into FB so don't create an event 67 return $args['post_id']; 68 } 58 $start_time=mktime($args['start_hour'],$args['start_min'],"00",$args['month'],$args['day'],$args['year']); 59 $start_time = substr(date('c',$start_time),0,16); 69 60 70 if(!$fb->api_client->users_hasAppPermission('create_event')) { 71 echo'<script type="text/javascript">window.open("http://www.facebook.com/authorize.php?api_key='.$fb->api_key.'&v=1.0&ext_perm=create_event", "Permission");</script>'; 72 // echo'<meta http-equiv="refresh" content="0; URL=javascript:history.back();">'; 73 wp_die(__('You should have seen a new Facebook window asking if you "Allow Events from [your Facebook page]". This tells Facebook it\'s OK for you to create events on your page. You should grant permission, then return here, press your browser back button and try again. If you did not see the window, your browser is set to not allow pop-ups. You must change your browser settings to allow pop-ups from Facebook and your Wordpress site.', 'sfce-create-event')); 74 } 75 76 $start_time=mktime($args['start_hour'],$args['start_min'],"00",$args['month'],$args['day'],$args['year']); 77 $start_time = substr(date('c',$start_time),0,16); 78 79 $end_time=mktime($args['end_hour'],$args['end_min'],"00",$args['month'],$args['day'],$args['year']); 80 $end_time = substr(date('c',$end_time),0,16); 61 $end_time=mktime($args['end_hour'],$args['end_min'],"00",$args['month'],$args['day'],$args['year']); 62 $end_time = substr(date('c',$end_time),0,16); 81 63 82 64 // Add promo link if ok … … 84 66 if ( $options['sfce_show_promo'] ) $args['description'] .= "\nAuto event creation by http://www.thehypervisor.com"; 85 67 86 $event_fb = array("name"=>$args['name'], "host"=>$args['host'], "start_time"=>$start_time, "end_time"=>$end_time, "description"=>$args['description'], "tagline"=>$args['tagline']); 87 if ( $args['is_fanpage'] == 'TRUE' ) $event_fb['page_id'] = $fboptions['fanpage']; else if ( $args['is_fanpage'] && $args['page_id'] <> '' ) $event_fb['page_id'] = $args['page_id']; 88 89 if ( $args['privacy'] ) $event_fb['privacy_type'] = $args['privacy']; 90 $event_fb = array_map(utf8_encode, $event_fb); 68 $event_data = array( 69 'name' => $args['name'], 70 'start_time' => $start_time, 71 'end_time' => $end_time, 72 'description' => $args['description'], 73 'tagline' => $args['tagline'], 74 ); 75 if ( isset($args['privacy']) ) $event_data['privacy_type'] = $args['privacy']; 91 76 92 if ( substr($args['photo'],0,4) == 'http' ) wp_die(_e('The path to your photo cannot begin with \'http\'. The photo must be stored on your Wordpress server, and the path must be in the local file system - e.g. /var/www/wordpress/photo.jpg. Your post has been saved but no event created. Press the browser\'s back button to go back and edit your post', 'sfce-create-event')); 77 if ( $args['is_fanpage'] == 'TRUE' ){ 78 $event_data['page_id'] = $fboptions['fanpage']; 79 $url = "https://graph.facebook.com/me/events?"; 80 $event_data['access_token'] = $fboptions['page_access_token']; 81 } 82 else if ( $args['is_fanpage'] == 'FALSE' ) 83 { 84 $url = "https://graph.facebook.com/me/events?"; 85 $event_data['access_token'] = $fboptions['access_token']; 86 } 93 87 94 if ( $_POST['sfce_event_photo'] <> '' ) { 95 if (!file_exists($args['photo'])) wp_die(_e('The path to your event image does not point to a valid file. Please check your path and try again. Your post has been saved but no event created. Press the browser\'s back button to go back and edit your post.', 'sfce-create-event')); 88 $data = wp_remote_post($url, array('body'=>$event_data)); 96 89 97 $pic_dims = getimagesize( $args['photo'] ); 98 if ( $pic_dims[0] < 100 || $pic_dims[1] < 100 ) wp_die(_e('Your event image is too small. Facebook requires event images to be at least 100 pixels wide and 100 pixels tall. Please remove the current image from your event parameters and try again. You post has been saved but no event created. Press the browser\'s back button to go back and edit your post', 'sfce-create-event')); 90 if (!is_wp_error($data)) { 91 $resp = json_decode($data['body'],true); 92 if ($resp['id']) $event_id = $resp['id']; 93 else 94 { 95 foreach ( $resp as $res ) foreach( $res as $re ) $tmptxt .= $re . '<br>'; 96 wp_die( 'Error: ' . $tmptxt . '<br>Use your browser\'s Back button to go back to your post and correct the problem then try again.'); 99 97 } 100 101 try{102 $event_id=$fb->api_client->events_create(json_encode( $event_fb ), $args['photo']);103 /* echo'<meta http-equiv="refresh" content="0; URL=">'; */104 } catch(Exception $e) {105 if ( $e->getCode() == '200' ) {106 // update_post_meta ( $post_id, 'fb_event', 'created' );107 wp_die(__('You must be an administrator of your Facebook page in order to create events. Please ask an existing Facebook page admin to fix this for you. Other details have been saved, press your browser "Back" button and carry on!', 'sfce-create-event'));108 }109 echo 'Error message: '.$e->getMessage().' Error code:'.$e->getCode();110 }111 // Invite people?112 if ( $args['group_id'] <> '') {113 $invite_ok = sfce_invite_people( array(114 'app_id' => $fboptions['appid']115 ,'app_secret' => $fboptions['app_secret']116 ,'fb' => $fb117 ,'group_id' => $args['group_id']118 ,'event_id' => $event_id119 ,'fb_user' => $fb_user120 ,'access_token' => $options['sfce_access_token']121 ));122 }123 if ( $args['invite_page'] <> '' ) {124 $invite_ok = sfce_invite_people( array(125 'app_id' => $fboptions['appid']126 ,'app_secret' => $fboptions['app_secret']127 ,'fb' => $fb128 ,'page_id' => $args['invite_page']129 ,'event_id' => $event_id130 ,'fb_user' => $fb_user131 ,'access_token' => $options['sfce_access_token']132 ));133 98 } 134 99 135 100 return $event_id; 136 } //end sfce_create_event 101 } 102 //end sfce_create_event 103 104 -
sfce-create-event/trunk/sfce-settings-page.php
r372466 r504332 13 13 function sfce_event_settings_page() { 14 14 global $sfce_text_inputs; 15 $options = get_option('sfce_event_options'); 15 16 16 17 if ( isset ($_POST['sfce_submit']) ) 17 18 { 18 19 if ( !wp_verify_nonce ( $_POST['verify-key'], 'sfce_event') ) die(__('Failed security check. Reload page and retry', 'sfce-create-event')); 19 if ( $_POST['sfce_event_privacy_visible'] && ( $_POST['sfce_event_privacy'] <> 'OPEN' &&$_POST['sfce_event_privacy'] <> 'CLOSED' )) $error .= 'You must provide a Privacy setting if you want to hide this option. Acceptable settings are OPEN or CLOSED.<p>';20 if ( $_POST['sfce_event_privacy_visible'] && ( $_POST['sfce_event_privacy'] <> 'OPEN' || $_POST['sfce_event_privacy'] <> 'CLOSED' )) $error .= 'You must provide a Privacy setting if you want to hide this option. Acceptable settings are OPEN or CLOSED.<p>'; 20 21 if ( $_POST['sfce_event_start_hour_visible'] && $_POST['sfce_event_start_hour'] == '' ) $error .= 'You must provide a Start Hour if you want to hide this option.<p>'; 21 22 if ( $_POST['sfce_event_start_min_visible'] && $_POST['sfce_event_start_min'] == '' ) $error .= 'You must provide a Start Minute if you want to hide this option.<p>'; … … 32 33 $options['sfce_hide_postpanel'] = $_POST['sfce_hide_postpanel']; 33 34 $options['sfce_show_promo'] = $_POST['sfce_show_promo']; 34 $options['sfce_access_token'] = $_POST['sfce_access_token'];35 $options['sfce_group_id'] = $_POST['sfce_group_id'];36 35 37 36 update_option('sfce_event_options', $options); … … 47 46 } 48 47 } // end if isset 49 $options = get_option('sfce_event_options');50 48 ?> 51 49 <form name="form1" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> … … 116 114 echo '." /></td></tr></table>'; 117 115 118 echo "<h3>";119 _e('Access Token', 'sfce-create-event');120 echo '</h3>';121 echo '<table><tr><td width="500">';122 _e('In order to invite members of a Facebook group to events you need to enter your Facebook access token here. If you use this feature, be careful who you allow to edit or use the plugin because your access token should be kept private. If you want to cancel an access token, change your Facebook password.', 'sfce-create-event');123 echo '</td>';124 echo '<td width="220"><input type="password"';125 echo ' name="sfce_access_token" ';126 echo 'title="';127 _e('Put a Facebook Access Token here, it should be from an account that has access to the Facebook Group you enter in the box below.', 'sfce-create-event');128 echo '"';129 echo ' value="';130 if ( $options['sfce_access_token'] ) echo $options['sfce_access_token'];131 echo '" /></td></tr></table>';132 133 echo "<h3>";134 _e('Group ID', 'sfce-create-event');135 echo '</h3>';136 echo '<table><tr><td width="500">';137 _e('The Facebook Group ID. All members of this group will automatically be invited to events.', 'sfce-create-event');138 echo '</td>';139 echo '<td width="220"><input type="text"';140 echo ' name="sfce_group_id" ';141 echo 'title="';142 _e('Put you Facebook Group ID here, it is used only to invite group members to events created with this plugin.', 'sfce-create-event');143 echo '"';144 echo ' value="';145 if ( $options['sfce_group_id'] ) echo $options['sfce_group_id'];146 echo '" /></td></tr></table>';147 148 116 ?><p class="submit"> 149 117 <input type="submit" name="sfce_submit" value="<?php _e('Submit!', 'sfce-create-event'); ?>" /> -
sfce-create-event/trunk/sfce_create_event_post.php
r401798 r504332 34 34 array( 'name' => 'sfce_event_host', 'maxlength' => 30, 'label' =>'Host'), 35 35 array( 'name' => 'sfce_event_tagline', 'maxlength' => 30, 'label' =>'Tagline'), 36 array( 'name' => 'sfce_event_photo', 'maxlength' => 255, 'size' => 60, 'label' =>'Local path to photo', 'title' => 'e.g. /var/www/wordpress/uploads/photo.jpg'),37 array( 'name' => 'sfce_event_is_fanpage', 'default' => 'TRUE', ' maxlength' => 5, 'size' => 6, 'label' => 'Use Fan Page?', 'title' => 'e.g. TRUE or FALSE'),38 array( 'name' => 'sfce_event_privacy', 'maxlength' => 6, ' size' => 6, 'label' =>'Privacy setting', 'default' =>'OPEN', 'title' => 'e.g. OPEN, CLOSED or SECRET' ),39 array( 'name' => 'sfce_event_start_hour', ' maxlength' => 2, 'size' => 2, 'label' =>'Start hour', 'required' => 1),40 array( 'name' => 'sfce_event_start_min', ' maxlength' => 2, 'size' => 2, 'label' =>'Start minute', 'required' => 1),41 array( 'name' => 'sfce_event_end_hour', ' maxlength' => 2, 'size' => 2, 'label' =>'End hour', 'required' => 1),42 array( 'name' => 'sfce_event_end_min', ' maxlength' => 2, 'size' => 2, 'label' =>'End minute', 'required' => 1)36 // array( 'name' => 'sfce_event_photo', 'maxlength' => 255, 'size' => 60, 'label' =>'Local path to photo', 'title' => 'e.g. /var/www/wordpress/uploads/photo.jpg'), 37 array( 'name' => 'sfce_event_is_fanpage', 'default' => 'TRUE', 'type' => 'select', 'values' => array('TRUE', 'FALSE'), 'label' => 'Use Fan Page?', 'title' => 'e.g. TRUE or FALSE'), 38 array( 'name' => 'sfce_event_privacy', 'maxlength' => 6, 'type' => 'select', 'values' => array( 'OPEN', 'CLOSED', 'SECRET'), 'size' => 6, 'label' =>'Privacy setting', 'default' =>'OPEN', 'title' => 'e.g. OPEN, CLOSED or SECRET' ), 39 array( 'name' => 'sfce_event_start_hour', 'type' => 'select', 'values' => array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'), 'label' =>'Start hour', 'required' => 1, 'no-end-br' => '1', 'title' => 'Time when the event will start.'), 40 array( 'name' => 'sfce_event_start_min', 'type' => 'select', 'values' => array('00','15','30','45'), 'label' =>'minute', 'required' => 1, 'no-start-br' => '1', 'title' => 'Time when the event will start.'), 41 array( 'name' => 'sfce_event_end_hour', 'type' => 'select', 'values' => array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24'), 'label' =>'End hour', 'required' => 1, 'no-end-br' => '1', 'title' => 'Time when the event will end.'), 42 array( 'name' => 'sfce_event_end_min', 'type' => 'select', 'values' => array('00','15','30','45'), 'label' =>'minute', 'required' => 1, 'no-start-br' => '1', 'title' => 'Time when the event will end.') 43 43 ); 44 45 44 46 45 $options = get_option('sfce_event_options'); 47 46 if ( !$options['sfce_hide_postpanel'] ) add_action('edit_form_advanced', 'sfce_create_event_post_hook'); 48 47 48 add_action('edit_post', 'sfce_create_event_post'); 49 49 50 50 function sfce_create_event_post_hook() { 51 51 /* Must be author or above to see this form */ 52 52 if ( !current_user_can('2') ) return; 53 53 54 $fboptions = get_option('sfc_options'); 55 54 56 global $sfce_text_inputs; 55 57 $options = get_option('sfce_event_options'); 56 58 59 global $current_user; 60 get_currentuserinfo(); 61 $fbuid = get_user_meta($current_user->ID, 'fbuid', true); 62 63 64 57 65 $post_id = $_GET['post']; 58 66 $eeventdate = get_post_meta ($post_id, 'sfce_event_date', true) ; 59 $sfce_group_id = get_post_meta ($post_id, 'sfce_group_id', true) ;60 61 67 if ( !$eeventdate ) $eeventdate = date('Y-m-d'); 62 68 … … 64 70 65 71 echo '<div class="postbox"><h3>'; _e('Create Facebook Event', 'sfce-create-event'); echo '</h3><div class="inside">'; 72 if ( empty($fbuid) ) { 73 echo 'To create Facebook events you must:<br>'; 74 echo '<li>Be logged into Facebook using the same browser - use a different tab.</li>'; 75 echo '<li>Connect your Facebook account to your Wordpress account using the button on your <a href="/wp-admin/profile.php">Wordpress Profile page</a>.</li></div></div>'; 76 return; 77 } 78 79 66 80 echo '<h2><b>'; _e('Event details', 'sfce-create-event') ; echo ':</b></h2>'; 67 81 _e('Insert text; [TITLE] for post title; [[name_of_custom_field]] for data from Custom field.'); … … 89 103 case 'hidden': 90 104 echo '<input type="hidden" name="' . $input['name'] . '" value="' . $$input['name'] .'" />'; 105 break; 106 107 case 'select': 108 if ( !$input['no-start-br'] ) echo '<li>'; 109 printf(__('%s', 'sfce-create-event'),$input['label']); 110 echo ' <select name="' . $input['name'] . '" title="'; 111 printf(__('%s', 'sfce-create-event'), $input['title']); 112 echo '" >'; 113 foreach ( $input['values'] as $val ){ 114 echo '<option value="' . $val .'" '; 115 if ( substr($input['name'],-4) == "hour" && $val == date('H')) echo 'selected="selected" '; 116 if ( substr($input['name'],-3) == "min" && $val > date('m')) echo 'selected="selected" '; 117 echo '>' . $val . '</option>'; 118 } 119 echo '</select>'; 120 if ( $input['no-end-br'] ) echo ' '; else echo '</li>'; 91 121 break; 92 122 … … 112 142 echo '<li>'; 113 143 _e('Event date', 'sfce-create-event'); 114 echo ' :<select type="text" name="sfce_event_day">';144 echo ' <select type="text" name="sfce_event_day">'; 115 145 for ( $i = 1; $i < 32; $i++) 116 146 { … … 145 175 echo '</select></li><br />'; 146 176 147 echo "<h3>";148 _e('Group ID', 'sfce-create-event');149 echo '</h3>';150 echo '<table><tr><td width="500">';151 _e('The Facebook Group ID. All members of this group will automatically be invited to events.', 'sfce-create-event');152 echo '</td>';153 echo '<td width="220"><input type="text"';154 echo ' name="sfce_group_id" ';155 echo 'title="';156 _e('Put you Facebook Group ID here, it is used only to invite group members to events created with this plugin.', 'sfce-create-event');157 echo '"';158 echo ' value="';159 if ( $sfce_group_id ) echo $sfce_group_id;160 else if ( $options['sfce_group_id'] ) echo $options['sfce_group_id'];161 echo '" /></td></tr></table><br>';162 163 164 177 $sfce_fb_event_status = get_post_meta($_GET['post'], 'sfce_fb_event_status', true ); 165 178 echo '<li>'; … … 169 182 echo 'value="1" />'; 170 183 171 //include_once('sfce-js-authenticate.php');172 173 // echo '<form name="sfce_create_event" action="sfce-authenticate-fb.php" method="post" ><a href="#" onclick="document.sfce_create_event.submit();" title="Create a Facebook event">Create Event</a></form>';174 175 184 176 185 echo '<p /><small>'; … … 179 188 180 189 $existing_events = get_post_meta ($post_id, 'fb_event_id') ; 190 $j=1; 181 191 if ( $existing_events ) foreach ( $existing_events as $event ) 182 192 { 193 if ( $event == '' ) continue; 183 194 echo '<br /><a href="http://www.facebook.com/event.php?eid=' . $event . '&index=1">'; 184 _e('Facebook event for this post.','sfce-create-event'); 195 echo addOrdinalNumberSuffix($j++) . ' '; 196 _e('Facebook event for this post','sfce-create-event'); 185 197 echo '</a><br />'; 186 198 } … … 221 233 } 222 234 223 224 235 foreach ( $sfce_text_inputs as $input ) 225 236 if ( $input['required'] && $_POST[$input['name']] == '' ) $error .= sprintf(__('You must enter a value for %s', 'sfce-create-event'), $input['label']) . '.<br />'; … … 236 247 if ( $_POST['sfce_create_fb_event'] ) 237 248 { 238 if ( $_POST['sfce_group_id'] ) update_post_meta ( $post_id, 'sfce_group_id' , $_POST['sfce_group_id'] );239 249 foreach ( $sfce_text_inputs as $input) 240 250 { … … 267 277 } 268 278 } 269 $sfce_fb_event_status = get_post_meta($post_id, 'sfce_fb_event_status', true );270 // if ( $_POST['sfce_create_fb_event'] == "1" ) update_post_meta( $post_id, 'sfce_fb_event_status', 'created' ); else update_post_meta( $post_id, 'sfce_fb_event_status', '' );271 279 272 280 // Call the facebook event creation... 273 $cookie = get_facebook_cookie3($args['app_id'], $args['app_secret']); 274 if (function_exists('sfce_create_event') && $_POST['sfce_create_fb_event'] && $sfce_fb_event_status <> "created") 281 if (function_exists('sfce_create_event') && $_POST['sfce_create_fb_event'] ) 275 282 { 276 283 $event_id = sfce_create_event( array( … … 289 296 ,'end_hour' => $_POST['sfce_event_end_hour'] 290 297 ,'end_min' => $_POST['sfce_event_end_min'] 291 ,'photo' => $_POST['sfce_event_photo'] 292 ,'group_id' => $_POST['sfce_group_id'] 298 // ,'photo' => $_POST['sfce_event_photo'] 293 299 )); 294 300 295 if ( $event_id ) 296 { 297 // update_post_meta( $post_id, 'fb_event', 'created' ); 298 update_post_meta( $post_id, 'fb_event_id', $event_id ); 299 } 301 if ( $event_id ) add_post_meta( $post_id, 'fb_event_id', $event_id ); 300 302 } 301 303 } 302 304 } 303 305 304 add_action('edit_post', 'sfce_create_event_post'); 305 306 function get_facebook_cookie3($app_id, $application_secret) { 307 $args = array(); 308 parse_str(trim($_COOKIE['fbs_' . $app_id], '\\"'), $args); 309 ksort($args); 310 $payload = ''; 311 foreach ($args as $key => $value) { 312 if ($key != 'sig') { 313 $payload .= $key . '=' . $value; 314 } 315 } 316 if (md5($payload . $application_secret) != $args['sig']) { 317 return null; 318 } 319 return $args; 306 function addOrdinalNumberSuffix($num) { 307 if (!in_array(($num % 100),array(11,12,13))){ 308 switch ($num % 10) { 309 // Handle 1st, 2nd, 3rd 310 case 1: return $num.'st'; 311 case 2: return $num.'nd'; 312 case 3: return $num.'rd'; 313 } 314 } 315 return $num.'th'; 320 316 } 317 318
Note: See TracChangeset
for help on using the changeset viewer.