Changeset 1378

Show
Ignore:
Timestamp:
02/19/08 03:16:04 (21 months ago)
Author:
takayama
Message:

Fixed BugId:67669
* Fixed a performance issue.

  • Changed to dialog based author selection instead of combo box.
Location:
branches/release-30
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • branches/release-30/lib/MT/App/CMS.pm

    r1369 r1378  
    204204        'dialog_select_sysadmin' => "${pkg}User::dialog_select_sysadmin", 
    205205        'dialog_grant_role'      => "${pkg}User::dialog_grant_role", 
     206        'dialog_select_author'   => "${pkg}User::dialog_select_author", 
    206207 
    207208        ## AJAX handlers 
  • branches/release-30/lib/MT/CMS/Entry.pm

    r1369 r1378  
    19361936    my ( $date_format, $datetime_format ); 
    19371937 
    1938     ## Load list of users for display in filter pulldown (and selection 
    1939     ## pulldown on power edit page). 
    1940     my ( @a_data, %authors ); 
    19411938    if ($is_power_edit) { 
    1942  
    1943         # FIXME: Scaling issue for lots of authors on one blog 
    1944         my $auth_iter = MT::Author->load_iter( 
    1945             { type => MT::Author::AUTHOR() }, 
    1946             { 
    1947                 'join' => MT::Permission->join_on( 
    1948                     'author_id', { blog_id => $blog_id } 
    1949                 ), 
    1950                 limit => 51, 
    1951             } 
    1952         ); 
    1953         while ( my $author = $auth_iter->() ) { 
    1954             $authors{ $author->id } = $author->name; 
    1955             push @a_data, 
    1956               { 
    1957                 author_id   => $author->id, 
    1958                 author_name => encode_js( $author->name ) 
    1959               }; 
    1960         } 
    1961         @a_data = sort { $a->{author_name} cmp $b->{author_name} } @a_data; 
    1962         my $i = 0; 
    1963         for my $row (@a_data) { 
    1964             $row->{author_index} = $i++; 
    1965         } 
    1966         $param->{author_loop} = \@a_data; 
    19671939        $date_format          = "%Y.%m.%d"; 
    19681940        $datetime_format      = "%Y-%m-%d %H:%M:%S"; 
     
    19731945    } 
    19741946 
    1975     my ( @cat_list, @auth_list ); 
     1947    my @cat_list; 
    19761948    if ($is_power_edit) { 
    19771949        @cat_list = 
    19781950          sort { $cats{$a}->{category_index} <=> $cats{$b}->{category_index} } 
    19791951          keys %cats; 
    1980         @auth_list = sort { $authors{$a} cmp $authors{$b} } keys %authors; 
    19811952    } 
    19821953 
     
    20802051            $row->{row_category_loop} = \@this_c_data; 
    20812052 
    2082             my @this_a_data; 
    2083             my $this_author_id = $obj->author_id; 
    2084             for my $a_id (@auth_list) { 
    2085                 push @this_a_data, 
    2086                   { 
    2087                     author_name => $authors{$a_id}, 
    2088                     author_id   => $a_id 
    2089                   }; 
    2090                 $this_a_data[-1]{author_is_selected} = $this_author_id 
    2091                   && $this_author_id == $a_id ? 1 : 0; 
    2092             } 
    2093             unless ( $obj->author ) { 
    2094                 push @this_a_data, 
    2095                   { 
    2096                     author_name => $app->translate( 
    2097                         '(user deleted - ID:[_1])', 
    2098                         $obj->author_id 
    2099                     ), 
    2100                     author_id          => $obj->author_id, 
    2101                     author_is_selected => 1, 
    2102                   }; 
    2103             } 
    2104             $row->{row_author_loop} = \@this_a_data; 
     2053            if ( $obj->author ) { 
     2054                $row->{row_author_name} = $obj->author->name; 
     2055                $row->{row_author_id}   = $obj->author->id; 
     2056            } else { 
     2057                $row->{row_author_name} = $app->translate( 
     2058                    '(user deleted - ID:[_1])', 
     2059                    $obj->author_id 
     2060                ); 
     2061                $row->{row_author_id} = $obj->author_id, 
     2062             } 
    21052063        } 
    21062064        if ( my $blog = $blogs{ $obj->blog_id } ||= 
  • branches/release-30/lib/MT/CMS/User.pm

    r1369 r1378  
    11711171} 
    11721172 
     1173sub dialog_select_author { 
     1174    my $app = shift; 
     1175 
     1176    my $hasher = sub { 
     1177        my ( $obj, $row ) = @_; 
     1178        $row->{label}       = $row->{name}; 
     1179        $row->{description} = $row->{nickname}; 
     1180    }; 
     1181 
     1182    $app->listing( 
     1183        { 
     1184            type  => 'author', 
     1185            terms => { 
     1186                type   => MT::Author::AUTHOR(), 
     1187                status => MT::Author::ACTIVE(), 
     1188            }, 
     1189            args => { 
     1190                sort => 'name', 
     1191                join => MT::Permission->join_on( 
     1192                    'author_id', 
     1193                    { 
     1194                        permissions => "\%'create_post'\%", 
     1195                        blog_id     => $app->blog->id, 
     1196                    }, 
     1197                    { 'like' => { 'permissions' => 1 } } 
     1198                ), 
     1199            }, 
     1200            code     => $hasher, 
     1201            template => 'dialog/select_users.tmpl', 
     1202            params   => { 
     1203                dialog_title => 
     1204                  $app->translate("Select a entry author"), 
     1205                items_prompt => 
     1206                  $app->translate("Selected author"), 
     1207                search_prompt => $app->translate( 
     1208                    "Type a username to filter the choices below."), 
     1209                panel_label       => $app->translate("Entry author"), 
     1210                panel_description => $app->translate("Name"), 
     1211                panel_type        => 'author', 
     1212                panel_multi       => defined $app->param('multi') 
     1213                ? $app->param('multi') 
     1214                : 0, 
     1215                panel_searchable => 1, 
     1216                panel_first      => 1, 
     1217                panel_last       => 1, 
     1218                list_noncron     => 1, 
     1219                idfield          => $app->param('idfield'), 
     1220                namefield        => $app->param('namefield'), 
     1221            }, 
     1222        } 
     1223    ); 
     1224} 
     1225 
    11731226sub dialog_select_sysadmin { 
    11741227    my $app = shift; 
  • branches/release-30/tmpl/cms/include/entry_table.tmpl

    r1260 r1378  
    168168                <td class="author"> 
    169169            <mt:if name="is_editable"> 
    170                     <select name="author_id_<$mt:var name="id"$>"> 
    171                 <mt:unless name="author_id"> 
    172                         <option value=""><__trans phrase="None"></option> 
    173                 </mt:unless> 
    174                 <mt:loop name="row_author_loop"> 
    175                         <option value="<$mt:var name="author_id"$>"<mt:if name="author_is_selected"> selected="selected"</mt:if>><$mt:var name="author_name"$></option> 
    176                 </mt:loop> 
    177                     </select> 
     170                    <input type="hidden" name="author_id_<$mt:var name="id"$>" value="<$mt:var name="row_author_id"$>" id="entry_author_id_<$mt:var name="id"$>"> 
     171                    <a href="javascript:void(0)" onclick="return openDialog(this.form, 'dialog_select_author', 'blog_id=<$mt:var name="blog_id"$>&amp;multi=0&amp;idfield=entry_author_id_<$mt:var name="id"$>&amp;namefield=entry_author_name_<$mt:var name="id"$>')"><span id="entry_author_name_<$mt:var name="id"$>"><$mt:var name="row_author_name"$></span></a> 
    178172            <mt:else> 
    179173                    <$mt:var name="author_name"$>