WebOrbiton

Code

Publisium

A modern, fast CMS for building article and blog websites.

Version history

Version 2.0.0.8 2026-11-19

Browse files
Files changed12
Lines added+105
Lines removed-9
article.php Modified +22 -1
⋮ 45 unchanged lines ⋮
      $_GET['slug'] = $languageRest;
  }
  
+ if (preg_match('#^(index|index\.php|index\.html)/?$#i', $slug) === 1) {
+     header('Location: ' . SiteFront::homeUrl(), true, 301);
+     exit;
+ }
+ 
  // Short links (/about, /jan-kowalski, /my-article) all arrive here; send pages and author pages on.
  $viaShortLink = false;
  if (!$isPreview && $slug !== '') {
⋮ 165 unchanged lines ⋮
      <?php if ($commentsJump): ?>
      <div class="article-actions">
          <?= SiteFront::renderShareControl($article) ?>
-         <a href="#article-comments" class="share-toggle-btn comments-jump-btn"><svg class="icon icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg><span><?= htmlspecialchars(Language::get('article_comments_title', 'Comments')) ?></span></a>
+         <button type="button" class="share-toggle-btn comments-jump-btn" data-target="article-comments"><svg class="icon icon-sm" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path></svg><span><?= htmlspecialchars(Language::get('article_comments_title', 'Comments')) ?></span></button>
      </div>
      <?php else: ?>
      <?= SiteFront::renderShareControl($article) ?>
⋮ 175 unchanged lines ⋮
  <?php if ($settings['comments_enabled'] === '1' && !$isLocked): ?>
      <section class="comments-section" id="article-comments">
          <h2><?= htmlspecialchars(Language::get('article_comments_title', 'Comments')) ?></h2>
+ 
+         <?php $commentsRules = array_values(array_filter(array_map('trim', explode("\n", (string) ($settings['comments_rules'] ?? ''))), static fn(string $line): bool => $line !== '')); ?>
+         <?php if ($commentsRules !== []): ?>
+             <details class="comments-rules">
+                 <summary><?= htmlspecialchars(Language::get('comments_rules_title', 'Commenting rules')) ?></summary>
+                 <?php if (count($commentsRules) === 1): ?>
+                     <p><?= htmlspecialchars($commentsRules[0]) ?></p>
+                 <?php else: ?>
+                     <ul>
+                         <?php foreach ($commentsRules as $commentsRule): ?>
+                             <li><?= htmlspecialchars($commentsRule) ?></li>
+                         <?php endforeach; ?>
+                     </ul>
+                 <?php endif; ?>
+             </details>
+         <?php endif; ?>
  
          <?= Comments::render($settings, $article) ?>
      </section>
⋮ 3 unchanged lines ⋮
assets/block-editor.js Modified

Not shown (binary file or too large to diff).

assets/dashboard.css Modified

Not shown (binary file or too large to diff).

assets/shortcuts.js Modified +1 -1
⋮ 8 unchanged lines ⋮
      underline: { label: 'Underline', combo: 'Ctrl+U' },
      strikethrough: { label: 'Strikethrough', combo: 'Ctrl+Shift+X' },
      add_block: { label: 'Add block below', combo: 'Ctrl+Enter' },
-     remove_block: { label: 'Remove block', combo: 'Ctrl+Backspace' },
+     remove_block: { label: 'Remove block', combo: 'Ctrl+Shift+Backspace' },
      move_block_up: { label: 'Move block up', combo: 'Ctrl+Shift+ArrowUp' },
      move_block_down: { label: 'Move block down', combo: 'Ctrl+Shift+ArrowDown' },
      save: { label: 'Save', combo: 'Ctrl+S' },
⋮ 122 unchanged lines ⋮
assets/site.css Modified

Not shown (binary file or too large to diff).

assets/site.js Modified +16 -0
⋮ 777 unchanged lines ⋮
    });
  })();
  
+ (function () {
+   document.querySelectorAll('.comments-jump-btn').forEach(function (button) {
+     button.addEventListener('click', function () {
+       var target = document.getElementById(button.getAttribute('data-target') || '');
+       if (!target) {
+         return;
+       }
+       var reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
+       target.scrollIntoView({ behavior: reduce ? 'auto' : 'smooth', block: 'start' });
+       if (history.replaceState) {
+         history.replaceState(null, '', '#' + target.id);
+       }
+     });
+   });
+ })();
+ 
includes/block-editor.php Modified +62 -6
⋮ 209 unchanged lines ⋮
          }
  
          if (!class_exists(\DOMDocument::class)) {
-             return strip_tags($text, '<b><strong><i><em><a><br><u><s><code>');
+             return strip_tags($text, '<b><strong><i><em><a><br><u><s><code><ul><ol><li>');
          }
  
-         $allowedTags = ['b', 'strong', 'i', 'em', 'u', 's', 'code', 'a', 'span', 'br'];
+         $allowedTags = ['b', 'strong', 'i', 'em', 'u', 's', 'code', 'a', 'span', 'br', 'ul', 'ol', 'li'];
          $allowedColors = '/^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/';
  
          $wrapped = '<?xml encoding="utf-8"?><div>' . $text . '</div>';
⋮ 46 unchanged lines ⋮
              }
  
              $tag = strtolower($child->tagName);
+             $parentTag = $node instanceof \DOMElement ? strtolower($node->tagName) : '';
+             $misplacedItem = $tag === 'li' && !in_array($parentTag, ['ul', 'ol'], true);
  
-             if (!in_array($tag, $allowedTags, true)) {
+             if ($misplacedItem || !in_array($tag, $allowedTags, true)) {
+                 $previousSibling = $child->previousSibling;
+                 if (in_array($tag, ['div', 'p', 'li'], true) && $previousSibling !== null
+                     && !($previousSibling instanceof \DOMElement && in_array(strtolower($previousSibling->tagName), ['br', 'ul', 'ol'], true))) {
+                     $node->insertBefore($dom->createElement('br'), $child);
+                 }
                  while ($child->firstChild) {
                      $node->insertBefore($child->firstChild, $child);
                  }
                  $node->removeChild($child);
-                 continue;
+                 self::sanitizeNode($dom, $node, $allowedTags, $allowedColors);
+                 return;
              }
  
              self::sanitizeAttributes($child, $tag, $allowedColors);
⋮ 132 unchanged lines ⋮
          $data = $block['data'] ?? [];
  
          return match ($type) {
-             'paragraph' => '<p>' . ($data['text'] ?? '') . '</p>',
+             'paragraph' => self::renderParagraph((string) ($data['text'] ?? '')),
              'quote' => '<blockquote>' . ($data['text'] ?? '') . '</blockquote>',
              'heading2' => '<h2>' . htmlspecialchars((string) ($data['text'] ?? '')) . '</h2>',
              'heading3' => '<h3>' . htmlspecialchars((string) ($data['text'] ?? '')) . '</h3>',
⋮ 117 unchanged lines ⋮
              '</div>';
      }
  
+     private static function renderParagraph(string $html): string
+     {
+         if (stripos($html, '<ul') === false && stripos($html, '<ol') === false) {
+             return '<p>' . $html . '</p>';
+         }
+ 
+         if (!class_exists(\DOMDocument::class)) {
+             return '<div class="paragraph-group">' . $html . '</div>';
+         }
+ 
+         $previous = libxml_use_internal_errors(true);
+         $dom = new \DOMDocument();
+         $dom->loadHTML('<?xml encoding="utf-8"?><div>' . $html . '</div>', LIBXML_NOERROR | LIBXML_NOWARNING);
+         libxml_clear_errors();
+         libxml_use_internal_errors($previous);
+ 
+         $root = $dom->getElementsByTagName('div')->item(0);
+         if ($root === null) {
+             return '<p>' . $html . '</p>';
+         }
+ 
+         $parts = [];
+         $buffer = '';
+         $flush = static function () use (&$buffer, &$parts): void {
+             $trimmed = preg_replace('#^(\s|<br\s*/?>)+|(\s|<br\s*/?>)+$#i', '', $buffer);
+             if ($trimmed !== null && trim(strip_tags($trimmed)) !== '') {
+                 $parts[] = '<p>' . $trimmed . '</p>';
+             }
+             $buffer = '';
+         };
+ 
+         foreach (iterator_to_array($root->childNodes) as $child) {
+             $outer = (string) $dom->saveHTML($child);
+             if ($child instanceof \DOMElement && in_array(strtolower($child->tagName), ['ul', 'ol'], true)) {
+                 $flush();
+                 $parts[] = $outer;
+                 continue;
+             }
+             $buffer .= $outer;
+         }
+         $flush();
+ 
+         return self::decodeTextEntities(implode('', $parts));
+     }
+ 
      private static function renderList(array $data): string
      {
          $tag = ($data['style'] ?? 'unordered') === 'ordered' ? 'ol' : 'ul';
          $items = '';
          foreach ($data['items'] ?? [] as $item) {
+             if (trim((string) $item) === '') {
+                 continue;
+             }
              $items .= '<li>' . htmlspecialchars((string) $item) . '</li>';
          }
-         return '<' . $tag . '>' . $items . '</' . $tag . '>';
+         return $items === '' ? '' : '<' . $tag . '>' . $items . '</' . $tag . '>';
      }
  
      private static function renderTable(array $data): string
⋮ 23 unchanged lines ⋮
includes/comments.php Modified +1 -0
⋮ 53 unchanged lines ⋮
          return [
              'comments_enabled' => isset($post['comments_enabled']) ? '1' : '0',
              'comments_jump_link' => isset($post['comments_jump_link']) ? '1' : '0',
+             'comments_rules' => mb_substr(trim(str_replace("\r", '', strip_tags((string) ($post['comments_rules'] ?? '')))), 0, 4000),
              'comments_provider' => $provider,
              'comments_shortname' => $match(strtolower($text('comments_shortname', 64)), '/^[a-z0-9-]{1,64}$/'),
              'comments_server_url' => self::cleanServerUrl($text('comments_server_url', 255)),
⋮ 169 unchanged lines ⋮
includes/site-front.php Modified +1 -0
⋮ 295 unchanged lines ⋮
              'rss_category_feeds_enabled' => '0',
              'comments_enabled' => '0',
              'comments_jump_link' => '0',
+             'comments_rules' => '',
              'comments_provider' => 'disqus',
              'comments_shortname' => '',
              'comments_server_url' => '',
⋮ 961 unchanged lines ⋮
settings.php Modified

Not shown (binary file or too large to diff).

translations/language.php Modified +1 -0
⋮ 31 unchanged lines ⋮
      'article_related' => 'Related articles',
      'article_latest' => 'More recent articles',
      'article_comments_title' => 'Comments',
+     'comments_rules_title' => 'Commenting rules',
      'article_share' => 'Share',
      'article_reading_time' => '%d min read',
      'article_views' => '{count} views',
⋮ 179 unchanged lines ⋮
version.txt Modified +1 -1
- 2.0.0.7
+ 2.0.0.8