<?php
namespace Vendor\Addon\Index\Provider;
use cv6\Core\Index\Provider\AbstractProvider;
use XF\Mvc\Entity\Finder;
use XF\Phrase;
class Georgian extends AbstractProvider
{
public function getId(): string
{
return 'georgian';
}
public function getTitle(): Phrase|string
{
return \XF::phrase('vendor_addon_alphabet_georgian');
}
/**
* Returns an array of uppercase/standard letter symbols for the index bar.
*
* @return string[]
*/
public function getLetters(): array
{
return [
'ა', 'ბ', 'გ', 'დ', 'ე', 'ვ', 'ზ', 'თ', 'ი', 'კ', 'ლ', 'მ', 'ნ',
'ო', 'პ', 'ჟ', 'რ', 'ს', 'ტ', 'უ', 'ფ', 'ქ', 'ღ', 'ყ', 'შ', 'ჩ',
'ც', 'ძ', 'წ', 'ჭ', 'ხ', 'ჯ', 'ჰ',
];
}
/**
* Normalizes an incoming letter character (e.g. casing, accents, variants).
*/
public function normalizeLetter(string $character): string
{
return mb_strtoupper($character, 'UTF-8');
}
/**
* Determines whether the given character belongs to this alphabet.
*/
public function isLetter(string $character): bool
{
return in_array($this->normalizeLetter($character), $this->getLetters(), true);
}
/**
* Filters the finder for records starting with the selected letter.
*/
public function applyLetterFilter(Finder $finder, string $column, string $letter): void
{
$escaped = $finder->escapeLike($letter, '?%');
$finder->whereSql($column . ' LIKE ' . \XF::db()->quote($escaped));
}
/**
* Filters for records starting with numbers (0-9).
*/
public function applyNumberFilter(Finder $finder, string $column): void
{
$finder->whereSql($column . ' REGEXP "^[0-9]"');
}
/**
* Filters for non-alphabetic, non-numeric characters ("Other / #").
*/
public function applyOtherFilter(Finder $finder, string $column): void
{
$finder->whereSql($column . ' REGEXP "^[^0-9\x{10D0}-\x{10FA}]"');
}
/**
* Return true if the alphabet requires Right-to-Left (RTL) layout.
*/
public function isRtl(): bool
{
return false;
}
}