Difference between revisions of "Email-article.php"
(updated - work done for div0) |
|||
Line 9: | Line 9: | ||
# If mail not sent but we have details, prepare for sending on view event | # If mail not sent but we have details, prepare for sending on view event | ||
xwSetProperty($properties, 'xpath:/properties:view', 'class.phpmailer.php'); | xwSetProperty($properties, 'xpath:/properties:view', 'class.phpmailer.php'); | ||
− | xwSetProperty($properties, 'xpath:/properties:view | + | xwSetProperty($properties, 'xpath:/properties:view', $tTitle); |
# Tells skin not to wrap site-template around article | # Tells skin not to wrap site-template around article | ||
Line 34: | Line 34: | ||
$utitle = urlencode($title); | $utitle = urlencode($title); | ||
xwGetProperty($properties, 'sendarticle/msg', $msg); | xwGetProperty($properties, 'sendarticle/msg', $msg); | ||
− | $msg = htmlentities($msg)."<br>Article source : <a href=\"$script/$utitle\">$script/$utitle</a>"; | + | xwGetProperty($properties, 'sendarticle/textonly', $textonly); |
− | + | if ($textonly) { | |
+ | $html = false; | ||
+ | if (ereg('<!-- start content -->(.+)<div class="printfooter">', $article, $m)) $article = $m[1]; | ||
+ | } | ||
+ | else { | ||
+ | $html = true; | ||
+ | $msg = htmlentities($msg)."<br>Article source : <a href=\"$script/$utitle\">$script/$utitle</a>"; | ||
+ | $article = str_replace($GLOBALS['xwMsgToken'], "$msg<br><hr><br>", $article); | ||
− | + | # Replace stylesheet-token with embedded stylesheets | |
− | + | xwReplaceTokens($article, true); | |
− | + | # Absoluterise relative urls Absolute url of wiki | |
− | + | $article = str_replace('"/wiki/', '"http://'.$_SERVER['HTTP_HOST'].'/wiki/', $article); | |
+ | } | ||
# Set up new mailer instance | # Set up new mailer instance | ||
Line 47: | Line 55: | ||
$mail->From = $GLOBALS['wgUser']->mEmail; | $mail->From = $GLOBALS['wgUser']->mEmail; | ||
$mail->FromName = $GLOBALS['xwUserName']; | $mail->FromName = $GLOBALS['xwUserName']; | ||
− | $mail->IsHTML( | + | $mail->IsHTML($html); |
− | $mail->AddAddress( | + | $mail->AddAddress($GLOBALS['sa-email']); |
$mail->Subject = $title; | $mail->Subject = $title; | ||
$mail->Body = $article; | $mail->Body = $article; | ||
Line 54: | Line 62: | ||
# Send message and redirect client back to article or raise error | # Send message and redirect client back to article or raise error | ||
if ($mail->Send()) { | if ($mail->Send()) { | ||
− | header("Location: $script?title=$utitle&xpath:/properties:data=$tTitle&xpath:/properties:sendarticle&xpath:/properties/sendarticle:sent=$email | + | header("Location: $script?title=$utitle&xpath:/properties:data=$tTitle&xpath:/properties:sendarticle&xpath:/properties/sendarticle:sent=".$GLOBALS['sa-email']); |
} else xwMessage($mail->ErrorInfo,'red'); | } else xwMessage($mail->ErrorInfo,'red'); | ||
} | } | ||
?> | ?> |
Revision as of 00:19, 3 December 2005
<? if ($event == 'data') {
if (xwGetProperty($properties, 'sendarticle/sent', $sent)) xwMessage("This article has been sent to $sent",'green');
elseif (xwGetProperty($properties, 'sendarticle/to', $GLOBALS['sa-email'])) {
# If mail not sent but we have details, prepare for sending on view event xwSetProperty($properties, 'xpath:/properties:view', 'class.phpmailer.php'); xwSetProperty($properties, 'xpath:/properties:view', $tTitle);
# Tells skin not to wrap site-template around article $GLOBALS['xwRaw'] = true; }
else {
# Not sent and no details either, render input form
xwSetProperty($properties, 'language', 'raw');
$article = "<form action=\"$script\">
<input type=hidden name=title value=\"$title\">
<input type=hidden name=xpath:/properties:data value=\"$tTitle\">
<input type=hidden name=xpath:/properties:sendarticle>
Email Address: <input type=text name=xpath:/properties/sendarticle:to size=30>
<input type=submit value=\" Send \">
You can also include a message before the article here if you like:
<textarea name=xpath:/properties/sendarticle:msg rows=10 cols=50></textarea> </form>";
} } else { # Replace msg-token with user article url and msg $utitle = urlencode($title); xwGetProperty($properties, 'sendarticle/msg', $msg); xwGetProperty($properties, 'sendarticle/textonly', $textonly); if ($textonly) { $html = false;
if (ereg('(.+)