コード例 #1
0
 /**
  * @param OW_ActionController $controller
  */
 public function __construct($controller)
 {
     parent::__construct('DisplayNameSearchForm');
     $this->controller = $controller;
     $questionService = BOL_QuestionService::getInstance();
     $this->setId('DisplayNameSearchForm');
     $submit = new Submit(self::SUBMIT_NAME);
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $questionName = OW::getConfig()->getValue('base', 'display_name_question');
     $question = $questionService->findQuestionByName($questionName);
     $questionPropertyList = array();
     foreach ($question as $property => $value) {
         $questionPropertyList[$property] = $value;
     }
     $this->addQuestions(array($questionName => $questionPropertyList), array(), array());
     $controller->assign('displayNameQuestion', $questionPropertyList);
 }
コード例 #2
0
 public function __construct(OW_ActionController $controller)
 {
     parent::__construct('settings-form');
     $lang = OW::getLanguage();
     $newLogin = new CheckboxField('newLogin');
     $newLogin->setLabel($lang->text('femaleregonlymen', 'login_as_user'));
     $this->addElement($newLogin);
     $questionNameList = array('username', 'email', 'password', 'sex');
     $questionDtoList = BOL_QuestionService::getInstance()->findQuestionByNameList($questionNameList);
     $orderedQuestionList = array();
     $questionService = BOL_QuestionService::getInstance();
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     foreach ($questionNameList as $questionName) {
         if (!empty($questionDtoList[$questionName])) {
             $orderedQuestionList[] = get_object_vars($questionDtoList[$questionName]);
         }
     }
     $this->addQuestions($orderedQuestionList, $questionValueList);
     $controller->assign('questions', $orderedQuestionList);
     $submit = new Submit('reg_fake');
     $submit->setValue($lang->text('femaleregonlymen', 'reg_fake'));
     $this->addElement($submit);
 }
コード例 #3
0
 /**
  * @param OW_ActionController $controller
  */
 public function __construct($controller)
 {
     parent::__construct('MainSearchForm');
     $this->controller = $controller;
     $questionService = BOL_QuestionService::getInstance();
     $this->setId('MainSearchForm');
     $submit = new Submit(self::SUBMIT_NAME);
     $submit->setValue(OW::getLanguage()->text('base', 'user_search_submit_button_label'));
     $this->addElement($submit);
     $questionData = OW::getSession()->get(self::FORM_SESSEION_VAR);
     if ($questionData === null) {
         $questionData = array();
         if (OW::getUser()->isAuthenticated()) {
             $data = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('match_sex'));
             $questionData['match_sex'] = $data[OW::getUser()->getId()]['match_sex'];
             $questionData['googlemap_location']['distance'] = 50;
             OW::getSession()->set(self::FORM_SESSEION_VAR, $questionData);
         }
     }
     if (!empty($questionData['match_sex'])) {
         if (is_array($questionData['match_sex'])) {
             $questionData['match_sex'] = array_shift($questionData['match_sex']);
         } else {
             for ($i = 0; $i < 31; $i++) {
                 if (pow(2, $i) & $questionData['match_sex']) {
                     $questionData['match_sex'] = pow(2, $i);
                     break;
                 }
             }
         }
     }
     $accounts = $this->getAccountTypes();
     $accountList = array();
     foreach ($accounts as $key => $account) {
         $accountList[$key] = $account;
     }
     $keys = array_keys($accountList);
     $this->accountType = $keys[0];
     $this->matchSexValue = USEARCH_BOL_Service::getInstance()->getGenderByAccounType($this->accountType);
     if (isset($questionData['match_sex'])) {
         $accountType = USEARCH_BOL_Service::getInstance()->getAccounTypeByGender($questionData['match_sex']);
         if (!empty($accountType)) {
             $this->accountType = $accountType;
             $this->matchSexValue = $questionData['match_sex'];
         }
     }
     $questions = $questionService->findSearchQuestionsForAccountType($this->accountType);
     $mainSearchQuestion = array();
     $questionNameList = array('sex' => 'sex', 'match_sex' => 'match_sex');
     foreach ($questions as $key => $question) {
         $sectionName = $question['sectionName'];
         $questionNameList[] = $question['name'];
         $isRequired = in_array($question['name'], array('googlemap_location', 'match_sex')) ? 1 : 0;
         $questions[$key]['required'] = $isRequired;
         if ($question['name'] == 'sex' || $question['name'] == 'match_sex') {
             unset($questions[$key]);
         } else {
             $mainSearchQuestion[$sectionName][] = $question;
         }
     }
     $questionValueList = $questionService->findQuestionsValuesByQuestionNameList($questionNameList);
     $controller->assign('displayGender', false);
     if (count($accounts) > 1) {
         $this->displayAccountType = true;
         if (!OW::getUser()->isAuthenticated()) {
             $controller->assign('displayGender', true);
             $sex = new Selectbox('sex');
             $sex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('sex'));
             $sex->setRequired();
             $sex->setHasInvitation(false);
             //$accountType->setHasInvitation(false);
             $this->setFieldOptions($sex, 'sex', $questionValueList['sex']);
             if (!empty($questionData['sex'])) {
                 $sex->setValue($questionData['sex']);
             }
             $this->addElement($sex);
         } else {
             $sexData = BOL_QuestionService::getInstance()->getQuestionData(array(OW::getUser()->getId()), array('sex'));
             if (!empty($sexData[OW::getUser()->getId()]['sex'])) {
                 $sex = new HiddenField('sex');
                 $sex->setValue($sexData[OW::getUser()->getId()]['sex']);
                 $this->addElement($sex);
             }
         }
         $matchSex = new Selectbox('match_sex');
         $matchSex->setLabel(BOL_QuestionService::getInstance()->getQuestionLang('match_sex'));
         $matchSex->setRequired();
         $matchSex->setHasInvitation(false);
         //$accountType->setHasInvitation(false);
         $this->setFieldOptions($matchSex, 'match_sex', $questionValueList['sex']);
         if (!empty($questionData['match_sex'])) {
             $matchSex->setValue($questionData['match_sex']);
         }
         $this->addElement($matchSex);
     }
     $this->addQuestions($questions, $questionValueList, $questionData);
     $locationField = $this->getElement('googlemap_location');
     if ($locationField) {
         $value = $locationField->getValue();
         if (empty($value['json'])) {
             $locationField->setDistance(50);
         }
     }
     $controller->assign('questionList', $mainSearchQuestion);
     $controller->assign('displayAccountType', $this->displayAccountType);
     // 'online' field
     $onlineField = new CheckboxField('online');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('online', $questionData)) {
         $onlineField->setValue($questionData['online']);
     }
     $onlineField->setLabel(OW::getLanguage()->text('usearch', 'online_only'));
     $this->addElement($onlineField);
     //        if ( OW::getPluginManager()->isPluginActive('photo') )
     //        {
     // with photo
     $withPhoto = new CheckboxField('with_photo');
     if (!empty($questionData) && is_array($questionData) && array_key_exists('with_photo', $questionData)) {
         $withPhoto->setValue($questionData['with_photo']);
     }
     $withPhoto->setLabel(OW::getLanguage()->text('usearch', 'with_photo'));
     $this->addElement($withPhoto);
     //        }
 }