/** * Return the 'about us' html block */ function _getProfileHTML(&$profile) { $tmpl = new CTemplate(); $profileModel = CFactory::getModel('profile'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $userid = JRequest::getVar('userid', $my->id); $user = CFactory::getUser($userid); $profileField =& $profile['fields']; CFactory::load('helpers', 'linkgenerator'); CFactory::load('helpers', 'validate'); // Allow search only on profile with type text and not empty foreach ($profileField as $key => $val) { foreach ($profileField[$key] as $pKey => $pVal) { $field =& $profileField[$key][$pKey]; // Remove this info if we don't want empty field displayed if (!$config->get('showemptyfield') && (empty($field['value']) && $field['value'] != "0")) { unset($profileField[$key][$pKey]); } else { if (!empty($field['value']) || $field['value'] == "0") { switch ($field['type']) { case 'text': if (CValidateHelper::email($field['value'])) { $profileField[$key][$pKey]['value'] = CLinkGeneratorHelper::getEmailURL($field['value']); } else { if (CValidateHelper::url($field['value'])) { $profileField[$key][$pKey]['value'] = CLinkGeneratorHelper::getHyperLink($field['value']); } else { if (!CValidateHelper::phone($field['value']) && !empty($field['fieldcode'])) { $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($field['value'])); } } } break; case 'select': case 'singleselect': case 'radio': case 'checkbox': $profileField[$key][$pKey]['searchLink'] = array(); $checkboxArray = explode(',', $field['value']); foreach ($checkboxArray as $item) { if (!empty($item)) { $profileField[$key][$pKey]['searchLink'][$item] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($item) . '&type=checkbox'); } } break; case 'country': $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($field['value'])); break; default: break; } } } } } CFactory::load('libraries', 'profile'); $tmpl->set('profile', $profile); $tmpl->set('isMine', COwnerHelper::isMine($my->id, $user->id)); return $tmpl->fetch('profile.about'); }
/** * Deprecated since 1.8 * Use CLinkGeneratorHelper::getHyperLink instead. */ function cGenerateHyperLink($hyperlink) { return CLinkGeneratorHelper::getHyperLink($hyperlink); }
/** * Return the 'about us' html block */ private function _getProfileHTML(&$profile) { $tmpl = new CTemplate(); $mainframe = JFactory::getApplication(); $jinput = $mainframe->input; $profileModel = CFactory::getModel('profile'); $my = CFactory::getUser(); $config = CFactory::getConfig(); $userid = $jinput->get('userid', $my->id, 'INT'); $user = CFactory::getUser($userid); $profileField = $profile['fields']; $isAdmin = COwnerHelper::isCommunityAdmin(); // Allow search only on profile with type text and not empty foreach ($profileField as $key => $val) { foreach ($profileField[$key] as $pKey => $pVal) { $field = $profileField[$key][$pKey]; //check for admin only fields if (!$isAdmin && $field['visible'] == 2) { unset($profileField[$key][$pKey]); } else { // Remove this info if we don't want empty field displayed if (!$config->get('showemptyfield') && (empty($field['value']) && $field['value'] != "0")) { unset($profileField[$key][$pKey]); } else { if ((!empty($field['value']) || $field['value'] == "0") && $field['searchable']) { switch ($field['type']) { case 'birthdate': $params = new CParameter($field['params']); $format = $params->get('display'); if ($format == 'age') { $profileField[$key][$pKey]['name'] = JText::_('COM_COMMUNITY_AGE'); } break; case 'text': if (CValidateHelper::email($field['value'])) { $profileField[$key][$pKey]['value'] = CLinkGeneratorHelper::getEmailURL($field['value']); } else { if (CValidateHelper::url($field['value'])) { $profileField[$key][$pKey]['value'] = CLinkGeneratorHelper::getHyperLink($field['value']); } else { if (!CValidateHelper::phone($field['value']) && !empty($field['fieldcode'])) { $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($field['value'])); } } } break; case 'select': case 'singleselect': $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($field['value']) . '&type=' . $field['type']); $profileField[$key][$pKey]['value'] = JText::_($field['value']); break; case 'radio': case 'checkbox': $profileField[$key][$pKey]['searchLink'] = array(); $checkboxArray = explode(',', $field['value']); foreach ($checkboxArray as $item) { if (!empty($item)) { $profileField[$key][$pKey]['searchLink'][$item] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($item) . '&type=' . $field['type']); } } break; case 'country': $lang = JFactory::getLanguage(); $lang->load('com_community.country'); $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode(JText::_($field['value']))); $profileField[$key][$pKey]['value'] = JText::_($field['value']); break; case 'gender': $profileField[$key][$pKey]['searchLink'] = CRoute::_('index.php?option=com_community&view=search&task=field&' . $field['fieldcode'] . '=' . urlencode($field['value'])); break; default: break; } } } } } } $profile['fields'] = $profileField; $html = $tmpl->set('profile', $profile)->set('isMine', COwnerHelper::isMine($my->id, $user->id))->fetch('profile.about'); return $html; }