| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaBaseView UNA Base Representation Classes
- * @{
- */
- /**
- * Basic Lucide iconset representation.
- * @see BxDolIconset
- */
- class BxBaseIconsetLucide extends BxBaseIconset
- {
- protected $_aMap;
- public function __construct ($aObject, $oTemplate)
- {
- parent::__construct ($aObject, $oTemplate);
- $this->_aMap = [
- 'ad' => 'circle-star',
- 'address-card' => 'id-card',
- 'angle-double-left' => 'chevrons-left',
- 'angle-double-right' => 'chevrons-right',
- 'arrows-alt' => 'move',
- 'book-reader' => 'book-open-text',
- 'buffer' => 'layers',
- 'building' => 'building',
- 'bullhorn' => 'megaphone',
- 'calendar-day' => 'calendar-days',
- 'calendar-plus' => 'calendar-plus',
- 'camera-retro' => 'camera',
- 'cart-arrow-down' => 'shopping-cart',
- 'cart-plus' => 'shopping-cart',
- 'cc-stripe' => 'credit-card',
- 'certificate' => 'award',
- 'chart-pie' => 'pie-chart',
- 'check-circle' => 'check-circle',
- 'check-double' => 'check-check',
- 'clipboard-check' => 'clipboard-check',
- 'cog' => 'settings',
- 'cogs' => 'settings',
- 'comment' => 'message-circle',
- 'comment-dots' => 'message-square-dashed',
- 'comments' => 'messages-square',
- 'donate' => 'hand-coins',
- 'ellipsis-h' => 'more-horizontal',
- 'ellipsis-v' => 'more-vertical',
- 'envelope' => 'mail',
- 'envelope-open-text' => 'mail-open',
- 'exchange-alt' => 'repeat',
- 'exclamation-circle' => 'alert-circle',
- 'exclamation-triangle' => 'alert-triangle',
- 'fa-book' => 'book-text',
- 'fa-bookmark' => 'bookmark',
- 'fa-smile' => 'smile',
- 'fa-thumbs-up' => 'thumbs-up',
- 'file-alt' => 'file',
- 'file-alt' => 'file-text',
- 'file-export' => 'file-output',
- 'file-invoice' => 'receipt',
- 'file-word' => 'file-text',
- 'group' => 'users',
- 'hand-holding-usd' => 'hand-coins',
- 'hashtag' => 'hash',
- 'helpcircle' => 'help-circle',
- 'house' => 'home',
- 'industry' => 'factory',
- 'info-circle' => 'info',
- 'keyround' => 'key-round',
- 'language' => 'languages',
- 'lockopen' => 'unlock',
- 'mail-bulk' => 'mails',
- 'map-marker' => 'map-pin',
- 'money-check-alt' => 'wallet-cards',
- 'object-group' => 'layout-dashboard',
- 'pencil-alt' => 'pencil-line',
- 'pencil-ruler' => 'ruler',
- 'photo-video' => 'image-play',
- 'plus-circle' => 'plus-circle',
- 'qrcode' => 'qr-code',
- 'quote-right' => 'quote',
- 'remove' => 'x',
- 'reply-all' => 'reply-all',
- 'search-location' => 'search-check',
- 'share-alt' => 'share-2',
- 'shield-alt' => 'shield',
- 'sign-in-alt' => 'log-in',
- 'sign-out-alt' => 'log-out',
- 'star-half-o' => 'star-half',
- 'swatchbook' => 'swatch-book',
- 'sync' => 'refresh-ccw',
- 'tachometer-alt' => 'gauge',
- 'tasks' => 'check-square',
- 'th-large' => 'grid-2x2',
- 'thumbtack' => 'pin',
- 'times' => 'x',
- 'times-circle' => 'x-circle',
- 'trash2' => 'trash-2',
- 'unlock-alt' => 'unlock',
- 'user-friends' => 'users',
- 'user-round' => 'user-round',
- 'user-slash' => 'user-x',
- 'user-times' => 'user-x',
- 'users-round' => 'users-round',
- 'video-camera' => 'video',
- ];
- }
- public function getPreloaderJs()
- {
- return 'https://unpkg.com/lucide@latest';
- }
- public function getIcon($sIcon)
- {
- $sIcon = trim(preg_replace('/(sys-icon|far|col-\w+)/i', '', $sIcon));
- if(isset($this->_aMap[$sIcon]))
- $sIcon = $this->_aMap[$sIcon];
- return bx_gen_method_name($sIcon, ['_', '-']);
- }
- public function getCode()
- {
- $sMap = json_encode($this->_aMap);
- $sCode = <<<BLAH
- function bx_iconset_init_lucide() {
- if(!window.lucide || !lucide.icons)
- return;
-
- const aMap = $sMap;
-
- document.querySelectorAll('i.sys-icon').forEach(el => {
- if(el.hasAttribute('data-lucide'))
- return;
- const sName = el.getAttribute('class').replace(/(sys-icon-bigger|sys-icon|fab|far|fas|col-\w+)/gi, '').trim().split(' ').shift();
- if(sName)
- el.setAttribute('data-lucide', aMap[sName] != undefined ? aMap[sName] : sName);
- else
- console.warn('Lucide: no icon class found on', el);
- });
- lucide.createIcons({
- attrs: { class: ['sys-icon'] },
- nameAttr: 'data-lucide'
- });
- };
- bx_iconset_init_lucide();
- if (typeof glOnProcessHtml === 'undefined')
- glOnProcessHtml = [];
- if (glOnProcessHtml instanceof Array) {
- glOnProcessHtml.push(function(e) {
- bx_iconset_init_lucide();
- });
- }
- BLAH;
- return $this->_oTemplate->_wrapInTagJsCode($sCode);
- }
- }
- /** @} */
|