aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/PageBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/PageBuilder.php')
-rw-r--r--application/PageBuilder.php40
1 files changed, 32 insertions, 8 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index 32c7f9f1..468f144b 100644
--- a/application/PageBuilder.php
+++ b/application/PageBuilder.php
@@ -1,5 +1,7 @@
1<?php 1<?php
2 2
3use Shaarli\Config\ConfigManager;
4
3/** 5/**
4 * This class is in charge of building the final page. 6 * This class is in charge of building the final page.
5 * (This is basically a wrapper around RainTPL which pre-fills some fields.) 7 * (This is basically a wrapper around RainTPL which pre-fills some fields.)
@@ -20,15 +22,24 @@ class PageBuilder
20 protected $conf; 22 protected $conf;
21 23
22 /** 24 /**
25 * @var LinkDB $linkDB instance.
26 */
27 protected $linkDB;
28
29 /**
23 * PageBuilder constructor. 30 * PageBuilder constructor.
24 * $tpl is initialized at false for lazy loading. 31 * $tpl is initialized at false for lazy loading.
25 * 32 *
26 * @param ConfigManager $conf Configuration Manager instance (reference). 33 * @param ConfigManager $conf Configuration Manager instance (reference).
34 * @param LinkDB $linkDB instance.
35 * @param string $token Session token
27 */ 36 */
28 function __construct(&$conf) 37 public function __construct(&$conf, $linkDB = null, $token = null)
29 { 38 {
30 $this->tpl = false; 39 $this->tpl = false;
31 $this->conf = $conf; 40 $this->conf = $conf;
41 $this->linkDB = $linkDB;
42 $this->token = $token;
32 } 43 }
33 44
34 /** 45 /**
@@ -40,7 +51,7 @@ class PageBuilder
40 51
41 try { 52 try {
42 $version = ApplicationUtils::checkUpdate( 53 $version = ApplicationUtils::checkUpdate(
43 shaarli_version, 54 SHAARLI_VERSION,
44 $this->conf->get('resource.update_check'), 55 $this->conf->get('resource.update_check'),
45 $this->conf->get('updates.check_updates_interval'), 56 $this->conf->get('updates.check_updates_interval'),
46 $this->conf->get('updates.check_updates'), 57 $this->conf->get('updates.check_updates'),
@@ -66,18 +77,28 @@ class PageBuilder
66 } 77 }
67 $this->tpl->assign('searchcrits', $searchcrits); 78 $this->tpl->assign('searchcrits', $searchcrits);
68 $this->tpl->assign('source', index_url($_SERVER)); 79 $this->tpl->assign('source', index_url($_SERVER));
69 $this->tpl->assign('version', shaarli_version); 80 $this->tpl->assign('version', SHAARLI_VERSION);
81 $this->tpl->assign(
82 'version_hash',
83 ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt'))
84 );
70 $this->tpl->assign('scripturl', index_url($_SERVER)); 85 $this->tpl->assign('scripturl', index_url($_SERVER));
71 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? 86 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
87 $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly']));
72 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); 88 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli'));
73 if ($this->conf->exists('general.header_link')) { 89 if ($this->conf->exists('general.header_link')) {
74 $this->tpl->assign('titleLink', $this->conf->get('general.header_link')); 90 $this->tpl->assign('titleLink', $this->conf->get('general.header_link'));
75 } 91 }
76 $this->tpl->assign('shaarlititle', $this->conf->get('general.title', 'Shaarli')); 92 $this->tpl->assign('shaarlititle', $this->conf->get('general.title', 'Shaarli'));
77 $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); 93 $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
78 $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); 94 $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', true));
95 $this->tpl->assign('feed_type', $this->conf->get('feed.show_atom', true) !== false ? 'atom' : 'rss');
79 $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); 96 $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
80 $this->tpl->assign('token', getToken($this->conf)); 97 $this->tpl->assign('token', $this->token);
98
99 if ($this->linkDB !== null) {
100 $this->tpl->assign('tags', $this->linkDB->linksCountPerTag());
101 }
81 // To be removed with a proper theme configuration. 102 // To be removed with a proper theme configuration.
82 $this->tpl->assign('conf', $this->conf); 103 $this->tpl->assign('conf', $this->conf);
83 } 104 }
@@ -140,9 +161,12 @@ class PageBuilder
140 * 161 *
141 * @param string $message A messate to display what is not found 162 * @param string $message A messate to display what is not found
142 */ 163 */
143 public function render404($message = 'The page you are trying to reach does not exist or has been deleted.') 164 public function render404($message = '')
144 { 165 {
145 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); 166 if (empty($message)) {
167 $message = t('The page you are trying to reach does not exist or has been deleted.');
168 }
169 header($_SERVER['SERVER_PROTOCOL'] .' '. t('404 Not Found'));
146 $this->tpl->assign('error_message', $message); 170 $this->tpl->assign('error_message', $message);
147 $this->renderPage('404'); 171 $this->renderPage('404');
148 } 172 }