WackoWiki: Handler: sendpage

https://wackowiki.org/doc     Version: 22 (12.02.2024 12:09)

Handler: sendpage

1,941


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

sendpage.php

handler/page/sendpage.php[link2]
<?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('', $tag, null, null, null, null, true, true) . "\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[link3]
[ === 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/custom.<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',	


[xyz] proposed translations
[el]

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

3. To Do

4. Changelog


Referring pages:

  1. Dev/PatchesHacks[link4]