Changeset 935
- Timestamp:
- 12/15/06 22:29:21 (2 years ago)
- Files:
-
- branches/wheeljack/lib/MT/App/CMS.pm (modified) (8 diffs)
- branches/wheeljack/lib/MT/Asset.pm (modified) (1 diff)
- branches/wheeljack/tmpl/cms/dialog_list_assets.tmpl (modified) (2 diffs)
- branches/wheeljack/tmpl/cms/edit_entry.tmpl (modified) (2 diffs)
- branches/wheeljack/tmpl/cms/upload_complete.tmpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/wheeljack/lib/MT/App/CMS.pm
r934 r935 98 98 'start_upload' => \&start_upload, 99 99 'upload_file' => \&upload_file, 100 'complete_ upload' => \&complete_upload,100 'complete_insert' => \&complete_insert, 101 101 'start_upload_entry' => \&start_upload_entry, 102 102 'logout' => \&logout, … … 5490 5490 5491 5491 sub asset_insert { 5492 my $app = shift; 5493 defined(my $text = $app->_process_post_upload) or return; 5492 my ($app, %args) = @_; 5493 5494 # Just insert text if there are arguments, unless one is 5495 # 'is_image' otherwise we are definitely uploading. 5496 my $text = !keys %args || $args{is_image} 5497 ? $app->_process_post_upload() 5498 : $app->asset_insert_text($args{asset_id}); 5499 return unless defined $text; 5500 5494 5501 $app->build_page('asset_insert.tmpl', { 5495 5502 upload_html => $text, … … 5686 5693 } 5687 5694 } 5695 5688 5696 return $app->asset_insert_text(); 5689 5697 } … … 5692 5700 my $app = shift; 5693 5701 my $q = $app->param; 5702 my $id = shift || $q->param('id'); 5694 5703 require MT::Asset; 5695 my $asset = MT::Asset->load($ q->param('id')) ||5696 return $app->errtrans("Can't load asset, ". $q->param('id') .'.');5704 my $asset = MT::Asset->load($id) || 5705 return $app->errtrans("Can't load asset, $id."); 5697 5706 my $text = $asset->as_html($q); 5698 5707 return $q->param('popup') || $q->param('link') … … 9193 9202 } 9194 9203 9195 sub complete_ upload{9204 sub complete_insert { 9196 9205 my ($app, %args) = @_; 9197 9206 … … 9213 9222 return $app->errtrans('No permissions'); 9214 9223 9215 my %param = (9216 asset_id => $asset->id,9217 bytes => $args{bytes},9218 direct_asset_insert => scalar $app->param('direct_asset_insert'),9219 edit_field => scalar $app->param('edit_field'),9220 entry_insert => scalar $app->param('entry_insert'),9221 fname => $asset->file_name,9222 height => $asset->image_height,9223 is_image => $args{is_image},9224 site_path => scalar $app->param('site_path'),9225 url => $asset->url,9226 width => $asset->image_width,9227 );9228 9229 9224 if ($args{is_image}) { 9225 my $param = { 9226 asset_id => $asset->id, 9227 bytes => $args{bytes}, 9228 direct_asset_insert => scalar $app->param('direct_asset_insert'), 9229 edit_field => scalar $app->param('edit_field'), 9230 entry_insert => scalar $app->param('entry_insert'), 9231 fname => $asset->file_name, 9232 height => $asset->image_height, 9233 is_image => $args{is_image}, 9234 site_path => scalar $app->param('site_path'), 9235 url => $asset->url, 9236 width => $asset->image_width, 9237 }; 9238 9230 9239 eval { require MT::Image; MT::Image->new or die; }; 9231 $param{do_thumb} = $@ ? 0 : 1; 9232 $param{can_save_image_defaults} = $perms->can_save_image_defaults ? 1 : 0; 9233 $param{constrain} = $blog->image_default_constrain ? 1 : 0; 9234 $param{popup_image} = $blog->image_default_popup ? 1 : 0; 9235 $param{image_defaults} = $blog->image_default_set ? 1 : 0; 9236 $param{wrap_text} = $blog->image_default_wrap_text ? 1 : 0; 9237 $param{make_thumb} = $blog->image_default_thumb ? 1 : 0; 9238 $param{'align_'.$_} = $blog->image_default_align eq $_ ? 1 : 0 for qw(left center right); 9239 $param{'unit_w'.$_} = $blog->image_default_wunits eq $_ ? 1 : 0 for qw(percent pixels); 9240 $param{'unit_h'.$_} = $blog->image_default_hunits eq $_ ? 1 : 0 for qw(percent pixels); 9241 $param{thumb_width} = $blog->image_default_width || $asset->image_width || 0; 9242 $param{thumb_height} = $blog->image_default_height || $asset->image_height || 0; 9243 } 9244 9245 $app->build_page('upload_complete.tmpl', \%param); 9240 $param->{do_thumb} = $@ ? 0 : 1; 9241 9242 $param->{can_save_image_defaults} = $perms->can_save_image_defaults ? 1 : 0; 9243 $param->{constrain} = $blog->image_default_constrain ? 1 : 0; 9244 $param->{popup} = $blog->image_default_popup ? 1 : 0; 9245 $param->{image_defaults} = $blog->image_default_set ? 1 : 0; 9246 $param->{wrap_text} = $blog->image_default_wrap_text ? 1 : 0; 9247 $param->{make_thumb} = $blog->image_default_thumb ? 1 : 0; 9248 $param->{'align_'.$_} = $blog->image_default_align eq $_ ? 1 : 0 for qw(left center right); 9249 $param->{'unit_w'.$_} = $blog->image_default_wunits eq $_ ? 1 : 0 for qw(percent pixels); 9250 $param->{'unit_h'.$_} = $blog->image_default_hunits eq $_ ? 1 : 0 for qw(percent pixels); 9251 $param->{thumb_width} = $blog->image_default_width || $asset->image_width || 0; 9252 $param->{thumb_height} = $blog->image_default_height || $asset->image_height || 0; 9253 9254 $app->build_page('upload_complete.tmpl', $param); 9255 } 9256 else { 9257 $app->asset_insert( 9258 asset_id => $asset->id, 9259 is_image => $args{is_image}, 9260 ); 9261 } 9246 9262 } 9247 9263 … … 9486 9502 } 9487 9503 9488 $app->complete_ upload(9504 $app->complete_insert( 9489 9505 asset => $asset, 9490 9506 blog => $blog, … … 12686 12702 =item * upload_file 12687 12703 12688 =item * complete_ upload12704 =item * complete_insert 12689 12705 12690 12706 =item * view_log branches/wheeljack/lib/MT/Asset.pm
r910 r935 257 257 } 258 258 259 sub as_html { 260 my ($self, $q) = @_; 261 (my $fname = $self->file_name) =~ s/'/\\'/g; 262 my $text = sprintf '<a href="%s">%s</a>', $self->url, $fname; 263 return $text; 264 } 265 259 266 1; 260 267 branches/wheeljack/tmpl/cms/dialog_list_assets.tmpl
r928 r935 49 49 <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> 50 50 51 <span class="modal_added"><MT_TRANS phrase="Select the image you wantto insert, or upload a new one."></span>51 <span class="modal_added"><MT_TRANS phrase="Select the asset you would like to insert, or upload a new one."></span> 52 52 53 53 <p class="page-desc"> … … 64 64 <TMPL_IF NAME=OBJECT_LOOP><TMPL_UNLESS NAME=JSON> 65 65 <form method="post" action="<TMPL_VAR NAME=SCRIPT_URL>" name="select_asset"> 66 <input type="hidden" name="__mode" value="complete_ upload" />66 <input type="hidden" name="__mode" value="complete_insert" /> 67 67 <input type="hidden" name="_type" value="asset" /> 68 68 <input type="hidden" name="return_args" value="<TMPL_VAR NAME=RETURN_ARGS ESCAPE=HTML>" /> branches/wheeljack/tmpl/cms/edit_entry.tmpl
r932 r935 548 548 write('<img title="|" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/separator.gif" alt="|" width="7" height="19" />'); 549 549 write('<img title="<MT_TRANS phrase="Insert Image" escape=singlequotes">" onclick="fixDialog(); openDialog(document.entry_form, \'list_assets\', \'_type=asset&edit_field=text&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&filter=class&filter_val=image&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/add_image.gif" alt="<MT_TRANS phrase="Insert Image" escape="singlequotes">" width="26" height="19" />'); 550 write('<img title="<MT_TRANS phrase="Insert File" escape=singlequotes">" onclick="fixDialog(); openDialog(document.entry_form, \'list_assets\', \'_type=asset&edit_field=text&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&filter=class&filter_val=file&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/upload_file.gif" alt="<MT_TRANS phrase="Insert File" escape="singlequotes">" width="26" height="19" />'); 550 551 } 551 552 } … … 591 592 write('<img title="<MT_TRANS phrase="Quote">" onclick="return formatStr(document.entry_form.text_more, \'blockquote\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/quote.gif" alt="<MT_TRANS phrase="Quote">" width="26" height="19" />'); 592 593 write('<img title="|" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/separator.gif" alt="|" width="7" height="19" />'); 593 write('<img title="<MT_TRANS phrase="Insert Image" escape=singlequotes">" onclick="fixDialog(); openDialog(document.entry_form, \'list_assets\', \'_type=asset&edit_field=text&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&filter=class&filter_val=image&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/add_image.gif" alt="<MT_TRANS phrase="Insert Image" escape="singlequotes">" width="26" height="19" />'); 594 write('<img title="<MT_TRANS phrase="Insert Image" escape=singlequotes">" onclick="fixDialog(); openDialog(document.entry_form, \'list_assets\', \'_type=asset&edit_field=text_more&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&filter=class&filter_val=image&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/add_image.gif" alt="<MT_TRANS phrase="Insert Image" escape="singlequotes">" width="26" height="19" />'); 595 write('<img title="<MT_TRANS phrase="Insert File" escape=singlequotes">" onclick="fixDialog(); openDialog(document.entry_form, \'list_assets\', \'_type=asset&edit_field=text_more&blog_id=<TMPL_VAR NAME=BLOG_ID>&dialog_view=1&filter=class&filter_val=file&return_args=<TMPL_VAR NAME=RETURN_ARGS ESCAPE=URL>\')" src="<TMPL_VAR NAME=STATIC_URI>images/formatting-icons/upload_file.gif" alt="<MT_TRANS phrase="Insert File" escape="singlequotes">" width="26" height="19" />'); 594 596 } 595 597 } branches/wheeljack/tmpl/cms/upload_complete.tmpl
r928 r935 157 157 </TMPL_IF> 158 158 159 <p><input type="checkbox" name="popup" value="1" /> <MT_TRANS phrase="Link image to full-size version in a popup window."></p>159 <p><input type="checkbox" name="popup" value="1" <TMPL_IF NAME=POPUP>checked="checked" </TMPL_IF>/> <MT_TRANS phrase="Link image to full-size version in a popup window."></p> 160 160 <TMPL_IF NAME=CAN_SAVE_IMAGE_DEFAULTS> 161 161 <p><input type="checkbox" name="image_defaults" value="1" <TMPL_IF NAME=IMAGE_DEFAULTS>checked="checked" </TMPL_IF>/> <MT_TRANS phrase="Remember these settings"></p>
