function &buildEditForm($node, $new) { include_once 'HTML/QuickForm.php'; $form =& new HTML_QuickForm('editForm', 'POST'); $form->clearAllTemplates(); $constants['node'] = $node; $defaults['contents'] = Wiki::getNodeContents($node); $form->setConstants($constants); $form->setDefaults($defaults); $form->addData('<table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee">'); $form->addData('<tr><td colspan="2" align="left">Node:'); if ($new) { $form->addElement('text', 'node', null, 'size="60"'); $form->addRule('node', 'Must have a node name', 'required', null, 'client'); } else { $form->addElement('hidden', 'node', $node); $form->addData("<tt>{$node}</tt>"); } $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('textarea', 'contents', null, 'cols="60" rows="20" wrap="virtual"'); $form->addData('</td></tr><tr><td align="center" colspan="2">'); $form->addElement('submit', 'mode', 'submit'); $form->addData('</td></tr></table>'); return $form; }
$form = new HTML_QuickForm($_SERVER['SCRIPT_NAME'], 'GET'); $form->addElement('text', 'email', null, 'size="40"'); $form->addRule('email', 'Please enter email address', 'required', null, 'client'); $form->addElement('submit'); $form->addElement('hidden', 'mode', $mode); $form_html = $form->toHtml(); $tpl =& new HTML_Template_IT($template_dir); $tpl->loadTemplatefile("mail.tpl"); $tpl->setVariable("Node", $node); $tpl->setVariable("MailForm", $form_html); $tpl->show(); exit; } else { include_once "Mail.php"; include_once "Mail/mime.php"; $html = Wiki::process(Wiki::getNodeContents($node)); $text = unhtmlentities(strip_tags($html)); $hdrs = array('From' => $a->getUsername() . '@php.net', 'Subject' => 'PEAR Wiki: ' . Wiki::formatWord($node)); $mime = new Mail_mime(); $mime->setTXTBody($text); $mime->setHTMLBody($html); $body = $mime->get(); $hdrs = $mime->headers($hdrs); $mail =& Mail::factory('mail'); $mail->send($_REQUEST['email'], $hdrs, $body); } } $tpl =& new HTML_Template_IT($template_dir); if ($mode == 'edit') { Wiki::displayEditor($tpl, $node); } elseif ($mode == 'new') {