diff options
| author | 2024-06-05 21:04:33 +0200 | |
|---|---|---|
| committer | 2024-06-05 21:04:33 +0200 | |
| commit | fec9e53d0ebcd74d9fc366da4951f1a1415314c5 (patch) | |
| tree | 573438908ba76d0f539f531aa7fc5f3ef75fb7b3 /app/Models/Entry.php | |
| parent | 99b1d551e61adb5cbd014677f151f443b0c6c35f (diff) | |
Empty title guid or first words (#6240)
* settings
* add comments for better understanding
* Update reading.phtml
* overhaul the code
* i18n
* typo
* add a constant to configure the amount of chars
* fix
* simplify
* Update Entry.php
* clean
* Update Entry.php
* Update app/Models/Entry.php
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
* Update constants.php
* Update app/Models/Entry.php
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Models/Entry.php')
| -rw-r--r-- | app/Models/Entry.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 3caa1ddb9..956134c78 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -117,7 +117,27 @@ class FreshRSS_Entry extends Minz_Model { return $this->guid; } public function title(): string { - return $this->title == '' ? $this->guid() : $this->title; + $title = ''; + + if ($this->title === '') { + // used while fetching the article from feed and store it in the database + $title = $this->guid(); + } else { + // used while fetching from the database + if ($this->title !== $this->guid) { + $title = $this->title; + } else { + $content = trim(strip_tags($this->content(false))); + $title = trim(mb_substr($content, 0, MAX_CHARS_EMPTY_FEED_TITLE, 'UTF-8')); + + if ($title === '') { + $title = $this->guid(); + } elseif (strlen($content) > strlen($title)) { + $title .= '…'; + } + } + } + return $title; } /** @deprecated */ public function author(): string { |
