Example #1
0
 /**
  * Constructor ContactForm
  * @param Page $page_object 
  * @param string $send_method 
  * @param string $table_style 
  */
 function __construct($page_object, $send_method, $table_style = '')
 {
     parent::__construct();
     if (!isset($page_object) || !isset($send_method)) {
         throw new NewException("2 arguments for " . get_class($this) . "::__construct() are mandatory", 0, getDebugBacktrace(1));
     }
     if (gettype($page_object) != "object" || !is_subclass_of($page_object, "Page")) {
         throw new NewException("Argument page_object for " . get_class($this) . "::__construct() error", 0, getDebugBacktrace(1));
     }
     $this->page_object = $page_object;
     $this->mail_to = SMTP_MAIL;
     $this->mail_to_name = SMTP_NAME;
     $table_main = new Table();
     $table_main->setClass($table_style);
     $form = new Form($this->page_object);
     $name = new TextBox($form, "contact_name");
     $name_validation = new LiveValidation();
     $name->setLiveValidation($name_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_NAME)));
     $table_main->addRowColumns(__(CONTACTFORM_NAME) . ": ", $name->setFocus())->setColumnWidth(2, "100%");
     $email = new TextBox($form, "contact_email");
     $email_validation = new LiveValidation();
     $email->setLiveValidation($email_validation->addValidateEmail()->addValidatePresence()->setFieldName(__(CONTACTFORM_EMAIL)));
     $table_main->addRowColumns(__(CONTACTFORM_EMAIL) . ": ", $email);
     $subject = new TextBox($form, "contact_subject");
     $subject_validation = new LiveValidation();
     $subject->setLiveValidation($subject_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_SUBJECT)));
     $table_main->addRowColumns(__(CONTACTFORM_SUBJECT) . ": ", $subject);
     $table_main->addRow();
     $editor = new Editor($form, "contact_message");
     $editor_validation = new LiveValidation();
     $editor->setLiveValidation($editor_validation->addValidatePresence()->setFieldName(__(CONTACTFORM_MESSAGE)));
     $editor->setToolbar(Editor::TOOLBAR_SIMPLE);
     $table_main->addRow(new Object(__(CONTACTFORM_MESSAGE) . ": ", "<br/>", $editor))->setColspan(3)->setAlign(RowTable::ALIGN_LEFT);
     $table_main->addRow();
     $this->captcha = new Captcha($form, "contact_captcha");
     $table_main->addRow($this->captcha)->setColspan(3);
     $table_main->addRow();
     $this->send_button = new Button($form, "contact_send", "", __(CONTACTFORM_SEND));
     $this->send_button->assignEnterKey()->onClick($send_method)->setAjaxEvent();
     $table_main->addRow($this->send_button)->setColspan(3);
     $table_main->addRow();
     $form->setContent($table_main);
     $this->render = $form;
 }