WebOrbiton
v3.1.0.0

FlatlyPage

2,441 lines · 119.6 KB
  1. <?php
  2. ​
  3. if (!defined('BASE_DIR')) {
  4. die('Direct access not permitted');
  5. }
  6. ​
  7. final class RenderCache
  8. {
  9. private static $cache = [];
  10. private static $validated = [];
  11. private static $hits = 0;
  12. private static $misses = 0;
  13. private const MAX_CACHE_SIZE = 100;
  14. private const MAX_KEY_LENGTH = 128;
  15. private const MAX_VALUE_SIZE = 102400;
  16. ​
  17. private static function generateSecureKey($data)
  18. {
  19. $serialized = serialize($data);
  20. return hash('sha256', $serialized);
  21. }
  22. ​
  23. ​
  24. private static function isValidCachedContent($value)
  25. {
  26. if (!is_string($value)) {
  27. return false;
  28. }
  29. ​
  30. if (strlen($value) > self::MAX_VALUE_SIZE) {
  31. return false;
  32. }
  33. ​
  34. $dangerous_patterns = [
  35. '/<script[^>]*>.*?<\/script>/is',
  36. '/javascript:/i',
  37. '/on\w+\s*=/i',
  38. '/<iframe[^>]*srcdoc/i',
  39. ];
  40. ​
  41. foreach ($dangerous_patterns as $pattern) {
  42. if (preg_match($pattern, $value)) {
  43. return false;
  44. }
  45. }
  46. ​
  47. return true;
  48. }
  49. ​
  50. public static function get($key)
  51. {
  52. $secure_key = self::generateSecureKey($key);
  53. ​
  54. if (isset(self::$cache[$secure_key])) {
  55. $value = self::$cache[$secure_key];
  56. ​
  57. if (isset(self::$validated[$secure_key]) || self::isValidCachedContent($value)) {
  58. self::$validated[$secure_key] = true;
  59. self::$hits++;
  60. return $value;
  61. } else {
  62. unset(self::$cache[$secure_key], self::$validated[$secure_key]);
  63. self::$misses++;
  64. return null;
  65. }
  66. }
  67. ​
  68. self::$misses++;
  69. return null;
  70. }
  71. ​
  72. public static function set($key, $value)
  73. {
  74. if (!is_string($value) || strlen($value) > self::MAX_VALUE_SIZE) {
  75. return false;
  76. }
  77. ​
  78. $secure_key = self::generateSecureKey($key);
  79. ​
  80. if (count(self::$cache) >= self::MAX_CACHE_SIZE) {
  81. array_shift(self::$cache);
  82. }
  83. ​
  84. unset(self::$validated[$secure_key]);
  85. self::$cache[$secure_key] = $value;
  86. return true;
  87. }
  88. ​
  89. public static function clear()
  90. {
  91. self::$cache = [];
  92. self::$validated = [];
  93. self::$hits = 0;
  94. self::$misses = 0;
  95. }
  96. ​
  97. public static function getStats()
  98. {
  99. return [
  100. 'hits' => self::$hits,
  101. 'misses' => self::$misses,
  102. 'size' => count(self::$cache)
  103. ];
  104. }
  105. }
  106. ​
  107. ​
  108. final class LazyLoadManager
  109. {
  110. private static $lazy_blocks = [];
  111. private static $script_added = false;
  112. private const MAX_LAZY_BLOCKS = 50;
  113. private const MAX_BLOCK_SIZE = 51200; // 50KB per block
  114. ​
  115. private static function generateSecureBlockId($block)
  116. {
  117. $data = serialize($block);
  118. return 'block_' . hash('sha256', $data . random_bytes(16));
  119. }
  120. ​
  121. private static function sanitizeLazyHTML($html)
  122. {
  123. if (!is_string($html)) {
  124. return '';
  125. }
  126. ​
  127. if (strlen($html) > self::MAX_BLOCK_SIZE) {
  128. return '';
  129. }
  130. ​
  131. $html = preg_replace('/<script[^>]*>.*?<\/script>/is', '', $html);
  132. ​
  133. $html = preg_replace('/javascript:/i', '', $html);
  134. ​
  135. $html = preg_replace('/\s*on\w+\s*=\s*["\'][^"\']*["\']/i', '', $html);
  136. ​
  137. return $html;
  138. }
  139. ​
  140. public static function registerLazyBlock($block_data, $rendered_html)
  141. {
  142. if (count(self::$lazy_blocks) >= self::MAX_LAZY_BLOCKS) {
  143. return null;
  144. }
  145. ​
  146. $sanitized_html = self::sanitizeLazyHTML($rendered_html);
  147. if (empty($sanitized_html)) {
  148. return null;
  149. }
  150. ​
  151. $block_id = self::generateSecureBlockId($block_data);
  152. self::$lazy_blocks[$block_id] = $sanitized_html;
  153. ​
  154. return $block_id;
  155. }
  156. ​
  157. public static function getLazyPlaceholder($block_id, $type)
  158. {
  159. if (!preg_match('/^block_[a-f0-9]{64}$/', $block_id)) {
  160. return '';
  161. }
  162. ​
  163. $min_height = self::getMinHeightForType($type);
  164. ​
  165. $safe_block_id = htmlspecialchars($block_id, ENT_QUOTES, 'UTF-8');
  166. ​
  167. return sprintf(
  168. '<div class="lazy-block" data-block-id="%s" style="min-height:%dpx">
  169. <div class="lazy-placeholder">
  170. <div class="lazy-spinner"></div>
  171. </div>
  172. </div>',
  173. $safe_block_id,
  174. (int)$min_height
  175. );
  176. }
  177. ​
  178. private static function getMinHeightForType($type)
  179. {
  180. $heights = [
  181. 'hero' => 500,
  182. 'features' => 400,
  183. 'testimonials' => 300,
  184. 'pricing' => 400,
  185. 'gallery' => 300,
  186. 'team' => 350,
  187. 'video' => 400,
  188. 'default' => 200
  189. ];
  190. ​
  191. return $heights[$type] ?? $heights['default'];
  192. }
  193. ​
  194. public static function outputLazyScript($nonce = '')
  195. {
  196. if (self::$script_added || empty(self::$lazy_blocks)) {
  197. return '';
  198. }
  199. ​
  200. self::$script_added = true;
  201. ​
  202. $blocks_json = json_encode(self::$lazy_blocks, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
  203. ​
  204. $nonce_attr = $nonce ? ' nonce="' . htmlspecialchars($nonce, ENT_QUOTES, 'UTF-8') . '"' : '';
  205. ​
  206. return <<<HTML
  207. <script{$nonce_attr}>
  208. (function() {
  209. 'use strict';
  210. ​
  211. let lazyBlocks;
  212. try {
  213. lazyBlocks = {$blocks_json};
  214. } catch (e) {
  215. console.error('Failed to parse lazy blocks:', e);
  216. return;
  217. }
  218. ​
  219. const validBlockIdPattern = /^block_[a-f0-9]{64}$/;
  220. ​
  221. const observer = new IntersectionObserver((entries) => {
  222. entries.forEach(entry => {
  223. if (entry.isIntersecting) {
  224. const element = entry.target;
  225. const blockId = element.getAttribute('data-block-id');
  226. ​
  227. if (!blockId || !validBlockIdPattern.test(blockId)) {
  228. console.warn('Invalid block ID detected');
  229. observer.unobserve(element);
  230. return;
  231. }
  232. ​
  233. if (lazyBlocks[blockId]) {
  234. const temp = document.createElement('div');
  235. temp.innerHTML = lazyBlocks[blockId];
  236. ​
  237. temp.querySelectorAll('script').forEach(s => s.remove());
  238. ​
  239. element.innerHTML = temp.innerHTML;
  240. observer.unobserve(element);
  241. delete lazyBlocks[blockId];
  242. ​
  243. element.dispatchEvent(new CustomEvent('blockLoaded', {
  244. detail: { blockId: blockId }
  245. }));
  246. }
  247. }
  248. });
  249. }, {
  250. rootMargin: '200px',
  251. threshold: 0.01
  252. });
  253. ​
  254. document.querySelectorAll('.lazy-block').forEach(block => {
  255. const blockId = block.getAttribute('data-block-id');
  256. ​
  257. if (blockId && validBlockIdPattern.test(blockId)) {
  258. observer.observe(block);
  259. }
  260. });
  261. ​
  262. if (!('IntersectionObserver' in window)) {
  263. document.querySelectorAll('.lazy-block').forEach(block => {
  264. const blockId = block.getAttribute('data-block-id');
  265. ​
  266. if (blockId && validBlockIdPattern.test(blockId) && lazyBlocks[blockId]) {
  267. const temp = document.createElement('div');
  268. temp.innerHTML = lazyBlocks[blockId];
  269. temp.querySelectorAll('script').forEach(s => s.remove());
  270. block.innerHTML = temp.innerHTML;
  271. }
  272. });
  273. }
  274. })();
  275. </script>
  276. HTML;
  277. }
  278. ​
  279. public static function clear()
  280. {
  281. self::$lazy_blocks = [];
  282. self::$script_added = false;
  283. }
  284. }
  285. ​
  286. ​
  287. final class IconRegistry
  288. {
  289. private static $used_icons = [];
  290. private static $used_social_icons = [];
  291. private static $custom_icons = [];
  292. private static $custom_social = [];
  293. private const MAX_TRACKED = 100;
  294. ​
  295. private const ALLOWED_ICONS = [
  296. 'bolt',
  297. 'layout',
  298. 'clock',
  299. 'shield',
  300. 'chart',
  301. 'code',
  302. 'star',
  303. 'heart',
  304. 'globe',
  305. 'users',
  306. 'settings',
  307. 'edit',
  308. 'plus',
  309. 'trash',
  310. 'copy',
  311. 'eye',
  312. 'eyeOff',
  313. 'image',
  314. 'file',
  315. 'upload',
  316. 'money'
  317. ];
  318. ​
  319. private const ALLOWED_SOCIAL = [
  320. 'twitter',
  321. 'github',
  322. 'linkedin',
  323. 'facebook',
  324. 'instagram',
  325. 'youtube',
  326. 'tiktok',
  327. 'pinterest',
  328. 'reddit',
  329. 'discord',
  330. 'snapchat',
  331. 'whatsapp',
  332. 'telegram',
  333. 'twitch',
  334. 'spotify',
  335. 'medium',
  336. 'slack',
  337. 'dribbble',
  338. 'mastodon',
  339. 'patreon',
  340. 'kofi',
  341. 'vimeo',
  342. 'tumblr',
  343. 'stackoverflow',
  344. 'gitlab',
  345. 'bluesky',
  346. 'line',
  347. 'wechat',
  348. 'flatlypage',
  349. 'xing'
  350. ];
  351. ​
  352. public static function registerIcon($name, $svg)
  353. {
  354. if (count(self::$custom_icons) >= 50) {
  355. return false;
  356. }
  357. ​
  358. if (!preg_match('/^[a-z0-9_-]+$/', $name)) {
  359. return false;
  360. }
  361. ​
  362. if (!is_string($svg) || strlen($svg) > 5000) {
  363. return false;
  364. }
  365. ​
  366. self::$custom_icons[$name] = $svg;
  367. return true;
  368. }
  369. ​
  370. public static function registerSocialIcon($platform, $svg)
  371. {
  372. if (count(self::$custom_social) >= 20) {
  373. return false;
  374. }
  375. ​
  376. if (!preg_match('/^[a-z0-9_-]+$/', $platform)) {
  377. return false;
  378. }
  379. ​
  380. if (!is_string($svg) || strlen($svg) > 5000) {
  381. return false;
  382. }
  383. ​
  384. self::$custom_social[$platform] = $svg;
  385. return true;
  386. }
  387. ​
  388. public static function getCustomIcon($name)
  389. {
  390. return self::$custom_icons[$name] ?? null;
  391. }
  392. ​
  393. public static function getCustomSocial($platform)
  394. {
  395. return self::$custom_social[$platform] ?? null;
  396. }
  397. ​
  398. public static function markIconUsed($icon)
  399. {
  400. if (count(self::$used_icons) >= self::MAX_TRACKED) {
  401. return false;
  402. }
  403. ​
  404. if (!in_array($icon, self::ALLOWED_ICONS, true) && !isset(self::$custom_icons[$icon])) {
  405. return false;
  406. }
  407. ​
  408. self::$used_icons[$icon] = true;
  409. return true;
  410. }
  411. ​
  412. public static function markSocialUsed($platform)
  413. {
  414. if (count(self::$used_social_icons) >= self::MAX_TRACKED) {
  415. return false;
  416. }
  417. ​
  418. if (!in_array($platform, self::ALLOWED_SOCIAL, true) && !isset(self::$custom_social[$platform])) {
  419. return false;
  420. }
  421. ​
  422. self::$used_social_icons[$platform] = true;
  423. return true;
  424. }
  425. ​
  426. public static function isIconAllowed($icon)
  427. {
  428. return in_array($icon, self::ALLOWED_ICONS, true) || isset(self::$custom_icons[$icon]);
  429. }
  430. ​
  431. public static function isSocialAllowed($platform)
  432. {
  433. return in_array($platform, self::ALLOWED_SOCIAL, true) || isset(self::$custom_social[$platform]);
  434. }
  435. }
  436. ​
  437. ​
  438. function get_icon_svg($icon)
  439. {
  440. $custom = IconRegistry::getCustomIcon($icon);
  441. if ($custom !== null) {
  442. return $custom;
  443. }
  444. ​
  445. if (!IconRegistry::isIconAllowed($icon)) {
  446. $icon = 'bolt';
  447. }
  448. ​
  449. static $icons = [
  450. 'bolt' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>',
  451. 'layout' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M3 9h18M9 21V9"/></svg>',
  452. 'clock' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',
  453. 'shield' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>',
  454. 'chart' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>',
  455. 'code' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>',
  456. 'star' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>',
  457. 'heart' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z"/></svg>',
  458. 'globe' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/></svg>',
  459. 'users' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>',
  460. 'settings' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg>',
  461. 'edit' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>',
  462. 'plus' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>',
  463. 'trash' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" y1="11" x2="10" y2="17"/><line x1="14" y1="11" x2="14" y2="17"/></svg>',
  464. 'copy' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>',
  465. 'eye' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>',
  466. 'eyeOff' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/></svg>',
  467. 'image' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>',
  468. 'file' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',
  469. 'upload' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/></svg>',
  470. 'money' => '<svg fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>',
  471. ];
  472. ​
  473. return $icons[$icon];
  474. }
  475. ​
  476. function render_icon($icon)
  477. {
  478. $icon = preg_replace('/[^a-z_-]/', '', strtolower($icon));
  479. ​
  480. if (!IconRegistry::markIconUsed($icon)) {
  481. $icon = 'bolt';
  482. }
  483. ​
  484. return get_icon_svg($icon);
  485. }
  486. ​
  487. function get_social_icon_svg($platform)
  488. {
  489. $custom = IconRegistry::getCustomSocial($platform);
  490. if ($custom !== null) {
  491. return $custom;
  492. }
  493. ​
  494. if (!IconRegistry::isSocialAllowed($platform)) {
  495. $platform = 'twitter';
  496. }
  497. ​
  498. static $icons = [
  499. 'twitter' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"/></svg>',
  500. 'github' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.477 2 2 6.477 2 12c0 4.42 2.865 8.17 6.839 9.49.5.092.682-.217.682-.482 0-.237-.008-.866-.013-1.7-2.782.603-3.369-1.34-3.369-1.34-.454-1.156-1.11-1.463-1.11-1.463-.908-.62.069-.608.069-.608 1.003.07 1.531 1.03 1.531 1.03.892 1.529 2.341 1.087 2.91.831.092-.646.35-1.086.636-1.336-2.22-.253-4.555-1.11-4.555-4.943 0-1.091.39-1.984 1.029-2.683-.103-.253-.446-1.27.098-2.647 0 0 .84-.269 2.75 1.025A9.578 9.578 0 0112 6.836c.85.004 1.705.114 2.504.336 1.909-1.294 2.747-1.025 2.747-1.025.546 1.377.203 2.394.1 2.647.64.699 1.028 1.592 1.028 2.683 0 3.842-2.339 4.687-4.566 4.935.359.309.678.919.678 1.852 0 1.336-.012 2.415-.012 2.743 0 .267.18.578.688.48C19.138 20.167 22 16.418 22 12c0-5.523-4.477-10-10-10z"/></svg>',
  501. 'linkedin' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"/></svg>',
  502. 'facebook' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>',
  503. 'instagram' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"/></svg>',
  504. 'youtube' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>',
  505. 'tiktok' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.525.02c1.31-.02 2.61-.01 3.91-.02.08 1.53.63 3.09 1.75 4.17 1.12 1.11 2.7 1.62 4.24 1.79v4.03c-1.44-.05-2.89-.35-4.2-.97-.57-.26-1.1-.59-1.62-.93-.01 2.92.01 5.84-.02 8.75-.08 1.4-.54 2.79-1.35 3.94-1.31 1.92-3.58 3.17-5.91 3.21-1.43.08-2.86-.31-4.08-1.03-2.02-1.19-3.44-3.37-3.65-5.71-.02-.5-.03-1-.01-1.49.18-1.9 1.12-3.72 2.58-4.96 1.66-1.44 3.98-2.13 6.15-1.72.02 1.48-.04 2.96-.04 4.44-.99-.32-2.15-.23-3.02.37-.63.41-1.11 1.04-1.36 1.75-.21.51-.15 1.07-.14 1.61.24 1.64 1.82 3.02 3.5 2.87 1.12-.01 2.19-.66 2.77-1.61.19-.33.4-.67.41-1.06.1-1.79.06-3.57.07-5.36.01-4.03-.01-8.05.02-12.07z"/></svg>',
  506. 'pinterest' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.017 0C5.396 0 .029 5.367.029 11.987c0 5.079 3.158 9.417 7.618 11.162-.105-.949-.199-2.403.041-3.439.219-.937 1.406-5.957 1.406-5.957s-.359-.72-.359-1.781c0-1.663.967-2.911 2.168-2.911 1.024 0 1.518.769 1.518 1.688 0 1.029-.653 2.567-.992 3.992-.285 1.193.6 2.165 1.775 2.165 2.128 0 3.768-2.245 3.768-5.487 0-2.861-2.063-4.869-5.008-4.869-3.41 0-5.409 2.562-5.409 5.199 0 1.033.394 2.143.889 2.741.099.12.112.225.085.345-.09.375-.293 1.199-.334 1.363-.053.225-.172.271-.401.165-1.495-.69-2.433-2.878-2.433-4.646 0-3.776 2.748-7.252 7.92-7.252 4.158 0 7.392 2.967 7.392 6.923 0 4.135-2.607 7.462-6.233 7.462-1.225 0-2.376-.637-2.771-1.388l-.753 2.87c-.271 1.048-1.007 2.361-1.497 3.161C9.142 23.812 10.544 24 12.017 24c6.627 0 11.999-5.373 11.999-11.987C24.016 5.367 18.644 0 12.017 0z"/></svg>',
  507. 'reddit' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z"/></svg>',
  508. 'discord' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994a.076.076 0 0 0-.041-.106 13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.928 1.793 8.18 1.793 12.062 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.892.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.03zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"/></svg>',
  509. 'snapchat' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12.206.793c.99 0 4.347.276 5.93 3.821.529 1.193.403 3.219.299 4.847l-.003.06c-.012.18-.022.345-.03.51.075.045.203.09.401.09.3-.016.659-.12 1.033-.301.165-.088.344-.104.464-.104.182 0 .359.029.509.09.45.149.734.479.734.838.015.449-.39.839-1.213 1.168-.089.029-.209.075-.344.119-.45.135-1.139.36-1.333.81-.09.224-.061.524.12.868l.015.015c.06.136 1.526 3.475 4.791 4.014.255.044.435.27.42.509 0 .075-.015.149-.045.225-.24.569-1.273.988-3.146 1.271-.059.091-.12.375-.164.57-.029.179-.074.36-.134.553-.076.271-.27.405-.555.405h-.03c-.135 0-.313-.031-.538-.074-.36-.075-.765-.135-1.273-.135-.3 0-.599.015-.913.074-.6.104-1.123.464-1.723.884-.853.599-1.826 1.288-3.294 1.288-.06 0-.119-.015-.18-.015h-.149c-1.468 0-2.427-.675-3.279-1.288-.599-.42-1.107-.779-1.707-.884-.314-.045-.629-.074-.928-.074-.54 0-.958.089-1.272.149-.211.043-.391.074-.54.074-.374 0-.523-.224-.583-.42-.061-.192-.09-.389-.135-.567-.046-.181-.105-.494-.166-.57-1.918-.222-2.95-.642-3.189-1.226-.031-.063-.052-.15-.055-.225-.015-.243.165-.465.42-.509 3.264-.54 4.73-3.879 4.791-4.02l.016-.029c.18-.345.224-.645.119-.869-.195-.434-.884-.658-1.332-.809-.121-.029-.24-.074-.346-.119-1.107-.435-1.257-.93-1.197-1.273.09-.479.674-.793 1.168-.793.146 0 .27.029.383.074.42.194.789.3 1.104.3.234 0 .384-.06.465-.105l-.046-.569c-.098-1.626-.225-3.651.307-4.837C7.392 1.077 10.739.807 11.727.807l.419-.015h.06z"/></svg>',
  510. 'whatsapp' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>',
  511. 'telegram' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M11.944 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0a12 12 0 0 0-.056 0zm4.962 7.224c.1-.002.321.023.465.14a.506.506 0 0 1 .171.325c.016.093.036.306.02.472-.18 1.898-.962 6.502-1.36 8.627-.168.9-.499 1.201-.82 1.23-.696.065-1.225-.46-1.9-.902-1.056-.693-1.653-1.124-2.678-1.8-1.185-.78-.417-1.21.258-1.91.177-.184 3.247-2.977 3.307-3.23.007-.032.014-.15-.056-.212s-.174-.041-.249-.024c-.106.024-1.793 1.14-5.061 3.345-.48.33-.913.49-1.302.48-.428-.008-1.252-.241-1.865-.44-.752-.245-1.349-.374-1.297-.789.027-.216.325-.437.893-.663 3.498-1.524 5.83-2.529 6.998-3.014 3.332-1.386 4.025-1.627 4.476-1.635z"/></svg>',
  512. 'twitch' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M11.571 4.714h1.715v5.143H11.57zm4.715 0H18v5.143h-1.714zM6 0L1.714 4.286v15.428h5.143V24l4.286-4.286h3.428L22.286 12V0zm14.571 11.143l-3.428 3.428h-3.429l-3 3v-3H6.857V1.714h13.714Z"/></svg>',
  513. 'spotify' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.4 0 0 5.4 0 12s5.4 12 12 12 12-5.4 12-12S18.66 0 12 0zm5.521 17.34c-.24.359-.66.48-1.021.24-2.82-1.74-6.36-2.101-10.561-1.141-.418.122-.779-.179-.899-.539-.12-.421.18-.78.54-.9 4.56-1.021 8.52-.6 11.64 1.32.42.18.479.659.301 1.02zm1.44-3.3c-.301.42-.841.6-1.262.3-3.239-1.98-8.159-2.58-11.939-1.38-.479.12-1.02-.12-1.14-.6-.12-.48.12-1.021.6-1.141C9.6 9.9 15 10.561 18.72 12.84c.361.181.54.78.241 1.2zm.12-3.36C15.24 8.4 8.82 8.16 5.16 9.301c-.6.179-1.2-.181-1.38-.721-.18-.601.18-1.2.72-1.381 4.26-1.26 11.28-1.02 15.721 1.621.539.3.719 1.02.419 1.56-.299.421-1.02.599-1.559.3z"/></svg>',
  514. 'medium' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M13.54 12a6.8 6.8 0 01-6.77 6.82A6.8 6.8 0 010 12a6.8 6.8 0 016.77-6.82A6.8 6.8 0 0113.54 12zM20.96 12c0 3.54-1.51 6.42-3.38 6.42-1.87 0-3.39-2.88-3.39-6.42s1.52-6.42 3.39-6.42 3.38 2.88 3.38 6.42M24 12c0 3.17-.53 5.75-1.19 5.75-.66 0-1.19-2.58-1.19-5.75s.53-5.75 1.19-5.75C23.47 6.25 24 8.83 24 12z"/></svg>',
  515. 'slack' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M5.042 15.165a2.528 2.528 0 0 1-2.52 2.523A2.528 2.528 0 0 1 0 15.165a2.527 2.527 0 0 1 2.522-2.52h2.52v2.52zM6.313 15.165a2.527 2.527 0 0 1 2.521-2.52 2.527 2.527 0 0 1 2.521 2.52v6.313A2.528 2.528 0 0 1 8.834 24a2.528 2.528 0 0 1-2.521-2.522v-6.313zM8.834 5.042a2.528 2.528 0 0 1-2.521-2.52A2.528 2.528 0 0 1 8.834 0a2.528 2.528 0 0 1 2.521 2.522v2.52H8.834zM8.834 6.313a2.528 2.528 0 0 1 2.521 2.521 2.528 2.528 0 0 1-2.521 2.521H2.522A2.528 2.528 0 0 1 0 8.834a2.528 2.528 0 0 1 2.522-2.521h6.312zM18.956 8.834a2.528 2.528 0 0 1 2.522-2.521A2.528 2.528 0 0 1 24 8.834a2.528 2.528 0 0 1-2.522 2.521h-2.522V8.834zM17.688 8.834a2.528 2.528 0 0 1-2.523 2.521 2.527 2.527 0 0 1-2.52-2.521V2.522A2.527 2.527 0 0 1 15.165 0a2.528 2.528 0 0 1 2.523 2.522v6.312zM15.165 18.956a2.528 2.528 0 0 1 2.523 2.522A2.528 2.528 0 0 1 15.165 24a2.527 2.527 0 0 1-2.52-2.522v-2.522h2.52zM15.165 17.688a2.527 2.527 0 0 1-2.52-2.523 2.526 2.526 0 0 1 2.52-2.52h6.313A2.527 2.527 0 0 1 24 15.165a2.528 2.528 0 0 1-2.522 2.523h-6.313z"/></svg>',
  516. 'dribbble' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 24C5.385 24 0 18.615 0 12S5.385 0 12 0s12 5.385 12 12-5.385 12-12 12zm10.12-10.358c-.35-.11-3.17-.953-6.384-.438 1.34 3.684 1.887 6.684 1.992 7.308 2.3-1.555 3.936-4.02 4.395-6.87zm-6.115 7.808c-.153-.9-.75-4.032-2.19-7.77l-.066.02c-5.79 2.015-7.86 6.025-8.04 6.4 1.73 1.358 3.92 2.166 6.29 2.166 1.42 0 2.77-.29 4-.814zm-11.62-2.58c.232-.4 3.045-5.055 8.332-6.765.135-.045.27-.084.405-.12-.26-.585-.54-1.167-.832-1.74C7.17 11.775 2.206 11.71 1.756 11.7l-.004.312c0 2.633.998 5.037 2.634 6.855zm-2.42-8.955c.46.008 4.683.026 9.477-1.248-1.698-3.018-3.53-5.558-3.8-5.928-2.868 1.35-5.01 3.99-5.676 7.17zM9.6 2.052c.282.38 2.145 2.914 3.822 6 3.645-1.365 5.19-3.44 5.373-3.702-1.81-1.61-4.19-2.586-6.795-2.586-.825 0-1.63.1-2.4.285zm10.335 3.483c-.218.29-1.935 2.493-5.724 4.04.24.49.47.985.68 1.486.08.18.15.36.22.53 3.41-.43 6.8.26 7.14.33-.02-2.42-.88-4.64-2.31-6.38z"/></svg>',
  517. 'mastodon' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.268 5.313c-.35-2.578-2.617-4.61-5.304-5.004C17.51.242 15.792 0 11.813 0h-.03c-3.98 0-4.835.242-5.288.309C3.882.692 1.496 2.518.917 5.127.64 6.412.61 7.837.661 9.143c.074 1.874.088 3.745.26 5.611.118 1.24.325 2.47.62 3.68.55 2.237 2.777 4.098 4.96 4.857 2.336.792 4.849.923 7.256.38.265-.061.527-.132.786-.213.585-.184 1.27-.39 1.774-.753a.057.057 0 0 0 .023-.043v-1.809a.052.052 0 0 0-.02-.041.053.053 0 0 0-.046-.01 20.282 20.282 0 0 1-4.709.545c-2.73 0-3.463-1.284-3.674-1.818a5.593 5.593 0 0 1-.319-1.433.053.053 0 0 1 .066-.054c1.517.363 3.072.546 4.632.546.376 0 .75 0 1.125-.01 1.57-.044 3.224-.124 4.768-.422.038-.008.077-.015.11-.024 2.435-.464 4.753-1.92 4.989-5.604.008-.145.03-1.52.03-1.67.002-.512.167-3.63-.024-5.545zm-3.748 9.195h-2.561V8.29c0-1.309-.55-1.976-1.67-1.976-1.23 0-1.846.79-1.846 2.35v3.403h-2.546V8.663c0-1.56-.617-2.35-1.848-2.35-1.112 0-1.668.668-1.67 1.977v6.218H4.822V8.102c0-1.31.337-2.35 1.011-3.12.696-.77 1.608-1.164 2.74-1.164 1.311 0 2.302.5 2.962 1.498l.638 1.06.638-1.06c.66-.999 1.65-1.498 2.96-1.498 1.13 0 2.043.395 2.74 1.164.675.77 1.012 1.81 1.012 3.12z"/></svg>',
  518. 'patreon' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M15.386.524c-4.764 0-8.64 3.876-8.64 8.64 0 4.75 3.876 8.613 8.64 8.613 4.75 0 8.614-3.864 8.614-8.613C24 4.4 20.136.524 15.386.524M.003 23.537h4.22V.524H.003"/></svg>',
  519. 'kofi' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.881 8.948c-.773-4.085-4.859-4.593-4.859-4.593H.723c-.604 0-.679.798-.679.798s-.082 7.324-.022 11.822c.164 2.424 2.586 2.672 2.586 2.672s8.267-.023 11.966-.049c2.438-.426 2.683-2.566 2.658-3.734 4.352.24 7.422-2.831 6.649-6.916zm-11.062 3.511c-1.246 1.453-4.011 3.976-4.011 3.976s-.121.119-.31.023c-.076-.057-.108-.09-.108-.09-.443-.441-3.368-3.049-4.034-3.954-.709-.965-1.041-2.7-.091-3.71.951-1.01 3.005-1.086 4.363.407 0 0 1.565-1.782 3.468-.963 1.904.82 1.832 3.011.723 4.311zm6.173.478c-.928.116-1.682.028-1.682.028V7.284h1.77s1.971.551 1.971 2.638c0 1.913-.985 2.667-2.059 3.015z"/></svg>',
  520. 'vimeo' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.977 6.416c-.105 2.338-1.739 5.543-4.894 9.609-3.268 4.247-6.026 6.37-8.29 6.37-1.409 0-2.578-1.294-3.553-3.881L5.322 11.4C4.603 8.816 3.834 7.522 3.01 7.522c-.179 0-.806.378-1.881 1.132L0 7.197c1.185-1.044 2.351-2.084 3.501-3.128C5.08 2.701 6.266 1.984 7.055 1.91c1.867-.18 3.016 1.1 3.447 3.838.465 2.953.789 4.789.971 5.507.539 2.45 1.131 3.674 1.776 3.674.502 0 1.256-.796 2.265-2.385 1.004-1.589 1.54-2.797 1.612-3.628.144-1.371-.395-2.061-1.614-2.061-.574 0-1.167.121-1.777.391 1.186-3.868 3.434-5.757 6.762-5.637 2.473.06 3.628 1.664 3.493 4.797z"/></svg>',
  521. 'tumblr' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M14.563 24c-5.093 0-7.031-3.756-7.031-6.411V9.747H5.116V6.648c3.63-1.313 4.512-4.596 4.71-6.469C9.84.051 9.941 0 9.999 0h3.517v6.114h4.801v3.633h-4.82v7.47c.016 1.001.375 2.371 2.207 2.371h.09c.631-.02 1.486-.205 1.936-.419l1.156 3.425c-.436.636-2.4 1.374-4.156 1.404h-.178l.011.002z"/></svg>',
  522. 'stackoverflow' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M15.725 0l-1.72 1.277 6.39 8.588 1.716-1.277L15.725 0zm-3.94 3.418l-1.369 1.644 8.225 6.85 1.369-1.644-8.225-6.85zm-3.15 4.465l-.905 1.94 9.702 4.517.904-1.94-9.701-4.517zm-1.85 4.86l-.44 2.093 10.473 2.201.44-2.092-10.473-2.203zM1.89 15.47V24h19.19v-8.53h-2.133v6.397H4.021v-6.396H1.89zm4.265 2.133v2.13h10.66v-2.13H6.154Z"/></svg>',
  523. 'gitlab' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M23.955 13.587l-1.342-4.135-2.664-8.189a.455.455 0 0 0-.867 0L16.418 9.45H7.582L4.919 1.263C4.783.84 4.185.84 4.05 1.26L1.386 9.449.044 13.587a.924.924 0 0 0 .331 1.023L12 23.054l11.625-8.443a.92.92 0 0 0 .330-1.024"/></svg>',
  524. 'bluesky' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8z"/></svg>',
  525. 'line' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M19.365 9.863c.349 0 .63.285.63.631 0 .345-.281.63-.63.63H17.61v1.125h1.755c.349 0 .63.283.63.63 0 .344-.281.629-.63.629h-2.386c-.345 0-.627-.285-.627-.629V8.108c0-.345.282-.63.63-.63h2.386c.346 0 .627.285.627.63 0 .349-.281.63-.63.63H17.61v1.125h1.755zm-3.855 3.016c0 .27-.174.51-.432.596-.064.021-.133.031-.199.031-.211 0-.391-.09-.51-.25l-2.443-3.317v2.94c0 .344-.279.629-.631.629-.346 0-.626-.285-.626-.629V8.108c0-.27.173-.51.43-.595.06-.023.136-.033.194-.033.195 0 .375.105.495.254l2.462 3.33V8.108c0-.345.282-.63.63-.63.345 0 .63.285.63.63v4.771zm-5.741 0c0 .344-.282.629-.631.629-.345 0-.627-.285-.627-.629V8.108c0-.345.282-.63.63-.63.346 0 .628.285.628.63v4.771zm-2.466.629H4.917c-.345 0-.63-.285-.63-.629V8.108c0-.345.285-.63.63-.63.348 0 .63.285.63.63v4.141h1.756c.348 0 .629.283.629.63 0 .344-.282.629-.629.629M24 10.314C24 4.943 18.615.572 12 .572S0 4.943 0 10.314c0 4.811 4.27 8.842 10.035 9.608.391.082.923.258 1.058.59.12.301.079.766.038 1.08l-.164 1.02c-.045.301-.24 1.186 1.049.645 1.291-.539 6.916-4.078 9.436-6.975C23.176 14.393 24 12.458 24 10.314"/></svg>',
  526. 'wechat' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.027zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z"/></svg>',
  527. 'flatlypage' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M1.139,10.785c2.355,-2.34 2.35,-2.344 2.556,-2.547c0.078,-0.077 3.035,-0.02 4.087,-0.036c0.256,-0.004 1.694,-2.812 5.62,-5.095c5.564,-3.236 9.601,-2.389 10.558,-2.232c0.071,0.012 0.043,0.088 -0.059,1.504c-0.647,8.983 -7.685,12.863 -8.987,13.72c-0.197,0.13 0.229,2.523 -0.192,3.517c-0.419,0.99 -3.908,3.683 -4.235,3.723c-0.417,0.051 -0.01,-2.035 -0.712,-3.864c-0.935,-2.437 -3.147,-1.942 -2.359,-3.122c0.131,-0.196 4.425,-3.782 5.035,-4.322c0.579,-0.513 0.008,-1.327 -0.6,-1.113c-0.322,0.114 -5.417,4.593 -5.553,4.647c-0.553,0.22 -0.839,-0.788 -0.974,-1.096c-0.816,-1.857 -3.157,-1.629 -4.786,-1.905c-1.026,-0.174 -0.451,-0.695 0.6,-1.78l17.729,-5.714c-0.291,-0.219 -0.274,-0.252 -0.625,-0.354c-1.886,-0.551 -2.944,2.007 -1.401,2.989c1.707,1.086 3.541,-1.228 2.026,-2.635l-17.729,5.714Z"/><path d="M7.464,20.241c-1.992,2.204 -4.202,1.853 -6.596,1.997c-0.097,0.006 -0.039,-1.98 0.059,-2.738c0.054,-0.421 0.244,-2.487 1.925,-3.848c1.683,-1.362 2.31,0.71 2.182,0.75c-2.12,0.665 -2.297,2.159 -2.629,3.897c-0.045,0.235 -0.08,0.321 0.157,0.341c0.161,0.014 1.862,-0.167 2.838,-0.777c1.305,-0.815 1.275,-1.923 1.418,-1.897c0.095,0.017 0.695,0.126 1.026,0.644c0.456,0.714 -0.364,1.61 -0.38,1.631Z"/></svg>',
  528. 'xing' => '<svg viewBox="0 0 24 24" fill="currentColor"><path d="M18.188 0c-.517 0-.741.325-.927.66 0 0-7.455 13.224-7.702 13.657.015.024 4.919 9.023 4.919 9.023.17.308.436.66.967.66h3.454c.211 0 .375-.078.463-.22.089-.151.089-.346-.009-.536l-4.879-8.916c-.004-.006-.004-.016 0-.022L22.139.756c.095-.191.097-.387.006-.535C22.056.078 21.894 0 21.686 0h-3.498zM3.648 4.74c-.211 0-.385.074-.473.216-.09.149-.078.339.02.531l2.34 4.05c.004.01.004.016 0 .021L1.86 16.051c-.099.188-.093.381 0 .529.085.142.239.234.45.234h3.461c.518 0 .766-.348.945-.667l3.734-6.609-2.378-4.155c-.172-.315-.434-.659-.962-.659H3.648v.016z"/></svg>',
  529. ];
  530. ​
  531. return $icons[$platform];
  532. }
  533. ​
  534. function render_social_icon($platform)
  535. {
  536. $platform = preg_replace('/[^a-z_-]/', '', strtolower($platform));
  537. ​
  538. if (!IconRegistry::markSocialUsed($platform)) {
  539. $platform = 'twitter';
  540. }
  541. ​
  542. return get_social_icon_svg($platform);
  543. }
  544. ​
  545. ​
  546. function apply_bbcode($html)
  547. {
  548. $html = (string) $html;
  549. if (strpos($html, '[') === false) {
  550. return $html;
  551. }
  552. ​
  553. $tags = [];
  554. $masked = preg_replace_callback('/<[^>]*>/', static function ($match) use (&$tags) {
  555. $tags[] = $match[0];
  556. return "\x01" . (count($tags) - 1) . "\x02";
  557. }, $html);
  558. ​
  559. if ($masked === null) {
  560. return $html;
  561. }
  562. ​
  563. $masked = preg_replace([
  564. '/\[u\](.*?)\[\/u\]/is',
  565. '/\[b\](.*?)\[\/b\]/is',
  566. '/\[i\](.*?)\[\/i\]/is',
  567. '/\[s\](.*?)\[\/s\]/is',
  568. '/\[h\](.*?)\[\/h\]/is',
  569. '/\[quote\](.*?)\[\/quote\]/is',
  570. ], [
  571. '<u>$1</u>',
  572. '<b>$1</b>',
  573. '<i>$1</i>',
  574. '<s>$1</s>',
  575. '<h3>$1</h3>',
  576. '<blockquote>$1</blockquote>',
  577. ], $masked);
  578. ​
  579. if ($masked === null) {
  580. return $html;
  581. }
  582. ​
  583. return preg_replace_callback('/\x01(\d+)\x02/', static function ($match) use ($tags) {
  584. return $tags[(int) $match[1]] ?? '';
  585. }, $masked);
  586. }
  587. ​
  588. final class BlockAssets
  589. {
  590. private const SCRIPT_TYPES = ['tabs', 'carousel', 'announcement', 'countdown'];
  591. private static $emitted = false;
  592. ​
  593. public static function forType($type)
  594. {
  595. if (self::$emitted || !in_array($type, self::SCRIPT_TYPES, true)) {
  596. return '';
  597. }
  598. ​
  599. self::$emitted = true;
  600. $path = BASE_DIR . '/assets/js/blocks.js';
  601. $version = is_file($path) ? (int) filemtime($path) : 1;
  602. ​
  603. return '<script src="/assets/js/blocks.js?v=' . $version . '" defer></script>';
  604. }
  605. }
  606. ​
  607. ​
  608. final class StructuredData
  609. {
  610. private const MAX_QUESTIONS = 100;
  611. private static $faq = [];
  612. private static $seen = [];
  613. private static $rendered = false;
  614. ​
  615. public static function addFaq($items)
  616. {
  617. if (!is_array($items)) {
  618. return;
  619. }
  620. ​
  621. foreach ($items as $item) {
  622. if (!is_array($item) || count(self::$faq) >= self::MAX_QUESTIONS) {
  623. continue;
  624. }
  625. ​
  626. $question = structured_plain_text($item['question'] ?? '');
  627. $answer = structured_plain_text($item['answer'] ?? '');
  628. if ($question === '' || $answer === '') {
  629. continue;
  630. }
  631. ​
  632. $key = hash('sha256', mb_strtolower($question));
  633. if (isset(self::$seen[$key])) {
  634. continue;
  635. }
  636. ​
  637. self::$seen[$key] = true;
  638. self::$faq[] = [
  639. '@type' => 'Question',
  640. 'name' => $question,
  641. 'acceptedAnswer' => [
  642. '@type' => 'Answer',
  643. 'text' => $answer,
  644. ],
  645. ];
  646. }
  647. }
  648. ​
  649. public static function render()
  650. {
  651. if (self::$rendered || empty(self::$faq)) {
  652. return '';
  653. }
  654. ​
  655. self::$rendered = true;
  656. $json = json_encode([
  657. '@context' => 'https://schema.org',
  658. '@type' => 'FAQPage',
  659. 'mainEntity' => self::$faq,
  660. ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP);
  661. ​
  662. if ($json === false) {
  663. return '';
  664. }
  665. ​
  666. return '<script type="application/ld+json">' . $json . '</script>' . "\n";
  667. }
  668. }
  669. ​
  670. function structured_plain_text($value)
  671. {
  672. if (!is_scalar($value)) {
  673. return '';
  674. }
  675. ​
  676. $text = (string) $value;
  677. $text = preg_replace('/\[\/?(?:u|b|i|s|h|quote)\]/i', '', $text) ?? $text;
  678. $text = html_entity_decode(strip_tags($text), ENT_QUOTES | ENT_HTML5, 'UTF-8');
  679. $text = str_replace(["\r\n", "\r"], "\n", $text);
  680. $text = preg_replace('/[ \t]+/u', ' ', $text) ?? $text;
  681. $text = preg_replace('/\n{3,}/', "\n\n", $text) ?? $text;
  682. ​
  683. return trim($text);
  684. }
  685. ​
  686. function render_structured_data()
  687. {
  688. return StructuredData::render();
  689. }
  690. ​
  691. function render_block($block, $options = [])
  692. {
  693. if (!is_array($block) || !empty($block['hidden'])) {
  694. return '';
  695. }
  696. ​
  697. $type = $block['type'] ?? '';
  698. $data = $block['data'] ?? [];
  699. ​
  700. if ($type === 'faq' && is_array($data) && ($data['schema'] ?? true) !== false) {
  701. StructuredData::addFaq($data['items'] ?? []);
  702. }
  703. ​
  704. $cache_key = ['type' => $type, 'data' => $data, 'id' => $block['id'] ?? ''];
  705. ​
  706. $cached = RenderCache::get($cache_key);
  707. if ($cached !== null) {
  708. return $cached . BlockAssets::forType($type);
  709. }
  710. ​
  711. $id = '';
  712. if (!empty($block['id'])) {
  713. $clean_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $block['id']);
  714. $id = ' id="' . e($clean_id) . '"';
  715. }
  716. ​
  717. $allowed_blocks = [
  718. 'hero',
  719. 'blog-hero',
  720. 'stats',
  721. 'features',
  722. 'testimonials',
  723. 'pricing',
  724. 'cta',
  725. 'text',
  726. 'image',
  727. 'image-text',
  728. 'product-cards',
  729. 'video',
  730. 'gallery',
  731. 'faq',
  732. 'team',
  733. 'audio',
  734. 'countdown',
  735. 'newsletter',
  736. 'logo-cloud',
  737. 'steps',
  738. 'comparison',
  739. 'contact-info',
  740. 'tabs',
  741. 'carousel',
  742. 'announcement',
  743. 'quote',
  744. 'downloads',
  745. 'social-follow',
  746. 'spacer',
  747. 'html'
  748. ];
  749. ​
  750. if (!in_array($type, $allowed_blocks, true)) {
  751. return '';
  752. }
  753. ​
  754. $lazy_types = ['gallery', 'team', 'testimonials', 'video', 'audio'];
  755. $should_lazy_load = isset($options['enable_lazy']) && $options['enable_lazy']
  756. && in_array($type, $lazy_types, true);
  757. ​
  758. $html = '';
  759. ​
  760. switch ($type) {
  761. case 'hero':
  762. $html = render_hero($data, $id);
  763. break;
  764. case 'blog-hero':
  765. $html = render_blog_hero($data, $id);
  766. break;
  767. case 'stats':
  768. $html = render_stats($data, $id);
  769. break;
  770. case 'features':
  771. $html = render_features($data, $id);
  772. break;
  773. case 'testimonials':
  774. $html = render_testimonials($data, $id);
  775. break;
  776. case 'pricing':
  777. $html = render_pricing($data, $id);
  778. break;
  779. case 'cta':
  780. $html = render_cta($data, $id);
  781. break;
  782. case 'text':
  783. $html = render_text($data, $id);
  784. break;
  785. case 'image':
  786. $html = render_image($data, $id);
  787. break;
  788. case 'image-text':
  789. $html = render_image_text($data, $id);
  790. break;
  791. case 'product-cards':
  792. $html = render_product_cards($data, $id);
  793. break;
  794. case 'video':
  795. $html = render_video($data, $id);
  796. break;
  797. case 'gallery':
  798. $html = render_gallery($data, $id);
  799. break;
  800. case 'faq':
  801. $html = render_faq($data, $id);
  802. break;
  803. case 'team':
  804. $html = render_team($data, $id);
  805. break;
  806. case 'audio':
  807. $html = render_audio($data, $id);
  808. break;
  809. case 'countdown':
  810. $html = render_countdown($data, $id);
  811. break;
  812. case 'newsletter':
  813. $html = render_newsletter($data, $id);
  814. break;
  815. case 'logo-cloud':
  816. $html = render_logo_cloud($data, $id);
  817. break;
  818. case 'steps':
  819. $html = render_steps($data, $id);
  820. break;
  821. case 'comparison':
  822. $html = render_comparison($data, $id);
  823. break;
  824. case 'contact-info':
  825. $html = render_contact_info($data, $id);
  826. break;
  827. case 'tabs':
  828. $html = render_tabs($data, $id);
  829. break;
  830. case 'carousel':
  831. $html = render_carousel($data, $id);
  832. break;
  833. case 'announcement':
  834. $html = render_announcement($data, $id);
  835. break;
  836. case 'quote':
  837. $html = render_quote($data, $id);
  838. break;
  839. case 'downloads':
  840. $html = render_downloads($data, $id);
  841. break;
  842. case 'social-follow':
  843. $html = render_social_follow($data, $id);
  844. break;
  845. case 'spacer':
  846. $html = render_spacer($data, $id);
  847. break;
  848. case 'html':
  849. $html = $data['html'] ?? '';
  850. break;
  851. default:
  852. return '';
  853. }
  854. ​
  855. if (!is_string($html)) {
  856. $html = '';
  857. }
  858. ​
  859. if ($html !== '') {
  860. RenderCache::set($cache_key, $html);
  861. }
  862. ​
  863. if ($should_lazy_load && $html !== '') {
  864. $block_id = LazyLoadManager::registerLazyBlock($block, $html);
  865. if ($block_id) {
  866. return LazyLoadManager::getLazyPlaceholder($block_id, $type);
  867. }
  868. }
  869. ​
  870. return $html === '' ? '' : $html . BlockAssets::forType($type);
  871. }
  872. ​
  873. function block_text($value)
  874. {
  875. return is_scalar($value) ? trim((string) $value) : '';
  876. }
  877. ​
  878. function block_list($value)
  879. {
  880. if (!is_array($value)) {
  881. return [];
  882. }
  883. ​
  884. return array_values(array_filter($value, 'is_array'));
  885. }
  886. ​
  887. function block_choice($value, array $allowed, $default)
  888. {
  889. return is_string($value) && in_array($value, $allowed, true) ? $value : $default;
  890. }
  891. ​
  892. function block_int($value, $min, $max, $default)
  893. {
  894. if (is_int($value) || (is_string($value) && preg_match('/^-?\d+$/', trim($value)))) {
  895. return max($min, min($max, (int) $value));
  896. }
  897. if (is_float($value)) {
  898. return max($min, min($max, (int) round($value)));
  899. }
  900. ​
  901. return $default;
  902. }
  903. ​
  904. function block_flag(array $d, $key, $default)
  905. {
  906. if (!array_key_exists($key, $d)) {
  907. return $default;
  908. }
  909. ​
  910. $value = $d[$key];
  911. if (is_string($value)) {
  912. return !in_array(strtolower(trim($value)), ['', '0', 'false', 'no', 'off'], true);
  913. }
  914. ​
  915. return !empty($value);
  916. }
  917. ​
  918. function block_safe_url($url, $fallback = '#')
  919. {
  920. $url = block_text($url);
  921. if ($url === '') {
  922. return $fallback;
  923. }
  924. ​
  925. $probe = strtolower(preg_replace('/[\x00-\x20]+/', '', $url) ?? '');
  926. if (preg_match('/^(?:javascript|vbscript|data|file):/', $probe)) {
  927. return $fallback;
  928. }
  929. ​
  930. return $url;
  931. }
  932. ​
  933. function block_is_external_url($url)
  934. {
  935. return preg_match('#^(?:https?:)?//#i', block_text($url)) === 1;
  936. }
  937. ​
  938. function block_link_target($url)
  939. {
  940. return block_is_external_url($url) ? ' target="_blank" rel="noopener"' : '';
  941. }
  942. ​
  943. function block_multiline($value)
  944. {
  945. return nl2br(e(block_text($value)));
  946. }
  947. ​
  948. function render_section_header(array $d)
  949. {
  950. $title = block_text($d['title'] ?? '');
  951. $subtitle = block_text($d['subtitle'] ?? '');
  952. if ($title === '' && $subtitle === '') {
  953. return '';
  954. }
  955. ​
  956. $html = '<div class="section-header">';
  957. if ($title !== '') {
  958. $html .= '<h2>' . e($title) . '</h2>';
  959. }
  960. if ($subtitle !== '') {
  961. $html .= '<p>' . block_multiline($subtitle) . '</p>';
  962. }
  963. ​
  964. return $html . '</div>';
  965. }
  966. ​
  967. function block_format_bytes($bytes)
  968. {
  969. $bytes = max(0, (int) $bytes);
  970. if ($bytes >= 1073741824) {
  971. return number_format($bytes / 1073741824, 1) . ' GB';
  972. }
  973. if ($bytes >= 1048576) {
  974. return number_format($bytes / 1048576, 1) . ' MB';
  975. }
  976. if ($bytes >= 1024) {
  977. return max(1, (int) round($bytes / 1024)) . ' KB';
  978. }
  979. ​
  980. return $bytes . ' B';
  981. }
  982. ​
  983. function block_local_media_path($url)
  984. {
  985. $url = block_text($url);
  986. if ($url === '') {
  987. return null;
  988. }
  989. ​
  990. if (defined('SITE_URL') && SITE_URL !== '' && stripos($url, SITE_URL) === 0) {
  991. $url = substr($url, strlen(SITE_URL));
  992. }
  993. if (block_is_external_url($url)) {
  994. return null;
  995. }
  996. ​
  997. $path = parse_url($url, PHP_URL_PATH);
  998. if (!is_string($path) || $path === '') {
  999. return null;
  1000. }
  1001. if (defined('BASE_URL') && BASE_URL !== '' && strpos($path, BASE_URL . '/') === 0) {
  1002. $path = substr($path, strlen(BASE_URL));
  1003. }
  1004. if (strpos($path, '/media/') !== 0) {
  1005. return null;
  1006. }
  1007. ​
  1008. $name = rawurldecode(substr($path, 7));
  1009. if ($name === '' || $name !== basename($name) || $name[0] === '.') {
  1010. return null;
  1011. }
  1012. ​
  1013. $file = BASE_DIR . '/media/' . $name;
  1014. ​
  1015. return is_file($file) ? $file : null;
  1016. }
  1017. ​
  1018. function social_platform_labels()
  1019. {
  1020. static $labels = [
  1021. 'twitter' => 'X',
  1022. 'github' => 'GitHub',
  1023. 'linkedin' => 'LinkedIn',
  1024. 'facebook' => 'Facebook',
  1025. 'instagram' => 'Instagram',
  1026. 'youtube' => 'YouTube',
  1027. 'tiktok' => 'TikTok',
  1028. 'pinterest' => 'Pinterest',
  1029. 'reddit' => 'Reddit',
  1030. 'discord' => 'Discord',
  1031. 'snapchat' => 'Snapchat',
  1032. 'whatsapp' => 'WhatsApp',
  1033. 'telegram' => 'Telegram',
  1034. 'twitch' => 'Twitch',
  1035. 'spotify' => 'Spotify',
  1036. 'medium' => 'Medium',
  1037. 'slack' => 'Slack',
  1038. 'dribbble' => 'Dribbble',
  1039. 'mastodon' => 'Mastodon',
  1040. 'patreon' => 'Patreon',
  1041. 'kofi' => 'Ko-fi',
  1042. 'vimeo' => 'Vimeo',
  1043. 'tumblr' => 'Tumblr',
  1044. 'stackoverflow' => 'Stack Overflow',
  1045. 'gitlab' => 'GitLab',
  1046. 'bluesky' => 'Bluesky',
  1047. 'line' => 'LINE',
  1048. 'wechat' => 'WeChat',
  1049. 'flatlypage' => 'FlatlyPage',
  1050. 'xing' => 'XING',
  1051. ];
  1052. ​
  1053. return $labels;
  1054. }
  1055. ​
  1056. function social_platform_label($platform)
  1057. {
  1058. $labels = social_platform_labels();
  1059. ​
  1060. return $labels[$platform] ?? ucfirst((string) $platform);
  1061. }
  1062. ​
  1063. function render_hero($d, $id = '')
  1064. {
  1065. if (!is_array($d)) return '';
  1066. ob_start(); ?>
  1067. <section class="hero" <?= $id ?>>
  1068. <div class="hero-grid"></div>
  1069. <div class="container hero-content">
  1070. <?php if (!empty($d['badge'])): ?><div class="badge"><span class="badge-dot"></span><span><?= e($d['badge']) ?></span></div><?php endif; ?>
  1071. <h1><?= e($d['title'] ?? '') ?></h1>
  1072. <p><?= e($d['subtitle'] ?? '') ?></p>
  1073. <div class="hero-buttons">
  1074. <?php if (!empty($d['button_primary'])): ?><a href="<?= e($d['button_primary_url'] ?? '#') ?>" class="btn btn-primary"><?= e($d['button_primary']) ?></a><?php endif; ?>
  1075. <?php if (!empty($d['button_secondary'])): ?><a href="<?= e($d['button_secondary_url'] ?? '#') ?>" class="btn btn-outline"><?= e($d['button_secondary']) ?></a><?php endif; ?>
  1076. </div>
  1077. </div>
  1078. </section>
  1079. <?php return ob_get_clean();
  1080. }
  1081. ​
  1082. function render_blog_hero($d, $id = '')
  1083. {
  1084. if (!is_array($d)) return '';
  1085. ​
  1086. ob_start(); ?>
  1087. <section class="blog-hero-section" <?= $id ?>>
  1088. <div class="container">
  1089. ​
  1090. <?php if (!empty($d['image'])): ?>
  1091. <div class="hero-image-wrapper" style="margin-bottom: 20px;">
  1092. <img
  1093. src="<?= e($d['image']) ?>"
  1094. alt="<?= e($d['title'] ?? '') ?>"
  1095. style="max-width: 100%; height: auto; border-radius: 8px;">
  1096. </div>
  1097. <?php endif; ?>
  1098. ​
  1099. <?php if (!empty($d['title'])): ?>
  1100. <h1 style="margin-bottom: 15px;" class="blog-h1">
  1101. <?= e($d['title']) ?>
  1102. </h1>
  1103. <?php endif; ?>
  1104. ​
  1105. <?php if (!empty($d['content'])): ?>
  1106. <div class="text-content" style="font-size: 1.1rem; line-height: 1.6; opacity: 0.9;">
  1107. <?= nl2br(e($d['content'])) ?>
  1108. </div>
  1109. <?php endif; ?>
  1110. </div>
  1111. </section>
  1112. <?php
  1113. return ob_get_clean();
  1114. }
  1115. ​
  1116. function render_stats($d, $id = '')
  1117. {
  1118. if (!is_array($d)) return '';
  1119. $items = $d['items'] ?? [];
  1120. if (empty($items) || !is_array($items)) return '';
  1121. ob_start(); ?>
  1122. <section class="stats" <?= $id ?>>
  1123. <div class="container">
  1124. <div class="stats-grid">
  1125. <?php foreach ($items as $item): if (!is_array($item)) continue; ?>
  1126. <div class="stat-item">
  1127. <h3><?= e($item['value'] ?? '') ?></h3>
  1128. <p><?= e($item['label'] ?? '') ?></p>
  1129. </div>
  1130. <?php endforeach; ?>
  1131. </div>
  1132. </div>
  1133. </section>
  1134. <?php return ob_get_clean();
  1135. }
  1136. ​
  1137. function render_features($d, $id = '')
  1138. {
  1139. if (!is_array($d)) return '';
  1140. $items = $d['items'] ?? [];
  1141. ob_start(); ?>
  1142. <section class="features" <?= $id ?>>
  1143. <div class="container">
  1144. <?php if (!empty($d['title'])): ?>
  1145. <div class="section-header">
  1146. <h2><?= e($d['title']) ?></h2>
  1147. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1148. </div>
  1149. <?php endif; ?>
  1150. <?php if (!empty($items) && is_array($items)): ?>
  1151. <div class="features-grid">
  1152. <?php foreach ($items as $item): if (!is_array($item)) continue; ?>
  1153. <div class="feature-card">
  1154. <div class="feature-icon"><?= render_icon($item['icon'] ?? 'bolt') ?></div>
  1155. <h3><?= e($item['title'] ?? '') ?></h3>
  1156. <p><?= e($item['description'] ?? '') ?></p>
  1157. </div>
  1158. <?php endforeach; ?>
  1159. </div>
  1160. <?php endif; ?>
  1161. </div>
  1162. </section>
  1163. <?php return ob_get_clean();
  1164. }
  1165. ​
  1166. function render_testimonials($d, $id = '')
  1167. {
  1168. if (!is_array($d)) return '';
  1169. $items = $d['items'] ?? [];
  1170. ob_start(); ?>
  1171. <section class="testimonials" <?= $id ?>>
  1172. <div class="container">
  1173. <?php if (!empty($d['title'])): ?>
  1174. <div class="section-header">
  1175. <h2><?= e($d['title']) ?></h2>
  1176. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1177. </div>
  1178. <?php endif; ?>
  1179. <?php if (!empty($items) && is_array($items)): ?>
  1180. <div class="testimonials-grid">
  1181. <?php foreach ($items as $item): if (!is_array($item)) continue; ?>
  1182. <div class="testimonial-card">
  1183. <p>"<?= e($item['quote'] ?? '') ?>"</p>
  1184. <div class="testimonial-author">
  1185. <div class="testimonial-avatar"><?= e($item['initials'] ?? '') ?></div>
  1186. <div class="testimonial-info">
  1187. <h4><?= e($item['name'] ?? '') ?></h4><span><?= e($item['role'] ?? '') ?></span>
  1188. </div>
  1189. </div>
  1190. </div>
  1191. <?php endforeach; ?>
  1192. </div>
  1193. <?php endif; ?>
  1194. </div>
  1195. </section>
  1196. <?php return ob_get_clean();
  1197. }
  1198. ​
  1199. function render_pricing($d, $id = '')
  1200. {
  1201. if (!is_array($d)) return '';
  1202. $items = $d['items'] ?? [];
  1203. ob_start(); ?>
  1204. <section class="pricing" <?= $id ?>>
  1205. <div class="container">
  1206. <?php if (!empty($d['title'])): ?>
  1207. <div class="section-header">
  1208. <h2><?= e($d['title']) ?></h2>
  1209. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1210. </div>
  1211. <?php endif; ?>
  1212. <?php if (!empty($items) && is_array($items)): ?>
  1213. <div class="pricing-grid">
  1214. <?php foreach ($items as $item): if (!is_array($item)) continue; ?>
  1215. <div class="pricing-card <?= !empty($item['featured']) ? 'featured' : '' ?>">
  1216. <?php if (!empty($item['featured'])): ?><span class="pricing-popular">Most Popular</span><?php endif; ?>
  1217. <h3><?= e($item['name'] ?? '') ?></h3>
  1218. <div class="price"><?= e($item['price'] ?? '') ?><span><?= e($item['period'] ?? '') ?></span></div>
  1219. <p class="description"><?= e($item['description'] ?? '') ?></p>
  1220. <?php if (!empty($item['features']) && is_array($item['features'])): ?>
  1221. <ul class="pricing-features">
  1222. <?php foreach ($item['features'] as $feature): ?>
  1223. <li><svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2">
  1224. <polyline points="20 6 9 17 4 12" />
  1225. </svg><?= e($feature) ?></li>
  1226. <?php endforeach; ?>
  1227. </ul>
  1228. <?php endif; ?>
  1229. <a href="<?= e($item['button_url'] ?? '#') ?>" class="btn <?= !empty($item['featured']) ? 'btn-primary' : 'btn-outline' ?>"><?= e($item['button_text'] ?? $item['button'] ?? 'Get Started') ?></a>
  1230. </div>
  1231. <?php endforeach; ?>
  1232. </div>
  1233. <?php endif; ?>
  1234. </div>
  1235. </section>
  1236. <?php return ob_get_clean();
  1237. }
  1238. ​
  1239. function render_cta($d, $id = '')
  1240. {
  1241. if (!is_array($d)) return '';
  1242. ob_start(); ?>
  1243. <section class="cta" <?= $id ?>>
  1244. <div class="container">
  1245. <div class="cta-inner">
  1246. <h2><?= e($d['title'] ?? '') ?></h2>
  1247. <p><?= e($d['subtitle'] ?? '') ?></p>
  1248. <div class="cta-buttons">
  1249. <?php if (!empty($d['button_primary'])): ?><a href="<?= e($d['button_primary_url'] ?? '#') ?>" class="btn btn-primary"><?= e($d['button_primary']) ?></a><?php endif; ?>
  1250. <?php if (!empty($d['button_secondary'])): ?><a href="<?= e($d['button_secondary_url'] ?? '#') ?>" class="btn btn-outline"><?= e($d['button_secondary']) ?></a><?php endif; ?>
  1251. </div>
  1252. </div>
  1253. </div>
  1254. </section>
  1255. <?php return ob_get_clean();
  1256. }
  1257. ​
  1258. function render_text($d, $id = '')
  1259. {
  1260. if (!is_array($d)) return '';
  1261. ob_start(); ?>
  1262. <section class="text-section" <?= $id ?>>
  1263. <div class="container">
  1264. <?php if (!empty($d['title'])): ?><h2><?= e($d['title']) ?></h2><?php endif; ?>
  1265. <div class="text-content"><?= nl2br(e($d['content'] ?? '')) ?></div>
  1266. </div>
  1267. </section>
  1268. <?php return ob_get_clean();
  1269. }
  1270. ​
  1271. function render_image($d, $id = '')
  1272. {
  1273. if (!is_array($d) || empty($d['url'])) return '';
  1274. ob_start(); ?>
  1275. <section class="image-section" <?= $id ?>>
  1276. <div class="container">
  1277. <figure>
  1278. <img src="<?= e($d['url']) ?>" alt="<?= e($d['alt'] ?? '') ?>" loading="lazy">
  1279. <?php if (!empty($d['caption'])): ?><figcaption><?= e($d['caption']) ?></figcaption><?php endif; ?>
  1280. </figure>
  1281. </div>
  1282. </section>
  1283. <?php return ob_get_clean();
  1284. }
  1285. ​
  1286. function render_image_text($d, $id = '')
  1287. {
  1288. if (!is_array($d)) return '';
  1289. $allowed_positions = ['left', 'right'];
  1290. $image_pos = in_array($d['image_position'] ?? '', $allowed_positions, true)
  1291. ? $d['image_position']
  1292. : 'left';
  1293. ​
  1294. ob_start(); ?>
  1295. <section class="image-text" <?= $id ?>>
  1296. <div class="container">
  1297. <div class="image-text-grid image-text-<?= e($image_pos) ?>">
  1298. <div class="image-text-image">
  1299. <img src="<?= e($d['image_url'] ?? '') ?>" alt="<?= e($d['image_alt'] ?? '') ?>" loading="lazy">
  1300. </div>
  1301. <div class="image-text-content">
  1302. <?php if (!empty($d['subtitle'])): ?><p class="section-subtitle"><?= e($d['subtitle']) ?></p><?php endif; ?>
  1303. <?php if (!empty($d['title'])): ?><h2><?= e($d['title']) ?></h2><?php endif; ?>
  1304. <div class="text-content"><?= nl2br(e($d['content'] ?? '')) ?></div>
  1305. <?php if (!empty($d['button_text'])): ?>
  1306. <a href="<?= e($d['button_url'] ?? '#') ?>" class="btn btn-primary"><?= e($d['button_text']) ?></a>
  1307. <?php endif; ?>
  1308. </div>
  1309. </div>
  1310. </div>
  1311. </section>
  1312. <?php return ob_get_clean();
  1313. }
  1314. ​
  1315. function render_product_cards($d, $id = '')
  1316. {
  1317. if (!is_array($d)) return '';
  1318. $products = $d['products'] ?? [];
  1319. if (empty($products) || !is_array($products)) return '';
  1320. ob_start(); ?>
  1321. <section class="product-cards" <?= $id ?>>
  1322. <div class="container">
  1323. <?php if (!empty($d['title'])): ?>
  1324. <div class="section-header">
  1325. <h2><?= e($d['title']) ?></h2>
  1326. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1327. </div>
  1328. <?php endif; ?>
  1329. <div class="products-grid">
  1330. <?php foreach ($products as $product): if (!is_array($product)) continue; ?>
  1331. <div class="product-card">
  1332. <?php if (!empty($product['image'])): ?>
  1333. <div class="product-image">
  1334. <img src="<?= e($product['image']) ?>" alt="<?= e($product['title'] ?? '') ?>" width="48" height="48" loading="lazy">
  1335. </div>
  1336. <?php endif; ?>
  1337. <h3><?= e($product['title'] ?? '') ?></h3>
  1338. <p class="product-description"><?= e($product['description'] ?? '') ?></p>
  1339. <?php if (!empty($product['features']) && is_array($product['features'])): ?>
  1340. <ul class="product-features">
  1341. <?php foreach ($product['features'] as $feature): ?>
  1342. <li><?= e($feature) ?></li>
  1343. <?php endforeach; ?>
  1344. </ul>
  1345. <?php endif; ?>
  1346. <?php if (!empty($product['button_text'])): ?>
  1347. <a href="<?= e($product['button_url'] ?? '#') ?>" class="btn btn-primary btn-sm"><?= e($product['button_text']) ?></a>
  1348. <?php endif; ?>
  1349. </div>
  1350. <?php endforeach; ?>
  1351. </div>
  1352. </div>
  1353. </section>
  1354. <?php return ob_get_clean();
  1355. }
  1356. ​
  1357. function render_video($d, $id = '')
  1358. {
  1359. if (!is_array($d) || empty($d['url'])) return '';
  1360. ​
  1361. $url = $d['url'];
  1362. $type = $d['type'] ?? 'url';
  1363. $poster = !empty($d['posterUrl']) ? $d['posterUrl'] : '';
  1364. $playIcon = !empty($d['playIcon']) ? $d['playIcon'] : '/assets/images/play.webp';
  1365. $pauseIcon = !empty($d['pauseIcon']) ? $d['pauseIcon'] : '/assets/images/pause.webp';
  1366. $reloadIcon = !empty($d['reloadIcon']) ? $d['reloadIcon'] : '/assets/images/reload.webp';
  1367. ​
  1368. $id_attr = '';
  1369. if (!empty($id)) {
  1370. $safe_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $id);
  1371. $id_attr = ' id="' . e($safe_id) . '"';
  1372. }
  1373. ​
  1374. $allowed_types = ['url', 'youtube', 'facebook'];
  1375. if (!in_array($type, $allowed_types, true)) {
  1376. $type = 'url';
  1377. }
  1378. ​
  1379. if ($type === 'url') {
  1380. if (preg_match('/youtube\.com|youtu\.be/i', $url)) {
  1381. $type = 'youtube';
  1382. } elseif (preg_match('/facebook\.com|fb\.watch/i', $url)) {
  1383. $type = 'facebook';
  1384. }
  1385. }
  1386. ​
  1387. $video_unique_id = 'video-' . uniqid();
  1388. ​
  1389. ob_start(); ?>
  1390. <section class="video-section" <?= $id_attr ?>>
  1391. <div class="container">
  1392. <?php if (!empty($d['title'])): ?>
  1393. <div class="section-header">
  1394. <h2><?= e($d['title']) ?></h2>
  1395. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1396. </div>
  1397. <?php endif; ?>
  1398. <div class="video-wrapper" style="position: relative;">
  1399. <?php
  1400. if ($poster && ($type === 'youtube' || $type === 'facebook')): ?>
  1401. <div class="video-overlay" style="background-image: url('<?= e($poster) ?>'); position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; z-index: 10; cursor: pointer; display: flex; align-items: center; justify-content: center;" onclick="this.style.display='none';" role="button" aria-label="Odtwórz wideo" tabindex="0" onkeypress="if(event.key==='Enter'||event.key===' '){this.style.display='none';}">
  1402. <picture>
  1403. <source srcset="<?= e($playIcon) ?>" type="image/webp">
  1404. <img src="<?= e(str_replace('.webp', '.png', $playIcon)) ?>"
  1405. alt="Play"
  1406. style="width: 80px;
  1407. height: 80px;
  1408. transition: transform 0.2s;
  1409. filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));"
  1410. onmouseover="this.style.transform='scale(1.1)'"
  1411. onmouseout="this.style.transform='scale(1)'"
  1412. loading="lazy">
  1413. </picture>
  1414. </div>
  1415. <?php endif; ?>
  1416. ​
  1417. <?php if ($type === 'youtube'):
  1418. preg_match('/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/ ]{11})/i', $url, $matches);
  1419. $video_id = $matches[1] ?? '';
  1420. if ($video_id && preg_match('/^[a-zA-Z0-9_-]{11}$/', $video_id)):
  1421. $yt_src = "https://www.youtube.com/embed/" . e($video_id);
  1422. $yt_src .= $poster ? "?autoplay=1&rel=0" : "?rel=0";
  1423. ?>
  1424. <iframe src="<?= $yt_src ?>"
  1425. frameborder="0"
  1426. allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
  1427. allowfullscreen
  1428. loading="lazy"
  1429. title="<?= !empty($d['title']) ? e($d['title']) : 'YouTube video' ?>"></iframe>
  1430. <?php endif;
  1431. elseif ($type === 'facebook'):
  1432. $fb_src = "https://www.facebook.com/plugins/video.php?href=" . urlencode($url) . "&show_text=false";
  1433. $fb_src .= $poster ? "&autoplay=true" : "";
  1434. ?>
  1435. <iframe src="<?= e($fb_src) ?>"
  1436. frameborder="0"
  1437. allow="autoplay; clipboard-write; encrypted-media; picture-in-picture; web-share"
  1438. allowfullscreen
  1439. loading="lazy"
  1440. title="<?= !empty($d['title']) ? e($d['title']) : 'Facebook video' ?>"></iframe>
  1441. <?php else: ?>
  1442. <video id="<?= $video_unique_id ?>"
  1443. preload="metadata"
  1444. <?= $poster ? 'poster="' . e($poster) . '"' : '' ?>
  1445. controlsList="nodownload">
  1446. <source src="<?= e($url) ?>" type="<?= e(media_mime_for_url($url, 'video/mp4')) ?>">
  1447. Your browser does not support the video tag.
  1448. </video>
  1449. ​
  1450. <button class="video-play-pause-btn" id="play-pause-<?= $video_unique_id ?>" style=" position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 15%; min-width: 90px; max-width: 150px; aspect-ratio: 1/1; background: none; border: none; cursor: pointer; z-index: 5; opacity: 1; transition: opacity 0.3s; pointer-events: auto; " aria-label="Play/Pause">
  1451. <picture>
  1452. <source srcset="<?= e($playIcon) ?>" type="image/webp">
  1453. <img class="play-icon" src="<?= e(str_replace('.webp', '.png', $playIcon)) ?>" alt="Play" style="width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));">
  1454. </picture>
  1455. <picture style="display: none;">
  1456. <source srcset="<?= e($pauseIcon) ?>" type="image/webp">
  1457. <img class="pause-icon" src="<?= e(str_replace('.webp', '.png', $pauseIcon)) ?>" alt="Pause" style="width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));">
  1458. </picture>
  1459. ​
  1460. <picture class="reload-pic" style="display: none;">
  1461. <?php $reloadIcon = str_replace(basename($playIcon), 'reload.webp', $playIcon); ?>
  1462. <source srcset="<?= e($reloadIcon) ?>" type="image/webp">
  1463. <img class="reload-icon" src="<?= e(str_replace('.webp', '.png', $reloadIcon)) ?>" alt="Pause" style="width: 100%; height: 100%; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.4));">
  1464. </picture>
  1465. </button>
  1466. <script>
  1467. (function() {
  1468. const video = document.getElementById('<?= $video_unique_id ?>');
  1469. const btn = document.getElementById('play-pause-<?= $video_unique_id ?>');
  1470. const playPicture = btn.querySelector('picture:nth-child(1)');
  1471. const pausePicture = btn.querySelector('picture:nth-child(2)');
  1472. const reloadPicture = btn.querySelector('picture.reload-pic'); // Pobranie nowej ikony
  1473. const wrapper = btn.parentElement;
  1474. let hideTimeout;
  1475. ​
  1476. function showButton() {
  1477. btn.style.opacity = '1';
  1478. clearTimeout(hideTimeout);
  1479. hideTimeout = setTimeout(() => {
  1480. if (!video.paused && !video.ended) {
  1481. btn.style.opacity = '0';
  1482. }
  1483. }, 2000);
  1484. }
  1485. ​
  1486. function updateButton() {
  1487. playPicture.style.display = 'none';
  1488. pausePicture.style.display = 'none';
  1489. reloadPicture.style.display = 'none';
  1490. ​
  1491. if (video.ended) {
  1492. reloadPicture.style.display = '';
  1493. btn.style.opacity = '1';
  1494. } else if (video.paused) {
  1495. playPicture.style.display = '';
  1496. btn.style.opacity = '1';
  1497. } else {
  1498. pausePicture.style.display = '';
  1499. showButton();
  1500. }
  1501. }
  1502. ​
  1503. btn.addEventListener('click', function(e) {
  1504. e.preventDefault();
  1505. e.stopPropagation();
  1506. ​
  1507. if (video.ended) {
  1508. video.currentTime = 0;
  1509. video.play();
  1510. } else if (video.paused) {
  1511. video.play();
  1512. } else {
  1513. video.pause();
  1514. }
  1515. });
  1516. ​
  1517. video.addEventListener('play', updateButton);
  1518. video.addEventListener('pause', updateButton);
  1519. video.addEventListener('ended', updateButton);
  1520. ​
  1521. wrapper.addEventListener('mousemove', showButton);
  1522. wrapper.addEventListener('mouseenter', showButton);
  1523. ​
  1524. updateButton();
  1525. })();
  1526. </script>
  1527. <?php endif; ?>
  1528. </div>
  1529. <?php if (!empty($d['caption'])): ?>
  1530. <p class="video-caption"><?= e($d['caption']) ?></p>
  1531. <?php endif; ?>
  1532. </div>
  1533. </section>
  1534. <?php return ob_get_clean();
  1535. }
  1536. ​
  1537. function render_gallery($d, $id = '')
  1538. {
  1539. if (!is_array($d)) return '';
  1540. $images = $d['images'] ?? [];
  1541. if (empty($images) || !is_array($images)) return '';
  1542. ob_start(); ?>
  1543. <section class="gallery-section" <?= $id ?>>
  1544. <div class="container">
  1545. <?php if (!empty($d['title'])): ?>
  1546. <div class="section-header">
  1547. <h2><?= e($d['title']) ?></h2>
  1548. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1549. </div>
  1550. <?php endif; ?>
  1551. <div class="gallery-grid">
  1552. <?php foreach ($images as $image): if (!is_array($image)) continue; ?>
  1553. <div class="gallery-item">
  1554. <img src="<?= e($image['url'] ?? '') ?>" alt="<?= e($image['alt'] ?? '') ?>" loading="lazy">
  1555. <?php if (!empty($image['caption'])): ?>
  1556. <div class="gallery-caption"><?= e($image['caption']) ?></div>
  1557. <?php endif; ?>
  1558. </div>
  1559. <?php endforeach; ?>
  1560. </div>
  1561. </div>
  1562. </section>
  1563. <?php return ob_get_clean();
  1564. }
  1565. ​
  1566. function render_faq($d, $id = '')
  1567. {
  1568. if (!is_array($d)) return '';
  1569. $items = $d['items'] ?? [];
  1570. if (empty($items) || !is_array($items)) return '';
  1571. ob_start(); ?>
  1572. <section class="faq-section" <?= $id ?>>
  1573. <div class="container">
  1574. <?php if (!empty($d['title'])): ?>
  1575. <div class="section-header">
  1576. <h2><?= e($d['title']) ?></h2>
  1577. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1578. </div>
  1579. <?php endif; ?>
  1580. <div class="faq-list">
  1581. <?php foreach ($items as $item): if (!is_array($item)) continue; ?>
  1582. <details class="faq-item">
  1583. <summary class="faq-question"><?= e($item['question'] ?? '') ?></summary>
  1584. <div class="faq-answer"><?= nl2br(e($item['answer'] ?? '')) ?></div>
  1585. </details>
  1586. <?php endforeach; ?>
  1587. </div>
  1588. </div>
  1589. </section>
  1590. <?php return ob_get_clean();
  1591. }
  1592. ​
  1593. function render_team($d, $id = '')
  1594. {
  1595. if (!is_array($d)) return '';
  1596. $members = $d['members'] ?? [];
  1597. if (empty($members) || !is_array($members)) return '';
  1598. ob_start(); ?>
  1599. <section class="team-section" <?= $id ?>>
  1600. <div class="container">
  1601. <?php if (!empty($d['title'])): ?>
  1602. <div class="section-header">
  1603. <h2><?= e($d['title']) ?></h2>
  1604. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1605. </div>
  1606. <?php endif; ?>
  1607. <div class="team-grid">
  1608. <?php foreach ($members as $member): if (!is_array($member)) continue; ?>
  1609. <div class="team-member">
  1610. <?php if (!empty($member['image'])): ?>
  1611. <img src="<?= e($member['image']) ?>" alt="<?= e($member['name'] ?? '') ?>" class="team-photo" loading="lazy">
  1612. <?php else: ?>
  1613. <div class="team-avatar"><?= e($member['initials'] ?? substr($member['name'] ?? '?', 0, 2)) ?></div>
  1614. <?php endif; ?>
  1615. <h3><?= e($member['name'] ?? '') ?></h3>
  1616. <p class="team-role"><?= e($member['role'] ?? '') ?></p>
  1617. <?php if (!empty($member['bio'])): ?>
  1618. <p class="team-bio"><?= e($member['bio']) ?></p>
  1619. <?php endif; ?>
  1620. <?php if (!empty($member['social']) && is_array($member['social'])): ?>
  1621. <div class="team-social">
  1622. <?php foreach ($member['social'] as $social): if (!is_array($social)) continue; ?>
  1623. <a href="<?= e($social['url'] ?? '#') ?>" target="_blank" rel="noopener" class="team-social-link">
  1624. <?= render_social_icon($social['platform'] ?? 'twitter') ?>
  1625. </a>
  1626. <?php endforeach; ?>
  1627. </div>
  1628. <?php endif; ?>
  1629. </div>
  1630. <?php endforeach; ?>
  1631. </div>
  1632. </div>
  1633. </section>
  1634. <?php return ob_get_clean();
  1635. }
  1636. ​
  1637. function render_audio($d, $id = '')
  1638. {
  1639. if (!is_array($d) || empty($d['url'])) return '';
  1640. ob_start(); ?>
  1641. <section class="audio-section" <?= $id ?>>
  1642. <div class="container">
  1643. <?php if (!empty($d['title'])): ?>
  1644. <div class="section-header">
  1645. <h2><?= e($d['title']) ?></h2>
  1646. <?php if (!empty($d['subtitle'])): ?><p><?= e($d['subtitle']) ?></p><?php endif; ?>
  1647. </div>
  1648. <?php endif; ?>
  1649. <div class="audio-wrapper">
  1650. <audio controls preload="metadata" class="audio-player">
  1651. <source src="<?= e($d['url']) ?>" type="<?= e(media_mime_for_url($d['url'], 'audio/mpeg')) ?>">
  1652. Your browser does not support the audio element.
  1653. </audio>
  1654. <?php if (!empty($d['music_link'])): ?>
  1655. <a href="<?= e($d['music_link']) ?>" class="btn btn-outline" target="_blank" rel="noopener"><?= e($d['music_link_text'] ?? 'Download') ?></a>
  1656. <?php endif; ?>
  1657. </div>
  1658. </div>
  1659. </section>
  1660. <?php return ob_get_clean();
  1661. }
  1662. ​
  1663. function countdown_target_timestamp(array $d)
  1664. {
  1665. $date = block_text($d['target_date'] ?? '');
  1666. if (!preg_match('/^\d{4}-\d{2}-\d{2}$/', $date)) {
  1667. return null;
  1668. }
  1669. ​
  1670. $time = block_text($d['target_time'] ?? '00:00');
  1671. if (!preg_match('/^([01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?$/', $time)) {
  1672. $time = '00:00';
  1673. }
  1674. if (strlen($time) === 5) {
  1675. $time .= ':00';
  1676. }
  1677. ​
  1678. $timezone = block_text($d['timezone'] ?? '');
  1679. try {
  1680. $zone = new DateTimeZone($timezone !== '' && preg_match('#^[A-Za-z0-9_+\-/]+$#', $timezone) ? $timezone : 'UTC');
  1681. } catch (Exception $e) {
  1682. $zone = new DateTimeZone('UTC');
  1683. }
  1684. ​
  1685. $target = DateTimeImmutable::createFromFormat('!Y-m-d H:i:s', $date . ' ' . $time, $zone);
  1686. ​
  1687. return $target instanceof DateTimeImmutable ? $target->getTimestamp() : null;
  1688. }
  1689. ​
  1690. function render_countdown($d, $id = '')
  1691. {
  1692. if (!is_array($d)) return '';
  1693. ​
  1694. $target = countdown_target_timestamp($d);
  1695. if ($target === null) return '';
  1696. ​
  1697. $action = block_choice($d['expired_action'] ?? 'zeros', ['zeros', 'message', 'hide'], 'zeros');
  1698. $message = block_text($d['expired_text'] ?? '');
  1699. if ($action === 'message' && $message === '') {
  1700. $action = 'zeros';
  1701. }
  1702. ​
  1703. $expired = $target <= time();
  1704. if ($expired && $action === 'hide') return '';
  1705. ​
  1706. $labels = [
  1707. 'days' => block_text($d['label_days'] ?? '') ?: 'Days',
  1708. 'hours' => block_text($d['label_hours'] ?? '') ?: 'Hours',
  1709. 'minutes' => block_text($d['label_minutes'] ?? '') ?: 'Minutes',
  1710. 'seconds' => block_text($d['label_seconds'] ?? '') ?: 'Seconds',
  1711. ];
  1712. ​
  1713. $remaining = max(0, $target - time());
  1714. $initial = [
  1715. 'days' => intdiv($remaining, 86400),
  1716. 'hours' => intdiv($remaining % 86400, 3600),
  1717. 'minutes' => intdiv($remaining % 3600, 60),
  1718. 'seconds' => $remaining % 60,
  1719. ];
  1720. $show_message = $expired && $action === 'message';
  1721. ​
  1722. ob_start(); ?>
  1723. <section class="countdown-section" <?= $id ?> data-countdown data-target="<?= e((string) ($target * 1000)) ?>" data-expired="<?= e($action) ?>">
  1724. <div class="container">
  1725. <?= render_section_header($d) ?>
  1726. <div class="countdown-timer" role="timer" aria-live="off"<?= $show_message ? ' hidden' : '' ?>>
  1727. <?php foreach ($labels as $unit => $label): ?>
  1728. <div class="countdown-item">
  1729. <div class="countdown-value" data-<?= $unit ?>><?= str_pad((string) $initial[$unit], 2, '0', STR_PAD_LEFT) ?></div>
  1730. <div class="countdown-label"><?= e($label) ?></div>
  1731. </div>
  1732. <?php endforeach; ?>
  1733. </div>
  1734. <?php if ($action === 'message'): ?>
  1735. <p class="countdown-expired"<?= $show_message ? '' : ' hidden' ?>><?= block_multiline($message) ?></p>
  1736. <?php endif; ?>
  1737. </div>
  1738. </section>
  1739. <?php return ob_get_clean();
  1740. }
  1741. ​
  1742. function render_newsletter($d, $id = '')
  1743. {
  1744. if (!is_array($d)) return '';
  1745. ​
  1746. $section_id = '';
  1747. if (!empty($id) && preg_match('/id="([^"]+)"/', $id, $m)) {
  1748. $section_id = $m[1];
  1749. }
  1750. ​
  1751. ob_start(); ?>
  1752. <section class="newsletter-section" <?= $id ?>>
  1753. <?php if ($section_id !== 'newsletter'): ?>
  1754. <div id="newsletter" style="height:1px; margin-top:-1px;"></div>
  1755. <?php endif; ?>
  1756. <div class="container">
  1757. <div class="newsletter-inner">
  1758. <?php if (!empty($d['title'])): ?>
  1759. <h2><?= e($d['title']) ?></h2>
  1760. <?php endif; ?>
  1761. <?php if (!empty($d['subtitle'])): ?>
  1762. <p><?= e($d['subtitle']) ?></p>
  1763. <?php endif; ?>
  1764. <form class="newsletter-form" method="POST" action="/newsletter/subscribe">
  1765. <input
  1766. type="email"
  1767. name="email"
  1768. class="newsletter-input"
  1769. placeholder="<?= e($d['placeholder'] ?? 'Enter your email') ?>"
  1770. required>
  1771. <button type="submit" class="btn btn-primary">
  1772. <?= e($d['button_text'] ?? 'Subscribe') ?>
  1773. </button>
  1774. </form>
  1775. </div>
  1776. </div>
  1777. </section>
  1778. <?php
  1779. return ob_get_clean();
  1780. }
  1781. ​
  1782. ​
  1783. function block_ui_icon($name)
  1784. {
  1785. static $icons = [
  1786. 'check' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polyline points="20 6 9 17 4 12"/></svg>',
  1787. 'cross' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
  1788. 'close' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',
  1789. 'prev' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polyline points="15 18 9 12 15 6"/></svg>',
  1790. 'next' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polyline points="9 18 15 12 9 6"/></svg>',
  1791. 'pin' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"/><circle cx="12" cy="10" r="3"/></svg>',
  1792. 'phone' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z"/></svg>',
  1793. 'mail' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><polyline points="22,6 12,13 2,6"/></svg>',
  1794. 'clock' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10"/><polyline points="12 6 12 12 16 14"/></svg>',
  1795. 'info' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="10"/><line x1="12" y1="16" x2="12" y2="12"/><line x1="12" y1="8" x2="12.01" y2="8"/></svg>',
  1796. 'success' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>',
  1797. 'warning' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>',
  1798. 'accent' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>',
  1799. 'download' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',
  1800. 'file' => '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/></svg>',
  1801. 'quote' => '<svg viewBox="0 0 32 32" fill="currentColor" aria-hidden="true" focusable="false"><path d="M9.3 26C5.4 26 3 23 3 19.3 3 12.6 7.6 7.3 13.7 6l1 2.4c-3.6 1.3-6 4.2-6.3 7.3.5-.2 1.1-.3 1.8-.3 3 0 5.2 2.2 5.2 5.2S13 26 9.3 26zm15.7 0c-3.9 0-6.3-3-6.3-6.7 0-6.7 4.6-12 10.7-13.3l1 2.4c-3.6 1.3-6 4.2-6.3 7.3.5-.2 1.1-.3 1.8-.3 3 0 5.2 2.2 5.2 5.2S28.7 26 25 26z"/></svg>',
  1802. ];
  1803. ​
  1804. return $icons[$name] ?? '';
  1805. }
  1806. ​
  1807. function render_logo_cloud($d, $id = '')
  1808. {
  1809. if (!is_array($d)) return '';
  1810. ​
  1811. $logos = [];
  1812. foreach (block_list($d['logos'] ?? []) as $logo) {
  1813. if (block_text($logo['image'] ?? '') !== '') {
  1814. $logos[] = $logo;
  1815. }
  1816. }
  1817. if (empty($logos)) return '';
  1818. ​
  1819. $layout = block_choice($d['layout'] ?? 'grid', ['grid', 'marquee'], 'grid');
  1820. $classes = 'logo-cloud logo-cloud-' . $layout;
  1821. if (block_flag($d, 'grayscale', true)) {
  1822. $classes .= ' logo-cloud-muted';
  1823. }
  1824. ​
  1825. $item = static function (array $logo, $decorative) {
  1826. $alt = $decorative ? '' : block_text($logo['alt'] ?? '');
  1827. $img = '<img src="' . e(block_text($logo['image'])) . '" alt="' . e($alt) . '" loading="lazy" decoding="async">';
  1828. $url = block_text($logo['url'] ?? '');
  1829. if ($url === '' || $url === '#') {
  1830. return '<span class="logo-cloud-item"' . ($decorative ? ' aria-hidden="true"' : '') . '>' . $img . '</span>';
  1831. }
  1832. ​
  1833. $extra = $decorative ? ' tabindex="-1" aria-hidden="true"' : '';
  1834. return '<a class="logo-cloud-item" href="' . e(block_safe_url($url)) . '"' . block_link_target($url) . $extra . '>' . $img . '</a>';
  1835. };
  1836. ​
  1837. ob_start(); ?>
  1838. <section class="<?= e($classes) ?>" <?= $id ?>>
  1839. <div class="container">
  1840. <?= render_section_header($d) ?>
  1841. <?php if ($layout === 'marquee'):
  1842. $repeat = (int) max(1, ceil(8 / count($logos)));
  1843. $duration = max(18, count($logos) * $repeat * 3); ?>
  1844. <div class="logo-marquee" style="--logo-duration: <?= (int) $duration ?>s">
  1845. <div class="logo-marquee-track">
  1846. <?php for ($group = 0; $group < 2; $group++): ?>
  1847. <div class="logo-marquee-group"<?= $group > 0 ? ' aria-hidden="true"' : '' ?>>
  1848. <?php for ($r = 0; $r < $repeat; $r++):
  1849. foreach ($logos as $logo):
  1850. echo $item($logo, $group > 0 || $r > 0);
  1851. endforeach;
  1852. endfor; ?>
  1853. </div>
  1854. <?php endfor; ?>
  1855. </div>
  1856. </div>
  1857. <?php else: ?>
  1858. <div class="logo-cloud-grid">
  1859. <?php foreach ($logos as $logo): echo $item($logo, false); endforeach; ?>
  1860. </div>
  1861. <?php endif; ?>
  1862. </div>
  1863. </section>
  1864. <?php return ob_get_clean();
  1865. }
  1866. ​
  1867. function render_steps($d, $id = '')
  1868. {
  1869. if (!is_array($d)) return '';
  1870. ​
  1871. $items = [];
  1872. foreach (block_list($d['items'] ?? []) as $item) {
  1873. if (block_text($item['title'] ?? '') !== '' || block_text($item['description'] ?? '') !== '') {
  1874. $items[] = $item;
  1875. }
  1876. }
  1877. if (empty($items)) return '';
  1878. ​
  1879. $layout = block_choice($d['layout'] ?? 'horizontal', ['horizontal', 'vertical'], 'horizontal');
  1880. $columns = min(4, count($items));
  1881. ​
  1882. ob_start(); ?>
  1883. <section class="steps-section" <?= $id ?>>
  1884. <div class="container">
  1885. <?= render_section_header($d) ?>
  1886. <ol class="steps-list steps-<?= e($layout) ?> steps-cols-<?= (int) $columns ?>">
  1887. <?php foreach ($items as $index => $item):
  1888. $marker = block_text($item['label'] ?? '');
  1889. if ($marker === '') {
  1890. $marker = str_pad((string) ($index + 1), 2, '0', STR_PAD_LEFT);
  1891. } ?>
  1892. <li class="step-item">
  1893. <div class="step-marker" aria-hidden="true"><?= e($marker) ?></div>
  1894. <div class="step-body">
  1895. <span class="step-eyebrow"><?= e($marker) ?></span>
  1896. <?php if (block_text($item['title'] ?? '') !== ''): ?><h3><?= e(block_text($item['title'])) ?></h3><?php endif; ?>
  1897. <?php if (block_text($item['description'] ?? '') !== ''): ?><p><?= block_multiline($item['description']) ?></p><?php endif; ?>
  1898. </div>
  1899. </li>
  1900. <?php endforeach; ?>
  1901. </ol>
  1902. </div>
  1903. </section>
  1904. <?php return ob_get_clean();
  1905. }
  1906. ​
  1907. function comparison_cell($value, $yes_text, $no_text)
  1908. {
  1909. $raw = block_text($value);
  1910. $key = mb_strtolower($raw, 'UTF-8');
  1911. ​
  1912. if (in_array($key, ['yes', 'y', 'true', 'tak', 'ja', 'oui', 'sí', 'si', 'sim', 'да', '✓', '✔', '✅', '+'], true)) {
  1913. return '<span class="cmp-mark cmp-yes" title="' . e($yes_text) . '">' . block_ui_icon('check') . '<span class="visually-hidden">' . e($yes_text) . '</span></span>';
  1914. }
  1915. if (in_array($key, ['no', 'n', 'false', 'nie', 'nein', 'non', 'não', 'нет', '✗', '✕', '✘', 'x', '❌'], true)) {
  1916. return '<span class="cmp-mark cmp-no" title="' . e($no_text) . '">' . block_ui_icon('cross') . '<span class="visually-hidden">' . e($no_text) . '</span></span>';
  1917. }
  1918. if (in_array($key, ['', '-', '–', '—'], true)) {
  1919. return '<span class="cmp-dash" aria-hidden="true">—</span>';
  1920. }
  1921. ​
  1922. return '<span class="cmp-text">' . e($raw) . '</span>';
  1923. }
  1924. ​
  1925. function render_comparison($d, $id = '')
  1926. {
  1927. if (!is_array($d)) return '';
  1928. ​
  1929. $columns = [];
  1930. foreach ((is_array($d['columns'] ?? null) ? $d['columns'] : []) as $column) {
  1931. $columns[] = block_text($column);
  1932. }
  1933. while (!empty($columns) && end($columns) === '') {
  1934. array_pop($columns);
  1935. }
  1936. if (empty($columns)) return '';
  1937. ​
  1938. $rows = [];
  1939. foreach (block_list($d['rows'] ?? []) as $row) {
  1940. $values = is_array($row['values'] ?? null) ? array_values($row['values']) : [];
  1941. $has_value = false;
  1942. foreach ($values as $value) {
  1943. if (block_text($value) !== '') {
  1944. $has_value = true;
  1945. break;
  1946. }
  1947. }
  1948. if (block_text($row['feature'] ?? '') !== '' || $has_value) {
  1949. $rows[] = ['feature' => block_text($row['feature'] ?? ''), 'values' => $values];
  1950. }
  1951. }
  1952. if (empty($rows)) return '';
  1953. ​
  1954. $highlight = block_int($d['highlight'] ?? -1, -1, count($columns) - 1, -1);
  1955. $yes_text = block_text($d['yes_text'] ?? '') ?: 'Included';
  1956. $no_text = block_text($d['no_text'] ?? '') ?: 'Not included';
  1957. $feature_label = block_text($d['feature_label'] ?? '');
  1958. $region_label = block_text($d['title'] ?? '') ?: 'Comparison';
  1959. ​
  1960. ob_start(); ?>
  1961. <section class="comparison-section" <?= $id ?>>
  1962. <div class="container">
  1963. <?= render_section_header($d) ?>
  1964. <div class="comparison-scroll" role="region" aria-label="<?= e($region_label) ?>" tabindex="0">
  1965. <table class="comparison-table">
  1966. <thead>
  1967. <tr>
  1968. <th scope="col" class="cmp-feature-head"><?= $feature_label !== '' ? e($feature_label) : '<span class="visually-hidden">' . e($region_label) . '</span>' ?></th>
  1969. <?php foreach ($columns as $index => $column): ?>
  1970. <th scope="col"<?= $index === $highlight ? ' class="is-highlight"' : '' ?>><?= e($column) ?></th>
  1971. <?php endforeach; ?>
  1972. </tr>
  1973. </thead>
  1974. <tbody>
  1975. <?php foreach ($rows as $row): ?>
  1976. <tr>
  1977. <th scope="row"><?= e($row['feature']) ?></th>
  1978. <?php foreach ($columns as $index => $column): ?>
  1979. <td<?= $index === $highlight ? ' class="is-highlight"' : '' ?>><?= comparison_cell($row['values'][$index] ?? '', $yes_text, $no_text) ?></td>
  1980. <?php endforeach; ?>
  1981. </tr>
  1982. <?php endforeach; ?>
  1983. </tbody>
  1984. </table>
  1985. </div>
  1986. </div>
  1987. </section>
  1988. <?php return ob_get_clean();
  1989. }
  1990. ​
  1991. function contact_phone_href($phone)
  1992. {
  1993. $digits = preg_replace('/[^0-9+]/', '', block_text($phone)) ?? '';
  1994. if ($digits === '') {
  1995. return '';
  1996. }
  1997. $plus = $digits[0] === '+';
  1998. $digits = str_replace('+', '', $digits);
  1999. if (!$plus && strpos($digits, '00') === 0) {
  2000. $plus = true;
  2001. $digits = substr($digits, 2);
  2002. }
  2003. ​
  2004. return $digits === '' ? '' : 'tel:' . ($plus ? '+' : '') . $digits;
  2005. }
  2006. ​
  2007. function contact_map_embed(array $d)
  2008. {
  2009. $provider = block_choice($d['map_provider'] ?? 'none', ['none', 'osm', 'google'], 'none');
  2010. $zoom = block_int($d['map_zoom'] ?? 15, 3, 19, 15);
  2011. ​
  2012. if ($provider === 'osm') {
  2013. $lat = block_text($d['map_lat'] ?? '');
  2014. $lng = block_text($d['map_lng'] ?? '');
  2015. if (!is_numeric($lat) || !is_numeric($lng)) {
  2016. return null;
  2017. }
  2018. $lat = (float) $lat;
  2019. $lng = (float) $lng;
  2020. if ($lat < -85 || $lat > 85 || $lng < -180 || $lng > 180) {
  2021. return null;
  2022. }
  2023. ​
  2024. $lng_span = 900 / pow(2, $zoom);
  2025. $lat_span = $lng_span * max(0.2, cos(deg2rad($lat))) * 0.6;
  2026. $bbox = sprintf('%.6F,%.6F,%.6F,%.6F', $lng - $lng_span / 2, $lat - $lat_span / 2, $lng + $lng_span / 2, $lat + $lat_span / 2);
  2027. $marker = sprintf('%.6F,%.6F', $lat, $lng);
  2028. ​
  2029. return [
  2030. 'src' => 'https://www.openstreetmap.org/export/embed.html?bbox=' . rawurlencode($bbox) . '&layer=mapnik&marker=' . rawurlencode($marker),
  2031. 'link' => sprintf('https://www.openstreetmap.org/?mlat=%.6F&mlon=%.6F#map=%d/%.6F/%.6F', $lat, $lng, $zoom, $lat, $lng),
  2032. ];
  2033. }
  2034. ​
  2035. if ($provider === 'google') {
  2036. $query = block_text($d['map_query'] ?? '');
  2037. if ($query === '') {
  2038. $query = trim(preg_replace('/\s*\n\s*/', ', ', block_text($d['address'] ?? '')) ?? '');
  2039. }
  2040. if ($query === '') {
  2041. return null;
  2042. }
  2043. ​
  2044. return [
  2045. 'src' => 'https://www.google.com/maps?q=' . rawurlencode($query) . '&z=' . $zoom . '&output=embed',
  2046. 'link' => 'https://www.google.com/maps/search/?api=1&query=' . rawurlencode($query),
  2047. ];
  2048. }
  2049. ​
  2050. return null;
  2051. }
  2052. ​
  2053. function render_contact_info($d, $id = '')
  2054. {
  2055. if (!is_array($d)) return '';
  2056. ​
  2057. $address = block_text($d['address'] ?? '');
  2058. $phone = block_text($d['phone'] ?? '');
  2059. $email = block_text($d['email'] ?? '');
  2060. $hours = array_values(array_filter(array_map('trim', preg_split('/\r\n|\r|\n/', block_text($d['hours'] ?? '')) ?: []), 'strlen'));
  2061. $map = contact_map_embed($d);
  2062. ​
  2063. if ($address === '' && $phone === '' && $email === '' && empty($hours) && $map === null) return '';
  2064. ​
  2065. $labels = [
  2066. 'address' => block_text($d['label_address'] ?? '') ?: 'Address',
  2067. 'phone' => block_text($d['label_phone'] ?? '') ?: 'Phone',
  2068. 'email' => block_text($d['label_email'] ?? '') ?: 'Email',
  2069. 'hours' => block_text($d['label_hours'] ?? '') ?: 'Opening hours',
  2070. ];
  2071. $map_title = block_text($d['title'] ?? '') ?: $labels['address'];
  2072. $map_link_text = block_text($d['map_link_text'] ?? '') ?: 'Open larger map';
  2073. $phone_href = contact_phone_href($phone);
  2074. $email_valid = filter_var($email, FILTER_VALIDATE_EMAIL) !== false;
  2075. ​
  2076. ob_start(); ?>
  2077. <section class="contact-info-section" <?= $id ?>>
  2078. <div class="container">
  2079. <?= render_section_header($d) ?>
  2080. <div class="contact-info-grid<?= $map !== null ? ' has-map' : '' ?>">
  2081. <?php if ($address !== '' || $phone !== '' || $email !== '' || !empty($hours)): ?>
  2082. <ul class="contact-info-list">
  2083. <?php if ($address !== ''): ?>
  2084. <li class="contact-info-item">
  2085. <span class="contact-info-icon"><?= block_ui_icon('pin') ?></span>
  2086. <div>
  2087. <span class="contact-info-label"><?= e($labels['address']) ?></span>
  2088. <address class="contact-info-value"><?= block_multiline($address) ?></address>
  2089. </div>
  2090. </li>
  2091. <?php endif; ?>
  2092. <?php if ($phone !== ''): ?>
  2093. <li class="contact-info-item">
  2094. <span class="contact-info-icon"><?= block_ui_icon('phone') ?></span>
  2095. <div>
  2096. <span class="contact-info-label"><?= e($labels['phone']) ?></span>
  2097. <?php if ($phone_href !== ''): ?>
  2098. <a class="contact-info-value" href="<?= e($phone_href) ?>"><?= e($phone) ?></a>
  2099. <?php else: ?>
  2100. <span class="contact-info-value"><?= e($phone) ?></span>
  2101. <?php endif; ?>
  2102. </div>
  2103. </li>
  2104. <?php endif; ?>
  2105. <?php if ($email !== ''): ?>
  2106. <li class="contact-info-item">
  2107. <span class="contact-info-icon"><?= block_ui_icon('mail') ?></span>
  2108. <div>
  2109. <span class="contact-info-label"><?= e($labels['email']) ?></span>
  2110. <?php if ($email_valid): ?>
  2111. <a class="contact-info-value" href="mailto:<?= e($email) ?>"><?= e($email) ?></a>
  2112. <?php else: ?>
  2113. <span class="contact-info-value"><?= e($email) ?></span>
  2114. <?php endif; ?>
  2115. </div>
  2116. </li>
  2117. <?php endif; ?>
  2118. <?php if (!empty($hours)): ?>
  2119. <li class="contact-info-item">
  2120. <span class="contact-info-icon"><?= block_ui_icon('clock') ?></span>
  2121. <div>
  2122. <span class="contact-info-label"><?= e($labels['hours']) ?></span>
  2123. <ul class="contact-hours">
  2124. <?php foreach ($hours as $line):
  2125. $parts = preg_split('/:\s+/u', $line, 2) ?: [$line]; ?>
  2126. <li class="contact-hours-row">
  2127. <?php if (count($parts) === 2): ?>
  2128. <span class="contact-hours-day"><?= e($parts[0]) ?></span>
  2129. <span class="contact-hours-time"><?= e($parts[1]) ?></span>
  2130. <?php else: ?>
  2131. <span class="contact-hours-time"><?= e($line) ?></span>
  2132. <?php endif; ?>
  2133. </li>
  2134. <?php endforeach; ?>
  2135. </ul>
  2136. </div>
  2137. </li>
  2138. <?php endif; ?>
  2139. </ul>
  2140. <?php endif; ?>
  2141. <?php if ($map !== null): ?>
  2142. <div class="contact-map">
  2143. <iframe src="<?= e($map['src']) ?>" title="<?= e($map_title) ?>" loading="lazy" referrerpolicy="no-referrer-when-downgrade" allowfullscreen></iframe>
  2144. <a class="contact-map-link" href="<?= e($map['link']) ?>" target="_blank" rel="noopener"><?= e($map_link_text) ?></a>
  2145. </div>
  2146. <?php endif; ?>
  2147. </div>
  2148. </div>
  2149. </section>
  2150. <?php return ob_get_clean();
  2151. }
  2152. ​
  2153. function render_tabs($d, $id = '')
  2154. {
  2155. if (!is_array($d)) return '';
  2156. ​
  2157. $items = [];
  2158. foreach (block_list($d['items'] ?? []) as $item) {
  2159. if (block_text($item['label'] ?? '') !== '' || block_text($item['content'] ?? '') !== '' || block_text($item['image'] ?? '') !== '') {
  2160. $items[] = $item;
  2161. }
  2162. }
  2163. if (empty($items)) return '';
  2164. ​
  2165. $uid = 'tabs-' . bin2hex(random_bytes(5));
  2166. $list_label = block_text($d['title'] ?? '') ?: 'Tabs';
  2167. ​
  2168. ob_start(); ?>
  2169. <section class="tabs-section" <?= $id ?>>
  2170. <div class="container">
  2171. <?= render_section_header($d) ?>
  2172. <div class="tabs-block" data-tabs>
  2173. <div class="tabs-list" role="tablist" aria-label="<?= e($list_label) ?>">
  2174. <?php foreach ($items as $index => $item):
  2175. $label = block_text($item['label'] ?? '') ?: 'Tab ' . ($index + 1); ?>
  2176. <button type="button" class="tabs-tab<?= $index === 0 ? ' is-active' : '' ?>" role="tab" id="<?= e($uid . '-tab-' . $index) ?>" aria-controls="<?= e($uid . '-panel-' . $index) ?>" aria-selected="<?= $index === 0 ? 'true' : 'false' ?>" tabindex="<?= $index === 0 ? '0' : '-1' ?>"><?= e($label) ?></button>
  2177. <?php endforeach; ?>
  2178. </div>
  2179. <?php foreach ($items as $index => $item):
  2180. $label = block_text($item['label'] ?? '') ?: 'Tab ' . ($index + 1);
  2181. $image = block_text($item['image'] ?? '');
  2182. $content = block_text($item['content'] ?? ''); ?>
  2183. <div class="tabs-panel<?= $index === 0 ? ' is-active' : '' ?>" role="tabpanel" id="<?= e($uid . '-panel-' . $index) ?>" aria-labelledby="<?= e($uid . '-tab-' . $index) ?>" tabindex="0">
  2184. <h3 class="tabs-panel-title"><?= e($label) ?></h3>
  2185. <div class="tabs-panel-body<?= $image !== '' ? ' has-image' : '' ?>">
  2186. <?php if ($content !== ''): ?><div class="text-content"><?= block_multiline($content) ?></div><?php endif; ?>
  2187. <?php if ($image !== ''): ?><img src="<?= e($image) ?>" alt="<?= e(block_text($item['image_alt'] ?? '')) ?>" loading="lazy" decoding="async"><?php endif; ?>
  2188. </div>
  2189. </div>
  2190. <?php endforeach; ?>
  2191. </div>
  2192. </div>
  2193. </section>
  2194. <?php return ob_get_clean();
  2195. }
  2196. ​
  2197. function render_carousel($d, $id = '')
  2198. {
  2199. if (!is_array($d)) return '';
  2200. ​
  2201. $slides = [];
  2202. foreach (block_list($d['slides'] ?? []) as $slide) {
  2203. if (block_text($slide['image'] ?? '') !== '') {
  2204. $slides[] = $slide;
  2205. }
  2206. }
  2207. if (empty($slides)) return '';
  2208. ​
  2209. $ratio = block_choice($d['ratio'] ?? '16-9', ['16-9', '21-9', '4-3', '3-2', '1-1'], '16-9');
  2210. $autoplay = count($slides) > 1 && block_flag($d, 'autoplay', false);
  2211. $interval = block_int($d['interval'] ?? 5, 2, 30, 5);
  2212. $label = block_text($d['title'] ?? '') ?: 'Image carousel';
  2213. $total = count($slides);
  2214. ​
  2215. ob_start(); ?>
  2216. <section class="carousel-section" <?= $id ?>>
  2217. <div class="container">
  2218. <?= render_section_header($d) ?>
  2219. <div class="carousel carousel-ratio-<?= e($ratio) ?>" data-carousel data-autoplay="<?= $autoplay ? '1' : '0' ?>" data-interval="<?= (int) ($interval * 1000) ?>" role="region" aria-roledescription="carousel" aria-label="<?= e($label) ?>">
  2220. <ul class="carousel-track" aria-live="<?= $autoplay ? 'off' : 'polite' ?>">
  2221. <?php foreach ($slides as $index => $slide):
  2222. $url = block_text($slide['url'] ?? '');
  2223. $caption = block_text($slide['caption'] ?? '');
  2224. $img = '<img src="' . e(block_text($slide['image'])) . '" alt="' . e(block_text($slide['alt'] ?? '')) . '"' . ($index === 0 ? '' : ' loading="lazy"') . ' decoding="async">'; ?>
  2225. <li class="carousel-slide" role="group" aria-roledescription="slide" aria-label="<?= ($index + 1) . ' / ' . $total ?>">
  2226. <figure>
  2227. <?php if ($url !== '' && $url !== '#'): ?>
  2228. <a class="carousel-media" href="<?= e(block_safe_url($url)) ?>"<?= block_link_target($url) ?>><?= $img ?></a>
  2229. <?php else: ?>
  2230. <div class="carousel-media"><?= $img ?></div>
  2231. <?php endif; ?>
  2232. <?php if ($caption !== ''): ?><figcaption><?= e($caption) ?></figcaption><?php endif; ?>
  2233. </figure>
  2234. </li>
  2235. <?php endforeach; ?>
  2236. </ul>
  2237. <?php if ($total > 1): ?>
  2238. <button type="button" class="carousel-btn carousel-prev" data-carousel-prev aria-label="Previous slide"><?= block_ui_icon('prev') ?></button>
  2239. <button type="button" class="carousel-btn carousel-next" data-carousel-next aria-label="Next slide"><?= block_ui_icon('next') ?></button>
  2240. <div class="carousel-dots">
  2241. <?php foreach ($slides as $index => $slide): ?>
  2242. <button type="button" class="carousel-dot<?= $index === 0 ? ' is-active' : '' ?>" data-carousel-dot="<?= (int) $index ?>" aria-label="<?= e('Slide ' . ($index + 1)) ?>"<?= $index === 0 ? ' aria-current="true"' : '' ?>></button>
  2243. <?php endforeach; ?>
  2244. </div>
  2245. <?php endif; ?>
  2246. </div>
  2247. </div>
  2248. </section>
  2249. <?php return ob_get_clean();
  2250. }
  2251. ​
  2252. function render_announcement($d, $id = '')
  2253. {
  2254. if (!is_array($d)) return '';
  2255. ​
  2256. $text = block_text($d['text'] ?? '');
  2257. if ($text === '') return '';
  2258. ​
  2259. $style = block_choice($d['style'] ?? 'info', ['info', 'success', 'warning', 'accent'], 'info');
  2260. $link_text = block_text($d['link_text'] ?? '');
  2261. $link_url = block_text($d['link_url'] ?? '');
  2262. $dismissible = block_flag($d, 'dismissible', true);
  2263. $key = substr(hash('sha256', $text . '|' . $link_text . '|' . $link_url), 0, 16);
  2264. $close_label = block_text($d['close_label'] ?? '') ?: 'Dismiss';
  2265. ​
  2266. ob_start(); ?>
  2267. <div class="announcement-bar announcement-<?= e($style) ?>" <?= $id ?><?= $dismissible ? ' data-announcement="' . e($key) . '"' : '' ?>>
  2268. <div class="container announcement-inner">
  2269. <span class="announcement-icon"><?= block_ui_icon($style) ?></span>
  2270. <p class="announcement-text">
  2271. <span><?= e($text) ?></span>
  2272. <?php if ($link_text !== '' && $link_url !== ''): ?>
  2273. <a class="announcement-link" href="<?= e(block_safe_url($link_url)) ?>"<?= block_link_target($link_url) ?>><?= e($link_text) ?></a>
  2274. <?php endif; ?>
  2275. </p>
  2276. <?php if ($dismissible): ?>
  2277. <button type="button" class="announcement-close" data-announcement-close aria-label="<?= e($close_label) ?>"><?= block_ui_icon('close') ?></button>
  2278. <?php endif; ?>
  2279. </div>
  2280. </div>
  2281. <?php if ($dismissible): ?>
  2282. <script>(function(s){try{var b=s&&s.previousElementSibling;if(b&&localStorage.getItem('flatly-announcement:'+b.getAttribute('data-announcement'))){b.hidden=true;}}catch(e){}})(document.currentScript);</script>
  2283. <?php endif; ?>
  2284. <?php return ob_get_clean();
  2285. }
  2286. ​
  2287. function render_quote($d, $id = '')
  2288. {
  2289. if (!is_array($d)) return '';
  2290. ​
  2291. $quote = block_text($d['quote'] ?? '');
  2292. if ($quote === '') return '';
  2293. ​
  2294. $author = block_text($d['author'] ?? '');
  2295. $role = block_text($d['role'] ?? '');
  2296. $image = block_text($d['image'] ?? '');
  2297. $align = block_choice($d['align'] ?? 'center', ['center', 'left'], 'center');
  2298. $size = block_choice($d['size'] ?? 'large', ['large', 'medium'], 'large');
  2299. ​
  2300. ob_start(); ?>
  2301. <section class="quote-section" <?= $id ?>>
  2302. <div class="container">
  2303. <figure class="quote-figure quote-<?= e($align) ?> quote-<?= e($size) ?>">
  2304. <span class="quote-mark"><?= block_ui_icon('quote') ?></span>
  2305. <blockquote class="quote-text"><p><?= block_multiline($quote) ?></p></blockquote>
  2306. <?php if ($author !== '' || $role !== ''): ?>
  2307. <figcaption class="quote-author">
  2308. <?php if ($image !== ''): ?>
  2309. <img class="quote-avatar" src="<?= e($image) ?>" alt="" loading="lazy" decoding="async" width="56" height="56">
  2310. <?php endif; ?>
  2311. <span class="quote-author-text">
  2312. <?php if ($author !== ''): ?><cite class="quote-name"><?= e($author) ?></cite><?php endif; ?>
  2313. <?php if ($role !== ''): ?><span class="quote-role"><?= e($role) ?></span><?php endif; ?>
  2314. </span>
  2315. </figcaption>
  2316. <?php endif; ?>
  2317. </figure>
  2318. </div>
  2319. </section>
  2320. <?php return ob_get_clean();
  2321. }
  2322. ​
  2323. function render_downloads($d, $id = '')
  2324. {
  2325. if (!is_array($d)) return '';
  2326. ​
  2327. $files = [];
  2328. foreach (block_list($d['files'] ?? []) as $file) {
  2329. $url = block_safe_url($file['url'] ?? '', '');
  2330. if ($url === '' || $url === '#') {
  2331. continue;
  2332. }
  2333. ​
  2334. $path = (string) (parse_url($url, PHP_URL_PATH) ?: $url);
  2335. $basename = rawurldecode(basename($path));
  2336. $ext = strtolower(pathinfo($basename, PATHINFO_EXTENSION));
  2337. $ext = preg_match('/^[a-z0-9]{1,5}$/', $ext) ? $ext : '';
  2338. $name = block_text($file['name'] ?? '');
  2339. if ($name === '') {
  2340. $name = preg_replace('/-[a-f0-9]{8}(\.[a-z0-9]+)$/i', '$1', $basename) ?? $basename;
  2341. }
  2342. ​
  2343. $local = block_local_media_path($url);
  2344. $size = $local !== null ? block_format_bytes((int) @filesize($local)) : '';
  2345. ​
  2346. $files[] = [
  2347. 'url' => $url,
  2348. 'name' => $name,
  2349. 'description' => block_text($file['description'] ?? ''),
  2350. 'ext' => $ext,
  2351. 'size' => $size,
  2352. 'local' => !block_is_external_url($url),
  2353. ];
  2354. }
  2355. if (empty($files)) return '';
  2356. ​
  2357. $button = block_text($d['button_text'] ?? '') ?: 'Download';
  2358. ​
  2359. ob_start(); ?>
  2360. <section class="downloads-section" <?= $id ?>>
  2361. <div class="container">
  2362. <?= render_section_header($d) ?>
  2363. <ul class="downloads-list">
  2364. <?php foreach ($files as $file):
  2365. $meta = array_filter([$file['ext'] !== '' ? strtoupper($file['ext']) : '', $file['size']], 'strlen'); ?>
  2366. <li>
  2367. <a class="download-item" href="<?= e($file['url']) ?>"<?= $file['local'] ? ' download' : ' target="_blank" rel="noopener"' ?>>
  2368. <span class="download-icon"><?= block_ui_icon('file') ?><?php if ($file['ext'] !== ''): ?><span class="download-ext"><?= e(strtoupper(substr($file['ext'], 0, 4))) ?></span><?php endif; ?></span>
  2369. <span class="download-info">
  2370. <span class="download-name"><?= e($file['name']) ?></span>
  2371. <?php if ($file['description'] !== ''): ?><span class="download-desc"><?= e($file['description']) ?></span><?php endif; ?>
  2372. <?php if (!empty($meta)): ?><span class="download-meta"><?= e(implode(' · ', $meta)) ?></span><?php endif; ?>
  2373. </span>
  2374. <span class="download-action"><?= block_ui_icon('download') ?><span><?= e($button) ?></span></span>
  2375. </a>
  2376. </li>
  2377. <?php endforeach; ?>
  2378. </ul>
  2379. </div>
  2380. </section>
  2381. <?php return ob_get_clean();
  2382. }
  2383. ​
  2384. function render_social_follow($d, $id = '')
  2385. {
  2386. if (!is_array($d)) return '';
  2387. ​
  2388. $links = [];
  2389. foreach (block_list($d['links'] ?? []) as $link) {
  2390. $platform = preg_replace('/[^a-z_-]/', '', strtolower(block_text($link['platform'] ?? ''))) ?? '';
  2391. $url = block_safe_url($link['url'] ?? '', '');
  2392. if ($platform === '' || $url === '' || $url === '#' || !IconRegistry::isSocialAllowed($platform)) {
  2393. continue;
  2394. }
  2395. $links[] = [
  2396. 'platform' => $platform,
  2397. 'url' => $url,
  2398. 'label' => block_text($link['label'] ?? '') ?: social_platform_label($platform),
  2399. ];
  2400. }
  2401. if (empty($links)) return '';
  2402. ​
  2403. $style = block_choice($d['style'] ?? 'buttons', ['buttons', 'icons'], 'buttons');
  2404. ​
  2405. ob_start(); ?>
  2406. <section class="social-follow-section" <?= $id ?>>
  2407. <div class="container">
  2408. <?= render_section_header($d) ?>
  2409. <ul class="social-follow-list social-follow-<?= e($style) ?>">
  2410. <?php foreach ($links as $link): ?>
  2411. <li>
  2412. <a class="social-follow-link social-<?= e($link['platform']) ?>" href="<?= e($link['url']) ?>" target="_blank" rel="noopener me"<?= $style === 'icons' ? ' aria-label="' . e($link['label']) . '" title="' . e($link['label']) . '"' : '' ?>>
  2413. <span class="social-follow-icon"><?= render_social_icon($link['platform']) ?></span>
  2414. <?php if ($style === 'buttons'): ?><span class="social-follow-label"><?= e($link['label']) ?></span><?php endif; ?>
  2415. </a>
  2416. </li>
  2417. <?php endforeach; ?>
  2418. </ul>
  2419. </div>
  2420. </section>
  2421. <?php return ob_get_clean();
  2422. }
  2423. ​
  2424. function render_spacer($d, $id = '')
  2425. {
  2426. if (!is_array($d)) $d = [];
  2427. ​
  2428. $height = block_int($d['height'] ?? 64, 0, 400, 64);
  2429. $divider = block_choice($d['divider'] ?? 'none', ['none', 'line', 'dashed', 'dotted', 'wave'], 'none');
  2430. ​
  2431. ob_start(); ?>
  2432. <div class="spacer-block spacer-<?= e($divider) ?>" <?= $id ?> style="--spacer-height: <?= (int) $height ?>px" aria-hidden="true">
  2433. <?php if ($divider === 'wave'): ?>
  2434. <svg class="spacer-wave" viewBox="0 0 1200 24" preserveAspectRatio="none" focusable="false"><path d="M0 12 C 50 0, 100 0, 150 12 S 250 24, 300 12 S 400 0, 450 12 S 550 24, 600 12 S 700 0, 750 12 S 850 24, 900 12 S 1000 0, 1050 12 S 1150 24, 1200 12" fill="none" stroke="currentColor" stroke-width="2" vector-effect="non-scaling-stroke"/></svg>
  2435. <?php elseif ($divider !== 'none'): ?>
  2436. <div class="container"><hr class="spacer-line"></div>
  2437. <?php endif; ?>
  2438. </div>
  2439. <?php return ob_get_clean();
  2440. }
  2441. ​