Making WordPress.org


Ignore:
Timestamp:
07/23/2015 10:43:49 AM (9 years ago)
Author:
ocean90
Message:

Translate: Show only active top level projects in the filter bar.

see #1091.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/translate.wordpress.org/includes/gp-plugins/wporg-routes/routes/locale.php

    r1778 r1780  
    6969        }
    7070
    71         $top_level_projects = GP::$project->top_level();
     71        $top_level_projects = $this->get_active_top_level_projects();
    7272        usort( $top_level_projects, array( $this, '_sort_reverse_name_callback' ) );
    7373
     
    199199        global $gpdb;
    200200
    201         $table = GP::$translation_set->table;
    202201        $project_ids = implode( ',', $project_ids );
    203202        $slugs = $gpdb->get_col( $gpdb->prepare( "
    204203            SELECT DISTINCT(slug), name
    205             FROM $table
     204            FROM {$gpdb->translation_sets}
    206205            WHERE
    207206                project_id IN( $project_ids )
     
    278277     */
    279278    private function get_active_sub_projects( $project, $with_sub_projects = false ) {
     279        global $gpdb;
     280
    280281        $_projects = $project->many( "
    281282            SELECT *
    282             FROM $project->table
     283            FROM {$gpdb->projects}
    283284            WHERE
    284285                parent_project_id = %d AND
     
    295296                $sub_projects = $project->many( "
    296297                    SELECT *
    297                     FROM $project->table
     298                    FROM {$gpdb->projects}
    298299                    WHERE
    299300                        parent_project_id = %d AND
     
    367368         * If not, we can simply filter them out, so that paging only has items returned that actually exist.
    368369         */
    369         $translation_sets_table = GP::$translation_set->table;
    370370        $_projects = $project->many( "
    371371            SELECT SQL_CALC_FOUND_ROWS tp.*
    372                 FROM {$project->table} tp
    373                 LEFT JOIN {$project->table} tp_sub ON tp.id = tp_sub.parent_project_id AND tp_sub.active = 1
    374                 LEFT JOIN {$translation_sets_table} sets ON sets.project_id = tp.id AND sets.locale = %s AND sets.slug = %s
    375                 LEFT JOIN {$translation_sets_table} sets_sub ON sets_sub.project_id = tp_sub.id AND sets_sub.locale = %s AND sets_sub.slug = %s
     372                FROM {$gpdb->projects} tp
     373                LEFT JOIN {$gpdb->projects} tp_sub ON tp.id = tp_sub.parent_project_id AND tp_sub.active = 1
     374                LEFT JOIN {$gpdb->translation_sets} sets ON sets.project_id = tp.id AND sets.locale = %s AND sets.slug = %s
     375                LEFT JOIN {$gpdb->translation_sets} sets_sub ON sets_sub.project_id = tp_sub.id AND sets_sub.locale = %s AND sets_sub.slug = %s
    376376            WHERE
    377377                tp.parent_project_id = %d
     
    385385
    386386        $results = (int) $project->found_rows();
    387         $pages = (int)ceil( $results / $per_page );
     387        $pages = (int) ceil( $results / $per_page );
    388388
    389389        $projects = array();
     
    398398    }
    399399
     400    /**
     401     * Retrieves active top level projects.
     402     *
     403     * @return array List of top level projects.
     404     */
     405    public function get_active_top_level_projects() {
     406        global $gpdb;
     407
     408        return GP::$project->many( "
     409            SELECT *
     410            FROM {$gpdb->projects}
     411            WHERE
     412                parent_project_id IS NULL
     413                AND active = 1
     414            ORDER BY name ASC
     415        " );
     416    }
     417
    400418    private function _sort_reverse_name_callback( $a, $b ) {
    401419        return - strcasecmp( $a->name, $b->name );
Note: See TracChangeset for help on using the changeset viewer.