Changeset 819
- Timestamp:
- 04/18/08 16:18:15 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/extensions/mailer/app/models/mailer_page.rb
r803 r819 2 2 class MailerPage < Page 3 3 TLDS = %w{com org net edu info mil gov biz ws} 4 4 5 5 class MailerTagError < StandardError; end 6 6 … … 15 15 end 16 16 end 17 17 18 18 # Page processing. If the page has posted-back, it will try to deliver the emails 19 19 # and redirect to a different page, if specified. … … 28 28 if form_conf.has_key? :recipients 29 29 if send_mail and form_conf.has_key? :redirect_to 30 response.redirect( form_conf[:redirect_to],"302")30 response.redirect(form_conf[:redirect_to], :status => 302) 31 31 else 32 super(request, response) 32 super(request, response) 33 33 end 34 34 else … … 45 45 false 46 46 end 47 47 48 48 # Mailer Tags: 49 49 50 50 desc %{ All mailer-related tags live inside this one. } 51 51 tag "mailer" do |tag| 52 52 tag.expand 53 53 end 54 54 55 55 desc %{ 56 56 Generates a form for submitting email. The 'name' attribute is required … … 79 79 raise_error_if_name_missing "mailer:#{type}" unless %(submit reset).include? type 80 80 input_tag_html( type ) 81 end 81 end 82 82 end 83 83 … … 105 105 results << "</textarea>" 106 106 end 107 107 108 108 %{ 109 109 Renders a series of @<input type="radio" .../>@ tags for a mailer form. The 'name' attribute is required. … … 117 117 end 118 118 119 desc %{ Renders an @<option/>@ tag if the parent is a 120 @<r:mailer:select>...</r:mailer:select>@ tag, an @<input type="radio"/>@ tag if 119 desc %{ Renders an @<option/>@ tag if the parent is a 120 @<r:mailer:select>...</r:mailer:select>@ tag, an @<input type="radio"/>@ tag if 121 121 the parent is a @<r:mailer:radiogroup>...</r:mailer:radiogroup>@ } 122 122 tag 'mailer:option' do |tag| … … 165 165 </script> 166 166 } 167 end 168 end 169 end 170 167 end 168 end 169 end 170 171 171 tag "mailer:email_option:label" do |tag| 172 172 tag.locals.params['label'] = tag.expand.strip 173 173 end 174 174 175 175 tag "mailer:email_option:address" do |tag| 176 176 tag.locals.params['address'] = tag.expand.strip 177 177 end 178 179 180 desc %{ 181 Renders the value of a datum submitted via a mailer form. Used in the 'email', 'email_html', and 178 179 180 desc %{ 181 Renders the value of a datum submitted via a mailer form. Used in the 'email', 'email_html', and 182 182 'config' parts to generate the resulting email. } 183 183 tag 'mailer:get' do |tag| … … 188 188 form_data.to_hash.to_yaml.to_s 189 189 end 190 end 190 end 191 191 192 192 protected … … 199 199 results << "#{add_attrs_to("", options)}/>" 200 200 end 201 201 202 202 def add_attrs_to(results, tag_attrs=tag_attr) 203 203 # Well, turns out I stringify the keys so I can sort them so I can test the tag output … … 207 207 results 208 208 end 209 209 210 210 # Get the default css class based on type 211 211 def get_class_name(type, class_name=nil) … … 216 216 class_name 217 217 end 218 218 219 219 # Raises a 'name missing' tag error 220 220 def raise_name_error(tag_name) … … 224 224 raise_name_error( tag_name ) if tag_attr[:name].nil? or tag_attr[:name].empty? 225 225 end 226 226 227 227 # Does the work of actually sending the emails 228 228 def send_mail() … … 254 254 @headers = options[:headers] || {} 255 255 @charset = options[:charset] || "utf-8" 256 @content_type = "multipart/alternative" 256 @content_type = "multipart/alternative" 257 257 if options.has_key? :plain_body 258 258 part :content_type => "text/plain", :body => (options[:plain_body] || "") … … 260 260 if options.has_key? :html_body and !options[:html_body].blank? 261 261 part :content_type => "text/html", :body => (options[:html_body] || "") 262 end 262 end 263 263 end 264 264 CODE
