optionslib->get_option('version_dialog_header'); ?>
optionslib) ? $this->optionslib->get_option('version_dialog') : 'release_notes'; if ($versionDialogMode == 'custom_text' || $versionDialogMode == 'both') { ?>
optionslib) ? $this->optionslib->get_option('version_dialog_text') : null; if ($versionDialogText !== null) { // Apply markdown conversion to custom text $htmlContent = $versionDialogText; // Convert inline code (`) - protect inline code from other conversions $htmlContent = preg_replace('/`([^`]+)`/', '$1', $htmlContent); // Convert markdown horizontal rules (---, ***, ___) - split by line for robustness $lines = preg_split('/\r?\n/', $htmlContent); $processedLines = array(); foreach ($lines as $line) { $trimmed = trim($line); // Check if line is ONLY HR markers (3+ of same character, optionally with spaces) if (preg_match('/^[ \t]{0,3}([\*\-_])\1{2,}[ \t]*$/', $trimmed)) { $processedLines[] = '
'; } else { $processedLines[] = $line; } } $htmlContent = implode("\n", $processedLines); // Convert blockquotes (>) before lists $htmlContent = preg_replace_callback( '/((?:^>[ \t]?.+$(?:\r?\n)?)+)/m', function($matches) { $blockquoteContent = $matches[1]; $blockquoteContent = preg_replace('/^>[ \t]?/m', '', $blockquoteContent); return "\n
\n" . $blockquoteContent . "
\n"; }, $htmlContent ); // Convert strikethrough (~~text~~) $htmlContent = preg_replace('/~~(.+?)~~/s', '$1', $htmlContent); // Convert bullet points to list items $htmlContent = preg_replace_callback( '/((?:^[ \t]*[\*\-\+] .+$(?:\r?\n)?)+)/m', function($matches) { $listContent = $matches[1]; // Handle task lists first $listContent = preg_replace_callback( '/^[ \t]*[\*\-\+] \[[ xX]\]/m', function($m) { $isChecked = strpos($m[0], '[x') !== false || strpos($m[0], '[X') !== false; return ' '; }, $listContent ); $listContent = preg_replace('/^[ \t]*[\*\-\+] (.+?)[ \t]*$/m', '
  • $1
  • ', $listContent); $listContent = preg_replace('/(<\/li>)\r?\n(?=
  • )/', '$1', $listContent); return "\n
      \n" . $listContent . "
    \n"; }, $htmlContent ); // Convert numbered lists $htmlContent = preg_replace_callback( '/((?:^[ \t]*\d+\. .+$(?:\r?\n)?)+)/m', function($matches) { $listContent = $matches[1]; $listContent = preg_replace('/^[ \t]*\d+\. (.+?)[ \t]*$/m', '
  • $1
  • ', $listContent); $listContent = preg_replace('/(<\/li>)\r?\n(?=
  • )/', '$1', $listContent); return "\n
      \n" . $listContent . "
    \n"; }, $htmlContent ); // Convert headers $htmlContent = preg_replace('/^#### (.+)$/m', '
    $1
    ', $htmlContent); $htmlContent = preg_replace('/^### (.+)$/m', '

    $1

    ', $htmlContent); $htmlContent = preg_replace('/^## (.+)$/m', '

    $1

    ', $htmlContent); $htmlContent = preg_replace('/^# (.+)$/m', '

    $1

    ', $htmlContent); // Convert bold and italic $htmlContent = preg_replace('/\*\*(.+?)\*\*/', '$1', $htmlContent); $htmlContent = preg_replace('/__(.+?)__/', '$1', $htmlContent); $htmlContent = preg_replace('/(?$1', $htmlContent); $htmlContent = preg_replace('/(?$1', $htmlContent); // Convert images and links $htmlContent = preg_replace('/!\[([^\]]*)\]\(([^)]+)\)/', '$1', $htmlContent); $htmlContent = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', '$1', $htmlContent); // Convert GitHub usernames and URLs $htmlContent = preg_replace('/(?@$1', $htmlContent); $htmlContent = preg_replace('/(?|>\s)(https?:\/\/[^\s<]+)/', '$1', $htmlContent); // Protect block elements from nl2br $htmlContent = preg_replace('/(<\/(?:h[1-6]|ul|ol|li|pre|blockquote)>)\r?\n/', '$1', $htmlContent); $htmlContent = preg_replace('/(<(?:ul|ol|pre|blockquote)>)\r?\n/', '$1', $htmlContent); $htmlContent = preg_replace('/(\r?\n)/', '$1', $htmlContent); // Convert line breaks $htmlContent = nl2br($htmlContent); // Remove block markers $htmlContent = preg_replace('//', '', $htmlContent); $htmlContent = preg_replace('//', '', $htmlContent); $htmlContent = preg_replace('//', '', $htmlContent); // Cleanup extra br tags around block elements // Remove ALL consecutive br tags before block elements $htmlContent = preg_replace('/(?:\s*)+(<(?:h[1-6]|ul|ol|li|pre|code|hr|blockquote)[^>]*>)/i', '$1', $htmlContent); $htmlContent = preg_replace('/(<\/(?:h[1-6]|ul|ol|li|pre|blockquote)>|\s*)\s*(?:\s*)+/i', '$1', $htmlContent); $htmlContent = preg_replace('/(){3,}/', '

    ', $htmlContent); // Remove br tags inside list items $htmlContent = preg_replace('/(
  • [^<]*)(\s*<\/li>)/i', '$1$2', $htmlContent); echo $htmlContent; } else { echo 'No Version Dialog text set. Go to the Admin Menu and set one.'; } ?>
  • [ 'header' => 'User-Agent: Cloudlog - Amateur Radio Logbook' ] ]; $context = stream_context_create($options); $response = file_get_contents($url, false, $context); if ($response !== false) { $data = json_decode($response, true); $current_version = $this->optionslib->get_option('version'); if ($data !== null && !empty($data)) { $firstRelease = null; foreach ($data as $singledata) { if ($singledata['tag_name'] == $current_version) { $firstRelease = $singledata; break; } } if ($firstRelease !== null) { $releaseBody = isset($firstRelease['body']) ? $firstRelease['body'] : 'No release information available'; $releaseName = isset($firstRelease['name']) ? $firstRelease['name'] : 'No version name information available'; echo "

    v" . $releaseName . "

    "; // Convert markdown to HTML using PHP $htmlContent = $releaseBody; // Convert code blocks (```) - do this first to protect code content $htmlContent = preg_replace('/```([a-z]*)\r?\n(.*?)\r?\n```/s', '
    $2
    ', $htmlContent); // Convert inline code (`) - protect inline code from other conversions $htmlContent = preg_replace('/`([^`]+)`/', '$1', $htmlContent); // Convert markdown horizontal rules (---, ***, ___) - split by line for robustness $lines = preg_split('/\r?\n/', $htmlContent); $processedLines = array(); foreach ($lines as $line) { $trimmed = trim($line); // Check if line is ONLY HR markers (3+ of same character, optionally with spaces) if (preg_match('/^[ \t]{0,3}([\*\-_])\1{2,}[ \t]*$/', $trimmed)) { $processedLines[] = '
    '; } else { $processedLines[] = $line; } } $htmlContent = implode("\n", $processedLines); // Convert blockquotes (>) before lists to avoid interference $htmlContent = preg_replace_callback( '/((?:^>[ \t]?.+$(?:\r?\n)?)+)/m', function($matches) { $blockquoteContent = $matches[1]; // Remove leading > from each line and trim $blockquoteContent = preg_replace('/^>[ \t]?/m', '', $blockquoteContent); // Wrap in
    tags return "\n
    \n" . $blockquoteContent . "
    \n"; }, $htmlContent ); // Convert strikethrough (~~text~~) $htmlContent = preg_replace('/~~(.+?)~~/s', '$1', $htmlContent); // Convert bullet points to list items (must be done before bold/italic to avoid interference) $htmlContent = preg_replace_callback( '/((?:^[ \t]*[\*\-\+] .+$(?:\r?\n)?)+)/m', function($matches) { $listContent = $matches[1]; // Handle task lists first: [ ] or [x] or [X] $listContent = preg_replace_callback( '/^[ \t]*[\*\-\+] \[[ xX]\]/m', function($m) { $isChecked = strpos($m[0], '[x') !== false || strpos($m[0], '[X') !== false; return ' '; }, $listContent ); // Convert each bullet point to
  • , stripping trailing whitespace $listContent = preg_replace('/^[ \t]*[\*\-\+] (.+?)[ \t]*$/m', '
  • $1
  • ', $listContent); // Remove newlines between list items to prevent nl2br from adding extra breaks $listContent = preg_replace('/(<\/li>)\r?\n(?=
  • )/', '$1', $listContent); // Wrap in
      tags return "\n
        \n" . $listContent . "
      \n"; }, $htmlContent ); // Convert numbered lists $htmlContent = preg_replace_callback( '/((?:^[ \t]*\d+\. .+$(?:\r?\n)?)+)/m', function($matches) { $listContent = $matches[1]; // Convert each numbered item to
    • , stripping trailing whitespace $listContent = preg_replace('/^[ \t]*\d+\. (.+?)[ \t]*$/m', '
    • $1
    • ', $listContent); // Remove newlines between list items to prevent nl2br from adding extra breaks $listContent = preg_replace('/(<\/li>)\r?\n(?=
    • )/', '$1', $listContent); // Wrap in
        tags return "\n
          \n" . $listContent . "
        \n"; }, $htmlContent ); // Convert headers (process smaller headers first, then larger) $htmlContent = preg_replace('/^#### (.+)$/m', '
        $1
        ', $htmlContent); $htmlContent = preg_replace('/^### (.+)$/m', '

        $1

        ', $htmlContent); $htmlContent = preg_replace('/^## (.+)$/m', '

        $1

        ', $htmlContent); $htmlContent = preg_replace('/^# (.+)$/m', '

        $1

        ', $htmlContent); // Convert bold text (**text** or __text__) - must be before italic $htmlContent = preg_replace('/\*\*(.+?)\*\*/', '$1', $htmlContent); $htmlContent = preg_replace('/__(.+?)__/', '$1', $htmlContent); // Convert italic text (*text* or _text_) $htmlContent = preg_replace('/(?$1', $htmlContent); $htmlContent = preg_replace('/(?$1', $htmlContent); // Convert markdown images ![alt](url) - must be before regular links $htmlContent = preg_replace('/!\[([^\]]*)\]\(([^)]+)\)/', '$1', $htmlContent); // Convert markdown links [text](url) $htmlContent = preg_replace('/\[([^\]]+)\]\(([^)]+)\)/', '$1', $htmlContent); // Convert GitHub usernames (@username) to profile links $htmlContent = preg_replace('/(?@$1', $htmlContent); // Convert plain URLs to links (but avoid already linked URLs) $htmlContent = preg_replace('/(?|>\s)(https?:\/\/[^\s<]+)/', '$1', $htmlContent); // Replace newlines after block-level elements with a marker to prevent nl2br from converting them $htmlContent = preg_replace('/(<\/(?:h[1-6]|ul|ol|li|pre|blockquote)>)\r?\n/', '$1', $htmlContent); $htmlContent = preg_replace('/(<(?:ul|ol|pre|blockquote)>)\r?\n/', '$1', $htmlContent); $htmlContent = preg_replace('/(\r?\n)/', '$1', $htmlContent); // Convert line breaks to
        tags $htmlContent = nl2br($htmlContent); // Remove the markers (and any br tags that might have been added near them) $htmlContent = preg_replace('//', '', $htmlContent); $htmlContent = preg_replace('//', '', $htmlContent); $htmlContent = preg_replace('//', '', $htmlContent); // Additional cleanup: remove br tags immediately before and after block elements // Remove ALL consecutive br tags before block elements $htmlContent = preg_replace('/(?:\s*)+(<(?:h[1-6]|ul|ol|li|pre|code|hr|blockquote)[^>]*>)/i', '$1', $htmlContent); $htmlContent = preg_replace('/(<\/(?:h[1-6]|ul|ol|li|pre|blockquote)>|\s*)\s*(?:\s*)+/i', '$1', $htmlContent); $htmlContent = preg_replace('/(){3,}/', '

        ', $htmlContent); // Remove br tags inside list items $htmlContent = preg_replace('/(
      1. [^<]*)(\s*<\/li>)/i', '$1$2', $htmlContent); echo "
        " . $htmlContent . "
        "; } else { echo '

        v' . $current_version . '

        '; echo '

        No release information found for this version on GitHub.

        '; } } else { echo 'Error decoding JSON data or received empty response.'; } } else { echo 'Error retrieving data from the GitHub API.'; } ?>