/**
  * 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') . '*';
 }
 /**
  * Outputs search format including $html being html with input fields
  *
  * @param  moscomprofilerFields  $field
  * @param  moscomprofilerUser    $user
  * @param  string                $html
  * @param  string                $type   'text', 'choice', 'isisnot', 'none'
  * @param  int                   $list_compare_types   IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
  * @param  string                $class  Extra-class (e.g. for jQuery)
  * @return string
  */
 function _fieldSearchModeHtml(&$field, &$user, $html, $type, $list_compare_types, $class = '')
 {
     switch ($list_compare_types) {
         case 1:
             // Advanced: all possibilities:
             $col = $field->name . '__srmch';
             $selected = $user->get($col);
             switch ($type) {
                 case 'text':
                     $choices = array('is' => _UE_MATCH_IS_EXACTLY, 'phrase' => _UE_MATCH_PHRASE, 'all' => _UE_MATCH_ALL, 'any' => _UE_MATCH_ANY, '-' => _UE_MATCH_EXCLUSIONS . ':', 'isnot' => _UE_MATCH_IS_EXACTLY_NOT, 'phrasenot' => _UE_MATCH_PHRASE_NOT, 'allnot' => _UE_MATCH_ALL_NOT, 'anynot' => _UE_MATCH_ANY_NOT);
                     break;
                 case 'singlechoice':
                     $choices = array('is' => _UE_MATCH_IS, 'anyis' => _UE_MATCH_IS_ONE_OF, '-' => _UE_MATCH_EXCLUSIONS . ':', 'isnot' => _UE_MATCH_IS_NOT, 'anyisnot' => _UE_MATCH_IS_NOT_ONE_OF);
                     break;
                 case 'multiplechoice':
                     $choices = array('is' => _UE_MATCH_ARE_EXACTLY, 'all' => _UE_MATCH_INCLUDE_ALL_OF, 'any' => _UE_MATCH_INCLUDE_ANY_OF, '-' => _UE_MATCH_EXCLUSIONS . ':', 'isnot' => _UE_MATCH_ARE_EXACTLY_NOT, 'allnot' => _UE_MATCH_INCLUDE_ALL_OF_NOT, 'anynot' => _UE_MATCH_INCLUDE_ANY_OF_NOT);
                     break;
                 case 'isisnot':
                     $choices = array('is' => _UE_MATCH_IS, '-' => _UE_MATCH_EXCLUSIONS . ':', 'isnot' => _UE_MATCH_IS_NOT);
                     break;
                 case 'none':
                 default:
                     $choices = null;
                     break;
             }
             if ($choices !== null) {
                 $drop = array();
                 $drop[] = moscomprofilerHTML::makeOption('', _UE_NO_PREFERENCE);
                 $group = false;
                 foreach ($choices as $k => $v) {
                     if ($k == '-') {
                         $drop[] = moscomprofilerHTML::makeOptGroup($v);
                         $group = true;
                     } else {
                         $drop[] = moscomprofilerHTML::makeOption($k, $v);
                     }
                 }
                 if ($group) {
                     $drop[] = moscomprofilerHTML::makeOptGroup(null);
                 }
                 $additional = ' class="inputbox"';
                 $list = moscomprofilerHTML::selectList($drop, $field->name . '__srmch', $additional, 'value', 'text', $selected, 1);
             } else {
                 $list = null;
             }
             $return = '<div class="cbSearchContainer cbSearchAdvanced">' . ($list ? '<div class="cbSearchKind">' . $list . '</div>' : '') . '<div class="cbSearchCriteria' . ($class ? ' ' . $class : '') . '">' . $html . '</div>' . '</div>';
             break;
         case 2:
             // Simple "contains" and ranges:
         // Simple "contains" and ranges:
         case 0:
         default:
             // Simple: Only 'is' and ranges:
             $return = '<div class="cbSearchContainer cbSearchSimple">' . '<div class="cbSearchCriteria' . ($class ? ' ' . $class : '') . '">' . $html . '</div>' . '</div>';
             break;
     }
     return $return;
 }
 /**
  * 
  * 
  * @param  string|array   $input
  * @param  boolean|array  $htmlspecialcharsParam  on replaced values only: FALSE : no htmlspecialchars, TRUE: do htmlspecialchars, ARRAY: callback method
  * @return string
  */
 function _evaluateCbFields($input, $htmlspecialcharsParam = null)
 {
     static $htmlspecialchars = null;
     $regex = '/\\[([\\w-]+)\\]/';
     if (is_array($input)) {
         if ($this !== null && is_object($this->_cbuser) && isset($this->_cbuser->id)) {
             $val = $this->getField($input[1], null, 'php', 'none', 'profile', 0, true);
             // allow accessing all fields in the data
             if (is_array($val)) {
                 $val = array_shift($val);
                 if (is_array($val)) {
                     $val = implode('|*|', $val);
                 }
             } elseif (isset($this->_cbuser->{$input}[1])) {
                 $val = $this->_cbuser->get($input[1]);
             } else {
                 $lowercaseVarName = strtolower($input[1]);
                 if (isset($this->_cbuser->{$lowercaseVarName})) {
                     $val = $this->_cbuser->get($lowercaseVarName);
                 } else {
                     $val = array();
                     // avoid substitution
                 }
             }
             if (!is_object($val) && !is_array($val)) {
                 if (!(strtolower($input[1]) == 'password' && strlen($val) >= 32)) {
                     if (is_array($htmlspecialchars)) {
                         $val = call_user_func_array($htmlspecialchars, array($val));
                     } elseif ($htmlspecialchars) {
                         $val = htmlspecialchars($val);
                     }
                     return $val;
                 }
             }
         }
         return '[' . $input[1] . ']';
     }
     $htmlspecialchars = $htmlspecialcharsParam;
     return preg_replace_callback($regex, array($this, '_evaluateCbFields'), $input);
 }