Ejemplo n.º 1
0
 /**
  * Replaces a given link be it email or hyperlink and return the proper
  * counterparts.
  *
  * @param    $url    A valid url
  *
  * return    $link    HTML formatted codes that links to given email
  */
 public static function getHyperLink($url)
 {
     $link = JString::trim($url);
     //CFactory::load( 'helpers' , 'validate' );
     if (CValidateHelper::email($link)) {
         return self::getEmailURL($link);
     }
     if (CValidateHelper::url($link)) {
         return self::getURL($link);
     }
     // Since the link is really not a link, we just return the original format.
     return $link;
 }
Ejemplo n.º 2
0
 /**
  * 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');
 }
Ejemplo n.º 3
0
 public function isValid($value, $required)
 {
     //CFactory::load( 'helpers' , 'validate' );
     $isValid = CValidateHelper::url($value);
     $url = parse_url($value);
     $host = isset($url['host']) ? $url['host'] : '';
     /* this field is required OR user entered something */
     if ($required || $value != '') {
         /* it must be valid AND NOT empty host AND validLength*/
         return $isValid && !empty($host) && $this->validLength($value);
     }
     /* no required and user no entered anything than of course VALID */
     return true;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 function isValid($value, $required)
 {
     CFactory::load('helpers', 'validate');
     $isValid = CValidateHelper::url($value);
     $url = parse_url($value);
     $host = isset($url['host']) ? $url['host'] : '';
     if (!$isValid && $required) {
         return false;
     } else {
         if (!empty($host) && !$isValid) {
             return false;
         }
     }
     return true;
 }
Ejemplo n.º 6
0
 public function isValid($value, $required)
 {
     CFactory::load('helpers', 'validate');
     $isValid = CValidateHelper::url($value);
     $url = parse_url($value);
     $host = isset($url['host']) ? $url['host'] : '';
     //validate url format
     if (!$isValid && $required) {
         return false;
     } else {
         if (!empty($host) && !$isValid) {
             return false;
         }
     }
     //validate length
     if (!$this->validLength($value)) {
         return false;
     }
     return true;
 }