aboutsummaryrefslogtreecommitdiff
path: root/app/views/index/normal.phtml
blob: d5ae8e2f9a493c1b8c036b9b3525d51174c8b30e (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
<?php

$this->partial('aside_feed');
$this->partial('nav_menu');

flush();
if (isset($this->callbackBeforeEntries)) {
	call_user_func($this->callbackBeforeEntries, $this);
}

if (!empty($this->entries)) {
	$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');
?>

<div id="stream" class="normal<?php echo $hidePosts ? ' hide_posts' : ''; ?>"><?php
	?><div id="new-article">
		<a href="<?php echo Minz_Url::display(Minz_Request::currentRequest()); ?>"><?php echo _t('gen.js.new_article'); /* TODO: move string in JS*/ ?></a>
	</div><?php
	foreach ($this->entries as $item) {
		$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"> — <?php echo timestamptodate(time(), false); ?></span><?php
				?><span class="name"><?php echo 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"> — <?php echo timestamptodate(time() - 86400, false); ?></span><?php
				?><span class="name"><?php echo 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"><?php echo FreshRSS_Context::$name; ?></span><?php
			?></div><?php
			$display_others = false;
		}
	?><div class="flux<?php echo !$this->entry->isRead() ? ' not_read' : '';
		?><?php echo $this->entry->isFavorite() ? ' favorite' : '';
		?>" id="flux_<?php echo $this->entry->id();
		?>" data-feed="<?php echo $this->feed->id();
		?>"><?php

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

		?><div class="flux_content">
			<div class="content <?php echo $content_width; ?>">
				<h1 class="title"><a target="_blank" rel="noreferrer" class="go_website" href="<?php echo $this->entry->link(); ?>"><?php echo $this->entry->title(); ?></a></h1>
				<div class="author"><?php
					$authors = $this->entry->authors();
					if (is_array($authors)):
						$first = true;
						foreach ($authors as $author):
							echo $first ? _t('gen.short.by_author') . ' ' : '· ';
							$first = false;
				?>
<em><a href="<?php echo _url('index', 'index', 'search', 'author:' . str_replace(' ', '+', htmlspecialchars_decode($author, ENT_QUOTES))); ?>"><?php echo $author; ?></a></em>
				<?php	endforeach; ?>
				</div><?php
					endif;
					echo $lazyload && $hidePosts ? lazyimg($this->entry->content()) : $this->entry->content();
				?>
			</div><?php

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

		?></div>
	</div><?php
	}

	$this->renderHelper('pagination');
?></div>

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

<?php } else { ?>
<div id="stream" class="prompt alert alert-warn normal">
	<h2><?php echo _t('index.feed.empty'); ?></h2>
	<a href="<?php echo _url('subscription', 'index'); ?>"><?php echo _t('index.feed.add'); ?></a><br /><br />
</div>
<?php } ?>