Пример #1
0
 public function init()
 {
     parent::init();
     $this->removeElement("id");
     $e = new Daq_Form_Element("coupon");
     $e->setLabel(__("Coupon", WPJB_DOMAIN));
     $this->addElement($e, "coupon");
     $payment = new Wpjb_Payment_Factory();
     if (count($payment->getEngines()) > 1) {
         $v = array();
         $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_SELECT);
         $e->setRequired(true);
         $e->setLabel(__("Payment Method", WPJB_DOMAIN));
         foreach ($payment->getEngines() as $key => $engine) {
             /* @var $engine Wpjb_Payment_Interface */
             $engine = new $engine();
             $pTitle = $engine->getTitle();
             $e->addOption($key, $key, $pTitle);
             $v[] = $key;
         }
         $e->addValidator(new Daq_Validate_InArray($v));
         $this->addElement($e, "coupon");
     } else {
         $engine = current($payment->getEngines());
         $engine = new $engine();
         $e = new Daq_Form_Element("payment_method", Daq_Form_Element::TYPE_HIDDEN);
         $e->setValue($engine->getEngine());
         $e->addValidator(new Daq_Validate_InArray(array($engine->getEngine())));
         $e->setRequired(true);
         $this->addGroup("hidden");
         $this->addElement($e, "hidden");
     }
     $e = new Daq_Form_Element("listing", Daq_Form_Element::TYPE_RADIO);
     $e->setRequired(true);
     $e->setLabel(__("Listing Type", WPJB_DOMAIN));
     $e->addValidator(new Daq_Validate_Db_RecordExists("Wpjb_Model_Listing", "id"));
     $default = __("<b>{title}</b> {price} ~ days visible: {visible}", WPJB_DOMAIN);
     $tpl = Wpjb_Project::getInstance()->conf("front_listing_tpl", $default);
     foreach ($this->_getListingArr() as $listing) {
         $visible = $listing->visible;
         if ($visible == 0) {
             $visible = __("<i>unlimited</i>", WPJB_DOMAIN);
         }
         $find = array("{price}", "{title}", "{visible}");
         $repl = array($listing->getTextPrice(), $listing->title, $visible);
         $e->addOption($listing->id, $listing->id, str_replace($find, $repl, $tpl));
     }
     $e->setRenderer("wpjb_form_helper_listing");
     $this->addElement($e, "coupon");
     apply_filters("wpjb_form_init_addjob", $this);
     $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_add_job", true));
 }
Пример #2
0
 public function init()
 {
     $this->addGroup("apply", "Apply");
     $e = new Daq_Form_Element("applicant_name", Daq_Form_Element::TYPE_TEXT);
     $e->addFilter(new Daq_Filter_Trim());
     $e->setLabel(__("Your name", WPJB_DOMAIN));
     $e->setRequired(true);
     $this->addElement($e, "apply");
     $e = new Daq_Form_Element("email", Daq_Form_Element::TYPE_TEXT);
     $e->setLabel(__("Your e-mail address", WPJB_DOMAIN));
     $e->setRequired(true);
     $e->addValidator(new Daq_Validate_Email());
     $this->addElement($e, "apply");
     $e = new Daq_Form_Element_File("cv_file", Daq_Form_Element::TYPE_FILE);
     $e->setDestination(Wpjb_List_Path::getPath("apply_file"));
     $e->setLabel(__("Your CV file", WPJB_DOMAIN));
     $this->addElement($e, "apply");
     $resume = Wpjb_Model_Resume::current();
     $isEmp = get_user_meta(wp_get_current_user()->ID, "is_employer", true);
     if ($resume->id > 0 && !$isEmp || is_admin()) {
         $e = new Daq_Form_Element("resume_id", Daq_Form_Element::TYPE_CHECKBOX);
         $e->setLabel(__("Send my profile resume", WPJB_DOMAIN));
         $id = $resume->id;
         $e->addOption($id, $id, "");
         $e->addValidator(new Daq_Validate_InArray(array($id)));
         $this->addElement($e, "apply");
     }
     $e = new Daq_Form_Element("resume", Daq_Form_Element::TYPE_TEXTAREA);
     $e->setLabel(__("Your resume/message", WPJB_DOMAIN));
     $this->addElement($e, "apply");
     $this->_additionalFields();
     if (Wpjb_Project::getInstance()->conf("front_enable_protection") == 1) {
         $e = new Daq_Form_Element("protection", Daq_Form_Element::TYPE_HIDDEN);
         $e->addValidator(new Daq_Validate_InArray(array(Wpjb_Project::getInstance()->conf("front_protection", "pr0t3ct1on"))));
         $e->setRequired(true);
         $this->addElement($e, "hidden");
     } elseif (Wpjb_Project::getInstance()->conf("front_enable_protection") == 2) {
         $e = new Daq_Form_Element("recaptcha_response_field");
         $e->setRequired(true);
         $e->addValidator(new Daq_Validate_Callback("wpjb_recaptcha_check"));
         $e->setRenderer("wpjb_recaptcha_form");
         $e->setLabel(__("Captcha", WPJB_DOMAIN));
         $this->addElement($e, "apply");
     }
     apply_filters("wpjb_form_init_apply", $this);
     $this->setModifiedScheme(Wpjb_Project::getInstance()->conf("form_apply_for_job", true));
 }