references($currentField, $query, $options)->initials(); $initials = []; if (array_key_exists('initial', $references[key($references)])) { foreach ($references as $reference => $referenceData) { $initial = $referenceData['initial']; if (empty($initials[$initial])) { $initials[preg_match('/\W|\d/u', $initial) ? '0-9' : $initial] = true; } } } else { foreach ($references as $reference => $referenceData) { $initial = mb_strtoupper(mb_substr($reference, 0, 1)); if (empty($initials[$initial])) { $initials[preg_match('/\W|\d/u', $initial) ? '0-9' : $initial] = true; } } } } else { $list = $initials; $initials = []; // Merge special initials. foreach ($list as $initial => $total) { if (empty($initials[$initial])) { $initials[preg_match('/\W|\d/u', $initial) ? '0-9' : $initial] = true; } } } // Add the empty letters. // Get the default list of initials for latin. To be updated for non-latin references. // Anyway, even in latin, some characters are not transcoded, like Œ. $alphabet = ['0-9' => false] + array_fill_keys(range('A', 'Z'), false); $initials = array_merge($alphabet, $initials); // Don't display symbols if useless. if (empty($initials['0-9'])) unset($initials['0-9']); if (!empty($options['by_initial'])) { $baseUrl = $this->url(null, [], true) . '?begin='; $initial = $this->params()->fromQuery('begin'); $active = $initial ? mb_strtolower($initial) : 'a'; } else { $baseUrl = '#'; $active = ''; } // Display the list of initials. $paginationList = '