public function getForm() { $strMaxLength = "Your input is too long. Maximum length is %s"; $strMinLength = "Your input is too short. Minimum length is %s"; $strRequired = "This field is required."; $objForm = new ValidForm("installForm"); $objForm->setMainAlert("One or more errors occured. Check the marked fields and try again."); $objForm->addFieldset("CMS type", NULL, "PunchCMS can be installed for a single website or multiple websites at once."); $objForm->addField("single_instance", "Single website", VFORM_BOOLEAN); $objForm->addFieldset("Administrator settings", NULL, "This is the account for the admin area. Later you can create an admin per website."); $objForm->addField("username", "Username", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter only letters and spaces.")); $objForm->addField("passwd", "Password", VFORM_PASSWORD, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter only letters and numbers.")); $objForm->addField("email", "Email address", VFORM_EMAIL, array("maxLength" => 32, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Use the format name@domain.extension."), array("tip" => "This address will be used as the sender address for password reminders.")); $objForm->addFieldset("MySQL settings", NULL, "The database and user must already exist, otherwise the installation will fail."); $objForm->addField("db_server", "Server address", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the address of the MySQL server."), array("default" => "localhost")); $objForm->addField("db_name", "Database name", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the name of the designated database."), array("default" => "punchcms")); $objForm->addField("db_username", "Username", VFORM_STRING, array("maxLength" => 255, "required" => true), array("maxLength" => $strMaxLength, "required" => $strRequired, "type" => "Enter the username for the database.")); $objForm->addField("db_passwd", "Password", VFORM_PASSWORD, array("maxLength" => 32, "required" => false), array("maxLength" => $strMaxLength, "type" => "Enter the password for the database.")); $objForm->setSubmitLabel("Submit"); return $objForm; }
if ($info['cssClass'] == 'radio') { $type = VFORM_RADIO_LIST; } elseif ($info['cssClass'] == 'checkbox') { $type = VFORM_CHECK_LIST; } else { $type = VFORM_SELECT_LIST; } //Multiple values are seperated by | ( pipe ) if (strpos($info['meta_value'], '|') !== false) { $info['meta_value'] = explode('|', $info['meta_value']); } $box = $form->addField('bum_' . $info['id'], $info['title'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['title']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); foreach ($info['values'] as $checkbox) { $box->addField($checkbox->value, htmlentities($checkbox->value)); } } //this is handling `input_text`, `textarea` if (in_array($info['cssClass'], array('input_text', 'textarea'))) { if ($info['cssClass'] == 'input_text') { $type = VFORM_STRING; } else { $type = VFORM_TEXT; } $form->addField('bum_' . $info['id'], $info['values'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['values']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); } } } $form->setSubmitLabel("Update Profile"); echo $form->toHtml(); ?> </div>
if (in_array($info['cssClass'], array('radio', 'checkbox', 'select'))) { if ($info['cssClass'] == 'radio') { $type = VFORM_RADIO_LIST; } elseif ($info['cssClass'] == 'checkbox') { $type = VFORM_CHECK_LIST; } else { $type = VFORM_SELECT_LIST; } //Multiple values are seperated by | ( pipe ) if (strpos($info['meta_value'], '|') !== false) { $info['meta_value'] = explode('|', $info['meta_value']); } $box = $form->addField('bum_' . $info['id'], $info['title'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['title']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); foreach ($info['values'] as $checkbox) { $box->addField($checkbox->value, htmlentities($checkbox->value)); } } //this is handling `input_text`, `textarea` if (in_array($info['cssClass'], array('input_text', 'textarea'))) { if ($info['cssClass'] == 'input_text') { $type = VFORM_STRING; } else { $type = VFORM_TEXT; } $form->addField('bum_' . $info['id'], $info['values'], $type, array('required' => $info['required'] == 'false' ? false : true), array('required' => 'The following field is required: ' . $info['values']), $info['tip'] ? array('tip' => $info['tip'], 'default' => $info['meta_value']) : array('default' => $info['meta_value'])); } } } $form->addParagraph("A password will be e-mailed to you", ""); $form->setSubmitLabel("Register"); echo $form->toHtml();
</a> <?php } ?> </p> <?php break; case 'login': default: $form = new ValidForm('loginform', '', bum_get_permalink_login()); $form->addField('log', 'Username', VFORM_STRING, array('required' => true), array('required' => 'You need a username.'), array('tip' => 'Usernames cannot be changed.')); $form->addField('pwd', 'Password', VFORM_PASSWORD, array('required' => true), array('required' => 'Enter your password.')); $remember = $form->addField('rememberme', '', VFORM_CHECK_LIST); $remember->addField('Remember Me', 'forever'); $form->setSubmitLabel("Login"); do_action('login_form'); if ($bum_interim_login) { $form->addField('interim-login', '', VFORM_HIDDEN, array(), array(), array('default' => '1')); } else { $form->addField('redirect_to', '', VFORM_HIDDEN, array(), array(), array('default' => esc_attr($bum_redirect_to))); } $form->addField('testcookie', '', VFORM_HIDDEN, array(), array(), array('default' => '1')); echo $form->toHtml(); if (!$bum_interim_login) { ?> <p id="nav"> <?php if (isset($_GET['checkemail']) && in_array($_GET['checkemail'], array('confirm', 'newpass'))) { ?> <?php
public function buildForm($blnSend = true, $blnClientSide = true) { $objCms = PCMS_Client::getInstance(); $strReturn = ""; $this->__maxLengthAlert = $this->__formElement->getField("AlertMaxLength")->getHtmlValue(); $this->__minLengthAlert = $this->__formElement->getField("AlertMinLength")->getHtmlValue(); $this->__requiredAlert = $this->__formElement->getField("AlertRequired")->getHtmlValue(); $this->__validForm->setRequiredStyle($this->__formElement->getField("RequiredIndicator")->getHtmlValue()); $this->__validForm->setMainAlert($this->__formElement->getField("AlertMain")->getHtmlValue()); //*** Form starts here. $objFieldsets = $this->__formElement->getElementsByTemplate(array("Fieldset", "Paragraph")); foreach ($objFieldsets as $objFieldset) { switch ($objFieldset->getTemplateName()) { case "Paragraph": $this->renderParagraph($this->__validForm, $objFieldset); break; case "Fieldset": $this->renderFieldset($this->__validForm, $objFieldset); $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField")); foreach ($objFields as $objField) { switch ($objField->getTemplateName()) { case "Field": $this->renderField($this->__validForm, $objField); break; case "ListField": $this->renderListField($this->__validForm, $objField); break; case "Area": $this->renderArea($this->__validForm, $objField); break; case "MultiField": $this->renderMultiField($this->__validForm, $objField); break; } } } } //*** Add conditions foreach ($objFieldsets as $objFieldset) { $this->addConditions($objFieldset); $objFields = $objFieldset->getElementsByTemplate(array("Field", "Area", "ListField", "MultiField")); foreach ($objFields as $objField) { $this->addConditions($objField); } } $this->__validForm->setSubmitLabel($this->__formElement->getField("SendLabel")->getHtmlValue()); if ($this->__validForm->isSubmitted() && $this->__validForm->isValid()) { if ($blnSend) { $objRecipientEmails = $this->__formElement->getElementsByTemplate("RecipientEmail"); foreach ($objRecipientEmails as $objRecipientEmail) { $strHtmlBody = "<html><head><title></title></head><body>"; $strHtmlBody .= sprintf($objRecipientEmail->getField("Body")->getHtmlValue(), $this->__validForm->valuesAsHtml(true)); $strHtmlBody .= "</body></html>"; $varEmailId = $objRecipientEmail->getField("SenderEmail")->getValue(); $objEmailElement = $objCms->getElementById($varEmailId); $strFrom = "webserver"; if (is_object($objEmailElement)) { $varEmailId = $objEmailElement->getElement()->getApiName(); if (empty($varEmailId)) { $varEmailId = $objEmailElement->getId(); } $strFrom = $this->__validForm->getValidField("formfield_" . strtolower($varEmailId))->getValue(); } $strErrors = $this->sendMail($objRecipientEmail->getField("Subject")->getHtmlValue(), $strHtmlBody, $strFrom, explode(",", $objRecipientEmail->getField("RecipientEmail")->getHtmlValue())); if (!empty($strErrors)) { throw new Exception($strErrors, E_ERROR); } } $objSenderEmails = $this->__formElement->getElementsByTemplate("SenderEmail"); foreach ($objSenderEmails as $objSenderEmail) { $strHtmlBody = "<html><head><title></title></head><body>"; $strHtmlBody .= sprintf($objSenderEmail->getField("Body")->getHtmlValue(), $this->__validForm->valuesAsHtml(true)); $strHtmlBody .= "</body></html>"; $varEmailId = $objSenderEmail->getField("RecipientEmail")->getValue(); $objEmailElement = $objCms->getElementById($varEmailId); if (is_object($objEmailElement)) { $varEmailId = $objEmailElement->getElement()->getApiName(); if (empty($varEmailId)) { $varEmailId = $objEmailElement->getId(); } } $strErrors = $this->sendMail($objSenderEmail->getField("Subject")->getHtmlValue(), $strHtmlBody, $objSenderEmail->getField("SenderEmail")->getHtmlValue(), array($this->__validForm->getValidField("formfield_" . strtolower($varEmailId))->getValue())); if (!empty($strErrors)) { throw new Exception($strErrors, E_ERROR); } } $strReturn = $this->__formElement->getField("ThanksBody")->getHtmlValue(); } else { $strReturn = $this->__formElement->getField("ThanksBody")->getHtmlValue(); } } else { $strReturn = $this->__validForm->toHtml($blnClientSide); } return $strReturn; }