コード例 #1
0
 /**
  * Shows the registration form.
  * @param  array $marker An array of markers, with which the template is to
  *                        be filled.
  * @param $conf
  * @return string         The registration form.
  */
 function showRegForm($marker, $conf)
 {
     $template = $this->cObj->getSubpart($this->tmpl, "###TEMPLATE_CREATE###");
     $marker["###FORM_URL###"] = $this->pi_getPageLink($GLOBALS["TSFE"]->id);
     $marker["###FORM_NAME###"] = $this->extKey . "[reg]";
     if (ExtensionManagementUtility::isLoaded('captcha') && $this->conf['useCaptcha']) {
         $marker['###CAPTCHA_IMAGE###'] = '<img src="' . ExtensionManagementUtility::siteRelPath('captcha') . 'captcha/captcha.php" alt="" />';
     } else {
         $template = $this->cObj->substituteSubpart($template, '###CAPTCHA###', '');
     }
     $fields = 'username,name,tx_mmforum_occ,city,tx_mmforum_interests,www,email';
     $fields = explode(',', $fields);
     //TODO: unused variable
     $requiredFields = GeneralUtility::trimExplode(',', $this->conf['required.']['fields']);
     $requiredFields[] = 'username';
     $requiredFields[] = 'password';
     $requiredFields[] = 'passwordrepeat';
     $llMarker = array('###LABEL_REQUIRED###' => $this->pi_getLL('reg.requiredNote'), '###LABEL_USERNAME###' => $this->pi_getLL('reg.username'), '###LABEL_PASSWORD###' => $this->pi_getLL('reg.password'), '###LABEL_PASSWORDREPEAT###' => $this->pi_getLL('reg.passwordRepeat'), '###LABEL_NAME###' => $this->pi_getLL('reg.name'), '###LABEL_TX_MMFORUM_OCC###' => $this->pi_getLL('reg.profession'), '###LABEL_CITY###' => $this->pi_getLL('reg.location'), '###LABEL_TX_MMFORUM_INTERESTS###' => $this->pi_getLL('reg.interests'), '###LABEL_WWW###' => $this->pi_getLL('reg.website'), '###LABEL_CREATE###' => $this->pi_getLL('reg.create'), '###LABEL_EMAIL###' => $this->pi_getLL('reg.email'), '###LABEL_CAPTCHA###' => $this->pi_getLL('reg.captcha'), '###LABEL_REGISTRATION###' => $this->pi_getLL('reg.title'), '###IMG_MAIL###' => tx_mmforum_pi1::createButton('email', array(), 0, true, '', true), '###IMG_ICQ###' => tx_mmforum_pi1::createButton('icq', array(), 0, true, '', true), '###IMG_AIM###' => tx_mmforum_pi1::createButton('aim', array(), 0, true, '', true), '###IMG_YIM###' => tx_mmforum_pi1::createButton('yim', array(), 0, true, '', true), '###IMG_MSN###' => tx_mmforum_pi1::createButton('msn', array(), 0, true, '', true), '###IMG_SKYPE###' => tx_mmforum_pi1::createButton('skype', array(), 0, true, '', true));
     /* Highlight required fields */
     foreach ($requiredFields as $field) {
         $llMarker['###LABEL_' . strtoupper($field) . '###'] = $this->cObj->wrap($llMarker['###LABEL_' . strtoupper($field) . '###'], $this->conf['required.']['fieldWrap']);
     }
     /* Restore old markers for backwards compatibility */
     $llMarker['###LABEL_PROFESSION###'] = $llMarker['###LABEL_TX_MMFORUM_OCC###'];
     $llMarker['###LABEL_LOCATION###'] = $llMarker['###LABEL_CITY###'];
     $llMarker['###LABEL_INTERESTS###'] = $llMarker['###LABEL_TX_MMFORUM_INTERESTS###'];
     $llMarker['###LABEL_WEBSITE###'] = $llMarker['###LABEL_WWW###'];
     $marker = array_merge($marker, $llMarker);
     $userField_template = $this->cObj->getSubpart($template, '###USERFIELDS###');
     $userFields_content = '';
     $res = $this->databaseHandle->exec_SELECTquery('*', 'tx_mmforum_userfields', 'deleted=0', '', 'sorting DESC');
     if ($this->databaseHandle->sql_num_rows($res) > 0) {
         $userField = GeneralUtility::makeInstance('tx_mmforum_userfield');
         $userField->init($this->userLib, $this->cObj);
         while ($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
             $userField->get($arr);
             if ($this->conf['showOnlyRequiredUserfields'] == 1 && $userField->isRequired() || $this->conf['showOnlyRequiredUserfields'] != 1) {
                 $label = $userField->getRenderedLabel();
                 if ($userField->isRequired()) {
                     $label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']);
                 }
                 $input = $userField->getRenderedInput($this->piVars['userfields'][$userField->getUID()]);
                 if ($input === null) {
                     $input = $this->cObj->getSubpart($userField_template, '###DEFUSERFIELD###');
                 }
                 $userField_thisTemplate = $this->cObj->substituteSubpart($userField_template, '###DEFUSERFIELD###', $input);
                 $userFields_marker = array('###USERFIELD_LABEL###' => $label, '###USERFIELD_UID###' => $userField->getUID(), '###USERFIELD_NAME###' => 'tx_mmforum_pi2[userfields][' . $userField->getUID() . ']', '###USERFIELD_VALUE###' => $this->piVars['userfields'][$userField->getUID()] ? $this->piVars['userfields'][$arr['uid']] : '', '###USERFIELD_ERROR###' => $marker['userfield_error'][$userField->getUID()]);
                 if ($userFields_marker['###USERFIELD_ERROR###']) {
                     $userFields_marker['###USERFIELD_ERROR###'] = $this->cObj->wrap($userFields_marker['###USERFIELD_ERROR###'], $this->conf['errorwrap']);
                 }
                 $userFields_content .= $this->cObj->substituteMarkerArrayCached($userField_thisTemplate, $userFields_marker);
             }
         }
         /*
         			$parser = GeneralUtility::makeInstance('t3lib_TSparser');
                     while($arr = $this->databaseHandle->sql_fetch_assoc($res)) {
                         $parser->setup = array();
                         if (strlen($arr['config'])>0) {
                             $parser->parse($arr['config']);
                             $config = $parser->setup;
                         } else $config = array();
             if ($config['label']) $label = $this->cObj->cObjGetSingle($config['label'],$config['label.']);
                         else $label = $arr['label'];
         
         				if ($config['required'])
         					$label = $this->cObj->wrap($label, $this->conf['required.']['fieldWrap']);
             if ($config['input']) {
                             $data = array(
                                 'fieldvalue'        => $value
                             );
                             $tmpData = $this->cObj->data;
                             $this->cObj->data = $data;
                 $input = $this->cObj->cObjGetSingle($config['input'],$config['input.']);
                 $this->cObj->data = $tmpData;
                         } else $input = $this->cObj->getSubpart($userField_template, '###DEFUSERFIELD###');
                         $userField_thisTemplate = $this->cObj->substituteSubpart($userField_template, '###DEFUSERFIELD###', $input);
             if ($config['datasource']) {
                             $label .= '<input type="hidden" name="tx_mmforum_pi2[userfields_exist]['.$arr['uid'].']" value="'.$config['datasource'].'" />';
                         }
             $userFields_marker = array(
                             '###USERFIELD_LABEL###'     => $label,
                             '###USERFIELD_UID###'       => $arr['uid'],
                             '###USERFIELD_NAME###'      => 'tx_mmforum_pi2[userfields]['.$arr['uid'].']',
                             '###USERFIELD_VALUE###'     => $this->piVars['userfields'][$arr['uid']]?$this->piVars['userfields'][$arr['uid']]:'',
         					'###USERFIELD_ERROR###'		=> $marker['userfield_error'][$arr['uid']]
                         );
                         $userFields_content .= $this->cObj->substituteMarkerArrayCached($userField_thisTemplate, $userFields_marker);
                     }
         */
     }
     $template = $this->cObj->substituteSubpart($template, '###USERFIELDS###', $userFields_content);
     $template = $this->cObj->substituteMarkerArrayCached($template, $marker);
     return $template;
 }