Changeset 2109 for sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/locale.php
- Timestamp:
- 11/22/2015 08:01:41 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/locale.php
r2080 r2109 11 11 * Provides the route for translate.wordpress.org/locale/$locale. 12 12 */ 13 class GP_WPorg_Route_Locale extends GP_Route {13 class WPorg_GP_Route_Locale extends GP_Route { 14 14 15 15 /** … … 21 21 */ 22 22 public function get_locale_projects( $locale_slug, $set_slug = 'default', $project_path = false ) { 23 global $ gpdb;23 global $wpdb; 24 24 25 25 $per_page = 20; … … 101 101 $project_ids = array_merge( 102 102 $project_ids, 103 $ gpdb->get_col( "SELECT id FROM {$gpdb->projects} WHERE parent_project_id IN(" . implode(', ', $project_ids ) . ")" )103 $wpdb->get_col( "SELECT id FROM {$wpdb->projects} WHERE parent_project_id IN(" . implode(', ', $project_ids ) . ")" ) 104 104 ); 105 105 … … 244 244 */ 245 245 private function get_locale_variants( $locale, $project_ids ) { 246 global $ gpdb;246 global $wpdb; 247 247 248 248 $project_ids = implode( ',', $project_ids ); 249 $slugs = $ gpdb->get_col( $gpdb->prepare( "249 $slugs = $wpdb->get_col( $wpdb->prepare( " 250 250 SELECT DISTINCT slug 251 FROM {$ gpdb->translation_sets}251 FROM {$wpdb->translation_sets} 252 252 WHERE 253 253 project_id IN( $project_ids ) … … 324 324 */ 325 325 private function get_active_sub_projects( $project, $with_sub_projects = false ) { 326 global $ gpdb;326 global $wpdb; 327 327 328 328 $_projects = $project->many( " 329 329 SELECT * 330 FROM {$ gpdb->projects}330 FROM {$wpdb->projects} 331 331 WHERE 332 332 parent_project_id = %d AND … … 343 343 $sub_projects = $project->many( " 344 344 SELECT * 345 FROM {$ gpdb->projects}345 FROM {$wpdb->projects} 346 346 WHERE 347 347 parent_project_id = %d AND … … 379 379 */ 380 380 private function get_paged_active_sub_projects( $project, $args = array() ) { 381 global $ gpdb;381 global $wpdb; 382 382 383 383 $defaults = array( … … 394 394 $limit_sql = ''; 395 395 if ( $per_page ) { 396 $limit_sql = $ gpdb->prepare( 'LIMIT %d, %d', ( $page - 1 ) * $per_page, $per_page );397 } 398 399 $parent_project_sql = $ gpdb->prepare( 'AND tp.parent_project_id = %d', $project->id );396 $limit_sql = $wpdb->prepare( 'LIMIT %d, %d', ( $page - 1 ) * $per_page, $per_page ); 397 } 398 399 $parent_project_sql = $wpdb->prepare( 'AND tp.parent_project_id = %d', $project->id ); 400 400 401 401 $search_sql = ''; 402 402 if ( $search ) { 403 403 $esc_search = '%%' . like_escape( $search ) . '%%'; 404 $search_sql = $ gpdb->prepare( 'AND ( tp.name LIKE %s OR tp.slug LIKE %s )', $esc_search, $esc_search );404 $search_sql = $wpdb->prepare( 'AND ( tp.name LIKE %s OR tp.slug LIKE %s )', $esc_search, $esc_search ); 405 405 } 406 406 … … 448 448 449 449 // Limit to only showing base-level projects 450 $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$ gpdb->projects} WHERE parent_project_id IS NULL AND active = 1) )";450 $parent_project_sql .= " AND tp.parent_project_id IN( (SELECT id FROM {$wpdb->projects} WHERE parent_project_id IS NULL AND active = 1) )"; 451 451 452 452 } … … 463 463 case 'special': 464 464 // Float favorites to the start, but only if they have untranslated strings 465 $user_fav_projects = array_map( array( $ gpdb, 'escape' ), $this->get_user_favorites( $project->slug ) );465 $user_fav_projects = array_map( array( $wpdb, 'escape' ), $this->get_user_favorites( $project->slug ) ); 466 466 467 467 // Float Favorites to the start, float fully translated to the bottom, order the rest by name … … 475 475 case 'favorites': 476 476 // Only list favorites 477 $user_fav_projects = array_map( array( $ gpdb, 'escape' ), $this->get_user_favorites( $project->slug ) );477 $user_fav_projects = array_map( array( $wpdb, 'escape' ), $this->get_user_favorites( $project->slug ) ); 478 478 479 479 if ( $user_fav_projects ) { … … 513 513 $_projects = $project->many( " 514 514 SELECT SQL_CALC_FOUND_ROWS tp.* 515 FROM {$ gpdb->projects} tp516 LEFT JOIN {$ gpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.locale = %s AND stats.locale_slug = %s515 FROM {$wpdb->projects} tp 516 LEFT JOIN {$wpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.locale = %s AND stats.locale_slug = %s 517 517 WHERE 518 518 tp.active = 1 … … 546 546 */ 547 547 function get_user_favorites( $project_slug = false ) { 548 global $ gpdb;548 global $wpdb; 549 549 $user = GP::$user->current(); 550 550 … … 572 572 if ( $plugin_fav_ids ) { 573 573 $plugin_fav_ids = implode( ',', array_map( 'intval', $plugin_fav_ids ) ); 574 $plugin_fav_slugs = $ gpdb->get_col( "SELECT topic_slug FROM " . PLUGINS_TABLE_PREFIX . "topics WHERE topic_id IN( $plugin_fav_ids )" );574 $plugin_fav_slugs = $wpdb->get_col( "SELECT topic_slug FROM " . PLUGINS_TABLE_PREFIX . "topics WHERE topic_id IN( $plugin_fav_ids )" ); 575 575 } 576 576 … … 594 594 */ 595 595 public function get_active_top_level_projects() { 596 global $ gpdb;596 global $wpdb; 597 597 598 598 return GP::$project->many( " 599 599 SELECT * 600 FROM {$ gpdb->projects}600 FROM {$wpdb->projects} 601 601 WHERE 602 602 parent_project_id IS NULL
Note: See TracChangeset
for help on using the changeset viewer.