Handler: sendpage

1,701

Compatible with: R6.0
Current version: 0.4
Credits: Evaggelos Balaskas

sendpage.php


handler/page/sendpage.php


<?php

if (!defined('IN_WACKO'))
{
    exit;
}

if (!
$this->page)
{
    
$this->http->redirect($this->href());
}

if (
$this->has_access('write'))
{
    if (!empty(
$_POST['email']))
    {
        
$email_to        $_POST['email'];

        if (!
$this->validate_email_address($email_to))
        {
            
$tpl->message $this->show_message($this->_t('NotAEmail'), 'error'false);
        }
        else
        {
            
$subject    $this->page['title'];
            
$user        $this->get_user();
            
$message    =
                            
$this->_t('EmailSubject') . $user['user_name'] . ' - ' /* $user['email']  .*/ "\n\n" .

                            
$this->href(''$tagnullnullnullnulltruetrue) . "\n\n" .
                            
$this->page['title'] . "\n" .
                            
"----------------------------------------------------------------------\n\n" .
                            
Ut::amp_decode($this->page['body']) . "\n\n" .
                            
"----------------------------------------------------------------------\n\n" .

                            
$this->_t('EmailDoNotReply') . "\n\n" .
                            
$this->db->site_name "\n" .
                            
$this->db->base_url;

            
$email = new Email($this);
            
$email->send_mail($email_to$email_to$subject$message);

            
$this->set_message($this->_t('SendPage'));

            
$this->http->redirect($this->href());
        }
    }
    else
    {
        
#$tpl->data = $this->format($this->page['body'], 'wiki');
        
$tpl->data $this->format($this->page['body'], 'source'); // -> [ ' data | pre ' ]
    
}
}
else
{
    
$this->http->redirect($this->href());
}

handler/page/template/sendpage.tpl

[ === main === ]
	[ ' dummy | default * // ADD_NO_DIV ' ]<div id="page" class="page">
		[ ' message ' ]
		<h3>[ ' _t: EmailPage ' ]</h3>
		<br>
		<form action="[ ' href: sendpage ' ]" method="post" name="send_page">
			[ ' csrf: send_page ' ]
			<label for="email_recipient">[ ' _t: WriteEmail ' ]:</label><br>
			<input type="email" id="email_recipient" name="email" size="60" maxlength="255">
			<button type="submit" id="submit_sendpage">[ ' _t: SendButton ' ]</button>
		</form>
		[ ' data | pre ' ]
	</div>	

1. Documentation


Just copy the above code to your WackoWiki under handler/page/sendpage.php
and add the below language variables/values to your wacko.xy.php with your translation.

2. How to


If you want to send a page to someone via email just type: /sendpage to your url
eg. http://ebalaskas.gr/wiki/HomePage/sendpage


ATTENTION You must have write permissions to a page - this is for security reasons -ANTISPAM protection.

2.1. Localization

put this at the end of your language file


/lang/wacko.<lang>.php

// sendpage handler
'EmailPage' => 'Send this page via email!',
'WriteEmail' => 'Write email address',
'EmailSubject' => 'You receive this page from: ',
'SendPage' => 'The page has been sent.<br>If for any reason the page wasnt delivered, please contact with your wackowiki administrator',	

pls. notice that this entry will not survive an Wacko upgrade, so you have to redo this


[xyz] proposed translations
[el]


// sendpage handler
'EmailPage' => "Αποστολή αυτής της σελίδας μέσω ηλεκτρονικού ταχυδρομείου!",
'WriteEmail' => "Εισάγετε την ηλεκτρονική διεύθυνση αποστολής",
'EmailSubject' => "Παραλάβατε αυτή την σελίδα από τον: ",
'SendPage' => "Η αποστολή της σελίδας πραγματοποιήθηκε.<br>Εάν για κάποιο λόγο δεν παραδόθηκε, επικοινωνήστε με τον διαχειριστή",	

3. To Do

  • To find a small email icon
  • convince the core developers that this is a beautiful idea and modify the first page to add this handler next to print with a nice description :)
  • add option for HTML email (?)
  • add recipient name to form (?)
  • safeguard the handler better to avoid misuse

4. Changelog

  • 0.3 - fixed the handler to work with 6.0 and the template engine
  • 0.4 - minor bug fixes

Referring pages:

  1. Dev/PatchesHacks