Changeset 899
- Timestamp:
- 12/13/06 01:46:52 (2 years ago)
- Files:
-
- branches/wheeljack/lib/MT/App/CMS.pm (modified) (9 diffs)
- branches/wheeljack/lib/MT/Asset/Image.pm (modified) (1 diff)
- branches/wheeljack/tmpl/cms/asset_insert.tmpl (modified) (1 diff)
- branches/wheeljack/tmpl/cms/dialog_list_assets.tmpl (modified) (2 diffs)
- branches/wheeljack/tmpl/cms/upload.tmpl (modified) (1 diff)
- branches/wheeljack/tmpl/cms/upload_complete.tmpl (modified) (3 diffs)
- branches/wheeljack/tmpl/cms/upload_confirm.tmpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/wheeljack/lib/MT/App/CMS.pm
r894 r899 153 153 'dialog_restore_upload' => \&dialog_restore_upload, 154 154 'restore_premature_cancel' => \&restore_premature_cancel, 155 'asset_insert' => \&asset_insert,156 155 ); 157 156 $app->{state_params} = [ … … 997 996 } 998 997 999 sub 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(class => $app->param('class') || ''),1007 edit_field => $app->param('edit_field'),1008 };1009 $app->build_page('asset_insert.tmpl', $param);1010 }1011 1012 998 sub list_roles { 1013 999 my $app = shift; … … 5469 5455 my $app = shift; 5470 5456 defined(my $text = $app->_process_post_upload) or return; 5471 $app->build_page('show_upload_html.tmpl', 5472 { upload_html => $text }); 5457 $app->build_page('asset_insert.tmpl', 5458 { upload_html => $text, edit_field => $app->param('edit_field'), }, 5459 ); 5473 5460 } 5474 5461 … … 5575 5562 $asset->save; 5576 5563 5564 $app->param('thumb_asset_id' => $asset->id); 5565 5577 5566 MT->run_callbacks('CMSUploadFile', 5578 5567 File => $t_file, Url => $thumb, Size => length($blob), … … 5652 5641 Blog => $blog); 5653 5642 } 5654 my $link = $thumb ? qq(<img src="$thumb" width="$thumb_width" height="$thumb_height" alt="" />) : q{<MT_TRANS phrase="View image">}; 5655 return $app->translate_templatized(<<"HTML"); 5656 <a href="$url" onclick="window.open('$url','popup','width=$width,height=$height,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">$link</a> 5657 HTML 5658 } elsif ($q->param('include')) { 5659 my $wrap_style = $q->param('wrap_text') && $q->param('align') 5660 ? 'class="display_img_'. $q->param('align') .'" ' : ''; 5661 if ($thumb) { 5662 return <<"HTML"; 5663 <a href="$url"><img alt="$fname" src="$thumb" width="$thumb_width" height="$thumb_height" $wrap_style/></a> 5664 HTML 5665 } else { 5666 return <<"HTML"; 5667 <img alt="$fname" src="$url" width="$width" height="$height" $wrap_style/> 5668 HTML 5669 } 5670 } elsif ($q->param('link')) { 5671 return $app->translate_templatized(<<"HTML"); 5672 <a href="$url"><MT_TRANS phrase="Download file"></a> 5673 HTML 5674 } 5643 } 5644 return $app->asset_insert_text(); 5645 } 5646 5647 sub asset_insert_text { 5648 my $app = shift; 5649 my $q = $app->param; 5650 require MT::Asset; 5651 my $asset = MT::Asset->load($q->param('id')) || 5652 return $app->errtrans("Can't load asset, ". $q->param('id') .'.'); 5653 my $text = $asset->as_html($q); 5654 return $q->param('popup') || $q->param('link') 5655 ? $app->translate_templatized($text) 5656 : $text; 5675 5657 } 5676 5658 … … 9161 9143 $param{missing_paths} = -d $blog->site_path || -d $blog->archive_path ? 0 : 1; 9162 9144 $param{entry_insert} = $app->param('entry_insert'); 9145 $param{edit_field} = $app->param('edit_field'); 9163 9146 $app->build_page('upload.tmpl', \%param); 9164 9147 } … … 9301 9284 middle_path => $middle_path, 9302 9285 entry_insert => $q->param('entry_insert'), 9286 edit_field => $app->param('edit_field'), 9303 9287 fname => $basename }); 9304 9288 } … … 9383 9367 $asset->save; 9384 9368 $param{asset_id} = $asset->id; 9369 9370 $param{edit_field} = $q->param('edit_field'); 9385 9371 9386 9372 if ($param{is_image}) { … … 12200 12186 Approves a comment or trackback for publication. 12201 12187 12202 =item * asset_insert12203 12204 Load an asset, given the I<asset id>, construct an appropriate12205 parameter list and render the I<asset_insert> template.12206 12207 12188 =item * ban_commenter 12208 12189 branches/wheeljack/lib/MT/Asset/Image.pm
r870 r899 101 101 102 102 sub as_html { 103 my $self = shift; 104 my %args = @_; 105 (my $name = $self->file_name) =~ s/'/\\'/g; 106 return sprintf '<img src="%s" height="%d" width="%d" alt="%s" class="%s" />', 107 $self->url, $self->image_height, $self->image_width, $name, $args{class}; 103 my ($self, $q) = @_; 104 105 my $text = ''; 106 107 (my $fname = $self->file_name) =~ s/'/\\'/g; 108 109 my $thumb = undef; 110 if ($q->param('thumb')) { 111 $thumb = MT::Asset->load($q->param('thumb_asset_id')) || 112 return MT::App->errtrans( 113 "Can't load asset, ". $q->param('thumb_asset_id') .'.' 114 ); 115 } 116 117 if ($q->param('popup')) { 118 my $link = $thumb 119 ? sprintf('<img src="%s" width="%d" height="%d" alt="%s" />', 120 $thumb->url, $thumb->image_width, $thumb->image_height, $fname, 121 ) 122 : '<MT_TRANS phrase="View image">'; 123 $text = sprintf( 124 q|<a href="%s" onclick="window.open('%s','popup','width=%d,height=%d,scrollbars=no,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false">%s</a>|, 125 $self->url, $self->url, $self->image_width, $self->image_height, $link, 126 ); 127 } 128 elsif ($q->param('include')) { 129 my $wrap_style = $q->param('wrap_text') && $q->param('align') 130 ? 'class="display_img_' . $q->param('align') . '" ' : ''; 131 if ($q->param('thumb')) { 132 $text = sprintf( 133 '<a href="%s"><img alt="%s" src="%s" width="%d" height="%d" %s/></a>', 134 $self->url, $fname, $thumb->url, $thumb->image_width, $thumb->image_height, $wrap_style, 135 ); 136 } 137 else { 138 $text = sprintf( 139 '<img alt="%s" src="%s" width="%d" height="%d" %s/>', 140 $fname, $self->url, $self->image_width, $self->image_height, $wrap_style, 141 ); 142 } 143 } 144 elsif ($q->param('link')) { 145 $text = sprintf( 146 '<a href="%s"><MT_TRANS phrase="Download file"></a>', $self->url, 147 ); 148 } 149 150 return $text; 108 151 } 109 152 branches/wheeljack/tmpl/cms/asset_insert.tmpl
r894 r899 3 3 <!-- 4 4 var str = getByID('<TMPL_VAR NAME=EDIT_FIELD>', window.parent.document); 5 setSelection(str, '<TMPL_VAR NAME= ASSET_HTML ESCAPE=JS>');5 setSelection(str, '<TMPL_VAR NAME=UPLOAD_HTML ESCAPE=JS>'); 6 6 closeDialog(); 7 7 //--> branches/wheeljack/tmpl/cms/dialog_list_assets.tmpl
r898 r899 15 15 var x = undefined; 16 16 for (var i = 0; i < f.id.length; i++) { 17 if (f.id[i].checked) f.__mode.value = ' asset_insert';17 if (f.id[i].checked) f.__mode.value = 'show_upload_html'; 18 18 } 19 19 return f['__mode'] ? true : false; … … 167 167 <TMPL_IF NAME=CAN_UPLOAD> 168 168 <img src="<TMPL_VAR NAME=STATIC_URI>images/status_icons/create.gif" alt="<MT_TRANS phrase="Upload New File">" width="9" height="9" /> 169 <a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=start_upload&_type=asset&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&entry_insert=1& return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>')"><MT_TRANS phrase="Upload New File"></a>169 <a href="<TMPL_VAR NAME=SCRIPT_URL>?__mode=start_upload&_type=asset&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&entry_insert=1&edit_field=<TMPL_VAR NAME=EDIT_FIELD>&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>')"><MT_TRANS phrase="Upload New File"></a> 170 170 </TMPL_IF> 171 171 </TMPL_IF> branches/wheeljack/tmpl/cms/upload.tmpl
r872 r899 30 30 <input type="hidden" name="middle_path" value="" /> 31 31 <input type="hidden" name="entry_insert" value="<TMPL_VAR NAME=ENTRY_INSERT>" /> 32 <input type="hidden" name="edit_field" value="<TMPL_VAR NAME=EDIT_FIELD>" /> 32 33 33 34 <h2><span class="weblog-title-highlight"><TMPL_VAR NAME=BLOG_NAME ESCAPE=HTML>:</span> <MT_TRANS phrase="Upload New File"></h2> branches/wheeljack/tmpl/cms/upload_complete.tmpl
r890 r899 7 7 var mode = 'list_assets'; 8 8 <TMPL_IF NAME=ENTRY_INSERT> 9 mode = ' asset_insert';9 mode = 'show_upload_html'; 10 10 <TMPL_ELSE> 11 11 <TMPL_IF NAME=CAN_POST> … … 13 13 </TMPL_IF> 14 14 </TMPL_IF> 15 doHandleMode(f, trigger, mode);15 doHandleMode(f, trigger, mode); 16 16 } 17 17 … … 42 42 if (f.image_defaults.checked) url += '&image_defaults=1'; 43 43 </TMPL_IF> 44 if (mode == 'asset_insert') { 45 url += '&id=<TMPL_VAR NAME=ASSET_ID>';46 location.href = url;47 } else { 48 closeDialog(url);49 } 44 <TMPL_IF NAME=ENTRY_INSERT> 45 url += '&id=<TMPL_VAR NAME=ASSET_ID>&edit_field=<TMPL_VAR NAME=EDIT_FIELD>'; 46 location.href = url; 47 <TMPL_ELSE> 48 closeDialog(url); 49 </TMPL_IF> 50 50 } 51 51 branches/wheeljack/tmpl/cms/upload_confirm.tmpl
r872 r899 11 11 <input type="hidden" name="magic_token" value="<TMPL_VAR NAME=MAGIC_TOKEN>" /> 12 12 <input type="hidden" name="entry_insert" value="<TMPL_VAR NAME=ENTRY_INSERT>" /> 13 <input type="hidden" name="edit_field" value="<TMPL_VAR NAME=EDIT_FIELD>" /> 13 14 14 15 <h2><span class="weblog-title-highlight"><TMPL_VAR NAME=BLOG_NAME ESCAPE=HTML>:</span> <MT_TRANS phrase="Upload New File"></h2>
