Making WordPress.org


Ignore:
Timestamp:
11/22/2015 08:01:41 PM (9 years ago)
Author:
ocean90
Message:

Translate: Convert the GP plugin "wporg-routes" to a WP plugin.

See #1352.

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  
    1111 * Provides the route for translate.wordpress.org/locale/$locale.
    1212 */
    13 class GP_WPorg_Route_Locale extends GP_Route {
     13class WPorg_GP_Route_Locale extends GP_Route {
    1414
    1515    /**
     
    2121     */
    2222    public function get_locale_projects( $locale_slug, $set_slug = 'default', $project_path = false ) {
    23         global $gpdb;
     23        global $wpdb;
    2424
    2525        $per_page = 20;
     
    101101        $project_ids = array_merge(
    102102            $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  ) . ")" )
    104104        );
    105105
     
    244244     */
    245245    private function get_locale_variants( $locale, $project_ids ) {
    246         global $gpdb;
     246        global $wpdb;
    247247
    248248        $project_ids = implode( ',', $project_ids );
    249         $slugs = $gpdb->get_col( $gpdb->prepare( "
     249        $slugs = $wpdb->get_col( $wpdb->prepare( "
    250250            SELECT DISTINCT slug
    251             FROM {$gpdb->translation_sets}
     251            FROM {$wpdb->translation_sets}
    252252            WHERE
    253253                project_id IN( $project_ids )
     
    324324     */
    325325    private function get_active_sub_projects( $project, $with_sub_projects = false ) {
    326         global $gpdb;
     326        global $wpdb;
    327327
    328328        $_projects = $project->many( "
    329329            SELECT *
    330             FROM {$gpdb->projects}
     330            FROM {$wpdb->projects}
    331331            WHERE
    332332                parent_project_id = %d AND
     
    343343                $sub_projects = $project->many( "
    344344                    SELECT *
    345                     FROM {$gpdb->projects}
     345                    FROM {$wpdb->projects}
    346346                    WHERE
    347347                        parent_project_id = %d AND
     
    379379     */
    380380    private function get_paged_active_sub_projects( $project, $args = array() ) {
    381         global $gpdb;
     381        global $wpdb;
    382382
    383383        $defaults = array(
     
    394394        $limit_sql = '';
    395395        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 );
    400400
    401401        $search_sql = '';
    402402        if ( $search ) {
    403403            $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 );
    405405        }
    406406
     
    448448
    449449            // 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) )";
    451451
    452452        }
     
    463463            case 'special':
    464464                // 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 ) );
    466466
    467467                // Float Favorites to the start, float fully translated to the bottom, order the rest by name
     
    475475            case 'favorites':
    476476                // 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 ) );
    478478
    479479                if ( $user_fav_projects ) {
     
    513513        $_projects = $project->many( "
    514514            SELECT SQL_CALC_FOUND_ROWS tp.*
    515             FROM {$gpdb->projects} tp
    516                 LEFT JOIN {$gpdb->project_translation_status} stats ON stats.project_id = tp.id AND stats.locale = %s AND stats.locale_slug = %s
     515            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
    517517            WHERE
    518518                tp.active = 1
     
    546546     */
    547547    function get_user_favorites( $project_slug = false ) {
    548         global $gpdb;
     548        global $wpdb;
    549549        $user = GP::$user->current();
    550550
     
    572572                if ( $plugin_fav_ids ) {
    573573                    $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 )" );
    575575                }
    576576
     
    594594     */
    595595    public function get_active_top_level_projects() {
    596         global $gpdb;
     596        global $wpdb;
    597597
    598598        return GP::$project->many( "
    599599            SELECT *
    600             FROM {$gpdb->projects}
     600            FROM {$wpdb->projects}
    601601            WHERE
    602602                parent_project_id IS NULL
Note: See TracChangeset for help on using the changeset viewer.