/**
  * Returns a list of grouped parameters
  *
  * 2 parameters are joined by "and":
  * => A and B
  * Up to 5 parameters are joined by "," and "and":
  * => A, B, C, D and E
  * More than 5 parameters are joined by "," and trimmed:
  * => A, B, C and #n more
  *
  * @param array $parameterList
  * @param array $plainParameterList
  * @param bool $highlightParams
  * @return string
  */
 protected function joinParameterList($parameterList, $plainParameterList, $highlightParams)
 {
     if (empty($parameterList)) {
         return '';
     }
     $count = sizeof($parameterList);
     $lastItem = array_pop($parameterList);
     if ($count === 1) {
         return $lastItem;
     } else {
         if ($count === 2) {
             $firstItem = array_pop($parameterList);
             return $this->l->t('%s and %s', array($firstItem, $lastItem));
         } else {
             if ($count <= 5) {
                 $list = implode($this->l->t(', '), $parameterList);
                 return $this->l->t('%s and %s', array($list, $lastItem));
             }
         }
     }
     $firstParams = array_slice($parameterList, 0, 3);
     $firstList = implode($this->l->t(', '), $firstParams);
     $trimmedParams = array_slice($plainParameterList, 3);
     $trimmedList = implode($this->l->t(', '), $trimmedParams);
     if ($highlightParams) {
         return $this->l->n('%s and <strong %s>%n more</strong>', '%s and <strong %s>%n more</strong>', $count - 3, array($firstList, 'class="has-tooltip" title="' . Util::sanitizeHTML($trimmedList) . '"'));
     }
     return $this->l->n('%s and %n more', '%s and %n more', $count - 3, array($firstList));
 }
Esempio n. 2
0
 /**
  * @return WizardResult
  * @throws \Exception
  */
 public function countUsers()
 {
     $filter = $this->access->getFilterForUserCount();
     $usersTotal = $this->formatCountResult($this->countEntries($filter, 'users'));
     $output = self::$l->n('%s user found', '%s users found', $usersTotal, array($usersTotal));
     $this->result->addChange('ldap_user_count', $output);
     return $this->result;
 }