Exemple #1
0
 public function prepareValueForDisplay($value, $field)
 {
     $db = JFactory::getDbo();
     $value = (array) $value;
     $condition = '';
     foreach ($value as $v) {
         if (!$v) {
             continue;
         }
         $condition .= ', ' . $db->q($v);
     }
     $query = $field->fieldparams->get('query', 'select id as value, name as text from #__users');
     // Run the query with a having condition because it support aliases
     $db->setQuery($query . ' having value in (' . trim($condition, ',') . ')');
     $items = array();
     try {
         $items = $db->loadObjectlist();
     } catch (Exception $e) {
         // If the query failed, we fetch all elements
         $db->setQuery($query);
         $items = $db->loadObjectlist();
     }
     $texts = array();
     foreach ($items as $item) {
         if (in_array($item->value, $value)) {
             $texts[] = $item->text;
         }
     }
     return parent::prepareValueForDisplay($texts, $field);
 }
Exemple #2
0
 public function prepareValueForDisplay($value, $field)
 {
     $value = (array) $value;
     JLoader::register('UsersHelper', JPATH_ADMINISTRATOR . '/components/com_users/helpers/users.php');
     $texts = array();
     foreach (UsersHelper::getGroups() as $group) {
         if (in_array($group->value, $value)) {
             $texts[] = parent::prepareValueForDisplay(trim($group->text, '- '), $field);
         }
     }
     return parent::prepareValueForDisplay($texts, $field);
 }
Exemple #3
0
 public function prepareValueForDisplay($value, $field)
 {
     if (!is_array($value)) {
         $value = array($value);
     }
     $texts = array();
     foreach ($this->getOptions($field) as $index => $optionsValue) {
         if (in_array($index, $value)) {
             $texts[] = $optionsValue;
         }
     }
     return parent::prepareValueForDisplay($texts, $field);
 }
Exemple #4
0
 public function prepareValueForDisplay($value, $field)
 {
     $value = (array) $value;
     $texts = array();
     foreach ($value as $userId) {
         if (!$userId) {
             continue;
         }
         $user = JFactory::getUser($userId);
         if ($user) {
             $texts[] = $user->name;
         } else {
             $texts[] = $userId;
         }
     }
     return parent::prepareValueForDisplay($texts, $field);
 }