setFunctionHook('list', [__CLASS__, 'onRenderTag']); } /** * Render tag function. * * @param Parser $parser * @param string $type * @param string $style * * @return string|null */ public static function onRenderTag(Parser $parser, string $type = '', string $style = ''): ?string { // Argument: type. $getType = MW_EXT_Kernel::outClear($type ?? '' ?: ''); $outType = MW_EXT_Kernel::outNormalize($getType); // Check license type, set error category. if (!self::getList($outType)) { $parser->addTrackingCategory('mw-list-error-category'); return null; } // Argument: style. $getStyle = MW_EXT_Kernel::outClear($style ?? '' ?: ''); $outStyle = MW_EXT_Kernel::outNormalize($getStyle); // Get data. $getList = self::getList($outType); // Sort data. asort($getList); // Build style class. switch ($outStyle) { case 'grid': $outClass = 'grid'; break; case 'list': $outClass = 'list'; break; case 'inline': $outClass = 'inline'; break; default: $parser->addTrackingCategory('mw-list-error-category'); return null; } // Set URL item. $outItem = ''; foreach ($getList as $item) { $title = empty($item['title']) ? '' : $item['title']; $icon = empty($item['icon']) ? 'fas fa-globe' : $item['icon']; $bg_color = empty($item['style']['background-color']) ? '' : 'background-color:' . $item['style']['background-color'] . ';'; $color = empty($item['style']['color']) ? '' : 'color:' . $item['style']['color'] . ';'; $href = empty($item['url']) ? '' : $item['url']; $desc = MW_EXT_Kernel::getMessageText('list', $item['description']); if ($outClass === 'grid') { $outItem .= '