Changeset 2109
- 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:
-
- 2 deleted
- 4 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/index.php
r1721 r2109 5 5 * Provides the route for translate.wordpress.org/. 6 6 */ 7 class GP_WPorg_Route_Index extends GP_Route {7 class WPorg_GP_Route_Index extends GP_Route { 8 8 9 9 /** -
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 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/redirector.php
r1721 r2109 5 5 * Provides redirection routes. 6 6 */ 7 class GP_WPorg_Route_Redirector extends GP_Route {7 class WPorg_GP_Route_Redirector extends GP_Route { 8 8 9 9 function redirect_languages( $path = '' ) { -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/stats-overview.php
r2108 r2109 5 5 * Provides the route for translate.wordpress.org/stats. 6 6 */ 7 class GP_WPorg_Route_Stats extends GP_Route {7 class WPorg_GP_Route_Stats extends GP_Route { 8 8 9 9 public function get_stats_overview() { 10 global $ gpdb;10 global $wpdb; 11 11 12 12 $projects = array( … … 41 41 (100 * stats.current/stats.all) as percent_complete, 42 42 stats.waiting+stats.fuzzy as waiting_strings 43 FROM {$ gpdb->prefix}project_translation_status stats44 LEFT JOIN {$ gpdb->prefix}projects p ON stats.project_id = p.id43 FROM {$wpdb->prefix}project_translation_status stats 44 LEFT JOIN {$wpdb->prefix}projects p ON stats.project_id = p.id 45 45 WHERE 46 46 p.path IN ( $all_project_paths_sql ) 47 47 AND p.active = 1"; 48 48 49 $rows = $ gpdb->get_results( $sql );49 $rows = $wpdb->get_results( $sql ); 50 50 51 51 // Split out into $[Locale][Project] = % … … 80 80 locale, locale_slug, 81 81 SUM( stats.waiting ) + SUM( stats.fuzzy ) as waiting_strings 82 FROM {$ gpdb->prefix}project_translation_status stats83 LEFT JOIN {$ gpdb->prefix}projects p ON stats.project_id = p.id82 FROM {$wpdb->prefix}project_translation_status stats 83 LEFT JOIN {$wpdb->prefix}projects p ON stats.project_id = p.id 84 84 WHERE 85 85 p.parent_project_id IN ( $parent_project_ids ) … … 87 87 GROUP BY locale, locale_slug"; 88 88 89 $rows = $ gpdb->get_results( $sql );89 $rows = $wpdb->get_results( $sql ); 90 90 foreach ( $rows as $set ) { 91 91 $locale_key = $set->locale; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/routes/wp-plugins.php
r2089 r2109 1 1 <?php 2 2 3 class GP_WPorg_Route_WP_Plugins extends GP_Route {3 class WPorg_GP_Route_WP_Plugins extends GP_Route { 4 4 5 5 public function get_plugin_projects( $project_slug ) { 6 global $ gpdb;6 global $wpdb; 7 7 8 8 $project_path = 'wp-plugins/' . $project_slug; … … 12 12 } 13 13 14 $rows = $ gpdb->get_results( "14 $rows = $wpdb->get_results( " 15 15 SELECT 16 16 path, locale, locale_slug, … … 18 18 stats.waiting+stats.fuzzy as waiting_strings, 19 19 stats.untranslated as untranslated 20 FROM {$ gpdb->prefix}project_translation_status stats21 LEFT JOIN {$ gpdb->prefix}projects p ON stats.project_id = p.id20 FROM {$wpdb->prefix}project_translation_status stats 21 LEFT JOIN {$wpdb->prefix}projects p ON stats.project_id = p.id 22 22 WHERE 23 23 p.parent_project_id = '{$project->id}' -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-routes/wporg-gp-routes.php
r2108 r2109 1 1 <?php 2 2 /** 3 * Register custom routes for translate.wordpress.org. 4 * 5 * @author ocean90, obenland, dd32 3 * Plugin name: GlotPress: Register custom routes for translate.wordpress.org. 4 * Plugin author: ocean90, obenland, dd32 6 5 */ 7 6 … … 12 11 require_once __DIR__ . '/routes/wp-plugins.php'; 13 12 14 class GP_WPorg_Routes extends GP_Plugin { 15 public $id = 'wporg-routes'; 13 class WPorg_GP_Routes { 16 14 17 15 public function __construct() { 18 parent::__construct(); 19 $this->add_action( 'init' ); 16 add_action( 'init', array( $this, 'register_routes' ) ); 20 17 } 21 18 22 public function init() {19 public function register_routes() { 23 20 // Bail for API requests. 24 21 $request_uri = GP::$router->request_uri(); … … 35 32 36 33 // Redirect routes. 37 GP::$router->prepend( '/languages', array( ' GP_WPorg_Route_Redirector', 'redirect_languages' ) );38 GP::$router->prepend( "/languages/$path", array( ' GP_WPorg_Route_Redirector', 'redirect_languages' ) );34 GP::$router->prepend( '/languages', array( 'WPorg_GP_Route_Redirector', 'redirect_languages' ) ); 35 GP::$router->prepend( "/languages/$path", array( 'WPorg_GP_Route_Redirector', 'redirect_languages' ) ); 39 36 40 37 // Register custom routes. 41 GP::$router->prepend( '/', array( ' GP_WPorg_Route_Index', 'get_locales' ) );42 GP::$router->prepend( "/locale/$locale", array( ' GP_WPorg_Route_Locale', 'get_locale_projects' ) );43 GP::$router->prepend( "/locale/$locale/$path", array( ' GP_WPorg_Route_Locale', 'get_locale_projects' ) );44 GP::$router->prepend( "/locale/$locale/$path/$path", array( ' GP_WPorg_Route_Locale', 'get_locale_projects' ) );45 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( ' GP_WPorg_Route_Locale', 'get_locale_project' ) );46 GP::$router->prepend( '/stats/?', array( ' GP_WPorg_Route_Stats', 'get_stats_overview' ) );38 GP::$router->prepend( '/', array( 'WPorg_GP_Route_Index', 'get_locales' ) ); 39 GP::$router->prepend( "/locale/$locale", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 40 GP::$router->prepend( "/locale/$locale/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 41 GP::$router->prepend( "/locale/$locale/$path/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_projects' ) ); 42 GP::$router->prepend( "/locale/$locale/$path/$path/$path", array( 'WPorg_GP_Route_Locale', 'get_locale_project' ) ); 43 GP::$router->prepend( '/stats/?', array( 'WPorg_GP_Route_Stats', 'get_stats_overview' ) ); 47 44 $project = '([^/]*)/?'; 48 GP::$router->prepend( "/projects/wp-plugins/$project", array( ' GP_WPorg_Route_WP_Plugins', 'get_plugin_projects' ) );45 GP::$router->prepend( "/projects/wp-plugins/$project", array( 'WPorg_GP_Route_WP_Plugins', 'get_plugin_projects' ) ); 49 46 } 50 47 } 51 48 52 GP::$plugins->wporg_routes = new GP_WPorg_Routes; 49 function wporg_gp_routes() { 50 global $wporg_gp_routes; 51 52 if ( ! isset( $wporg_gp_routes ) ) { 53 $wporg_gp_routes = new WPorg_GP_Routes(); 54 } 55 56 return $wporg_gp_routes; 57 } 58 add_action( 'plugins_loaded', 'wporg_gp_routes' );
Note: See TracChangeset
for help on using the changeset viewer.