| 1: | <?php |
| 2: | namespace TIC\CoreBundle\Util; |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | class IconHelper |
| 8: | { |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | private function __construct() |
| 14: | { |
| 15: | } |
| 16: | |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | public static function biName(string $name): string |
| 24: | { |
| 25: | if ($name === null || $name == '') return ''; |
| 26: | if (\substr($name, 0, 3) === 'bi-') return $name; |
| 27: | switch ($name) { |
| 28: | case 'list' : return 'bi-list'; |
| 29: | case 'next' : return 'bi-chevron-right'; |
| 30: | case 'prev' : |
| 31: | case 'back' : return 'bi-chevron-left'; |
| 32: | case 'show' : |
| 33: | case 'view' : return 'bi-eye'; |
| 34: | case 'create' : |
| 35: | case 'new' : return 'bi-plus-circle-fill'; |
| 36: | case 'update' : |
| 37: | case 'edit' : return 'bi-pencil-square'; |
| 38: | case 'close' : return 'bi-x-circle-fill'; |
| 39: | case 'submit' : return 'bi-check-circle-fill'; |
| 40: | case 'enable' : return 'bi-check-circle'; |
| 41: | case 'disable': return 'bi-slash-circle'; |
| 42: | case 'reset' : |
| 43: | case 'undo' : return 'bi-arrow-counterclockwise'; |
| 44: | case 'refresh': |
| 45: | case 'redo' : return 'bi-arrow-clockwise'; |
| 46: | case 'export' : return 'bi-cloud-download'; |
| 47: | case 'import' : return 'bi-cloud-upload'; |
| 48: | case 'login' : return 'bi-box-arrow-in-right'; |
| 49: | case 'logged' : return 'bi-person-circle'; |
| 50: | case 'home' : return 'bi-house-door-fill'; |
| 51: | case 'mail' : return 'bi-envelope'; |
| 52: | } |
| 53: | return 'bi-' . $name; |
| 54: | } |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | |
| 60: | |
| 61: | |
| 62: | public static function faName(string $name): string |
| 63: | { |
| 64: | if ($name === null || $name == '') return ''; |
| 65: | if (\substr($name, 0, 2) === 'fa') return $name; |
| 66: | switch ($name) { |
| 67: | case 'list' : return 'fas-list'; |
| 68: | case 'next' : return 'fas-chevron-right'; |
| 69: | case 'prev' : |
| 70: | case 'back' : return 'fas-chevron-left'; |
| 71: | case 'show' : |
| 72: | case 'view' : return 'fas-eye'; |
| 73: | case 'create' : |
| 74: | case 'new' : return 'fas-plus-circle'; |
| 75: | case 'update' : |
| 76: | case 'edit' : return 'fas-edit'; |
| 77: | case 'close' : return 'fas-circle-xmark'; |
| 78: | case 'submit' : return 'fas-check-circle'; |
| 79: | case 'enable' : return 'far-check-circle'; |
| 80: | case 'disable': return 'fas-ban'; |
| 81: | case 'reset' : |
| 82: | case 'undo' : return 'far-rotate-left'; |
| 83: | case 'refresh': |
| 84: | case 'redo' : return 'far-rotate-right'; |
| 85: | case 'export' : return 'far-cloud-arrow-down'; |
| 86: | case 'import' : return 'far-cloud-arrow-up'; |
| 87: | case 'login' : return 'fas-right-to-bracket'; |
| 88: | case 'logged' : return 'far-circle-user'; |
| 89: | case 'home' : return 'far-house'; |
| 90: | case 'mail' : return 'fas-envelope'; |
| 91: | } |
| 92: | return 'fa-' . $name; |
| 93: | } |
| 94: | |
| 95: | |
| 96: | |
| 97: | |
| 98: | |
| 99: | |
| 100: | |
| 101: | |
| 102: | public static function biTag(string $name, string $class=''): string |
| 103: | { |
| 104: | $name = self::biName($name); |
| 105: | if (\preg_match('/^(bi)-([a-z\-]*)$/', $name, $m)) return \sprintf( |
| 106: | '<i class="tic-icon bi bi-%1$s %2$s" aria-hidden="true" aria-label="%1$s" role="img"></i>', |
| 107: | $m[2], $class |
| 108: | ); |
| 109: | return ''; |
| 110: | } |
| 111: | |
| 112: | |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | |
| 119: | public static function faTag(string $name, string $class=''): string |
| 120: | { |
| 121: | $name = self::faName($name); |
| 122: | if (\preg_match('/^(fa[srlb]?)-(.*)$/', $name, $m)) return \sprintf( |
| 123: | '<i class="tic-icon %1$s fa-%2$s %3$s" aria-hidden="true" aria-label="%2$s" role="img"></i>', |
| 124: | $m[1], $m[2], $class |
| 125: | ); |
| 126: | return ''; |
| 127: | } |
| 128: | |
| 129: | } |
| 130: | |