From df608980e5897937d883cba402f660400d2e83cf Mon Sep 17 00:00:00 2001 From: Douglas Black Date: Fri, 6 Jul 2018 13:07:29 -0400 Subject: [PATCH] Doing all the porting --- addon.setup.php | 14 +++ config.php | 4 - pi.email_from_template.php | 169 +++++++++++-------------------------- readme.md | 39 +++++++++ 4 files changed, 104 insertions(+), 122 deletions(-) create mode 100644 addon.setup.php delete mode 100644 config.php create mode 100644 readme.md diff --git a/addon.setup.php b/addon.setup.php new file mode 100644 index 0000000..9980cc1 --- /dev/null +++ b/addon.setup.php @@ -0,0 +1,14 @@ + 'Doug Black', + 'author_url' => 'https://github.com/dougblackjr', + 'docs_url' => 'https://github.com/dougblackjr/Email-From-Template', + 'name' => 'RogEE Email-from-Template', + 'description' => 'Add json-ld data to entry', + 'version' => '2.0.0', + 'namespace' => 'Email_from_template', + 'settings_exist' => TRUE +); + +/* End of file addon.setup.php */ \ No newline at end of file diff --git a/config.php b/config.php deleted file mode 100644 index e834b4e..0000000 --- a/config.php +++ /dev/null @@ -1,4 +0,0 @@ - "RogEE Email-from-Template", - 'pi_version' => "1.5.0", - 'pi_author' => "Michael Rog", - 'pi_author_url' => "http://michaelrog.com/ee", - 'pi_description' => "Emails enclosed contents to a provided email address.", - 'pi_usage' => Email_from_template::usage() -); - /** --------------------------------------- /** Email_from_template class /** ---------------------------------------*/ @@ -38,42 +29,39 @@ class Email_from_template { function Email_from_template($str = '') { - $this->EE =& get_instance() ; - - // defaults - - $this->to = $this->EE->config->item('webmaster_email'); + // defaults + $this->to = ee()->config->item('webmaster_email'); $this->cc = ""; $this->bcc = ""; - $this->from = $this->EE->config->item('webmaster_email'); - $this->subject = "Email-from-Template: ".$this->EE->uri->uri_string(); + $this->from = ee()->config->item('webmaster_email'); + $this->subject = "Email-from-Template: ".ee()->uri->uri_string(); $this->echo_tagdata = TRUE; $this->append_debug = FALSE; // params: fetch / sanitize / validate - $mailtype = (($mailtype = $this->EE->TMPL->fetch_param('mailtype')) == "html") ? "html" : "text"; + $mailtype = (($mailtype = ee()->TMPL->fetch_param('mailtype')) == "html") ? "html" : "text"; - $from = (($from = $this->EE->TMPL->fetch_param('from')) === FALSE) ? $this->from : $this->EE->security->xss_clean($from); - $to = (($to = $this->EE->TMPL->fetch_param('to')) === FALSE) ? $this->to : $this->EE->security->xss_clean($to); - $cc = (($cc = $this->EE->TMPL->fetch_param('cc')) === FALSE) ? FALSE : $this->EE->security->xss_clean($cc); - $bcc = (($bcc = $this->EE->TMPL->fetch_param('bcc')) === FALSE) ? FALSE : $this->EE->security->xss_clean($bcc); + $from = (($from = ee()->TMPL->fetch_param('from')) === FALSE) ? $this->from : ee()->security->xss_clean($from); + $to = (($to = ee()->TMPL->fetch_param('to')) === FALSE) ? $this->to : ee()->security->xss_clean($to); + $cc = (($cc = ee()->TMPL->fetch_param('cc')) === FALSE) ? FALSE : ee()->security->xss_clean($cc); + $bcc = (($bcc = ee()->TMPL->fetch_param('bcc')) === FALSE) ? FALSE : ee()->security->xss_clean($bcc); - $subject = (($subject = $this->EE->TMPL->fetch_param('subject')) === FALSE) ? $this->subject : $subject; - $alt_message = (($alt_message = $this->EE->TMPL->fetch_param('alt_message')) === FALSE) ? FALSE : $this->EE->security->xss_clean($alt_message); + $subject = (($subject = ee()->TMPL->fetch_param('subject')) === FALSE) ? $this->subject : $subject; + $alt_message = (($alt_message = ee()->TMPL->fetch_param('alt_message')) === FALSE) ? FALSE : ee()->security->xss_clean($alt_message); - $decode_subject_entities = (strtolower($this->EE->TMPL->fetch_param('decode_subject_entities')) == "no") ? FALSE : TRUE ; - $decode_message_entities = (strtolower($this->EE->TMPL->fetch_param('decode_message_entities')) == "no") ? FALSE : TRUE ; + $decode_subject_entities = (strtolower(ee()->TMPL->fetch_param('decode_subject_entities')) == "no") ? FALSE : TRUE ; + $decode_message_entities = (strtolower(ee()->TMPL->fetch_param('decode_message_entities')) == "no") ? FALSE : TRUE ; - $attachments = (($attachments = $this->EE->TMPL->fetch_param('attachments')) === FALSE) ? FALSE : $this->EE->security->xss_clean($attachments); + $attachments = (($attachments = ee()->TMPL->fetch_param('attachments')) === FALSE) ? FALSE : ee()->security->xss_clean($attachments); - $echo_tagdata = (strtolower($this->EE->TMPL->fetch_param('echo')) == "no" || strtolower($this->EE->TMPL->fetch_param('echo')) == "off") ? FALSE : TRUE ; + $echo_tagdata = (strtolower(ee()->TMPL->fetch_param('echo')) == "no" || strtolower(ee()->TMPL->fetch_param('echo')) == "off") ? FALSE : TRUE ; // fetch tag data if ($str == '') { - $str = $this->EE->TMPL->tagdata ; + $str = ee()->TMPL->tagdata ; } $tagdata = $str; @@ -88,86 +76,86 @@ function Email_from_template($str = '') 'cc' => $cc, 'bcc' => $bcc, 'subject' => $subject, - 'ip' => $this->EE->input->ip_address(), - 'httpagent' => $this->EE->input->user_agent(), - 'uri_string' => $this->EE->uri->uri_string() + 'ip' => ee()->input->ip_address(), + 'httpagent' => ee()->input->user_agent(), + 'uri_string' => ee()->uri->uri_string() ); $variables[] = $single_variables; - $message = $this->EE->TMPL->parse_variables($tagdata, $variables) ; + $message = ee()->TMPL->parse_variables($tagdata, $variables) ; // parse global variables - $subject = $this->EE->TMPL->parse_globals($subject); - $message = $this->EE->TMPL->parse_globals($message); + $subject = ee()->TMPL->parse_globals($subject); + $message = ee()->TMPL->parse_globals($message); // decode HTML entities if ($decode_subject_entities) { - $this->EE->TMPL->log_item('Decoding HTML entities in subject...'); + ee()->TMPL->log_item('Decoding HTML entities in subject...'); $subject = $decode_subject_entities ? html_entity_decode($subject) : $subject; } if ($decode_message_entities) { - $this->EE->TMPL->log_item('Decoding HTML entities in message...'); + ee()->TMPL->log_item('Decoding HTML entities in message...'); $message = $decode_message_entities ? html_entity_decode($message) : $message; } // mail the message - $this->EE->TMPL->log_item('Sending email from template...'); + ee()->TMPL->log_item('Sending email from template...'); - $this->EE->load->library('email'); - $this->EE->email->initialize() ; + ee()->load->library('email'); + ee()->email->initialize() ; - $this->EE->TMPL->log_item('MAILTYPE: ' . $mailtype); - $this->EE->email->mailtype = $mailtype; + ee()->TMPL->log_item('MAILTYPE: ' . $mailtype); + ee()->email->mailtype = $mailtype; - $this->EE->TMPL->log_item('FROM: ' . $from); - $this->EE->email->from($from); + ee()->TMPL->log_item('FROM: ' . $from); + ee()->email->from($from); - $this->EE->TMPL->log_item('TO: ' . $to); - $this->EE->email->to($to); + ee()->TMPL->log_item('TO: ' . $to); + ee()->email->to($to); - $this->EE->TMPL->log_item('CC: ' . ($cc ? $cc : '(none)')); - $this->EE->email->cc($cc); + ee()->TMPL->log_item('CC: ' . ($cc ? $cc : '(none)')); + ee()->email->cc($cc); - $this->EE->TMPL->log_item('BCC: ' . ($bcc ? $bcc : '(none)')); - $this->EE->email->bcc($bcc); + ee()->TMPL->log_item('BCC: ' . ($bcc ? $bcc : '(none)')); + ee()->email->bcc($bcc); - $this->EE->TMPL->log_item('SUBJECT: ' . $subject); - $this->EE->email->subject($subject); + ee()->TMPL->log_item('SUBJECT: ' . $subject); + ee()->email->subject($subject); - $this->EE->email->message($message); + ee()->email->message($message); if ($alt_message !== FALSE) { - $this->EE->email->set_alt_message($alt_message); + ee()->email->set_alt_message($alt_message); } if ($attachments !== FALSE) { - $this->EE->TMPL->log_item('Adding attachemnts...'); + ee()->TMPL->log_item('Adding attachemnts...'); $attachments_array = explode(",", $attachments); foreach($attachments_array as $attachment_path) { - $this->EE->TMPL->log_item('Attachment: '.$attachment_path); - $this->EE->email->attach($attachment_path); + ee()->TMPL->log_item('Attachment: '.$attachment_path); + ee()->email->attach($attachment_path); } } - $this->EE->email->Send(); + ee()->email->Send(); // more template debugging - $this->EE->TMPL->log_item('Email sent!'); + ee()->TMPL->log_item('Email sent!'); - if (! $echo_tagdata) { $this->EE->TMPL->log_item('Echo is off. Outputting nothing to template.'); } - else { $this->EE->TMPL->log_item('Echo is on. Repeating message to template.'); } + if (! $echo_tagdata) { ee()->TMPL->log_item('Echo is off. Outputting nothing to template.'); } + else { ee()->TMPL->log_item('Echo is on. Repeating message to template.'); } // return data to template @@ -175,67 +163,12 @@ function Email_from_template($str = '') if ($this->append_debug) { - $this->return_data .= "


".$this->EE->email->print_debugger(); + $this->return_data .= "


".ee()->email->print_debugger(); } - } // END Email_from_template() constructor + } - /** ---------------------------------------- - /** Plugin Usage - /** ----------------------------------------*/ - - function usage() - { - - ob_start(); - ?> - - This plugin emails the enclosed content to a provided email address. - - PARAMETERS: - - from - sender email address (default: site webmaster) - to - destination email address (default: site webmaster) - cc - email addresses to carbon copy - bcc - email addresses to blind carbon copy - subject - email subject line (default: template URI) - mailtype - "text" or "html" - alt_message - a plain-text fallback for use with HTML emails - decode_subject_entities - Set to "no" if you don't want to parse the HTML entities in the subject line. - decode_message_entities - Set to "no" if you don't want to parse the HTML entities in the message text. - echo - Set to "off" if you don't want to display the tag contents in the template. - - VARIABLES: - - {to} - {from} - {subject} - {ip} - {httpagent} - {uri_string} - - EXAMPLE USAGE: - - {exp:email_from_template to="admin@ee.com" from="server@ee.com" subject="Hello!" echo="off"} - - This tag content is being viewed at {uri_string}. Sending notification to {to}! - - {/exp:email_from_template} - - USING WITH OTHER PLUGINS AND TAGS: - - When you want to email the output of other tags, put Email_from_Template INSIDE the other tag and use parse="inward" on the outer tags. - -