/** * Retrieve and set the message preview for display. * * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview. * @return void */ public function _preview_message($send = FALSE) { //first make sure we've got the necessary parameters if (!isset($this->_req_data['message_type']) || !isset($this->_req_data['messenger']) || !isset($this->_req_data['messenger']) || !isset($this->_req_data['GRP_ID'])) { EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); } EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']); $MSG = new EE_messages(); //get the preview! $preview = $MSG->preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send); if ($send) { return $preview; } //let's add a button to go back to the edit view $query_args = array('id' => $this->_req_data['GRP_ID'], 'context' => $this->_req_data['context'], 'action' => 'edit_message_template'); $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>'; //let's provide a helpful title for context $preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular'])); //setup display of preview. $this->_admin_page_title = $preview_title; $this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview); $this->_template_args['data']['force_json'] = TRUE; }