/**
  * Returns a field in specified format
  *
  * @param  moscomprofilerFields  $field
  * @param  moscomprofilerUser    $user
  * @param  string                $output  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string                $reason  'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @return mixed                
  */
 function getField(&$field, &$user, $output, $reason, $list_compare_types)
 {
     global $ueConfig;
     $value = $user->get($field->name);
     switch ($output) {
         case 'html':
         case 'rss':
             if ($value == null) {
                 return '';
             } elseif ($ueConfig['allow_website'] == 1) {
                 $oReturn = $this->_explodeCBvalues($value);
                 if (count($oReturn) < 2) {
                     $oReturn[1] = $oReturn[0];
                 }
                 return '<a href="http://' . htmlspecialchars($oReturn[0]) . '" target="_blank" rel="nofollow">' . htmlspecialchars($oReturn[1]) . '</a>';
             } else {
                 return htmlspecialchars($value);
             }
             break;
         case 'htmledit':
             if ($field->rows != 2) {
                 $oReturn = $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $value, '');
             } else {
                 $oValuesArr = $this->_explodeCBvalues($value);
                 if (count($oValuesArr) < 2) {
                     $oValuesArr[1] = '';
                 }
                 $oReturn = '<span class="webUrlSpan">' . '<span class="subTitleSpan">' . _UE_WEBURL . ':</span>' . '<span class="subFieldSpan">' . $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $oValuesArr[0], '') . '</span></span>';
                 $saveFieldName = $field->name;
                 $saveFieldTitle = $field->title;
                 $field->name = $saveFieldName . 'Text';
                 $field->title = $field->title . ': ' . _UE_WEBTEXT;
                 $oReturn .= '<span class="webTextSpan">' . '<span class="subTitleSpan">' . _UE_WEBTEXT . ':</span>' . '<span class="subFieldSpan">' . $this->_fieldEditToHtml($field, $user, $reason, 'input', 'text', $oValuesArr[1], '') . '</span></span>';
                 $field->name = $saveFieldName;
                 $field->title = $saveFieldTitle;
             }
             if ($reason == 'search') {
                 $oReturn = $this->_fieldSearchModeHtml($field, $user, $oReturn, 'text', $list_compare_types);
             }
             return $oReturn;
             break;
         case 'json':
         case 'php':
         case 'xml':
         case 'csvheader':
         case 'fieldslist':
         case 'csv':
         default:
             return parent::getField($field, $user, $output, $reason, $list_compare_types);
             break;
     }
     return '*' . CBTxt::T('Unknown Output Format') . '*';
 }
Exemple #2
0
 /**
  *
  *
  * @param  FieldTable  $field
  * @param  UserTable   $user
  * @param  string      $output             'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
  * @param  string      $reason             'profile' for user profile view, 'edit' for profile edit, 'register' for registration, 'list' for user-lists
  * @param  boolean     $displayFieldIcons
  * @return string                          HTML: <tag type="$type" value="$value" xxxx="xxx" yy="y" />
  */
 function _htmlEditForm(&$field, &$user, $output, $reason, $displayFieldIcons = true)
 {
     global $_CB_framework;
     $fieldName = $field->get('name');
     $value = $user->get($fieldName);
     $required = $this->_isRequired($field, $user, $reason);
     $uploadSizeLimitMax = $field->params->get('fieldValidateAudio_sizeMax', 1024);
     $uploadSizeLimitMin = $field->params->get('fieldValidateAudio_sizeMin', 0);
     $uploadExtensionLimit = $this->allowedExtensions();
     $restrictions = array();
     if ($uploadExtensionLimit) {
         $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_EXT', 'Your audio file must be of [ext] type.', array('[ext]' => implode(', ', $uploadExtensionLimit)));
     }
     if ($uploadSizeLimitMin) {
         $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_MIN', 'Your audio file should exceed [size].', array('[size]' => $this->formattedFileSize($uploadSizeLimitMin * 1024)));
     }
     if ($uploadSizeLimitMax) {
         $restrictions[] = CBTxt::Th('AUDIO_FILE_UPLOAD_LIMITS_MAX', 'Your audio file should not exceed [size].', array('[size]' => $this->formattedFileSize($uploadSizeLimitMax * 1024)));
     }
     $existingFile = $user->get('id') ? $value != null ? true : false : false;
     $choices = array();
     if ($reason == 'register' || $reason == 'edit' && $user->id == 0) {
         if ($required == 0) {
             $choices[] = moscomprofilerHTML::makeOption('', CBTxt::T('No audio file'));
         }
     } else {
         if ($existingFile || $required == 0) {
             $choices[] = moscomprofilerHTML::makeOption('', CBTxt::T('No change of audio file'));
         }
     }
     $selected = null;
     if ($required == 1 && !$existingFile) {
         $selected = 'upload';
     }
     if ($field->params->get('audio_allow_links', 1)) {
         $choices[] = moscomprofilerHTML::makeOption('link', $existingFile ? CBTxt::T('Link to new audio file') : CBTxt::T('Link to audio file'));
     }
     $choices[] = moscomprofilerHTML::makeOption('upload', $existingFile ? CBTxt::T('Upload new audio file') : CBTxt::T('Upload audio file'));
     if ($existingFile && $required == 0) {
         $choices[] = moscomprofilerHTML::makeOption('delete', CBTxt::T('Remove audio file'));
     }
     $return = null;
     if ($reason != 'register' && $user->id != 0 && $existingFile) {
         $return .= '<div class="form-group cb_form_line clearfix">' . $this->getEmbed($field, $user, $value, $reason) . '</div>';
     }
     if (count($choices) > 1) {
         static $functOut = false;
         $additional = ' class="form-control"';
         if ($_CB_framework->getUi() == 1 && $reason == 'edit' && $field->get('readonly')) {
             $additional .= ' disabled="disabled"';
         }
         $translatedTitle = $this->getFieldTitle($field, $user, 'html', $reason);
         $htmlDescription = $this->getFieldDescription($field, $user, 'htmledit', $reason);
         $trimmedDescription = trim(strip_tags($htmlDescription));
         $tooltip = $trimmedDescription ? cbTooltip($_CB_framework->getUi(), $htmlDescription, $translatedTitle, null, null, null, null, $additional) : $additional;
         $return .= '<div class="form-group cb_form_line clearfix">' . moscomprofilerHTML::selectList($choices, $fieldName . '__choice', $tooltip, 'value', 'text', $selected, $required, true, null, false) . $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, 'select', '', null, '', array(), $displayFieldIcons, $required) . '</div>';
         if (!$functOut) {
             $js = "function cbslideAudioFile( choice, name ) {" . "if ( ( choice == '' ) || ( choice == 'delete' ) ) {" . "\$( '#cbaudiofile_upload_' + name + ',#cbaudiofile_link_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_upload_' + name + ' input,#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', true );" . "} else if ( choice == 'upload' ) {" . "\$( '#cbaudiofile_link_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_upload_' + name ).slideDown( 'slow' );" . "\$( '#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', true );" . "\$( '#cbaudiofile_upload_' + name + ' input' ).prop( 'readonly', false );" . "} else if ( choice == 'link' ) {" . "\$( '#cbaudiofile_upload_' + name ).slideUp( 'slow' );" . "\$( '#cbaudiofile_link_' + name ).slideDown( 'slow' );" . "\$( '#cbaudiofile_upload_' + name + ' input' ).prop( 'readonly', true );" . "\$( '#cbaudiofile_link_' + name + ' input' ).prop( 'readonly', false );" . "}" . "}";
             $_CB_framework->outputCbJQuery($js);
             $functOut = true;
         }
         $js = "\$( '#cbaudiofile_upload_" . addslashes($fieldName) . ",#cbaudiofile_link_" . addslashes($fieldName) . "' ).hide();" . "\$( '#cbaudiofile_upload_" . addslashes($fieldName) . " input,#cbaudiofile_link_" . addslashes($fieldName) . " input' ).prop( 'readonly', true );" . "\$( '#" . addslashes($fieldName) . "__choice' ).on( 'click change', function() {" . "cbslideAudioFile( \$( this ).val(), '" . addslashes($fieldName) . "' );" . "}).change();";
         $_CB_framework->outputCbJQuery($js);
     } else {
         $return .= '<input type="hidden" name="' . htmlspecialchars($fieldName) . '__choice" value="' . htmlspecialchars($choices[0]->value) . '" />';
     }
     $validationAttributes = array();
     $validationAttributes[] = cbValidator::getRuleHtmlAttributes('extension', implode(',', $uploadExtensionLimit));
     if ($uploadSizeLimitMin || $uploadSizeLimitMax) {
         $validationAttributes[] = cbValidator::getRuleHtmlAttributes('filesize', array($uploadSizeLimitMin, $uploadSizeLimitMax, 'KB'));
     }
     $return .= '<div id="cbaudiofile_upload_' . htmlspecialchars($fieldName) . '" class="form-group cb_form_line clearfix">' . ($restrictions ? '<div class="help-block">' . implode(' ', $restrictions) . '</div>' : null) . '<div>' . CBTxt::T('Select audio file') . ' <input type="file" name="' . htmlspecialchars($fieldName) . '__file" value="" class="form-control' . ($required == 1 ? ' required' : null) . '"' . implode(' ', $validationAttributes) . ' />' . (count($choices) <= 0 ? $this->_fieldIconsHtml($field, $user, 'htmledit', $reason, 'select', '', null, '', array(), $displayFieldIcons, $required) : null) . '</div>' . '<div class="help-block">';
     if ($field->params->get('audio_terms', 0)) {
         $termsOutput = $field->params->get('terms_output', 'url');
         $termsType = CBTxt::T($field->params->get('terms_type', null));
         $termsDisplay = $field->params->get('terms_display', 'modal');
         $termsURL = $field->params->get('terms_url', null);
         $termsText = $field->params->get('terms_text', null);
         $termsWidth = (int) $field->params->get('terms_width', 400);
         $termsHeight = (int) $field->params->get('terms_height', 200);
         if (!$termsType) {
             $termsType = CBTxt::T('TERMS_AND_CONDITIONS', 'Terms and Conditions');
         }
         if (!$termsWidth) {
             $termsWidth = 400;
         }
         if (!$termsHeight) {
             $termsHeight = 200;
         }
         if ($termsOutput == 'url' && $termsURL || $termsOutput == 'text' && $termsText) {
             if ($termsDisplay == 'iframe') {
                 if (is_numeric($termsHeight)) {
                     $termsHeight .= 'px';
                 }
                 if (is_numeric($termsWidth)) {
                     $termsWidth .= 'px';
                 }
                 if ($termsOutput == 'url') {
                     $return .= '<div class="embed-responsive cbTermsFrameContainer" style="padding-bottom: ' . htmlspecialchars($termsHeight) . ';">' . '<iframe class="embed-responsive-item cbTermsFrameURL" style="width: ' . htmlspecialchars($termsWidth) . ';" src="' . htmlspecialchars($termsURL) . '"></iframe>' . '</div>';
                 } else {
                     $return .= '<div class="cbTermsFrameText" style="height:' . htmlspecialchars($termsHeight) . ';width:' . htmlspecialchars($termsWidth) . ';overflow:auto;">' . $termsText . '</div>';
                 }
                 $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE_TERMS', 'By uploading, you certify that you have the right to distribute this audio file and that it does not violate the above [type].', array('[type]' => $termsType));
             } else {
                 $attributes = ' class="cbTermsLink"';
                 if ($termsOutput == 'text' && $termsDisplay == 'window') {
                     $termsDisplay = 'modal';
                 }
                 if ($termsDisplay == 'modal') {
                     // Tooltip height percentage would be based off window height (including scrolling); lets change it to be based off the viewport height:
                     $termsHeight = substr($termsHeight, -1) == '%' ? (int) substr($termsHeight, 0, -1) . 'vh' : $termsHeight;
                     if ($termsOutput == 'url') {
                         $tooltip = '<iframe class="cbTermsModalURL" height="100%" width="100%" src="' . htmlspecialchars($termsURL) . '"></iframe>';
                     } else {
                         $tooltip = '<div class="cbTermsModalText" style="height:100%;width:100%;overflow:auto;">' . $termsText . '</div>';
                     }
                     $url = 'javascript:void(0);';
                     $attributes .= ' ' . cbTooltip($_CB_framework->getUi(), $tooltip, $termsType, array($termsWidth, $termsHeight), null, null, null, 'data-hascbtooltip="true" data-cbtooltip-modal="true"');
                 } else {
                     $url = htmlspecialchars($termsURL);
                     $attributes .= ' target="_blank"';
                 }
                 $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE_URL_TERMS', 'By uploading, you certify that you have the right to distribute this audio file and that it does not violate the <a href="[url]"[attributes]>[type]</a>', array('[url]' => $url, '[attributes]' => $attributes, '[type]' => $termsType));
             }
         } else {
             $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE', 'By uploading, you certify that you have the right to distribute this audio file.');
         }
     } else {
         $return .= CBTxt::Th('BY_UPLOADING_YOU_CERTIFY_THAT_YOU_HAVE_THE_RIGHT_TO_DISTRIBUTE_THIS_AUDIO_FILE', 'By uploading, you certify that you have the right to distribute this audio file.');
     }
     $return .= '</div>' . '</div>' . '<div id="cbaudiofile_link_' . htmlspecialchars($fieldName) . '" class="form-group cb_form_line clearfix">' . '<p>';
     if ($field->params->get('audio_allow_links', 1)) {
         $linkField = new FieldTable($field->getDbo());
         foreach (array_keys(get_object_vars($linkField)) as $k) {
             $linkField->set($k, $field->get($k));
         }
         $linkField->set('type', 'text');
         $linkField->set('description', null);
         $user->set($fieldName, strpos($value, '/') !== false || strpos($value, '\\') !== false ? $value : null);
         $return .= parent::getField($linkField, $user, $output, $reason, 0);
         $user->set($fieldName, $value);
         unset($linkField);
     }
     $return .= '</p>' . '</div>';
     return $return;
 }
Exemple #3
0
	/**
	 * @param FieldTable $field
	 * @param UserTable  $user
	 * @param string     $output
	 * @param string     $reason
	 * @param int        $list_compare_types
	 * @return mixed
	 */
	public function getField( &$field, &$user, $output, $reason, $list_compare_types )
	{
		if ( ( $reason == 'register' ) && ( $output == 'htmledit' ) ) {
			$code	=	cbGetParam( $_GET, 'invite_code' );

			if ( $code ) {
				$user->set( 'invite_code', $code );
			}
		}

		$field->set( 'type', 'text' );

		return parent::getField( $field, $user, $output, $reason, $list_compare_types );
	}