Handler: sendpage



bugs: NONE !!!
Compatible with: R5.x
Current version: 5.5
Credits: Evaggelos Balaskas

sendpage.php


Your wackowiki /handlers/page/sendpage.php



<?php

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

?>
<div class="page">
<?php

if ( $this->has_access('write') && $this->has_access('read') )
{
    if (!
$this->page)
    {
        echo 
str_replace('%1'$this->href('edit'), $this->_t('DoesNotExists'));
    }
    else
    {
        if (!empty(
$_POST['email']))
        {
            
$email        $_POST['email'];

            
// check form token
            
if (!$this->validate_form_token('send_page'))
            {
                
$this->show_message($this->_t('FormInvalid'));
            }
            else if (!
$this->validate_email($email))
            {
                
$this->show_message($this->_t('NotAEmail'));
            }
            else
            {
                
$url        $this->config['base_url'].$this->tag;
                
$subject    $url;
                
$user        $this->get_user();
                
$message    $this->_t('EmailSubject') . $user['user_name'] ." - ".$user['email']."\r\n<br>";
                
$message    .= $data $this->format($this->page['body'], 'wiki');

                
$this->send_mail($email$subject$message);
                
$this->set_message($this->_t('SendPage').'');
                
$this->redirect($this->href(''$this->tag));
            }
        }
        else
        {
?>
  <h2><?php echo $this->_t('EmailPage'); ?></h2>
<?php     echo $this->form_open('send_page''sendpage'''true); ?>
      <p><?php echo $this->_t('WriteEmail'); ?></p>
      <input type="email" name="email" size="25" maxlength="50">
      <input type="submit" value="Send">
    <?php    echo $this->form_close(); ?>
  <p> </p>
<?php
        
echo $data $this->format($this->page['body'], 'wiki');
        }
    }
}
else
{
    
$message $this->_t('ReadAccessDenied');
    
$this->show_message($message'info');
}
?>
</div>

1. Documentation


Just copy the above code to your wackowiki under handlers/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.xyz.php

// sendpage handler
'EmailPage' => 'Send this page via email!',
'WriteEmail' => 'Write email address',
'BadEmail' => 'No valid email address',
'ReturnToPage' => 'Return',
'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' => "Εισάγετε την ηλεκτρονική διεύθυνση αποστολής",
'BadEmail' => "Η ηλεκτρονική διεύθυνση που έχετε εισάγει για την αποστολή της σελίδας ΔΕΝ είναι έγκυρη",
'ReturnToPage' => "Επιστροφή στην σελίδα",
'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 :)

Referring pages:

Dev/PatchesHacks

Read comment (1 comment)