Changeset 865

Show
Ignore:
Timestamp:
12/09/06 02:01:42 (2 years ago)
Author:
gboggs
Message:

MT/Asset/Image:

  • Added (and documented) as_html() to return the appropriate HTML to insert.
  • Fixed the A&C POD link.

MT/App/CMS:

  • Added (and documented) an asset_insert() method to load an asset, construct appropriate parameters and call the insertion template.

dialog_list_assets.tmpl:

  • Added function validate() to toggle the mode if an asset is chosen onsubmit.
  • Removed unneeded list_assets HTML (like tabls, etc) and rearranged things a bit.
  • Changed the chckboxes to radio buttons.

asset_insert.tmpl: - Added this template to serve at the end of the insert asset selection process.

BugId: 45620

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/lib/MT/App/CMS.pm

    r857 r865  
    153153        'dialog_restore_upload' => \&dialog_restore_upload, 
    154154        'restore_premature_cancel' => \&restore_premature_cancel, 
     155        'asset_insert' => \&asset_insert, 
    155156    ); 
    156157    $app->{state_params} = [ 
     
    996997} 
    997998 
     999sub asset_insert { 
     1000    my $app = shift; 
     1001    my $asset = $app->param('id'); 
     1002    require MT::Asset; 
     1003    $asset = MT::Asset->load($asset) || 
     1004        return $app->errtrans("Can't load asset, $asset."); 
     1005    my $param = { 
     1006        asset_html => $asset->as_html, 
     1007        class => $app->param('class'), 
     1008        magic_token => $app->param('magic_token'), 
     1009    }; 
     1010    $app->build_page('asset_insert.tmpl', $param); 
     1011} 
     1012 
    9981013sub list_roles { 
    9991014    my $app = shift; 
     
    1207012085Approves a comment or trackback for publication. 
    1207112086 
     12087=item * asset_insert 
     12088 
     12089Load an asset, given the I<asset id>, construct an appropriate 
     12090parameter list and render the I<asset_insert> template. 
     12091 
    1207212092=item * ban_commenter 
    1207312093 
     
    1222212242 
    1222312243Ajax-style handler for returning the tags that exist on a particular blog. 
     12244 
     12245=item * list_assets 
     12246 
     12247Handler for displaying a list of blog-level assets. 
    1222412248 
    1222512249=item * list_associations 
  • branches/wheeljack/lib/MT/Asset/Image.pm

    r829 r865  
    100100} 
    101101 
     102sub as_html { 
     103    my $self = shift; 
     104    my %args = @_; 
     105    return sprintf '<img src="%s" height="%d" width="%d" alt="%s" class="%s" />', 
     106        $self->url, $self->image_height, $self->image_width, $self->file_name, $args{class}; 
     107} 
     108 
    1021091; 
    103110 
     
    141148undef. 
    142149 
    143 =head1 AUTHORS & COPYRIGHT 
     150=head2 $asset->as_html 
    144151 
    145 Please see the I<MT> manpage for author, copyright, and license information. 
     152Return the HTML I<IMG> element with the image asset attributes. 
     153 
     154=head1 AUTHOR & COPYRIGHT 
     155 
     156Please see the L<MT/"AUTHOR & COPYRIGHT"> for author, copyright, and 
     157license information. 
    146158 
    147159=cut 
  • branches/wheeljack/tmpl/cms/dialog_list_assets.tmpl

    r858 r865  
    99assets[<TMPL_VAR NAME=ID>] = <TMPL_VAR NAME=METADATA_JSON>; 
    1010</TMPL_LOOP> 
     11 
     12function validate (f) { 
     13    var x = undefined; 
     14    for (var i = 0; i < f.id.length; i++) { 
     15        if (f.id[i].checked) f.__mode.value = 'asset_insert'; 
     16    } 
     17    return f['__mode'] ? true : false; 
     18} 
    1119 
    1220function displayAssetDetails(id) { 
     
    115123<h2><span class="weblog-title-highlight"><TMPL_IF NAME=EDIT_BLOG_ID><TMPL_VAR NAME=BLOG_NAME ESCAPE=HTML><TMPL_ELSE><MT_TRANS phrase="System-wide"></TMPL_IF>: </span> <MT_TRANS phrase="Assets"></h2> 
    116124 
    117 <p class="page-desc"><MT_TRANS phrase="TBD"></p> 
    118  
    119125<div class="tabs"> 
    120126<ul> 
    121 <li class="yah"><a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=list_assets<TMPL_IF NAME=EDIT_BLOG_ID>&amp;blog_id=<TMPL_VAR NAME=EDIT_BLOG_ID></TMPL_IF>"><MT_TRANS phrase="Assets"></a></li> 
    122127<TMPL_IF NAME=EDIT_BLOG_ID> 
    123128<TMPL_IF NAME=CAN_UPLOAD> 
     
    206211<div class="list-wrapper"> 
    207212<TMPL_IF NAME=OBJECT_LOOP> 
    208 <form method="post" action="<TMPL_VAR NAME=SCRIPT_URL>" onsubmit="return this['__mode'] ? true : false"> 
     213<form method="post" action="<TMPL_VAR NAME=SCRIPT_URL>" onsubmit="return validate(this)"> 
    209214<input type="hidden" name="__mode" value="" /> 
    210 <input type="hidden" name="_type" value="asset" /><TMPL_IF NAME=EDIT_BLOG_ID> 
    211 <input type="hidden" name="blog_id" value="<TMPL_VAR NAME=EDIT_BLOG_ID>" /> 
    212 </TMPL_IF> 
     215<input type="hidden" name="_type" value="asset" /> 
    213216<input type="hidden" name="filter_args" value="<TMPL_VAR NAME=FILTER_ARGS>" /> 
    214217<input type="hidden" name="return_args" value="<TMPL_VAR NAME=RETURN_ARGS ESCAPE=HTML>" /> 
    215218<input type="hidden" name="magic_token" value="<TMPL_VAR NAME=MAGIC_TOKEN>" /> 
    216219<input type="hidden" name="dialog_view" value="1" /> 
     220<TMPL_IF NAME=EDIT_BLOG_ID> 
     221<input type="hidden" name="blog_id" value="<TMPL_VAR NAME=EDIT_BLOG_ID>" /> 
     222</TMPL_IF> 
    217223 
    218224<div class="list" id="selector"> 
     
    221227<thead> 
    222228<tr> 
    223 <th class="cb"><input type="checkbox" name="id-head" value="all" class="select" /></th> 
     229<th class=""></th> 
    224230<th id="as-file-status"><img src="<TMPL_VAR NAME=STATIC_URI>images/status_icons/flag.gif" alt="<MT_TRANS phrase="Status">" title="<MT_TRANS phrase="Status">" width="9" height="9" /></th> 
    225231<th id="as-file-name"><MT_TRANS phrase="Filename"></th> 
     
    239245<TMPL_LOOP NAME=OBJECT_LOOP> 
    240246<tr class="<TMPL_IF __ODD__>odd<TMPL_ELSE>even</TMPL_IF>"> 
    241 <td class="cb"><input type="checkbox" name="id" value="<TMPL_VAR NAME=ID>" class="select" /></td> 
     247<td class="cb"><input type="radio" name="id" value="<TMPL_VAR NAME=ID>" class="select" /></td> 
    242248<td class="status-<TMPL_IF NAME=FILE_IS_MISSING>missing<TMPL_ELSE>publish</TMPL_IF>"><img src="<TMPL_VAR NAME=STATIC_URI>images/spacer.gif" <TMPL_IF NAME=FILE_IS_MISSING>alt="<MT_TRANS phrase="Pending">"<TMPL_ELSE>alt="<MT_TRANS phrase="Published">"</TMPL_IF> width="9" height="9" /</td> 
    243249<td><span title="<TMPL_VAR NAME=FILE_PATH ESCAPE=HTML>"><TMPL_UNLESS NAME=FILE_IS_MISSING><a href="javascript:void(0)" onclick="return displayAssetDetails('<TMPL_VAR NAME=ID>');"></TMPL_UNLESS><TMPL_VAR NAME=FILE_NAME ESCAPE=HTML><TMPL_UNLESS NAME=FILE_IS_MISSING></a></TMPL_UNLESS></span><div id="asset-<TMPL_VAR NAME=ID>-detail" class="asset-detail-panel"><div id="asset-<TMPL_VAR NAME=ID>-detail-inner" class="asset-detail-panel-inner"></div></div></td>