diff options
author | ArthurHoaro <arthur@hoa.ro> | 2018-07-28 11:19:53 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2018-07-28 11:19:53 +0200 |
commit | 7982c3ff183aa985177bdaeacda4feb22a739e00 (patch) | |
tree | 728e07251072f3a1df63c017c0dce54fa1acb390 /application/PageBuilder.php | |
parent | 2075321f6569dfa610905991b315aae1956b7f78 (diff) | |
parent | ed7e1be12d65bdb1b924c7efb6a84fd591192c6c (diff) | |
download | Shaarli-7982c3ff183aa985177bdaeacda4feb22a739e00.tar.gz Shaarli-7982c3ff183aa985177bdaeacda4feb22a739e00.tar.zst Shaarli-7982c3ff183aa985177bdaeacda4feb22a739e00.zip |
Merge tag 'v0.10.0' into latest
Release v0.10.0
Diffstat (limited to 'application/PageBuilder.php')
-rw-r--r-- | application/PageBuilder.php | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 468f144b..b1abe0d0 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -1,6 +1,7 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Shaarli\Config\ConfigManager; | 3 | use Shaarli\Config\ConfigManager; |
4 | use Shaarli\Thumbnailer; | ||
4 | 5 | ||
5 | /** | 6 | /** |
6 | * This class is in charge of building the final page. | 7 | * This class is in charge of building the final page. |
@@ -22,24 +23,41 @@ class PageBuilder | |||
22 | protected $conf; | 23 | protected $conf; |
23 | 24 | ||
24 | /** | 25 | /** |
26 | * @var array $_SESSION | ||
27 | */ | ||
28 | protected $session; | ||
29 | |||
30 | /** | ||
25 | * @var LinkDB $linkDB instance. | 31 | * @var LinkDB $linkDB instance. |
26 | */ | 32 | */ |
27 | protected $linkDB; | 33 | protected $linkDB; |
28 | 34 | ||
29 | /** | 35 | /** |
36 | * @var null|string XSRF token | ||
37 | */ | ||
38 | protected $token; | ||
39 | |||
40 | /** @var bool $isLoggedIn Whether the user is logged in **/ | ||
41 | protected $isLoggedIn = false; | ||
42 | |||
43 | /** | ||
30 | * PageBuilder constructor. | 44 | * PageBuilder constructor. |
31 | * $tpl is initialized at false for lazy loading. | 45 | * $tpl is initialized at false for lazy loading. |
32 | * | 46 | * |
33 | * @param ConfigManager $conf Configuration Manager instance (reference). | 47 | * @param ConfigManager $conf Configuration Manager instance (reference). |
34 | * @param LinkDB $linkDB instance. | 48 | * @param array $session $_SESSION array |
35 | * @param string $token Session token | 49 | * @param LinkDB $linkDB instance. |
50 | * @param string $token Session token | ||
51 | * @param bool $isLoggedIn | ||
36 | */ | 52 | */ |
37 | public function __construct(&$conf, $linkDB = null, $token = null) | 53 | public function __construct(&$conf, $session, $linkDB = null, $token = null, $isLoggedIn = false) |
38 | { | 54 | { |
39 | $this->tpl = false; | 55 | $this->tpl = false; |
40 | $this->conf = $conf; | 56 | $this->conf = $conf; |
57 | $this->session = $session; | ||
41 | $this->linkDB = $linkDB; | 58 | $this->linkDB = $linkDB; |
42 | $this->token = $token; | 59 | $this->token = $token; |
60 | $this->isLoggedIn = $isLoggedIn; | ||
43 | } | 61 | } |
44 | 62 | ||
45 | /** | 63 | /** |
@@ -55,7 +73,7 @@ class PageBuilder | |||
55 | $this->conf->get('resource.update_check'), | 73 | $this->conf->get('resource.update_check'), |
56 | $this->conf->get('updates.check_updates_interval'), | 74 | $this->conf->get('updates.check_updates_interval'), |
57 | $this->conf->get('updates.check_updates'), | 75 | $this->conf->get('updates.check_updates'), |
58 | isLoggedIn(), | 76 | $this->isLoggedIn, |
59 | $this->conf->get('updates.check_updates_branch') | 77 | $this->conf->get('updates.check_updates_branch') |
60 | ); | 78 | ); |
61 | $this->tpl->assign('newVersion', escape($version)); | 79 | $this->tpl->assign('newVersion', escape($version)); |
@@ -67,6 +85,7 @@ class PageBuilder | |||
67 | $this->tpl->assign('versionError', escape($exc->getMessage())); | 85 | $this->tpl->assign('versionError', escape($exc->getMessage())); |
68 | } | 86 | } |
69 | 87 | ||
88 | $this->tpl->assign('is_logged_in', $this->isLoggedIn); | ||
70 | $this->tpl->assign('feedurl', escape(index_url($_SERVER))); | 89 | $this->tpl->assign('feedurl', escape(index_url($_SERVER))); |
71 | $searchcrits = ''; // Search criteria | 90 | $searchcrits = ''; // Search criteria |
72 | if (!empty($_GET['searchtags'])) { | 91 | if (!empty($_GET['searchtags'])) { |
@@ -83,7 +102,8 @@ class PageBuilder | |||
83 | ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) | 102 | ApplicationUtils::getVersionHash(SHAARLI_VERSION, $this->conf->get('credentials.salt')) |
84 | ); | 103 | ); |
85 | $this->tpl->assign('scripturl', index_url($_SERVER)); | 104 | $this->tpl->assign('scripturl', index_url($_SERVER)); |
86 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? | 105 | $visibility = ! empty($_SESSION['visibility']) ? $_SESSION['visibility'] : ''; |
106 | $this->tpl->assign('visibility', $visibility); | ||
87 | $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); | 107 | $this->tpl->assign('untaggedonly', !empty($_SESSION['untaggedonly'])); |
88 | $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); | 108 | $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli')); |
89 | if ($this->conf->exists('general.header_link')) { | 109 | if ($this->conf->exists('general.header_link')) { |
@@ -99,6 +119,19 @@ class PageBuilder | |||
99 | if ($this->linkDB !== null) { | 119 | if ($this->linkDB !== null) { |
100 | $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); | 120 | $this->tpl->assign('tags', $this->linkDB->linksCountPerTag()); |
101 | } | 121 | } |
122 | |||
123 | $this->tpl->assign( | ||
124 | 'thumbnails_enabled', | ||
125 | $this->conf->get('thumbnails.mode', Thumbnailer::MODE_NONE) !== Thumbnailer::MODE_NONE | ||
126 | ); | ||
127 | $this->tpl->assign('thumbnails_width', $this->conf->get('thumbnails.width')); | ||
128 | $this->tpl->assign('thumbnails_height', $this->conf->get('thumbnails.height')); | ||
129 | |||
130 | if (! empty($_SESSION['warnings'])) { | ||
131 | $this->tpl->assign('global_warnings', $_SESSION['warnings']); | ||
132 | unset($_SESSION['warnings']); | ||
133 | } | ||
134 | |||
102 | // To be removed with a proper theme configuration. | 135 | // To be removed with a proper theme configuration. |
103 | $this->tpl->assign('conf', $this->conf); | 136 | $this->tpl->assign('conf', $this->conf); |
104 | } | 137 | } |