aboutsummaryrefslogtreecommitdiff
path: root/app/views/index/normal.phtml
blob: eb388fad35b850c25d59f749f218838f42b9fbe4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
/** @var FreshRSS_View $this */
$this->partial('aside_feed');
$this->partial('nav_menu');

call_user_func($this->callbackBeforeEntries, $this);

$display_today = true;
$display_yesterday = true;
$display_others = true;
$hidePosts = !FreshRSS_Context::$user_conf->display_posts;
$lazyload = FreshRSS_Context::$user_conf->lazyload;
$content_width = FreshRSS_Context::$user_conf->content_width;

$today = @strtotime('today');
?>

<main id="stream" class="normal<?= $hidePosts ? ' hide_posts' : '' ?>">
	<div id="new-article">
		<a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
	</div><?php
	$lastEntry = null;
	$nbEntries = 0;
	foreach ($this->entries as $item):
		$lastEntry = $item;
		$nbEntries++;
		ob_flush();
		$this->entry = Minz_ExtensionManager::callHook('entry_before_display', $item);
		if ($this->entry == null) {
			continue;
		}

		// We most likely already have the feed object in cache
		$this->feed = FreshRSS_CategoryDAO::findFeed($this->categories, $this->entry->feed());
		if ($this->feed == null) {
			$this->feed = $this->entry->feed(true);
			if ($this->feed == null) {
				$this->feed = FreshRSS_Feed::example();
			}
		}

		if ($display_today && $this->entry->isDay(FreshRSS_Days::TODAY, $today)) {
			?><div class="day" id="day_today"><?php
				echo _t('gen.date.today');
				?><span class="date"> — <?= timestamptodate(time(), false) ?></span><?php
				?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
			?></div><?php
			$display_today = false;
		}
		if ($display_yesterday && $this->entry->isDay(FreshRSS_Days::YESTERDAY, $today)) {
			?><div class="day" id="day_yesterday"><?php
				echo _t('gen.date.yesterday');
				?><span class="date"> — <?= timestamptodate(time() - 86400, false) ?></span><?php
				?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
			?></div><?php
			$display_yesterday = false;
		}
		if ($display_others && $this->entry->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) {
			?><div class="day" id="day_before_yesterday"><?php
				echo _t('gen.date.before_yesterday');
				?><span class="name"><?= FreshRSS_Context::$name ?></span><?php
			?></div><?php
			$display_others = false;
		}
	?><div class="flux<?= !$this->entry->isRead() ? ' not_read' : ''
		?><?= $this->entry->isFavorite() ? ' favorite' : ''
		?>" id="flux_<?= $this->entry->id()
		?>" data-feed="<?= $this->feed->id()
		?>"><?php

			$this->renderHelper('index/normal/entry_header');

		?><div class="flux_content" dir="auto">
			<div class="content <?= $content_width ?>">
				<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?= $this->entry->link() ?>"><?= $this->entry->title() ?></a></h1>
				<div class="subtitle">
					<div class="website"><a href="<?= _url('index', 'index', 'get', 'f_' . $this->feed->id()) ?>">
						<?php if (FreshRSS_Context::$user_conf->show_favicons): ?>
							<img class="favicon" src="<?= $this->feed->favicon() ?>" alt="✇" loading="lazy" />
						<?php endif; ?>
						<span><?= $this->feed->name() ?></span></a>
					</div>
					<div class="date"><?= $this->entry->date() ?></div>
					<?php
						$authors = $this->entry->authors();
						if (!empty($authors) && is_array($authors)):
							$first = true;
					?>
					<div class="author"><?php
							foreach ($authors as $author):
								echo $first ? _t('gen.short.by_author') . ' ' : '· ';
								$first = false;
					?>
	<em><a href="<?= Minz_Url::display(Minz_Request::modifiedCurrentRequest(
			['search' => 'author:"' . htmlspecialchars_decode($author, ENT_QUOTES) . '"'])
		) ?>"><?= $author ?></a></em>
					<?php	endforeach; ?>
					</div><?php endif; ?>
				</div>
				<div class="text"><?php
					echo $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content();
				?></div>
			</div><?php

			$this->renderHelper('index/normal/entry_bottom');

		?></div>
	</div><?php
	endforeach;

	if ($nbEntries > 0):
		call_user_func($this->callbackBeforePagination, $this, $nbEntries, $lastEntry);
		$this->renderHelper('pagination');
?></main><?php
	else:
		ob_end_clean();	//Discard the articles headers, as we have no articles
?>
<main id="stream" class="normal">
	<div id="new-article">
		<a href="<?= Minz_Url::display(Minz_Request::currentRequest()) ?>"><?= _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
	</div>
	<div class="prompt alert alert-warn">
		<h2 class="alert-head"><?= _t('index.feed.empty') ?></h2>
		<?php if (FreshRSS_Auth::hasAccess()) { ?>
			<p><a href="<?= _url('subscription', 'add') ?>"><?= _t('index.feed.add') ?></a></p>
		<?php } ?>
	</div>
</main>
<?php endif; ?>

<?php if ($nbEntries > 0 && FreshRSS_Context::$user_conf->show_nav_buttons) $this->partial('nav_entries'); ?>