function actionDefault() { // Mark the form as not valid $this->setVar('formValid', false); // Create the form $form = new YDForm('emailForm'); // Add the elements $form->addElement('text', 'email', 'Enter your email address:', array('style' => 'width: 300px;')); $form->addElement('submit', 'cmdSubmit', 'Send'); // Apply a filter $form->addFilter('email', 'trim'); // Add a rule $form->addRule('email', 'email', 'Please enter a valid email address'); // Process the form if ($form->validate()) { // Mark the form as valid $this->setVar('formValid', true); // Parse the template for the email $emlTpl = new YDTemplate(); $emlTpl->setVar('email', $form->getValue('email')); $body = $emlTpl->getOutput('email_template'); // Send the email $eml = new YDEmail(); $eml->setFrom('*****@*****.**', YD_FW_NAME); $eml->addTo($form->getValue('email'), 'Yellow Duck'); $eml->setSubject('Hello from Pieter & Fiona!'); $eml->setHtmlBody($body); $eml->addAttachment('email.tpl'); $eml->addHtmlImage('fsimage.jpg', 'image/jpeg'); $result = $eml->send(); // Add the result $this->setVar('result', $result); } // Add the form to the template $this->setVar('form_html', $form->toHtml()); $this->addForm('form', $form); // Output the template $this->outputTemplate(); }
/** * This function will be executed if there is no post data found. This is happening when there is no XML/RPC * request found. */ function requestNotXmlRpc() { // Get the list of methods $methods = array(); $methodNames = $this->listMethods(null); // Loop over the methods foreach ($methodNames as $method) { if (isset($this->signatures[$method])) { if (sizeof($this->signatures[$method]) == 1) { $paramsIn = null; $paramsOut = $this->signatures[$method]; } else { $paramsIn = $this->signatures[$method]; $paramsOut = array_shift($paramsIn); } } else { $paramsIn = null; $paramsOut = null; } $methodInfo = array(); $methodInfo['signature'] = @$this->signatures[$method]; $methodInfo['paramsIn'] = $paramsIn; $methodInfo['paramsOut'] = $paramsOut; $methodInfo['help'] = @$this->help[$method]; $methods[$method] = $methodInfo; } // Create a new template require_once 'YDTemplate.php'; $template = new YDTemplate(); $template->setVar('methods', $methods); $template->setVar('xmlRpcUrl', $this->getCurrentUrl()); $template->setVar('capabilities', $this->getCapabilities(null)); $template->setVar('rowcolor', '#EEEEEE'); echo $template->getOutput(dirname(__FILE__) . '/YDXmlRpcServer.tpl'); }