function actionDefault() { // Create the template object $tpl = new YDTemplate(); // Assign some stuff $browser = new YDBrowserInfo(); $tpl->assign('browser', $browser); // Display the template $tpl->display(); }
function actionDefault() { // create template object $tpl = new YDTemplate(); // create ajax object with waiting message $this->ajax = new YDAjax($tpl); $this->ajax->useWaitingMessage(); // add custom event $this->ajax->addEvent('customFunction(x)', array(&$this, 'getResult'), 'var x'); // process ajax events $this->ajax->processEvents(); // assign title and display template $tpl->assign('title', 'This example demonstrates YDAjax without YDForm'); $tpl->display(); }
function actionDefault() { // Create the form $form = new YDForm('form1'); // Add the checkboxgroup $form->addElement('checkboxgroup', 'choose_multiple', 'Choose multiple default', array(), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple2', 'Choose multiple HORIZONTAL', array('sep' => 'h'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple3', 'Choose multiple VERTICAL', array('sep' => 'v'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple4', 'Choose multiple LEFT', array('sep' => 'l'), array(0 => 'choice 1', 1 => 'choice 2')); $el =& $form->addElement('checkboxgroup', 'choose_multiple5', 'Choose multiple RIGHT', array('sep' => 'r'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple6', 'Choose multiple VERTICAL LEFT', array('sep' => 'vl'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple7', 'Choose multiple VERTICAL RIGHT', array('sep' => 'vr'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple8', 'Choose multiple HORIZONTAL LEFT', array('sep' => 'hl'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple9', 'Choose multiple HORIZONTAL RIGHT', array('sep' => 'hr'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple10', 'Custom Separator "|"', array('separator' => ' | '), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple11', 'Custom Separator "XXX" and LEFT', array('sep' => 'l', 'separator' => ' XXX '), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple12', 'Custom Separator "...", LEFT and VERTICAL', array('sep' => 'l', 'separator' => '...<br />'), array(0 => 'choice 1', 1 => 'choice 2')); $form->addElement('checkboxgroup', 'choose_multiple_big', 'Choose with column format', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8')); $el2 =& $form->addElement('checkboxgroup', 'choose_multiple_big2', 'Choose with column format (2 columns)', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8')); $el2->setColumns(2); $el3 =& $form->addElement('checkboxgroup', 'choose_multiple_big3', 'Choose with column format (3 columns and a default "select all")', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8', 'choice 9')); $el3->setColumns(3); $el3->addSelectAll(); $el4 =& $form->addElement('checkboxgroup', 'choose_multiple_big4', 'Choose with column format (3 columns and a "select all" on top)', array(), array(0 => 'choice 1', 'choice 2', 'choice 3', 'choice 4', 'choice 5', 'choice 6', 'choice 7', 'choice 8')); $el4->setColumns(3); $el4->addSelectAll(false); // demonstrate disable on checkboxgroup $form->disable('choose_multiple', 1); $form->disable('choose_multiple2', array(0, 1)); $form->disable('choose_multiple3'); // Add and example about 'select all' button $el->addSelectAll(); // Add the submit button $form->addElement('submit', 'btnSubmit', 'submit'); // Set the defaults $form->setDefaults(array('choose_multiple' => array(0 => 0, 1 => 1))); // Process the form if ($form->validate() === true) { YDDebugUtil::dump($form->getValues()); } // Add the template $tpl = new YDTemplate(); // Add the form to the template $tpl->assign('form', $form->toHTML()); // Display the template $tpl->display(); }
function actionDefault() { // Mark the form as not valid $this->template->assign('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->template->assign('formValid', true); // Parse the template for the email $emlTpl = new YDTemplate(); $emlTpl->assign('email', $form->getValue('email')); $body = $emlTpl->fetch('email_template', null); // 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->template->assign('result', $result); } // Add the form to the template $this->template->assign('form_html', $form->toHtml()); $this->template->assignForm('form', $form); // Output the template $this->template->display(); }
/** * 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->_server->listMethods(null); // Loop over the methods foreach ($methodNames as $method) { if (isset($this->_server->signatures[$method])) { if (sizeof($this->_server->signatures[$method]) == 1) { $paramsIn = null; $paramsOut = $this->_server->signatures[$method]; } else { $paramsIn = $this->_server->signatures[$method]; $paramsOut = array_shift($paramsIn); } } else { $paramsIn = null; $paramsOut = null; } $methodInfo = array(); $methodInfo['signature'] = @$this->_server->signatures[$method]; $methodInfo['paramsIn'] = $paramsIn; $methodInfo['paramsOut'] = $paramsOut; $methodInfo['help'] = @$this->_server->help[$method]; $methods[$method] = $methodInfo; } // Create a new template YDInclude('YDTemplate.php'); $template = new YDTemplate(); $template->template_dir = dirname(__FILE__); $template->assign('methods', $methods); $template->assign('xmlRpcUrl', $this->getCurrentUrl()); $template->assign('capabilities', $this->_server->getCapabilities(null)); $template->assign('rowcolor', '#EEEEEE'); $template->display('YDXmlRpcServer.tpl'); }
/** * This function will return the element as HTML. * * @returns The form element as HTML text. */ function toHtml() { // Create the list of attributes $attribs = array('id' => $this->_form . '_' . $this->_name); $attribs = array_merge($this->_attributes, $attribs); $template_record = new YDTemplate(); // set form defaults if (isset($this->defaults)) { $this->form->setDefaults($this->defaults); $template_record->assign('defaults', $this->defaults); } // get record template and assign recordset $template_record->assign('recordset', $this->_value); $template_record->assign('columns', $this->columns); $template_record->assignForm('form', $this->form); // Get the HTML return $template_record->fetch(dirname(__FILE__) . '/YDFormElement_Grid.tpl'); }