Changeset 766
- Timestamp:
- 11/18/06 23:06:44 (2 years ago)
- Files:
-
- branches/wheeljack/lib/MT/App/CMS.pm (modified) (3 diffs)
- branches/wheeljack/lib/MT/Blog.pm (modified) (3 diffs)
- branches/wheeljack/lib/MT/Permission.pm (modified) (1 diff)
- branches/wheeljack/tmpl/cms/upload_complete.tmpl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/wheeljack/lib/MT/App/CMS.pm
r755 r766 5467 5467 my $blog = MT::Blog->load($blog_id, {cached_ok=>1}); 5468 5468 my($thumb, $thumb_width, $thumb_height); 5469 # Save new defaults if requested. 5470 if($q->param('image_defaults')) { 5471 return $app->error($app->translate( 5472 'Permission denied setting image defaults for blog #[_2]', $blog_id 5473 )) unless $app->{perms}->can_save_image_defaults; 5474 $blog->image_default_wrap_text($q->param('wrap_text') ? 1 : 0); 5475 $blog->image_default_align($q->param('align') || MT::Blog::ALIGN()); 5476 $blog->image_default_thumb($q->param('thumb') ? 1 : 0); 5477 $blog->image_default_width($q->param('thumb_width') || MT::Blog::WIDTH()); 5478 $blog->image_default_wunits($q->param('thumb_width_type') || MT::Blog::UNITS()); 5479 $blog->image_default_height($q->param('thumb_height') || MT::Blog::HEIGHT()); 5480 $blog->image_default_hunits($q->param('thumb_height_type') || MT::Blog::UNITS()); 5481 $blog->image_default_constrain($q->param('constrain') ? 1 : 0); 5482 $blog->image_default_popup($q->param('popup') ? 1 : 0); 5483 $blog->save; 5484 } 5469 5485 if ($thumb = $q->param('thumb')) { 5470 5486 require MT::Image; … … 5603 5619 HTML 5604 5620 } elsif ($q->param('include')) { 5605 my $wrap_style = $q->param('wrap_text') && $q->param('align ment')5606 ? 'class="display_img_'. $q->param('align ment') .'" ' : '';5621 my $wrap_style = $q->param('wrap_text') && $q->param('align') 5622 ? 'class="display_img_'. $q->param('align') .'" ' : ''; 5607 5623 if ($thumb) { 5608 5624 return <<"HTML"; … … 9308 9324 eval { require MT::Image; MT::Image->new or die; }; 9309 9325 $param{do_thumb} = !$@ ? 1 : 0; 9326 # Pass image default settings along. 9327 $param{make_thumb} = $blog->image_default_thumb() ? 1 : 0; 9328 $param{wrap_text} = $blog->image_default_wrap_text() ? 1 : 0; 9329 $param{align_left} = $blog->image_default_align() eq 'left' ? 1 : 0; 9330 $param{align_center} = $blog->image_default_align() eq 'center' ? 1 : 0; 9331 $param{align_right} = $blog->image_default_align() eq 'right' ? 1 : 0; 9332 $param{thumb_width} = $blog->image_default_width() || $w; 9333 $param{unit_wpixels} = $blog->image_default_wunits() eq 'pixels' ? 1 : 0; 9334 $param{unit_wpercent} = $blog->image_default_wunits() eq 'percent' ? 1 : 0; 9335 $param{thumb_height} = $blog->image_default_height() || $h; 9336 $param{unit_hpixels} = $blog->image_default_hunits() eq 'pixels' ? 1 : 0; 9337 $param{unit_hpercent} = $blog->image_default_hunits() eq 'percent' ? 1 : 0; 9338 $param{constrain} = $blog->image_default_constrain() ? 1 : 0; 9339 $param{popup_image} = $blog->image_default_popup() ? 1 : 0; 9340 $param{can_save_image_defaults} = $perms->can_save_image_defaults() ? 1 : 0; 9310 9341 MT->run_callbacks('CMSUploadFile', 9311 9342 File => $local_file, Url => $url, Size => $bytes, branches/wheeljack/lib/MT/Blog.pm
r751 r766 74 74 'archive_tmpl_category' => 'string(255)', 75 75 'archive_tmpl_individual' => 'string(255)', 76 'image_default_wrap_text' => 'boolean', 77 'image_default_align' => 'string(10)', 78 'image_default_thumb' => 'boolean', 79 'image_default_width' => 'integer', 80 'image_default_wunits' => 'string(10)', 81 'image_default_height' => 'integer', 82 'image_default_hunits' => 'string(10)', 83 'image_default_constrain' => 'boolean', 84 'image_default_popup' => 'boolean', 76 85 }, 77 86 indexes => { … … 89 98 primary_key => 'id', 90 99 }); 100 101 # Image upload defaults. 102 use constant ALIGN => 'left'; 103 use constant WIDTH => 100; 104 use constant HEIGHT => 100; 105 use constant UNITS => 'pixels'; 91 106 92 107 sub set_defaults { … … 130 145 # something far in the future to force dynamic side to read it. 131 146 $blog->children_modified_on('20101231120000'); 132 $blog; 147 # Image upload default settings. 148 $blog->image_default_wrap_text(0); 149 $blog->image_default_align('left'); 150 $blog->image_default_thumb(0); 151 $blog->image_default_width(0); 152 $blog->image_default_height(0); 153 $blog->image_default_wunits('pixels'); 154 $blog->image_default_hunits('pixels'); 155 $blog->image_default_constrain(1); 156 $blog->image_default_popup(0); 157 158 return $blog; 133 159 } 134 160 branches/wheeljack/lib/MT/Permission.pm
r717 r766 94 94 # 32 is deprecated; reserved for future use 95 95 [ 128, 'rebuild', 'Rebuild Files', 1, 'blog'], 96 # Not a real permission but a denial there eof; unlisted because it96 # Not a real permission but a denial thereof; unlisted because it 97 97 # has no label. 98 98 [ 2048, 'not_comment', '', 1, 'blog'], 99 [ 32768, 'save_image_defaults', '', 1, 'blog'], 99 100 ); 100 101 branches/wheeljack/tmpl/cms/upload_complete.tmpl
r746 r766 15 15 function doHandleMode (f, mode, type) { 16 16 var url = '<TMPL_VAR NAME=SCRIPT_URL>?__mode=' + type; 17 url += '&blog_id=<TMPL_VAR NAME=BLOG_ID>&url=<TMPL_VAR NAME=URL ESCAPE=URL>&site_path=<TMPL_VAR NAME=SITE_PATH>&fname=<TMPL_VAR NAME=FNAME ESCAPE=URL>&' + mode; 17 url += '&blog_id=<TMPL_VAR NAME=BLOG_ID>&url=<TMPL_VAR NAME=URL ESCAPE=URL>&site_path=<TMPL_VAR NAME=SITE_PATH>&fname=<TMPL_VAR NAME=FNAME ESCAPE=URL>'; 18 url += mode; 18 19 <TMPL_IF NAME=DO_THUMB> 19 20 if (f.thumb.checked) 20 url += '&thumb=1&' + calcGeometry(f); 21 url += '&thumb=1' + calcGeometry(f); 22 url += '&thumb_width_type=' + f.thumb_width_type.options[f.thumb_width_type.selectedIndex].value; 23 url += '&thumb_height_type=' + f.thumb_height_type.options[f.thumb_height_type.selectedIndex].value; 24 if (f.constrain.checked) 25 url += '&constrain=1'; 21 26 </TMPL_IF> 22 27 if (f.wrap_text.checked) { 23 url += '&wrap_text=1&align ment=';24 for (i=0; i<f.align ment.length; i++) {25 if (f.align ment[i].checked) {26 url += f.align ment[i].value;28 url += '&wrap_text=1&align='; 29 for (i=0; i<f.align.length; i++) { 30 if (f.align[i].checked) { 31 url += f.align[i].value; 27 32 } 28 33 } 29 34 } 35 if (f.image_defaults.checked) 36 url += '&image_defaults=1'; 30 37 if (type == 'start_upload_entry') { 31 38 window.opener.location = url; … … 42 49 var w = calcDim(f.thumb_width, f.thumb_width_type, f.full_width.value); 43 50 var h = calcDim(f.thumb_height, f.thumb_height_type, f.full_height.value); 44 return 'thumb_width=' + w + '&thumb_height=' + h; 51 var url = '&thumb_width=' + w + '&thumb_height=' + h; 52 return url; 45 53 } 46 54 … … 119 127 <TMPL_IF NAME=IS_IMAGE> 120 128 <p> 121 <input type="checkbox" name="wrap_text" value="1" /> <MT_TRANS phrase="Wrap text">: 122 <input type="radio" name="alignment" value="left" checked="checked" /> <MT_TRANS phrase="Left"> 123 <input type="radio" name="alignment" value="right" /> <MT_TRANS phrase="Right"> 129 <input type="checkbox" name="wrap_text" value="1" <TMPL_IF NAME=WRAP_TEXT>checked="checked"</TMPL_IF>/> 130 <MT_TRANS phrase="Wrap text">: 131 <input type="radio" name="align" value="left" <TMPL_IF NAME=ALIGN_LEFT>checked="checked"</TMPL_IF>/> 132 <MT_TRANS phrase="Left"> 133 <input type="radio" name="align" value="center" <TMPL_IF NAME=ALIGN_CENTER>checked="checked"</TMPL_IF>/> 134 <MT_TRANS phrase="Center"> 135 <input type="radio" name="align" value="right" <TMPL_IF NAME=ALIGN_RIGHT>checked="checked"</TMPL_IF>/> 136 <MT_TRANS phrase="Right"> 124 137 </p> 125 138 </TMPL_IF> … … 128 141 <h4><MT_TRANS phrase="Image Thumbnail"></h4> 129 142 130 <p><label><input type="checkbox" name="thumb" value="1"> <MT_TRANS phrase="Create a thumbnail for this image"></label> <a href="#" onclick="return openManual('file_upload', 'creating_thumbnails')" class="help">?</a></p> 143 <p> 144 <label> 145 <input type="checkbox" name="thumb" value="1" <TMPL_IF NAME=MAKE_THUMB>checked="checked"</TMPL_IF> /> 146 <MT_TRANS phrase="Create a thumbnail for this image"> 147 </label> 148 <a href="#" onclick="return openManual('file_upload', 'creating_thumbnails')" class="help">?</a> 149 </p> 131 150 132 151 <blockquote> … … 134 153 <p> 135 154 <label for="thumb_width"><MT_TRANS phrase="Width:"></label> 136 <input name="thumb_width" id="thumb_width" value="<TMPL_VAR NAME= WIDTH>" onchange="adjustWidthHeight(this.form, 1)" size="4" />155 <input name="thumb_width" id="thumb_width" value="<TMPL_VAR NAME=THUMB_WIDTH>" onchange="adjustWidthHeight(this.form, 1)" size="4" /> 137 156 <select name="thumb_width_type" onchange="adjustPixelsPct(this.form, 1)"> 138 <option value="pixels" selected="selected"><MT_TRANS phrase="Pixels"></option>139 <option value="percent" ><MT_TRANS phrase="Percent"></option>157 <option value="pixels" <TMPL_IF NAME=UNIT_WPIXELS>selected="selected"</TMPL_IF>><MT_TRANS phrase="Pixels"></option> 158 <option value="percent" <TMPL_IF NAME=UNIT_WPERCENT>selected="selected"</TMPL_IF>><MT_TRANS phrase="Percent"></option> 140 159 </select> 141 160 </p> … … 143 162 <p> 144 163 <label for="thumb_height"><MT_TRANS phrase="Height:"></label> 145 <input name="thumb_height" value="<TMPL_VAR NAME= HEIGHT>" onchange="adjustWidthHeight(this.form, 0)" size="4" />164 <input name="thumb_height" value="<TMPL_VAR NAME=THUMB_HEIGHT>" onchange="adjustWidthHeight(this.form, 0)" size="4" /> 146 165 <select name="thumb_height_type" onchange="adjustPixelsPct(this.form, 0)"> 147 <option value="pixels" selected="selected"><MT_TRANS phrase="Pixels"></option>148 <option value="percent" ><MT_TRANS phrase="Percent"></option>166 <option value="pixels" <TMPL_IF NAME=UNIT_HPIXELS>selected="selected"</TMPL_IF>><MT_TRANS phrase="Pixels"></option> 167 <option value="percent" <TMPL_IF NAME=UNIT_HPERCENT>selected="selected"</TMPL_IF>><MT_TRANS phrase="Percent"></option> 149 168 </select> 150 169 </p> 151 170 152 <p><label><input type="checkbox" name="constrain" value="1" checked="checked"> <MT_TRANS phrase="Constrain proportions"></p> 171 <p> 172 <label> 173 <input type="checkbox" name="constrain" value="1" <TMPL_IF NAME=CONSTRAIN>checked="checked"</TMPL_IF>/> 174 <MT_TRANS phrase="Constrain proportions"> 175 </label> 176 </p> 153 177 154 178 </blockquote> 155 179 </TMPL_IF> 156 180 181 <div> 157 182 <p><MT_TRANS phrase="Would you like this file to be a:"></p> 158 159 <div>160 183 <TMPL_IF NAME=IS_IMAGE> 161 <input type="button" onclick="doClick(this.form, ' popup=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Popup Image">" />162 <input type="button" onclick="doClick(this.form, ' include=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Embedded Image">" />184 <input type="button" onclick="doClick(this.form, '&popup=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Popup Image">" /> 185 <input type="button" onclick="doClick(this.form, '&include=1&width=<TMPL_VAR NAME=WIDTH>&height=<TMPL_VAR NAME=HEIGHT>&image_type=<TMPL_VAR NAME=IMAGE_TYPE>')" value="<MT_TRANS phrase="Embedded Image">" /> 163 186 <TMPL_ELSE> 164 <input type="button" onclick="doClick(this.form, ' link=1')" value="<MT_TRANS phrase="Link">" />187 <input type="button" onclick="doClick(this.form, '&link=1')" value="<MT_TRANS phrase="Link">" /> 165 188 </TMPL_IF> 166 189 </div> 167 190 191 <TMPL_IF NAME=CAN_SAVE_IMAGE_DEFAULTS> 192 <p> 193 <label> 194 <input type="checkbox" name="image_defaults" value="1" /> 195 <MT_TRANS phrase="Remember these settings"> 196 </label> 197 </p> 198 </TMPL_IF> 199 168 200 </form> 169 201
