diff options
Diffstat (limited to 'application/PageBuilder.php')
-rw-r--r-- | application/PageBuilder.php | 46 |
1 files changed, 29 insertions, 17 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php index 82580787..7cd88370 100644 --- a/application/PageBuilder.php +++ b/application/PageBuilder.php | |||
@@ -15,12 +15,20 @@ class PageBuilder | |||
15 | private $tpl; | 15 | private $tpl; |
16 | 16 | ||
17 | /** | 17 | /** |
18 | * @var ConfigManager $conf Configuration Manager instance. | ||
19 | */ | ||
20 | protected $conf; | ||
21 | |||
22 | /** | ||
18 | * PageBuilder constructor. | 23 | * PageBuilder constructor. |
19 | * $tpl is initialized at false for lazy loading. | 24 | * $tpl is initialized at false for lazy loading. |
25 | * | ||
26 | * @param ConfigManager $conf Configuration Manager instance (reference). | ||
20 | */ | 27 | */ |
21 | function __construct() | 28 | function __construct(&$conf) |
22 | { | 29 | { |
23 | $this->tpl = false; | 30 | $this->tpl = false; |
31 | $this->conf = $conf; | ||
24 | } | 32 | } |
25 | 33 | ||
26 | /** | 34 | /** |
@@ -33,17 +41,17 @@ class PageBuilder | |||
33 | try { | 41 | try { |
34 | $version = ApplicationUtils::checkUpdate( | 42 | $version = ApplicationUtils::checkUpdate( |
35 | shaarli_version, | 43 | shaarli_version, |
36 | $GLOBALS['config']['UPDATECHECK_FILENAME'], | 44 | $this->conf->get('resource.update_check'), |
37 | $GLOBALS['config']['UPDATECHECK_INTERVAL'], | 45 | $this->conf->get('updates.check_updates_interval'), |
38 | $GLOBALS['config']['ENABLE_UPDATECHECK'], | 46 | $this->conf->get('updates.check_updates'), |
39 | isLoggedIn(), | 47 | isLoggedIn(), |
40 | $GLOBALS['config']['UPDATECHECK_BRANCH'] | 48 | $this->conf->get('updates.check_updates_branch') |
41 | ); | 49 | ); |
42 | $this->tpl->assign('newVersion', escape($version)); | 50 | $this->tpl->assign('newVersion', escape($version)); |
43 | $this->tpl->assign('versionError', ''); | 51 | $this->tpl->assign('versionError', ''); |
44 | 52 | ||
45 | } catch (Exception $exc) { | 53 | } catch (Exception $exc) { |
46 | logm($GLOBALS['config']['LOG_FILE'], $_SERVER['REMOTE_ADDR'], $exc->getMessage()); | 54 | logm($this->conf->get('resource.log'), $_SERVER['REMOTE_ADDR'], $exc->getMessage()); |
47 | $this->tpl->assign('newVersion', ''); | 55 | $this->tpl->assign('newVersion', ''); |
48 | $this->tpl->assign('versionError', escape($exc->getMessage())); | 56 | $this->tpl->assign('versionError', escape($exc->getMessage())); |
49 | } | 57 | } |
@@ -62,19 +70,24 @@ class PageBuilder | |||
62 | $this->tpl->assign('scripturl', index_url($_SERVER)); | 70 | $this->tpl->assign('scripturl', index_url($_SERVER)); |
63 | $this->tpl->assign('pagetitle', 'Shaarli'); | 71 | $this->tpl->assign('pagetitle', 'Shaarli'); |
64 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? | 72 | $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? |
65 | if (!empty($GLOBALS['title'])) { | 73 | if ($this->conf->exists('general.title')) { |
66 | $this->tpl->assign('pagetitle', $GLOBALS['title']); | 74 | $this->tpl->assign('pagetitle', $this->conf->get('general.title')); |
67 | } | 75 | } |
68 | if (!empty($GLOBALS['titleLink'])) { | 76 | if ($this->conf->exists('general.header_link')) { |
69 | $this->tpl->assign('titleLink', $GLOBALS['titleLink']); | 77 | $this->tpl->assign('titleLink', $this->conf->get('general.header_link')); |
70 | } | 78 | } |
71 | if (!empty($GLOBALS['pagetitle'])) { | 79 | if ($this->conf->exists('pagetitle')) { |
72 | $this->tpl->assign('pagetitle', $GLOBALS['pagetitle']); | 80 | $this->tpl->assign('pagetitle', $this->conf->get('pagetitle')); |
73 | } | 81 | } |
74 | $this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title']); | 82 | $this->tpl->assign('shaarlititle', $this->conf->get('title', 'Shaarli')); |
83 | $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false)); | ||
84 | $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false)); | ||
85 | $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false)); | ||
75 | if (!empty($GLOBALS['plugin_errors'])) { | 86 | if (!empty($GLOBALS['plugin_errors'])) { |
76 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); | 87 | $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']); |
77 | } | 88 | } |
89 | // To be removed with a proper theme configuration. | ||
90 | $this->tpl->assign('conf', $this->conf); | ||
78 | } | 91 | } |
79 | 92 | ||
80 | /** | 93 | /** |
@@ -85,7 +98,6 @@ class PageBuilder | |||
85 | */ | 98 | */ |
86 | public function assign($placeholder, $value) | 99 | public function assign($placeholder, $value) |
87 | { | 100 | { |
88 | // Lazy initialization | ||
89 | if ($this->tpl === false) { | 101 | if ($this->tpl === false) { |
90 | $this->initialize(); | 102 | $this->initialize(); |
91 | } | 103 | } |
@@ -101,7 +113,6 @@ class PageBuilder | |||
101 | */ | 113 | */ |
102 | public function assignAll($data) | 114 | public function assignAll($data) |
103 | { | 115 | { |
104 | // Lazy initialization | ||
105 | if ($this->tpl === false) { | 116 | if ($this->tpl === false) { |
106 | $this->initialize(); | 117 | $this->initialize(); |
107 | } | 118 | } |
@@ -113,6 +124,7 @@ class PageBuilder | |||
113 | foreach ($data as $key => $value) { | 124 | foreach ($data as $key => $value) { |
114 | $this->assign($key, $value); | 125 | $this->assign($key, $value); |
115 | } | 126 | } |
127 | return true; | ||
116 | } | 128 | } |
117 | 129 | ||
118 | /** | 130 | /** |
@@ -123,10 +135,10 @@ class PageBuilder | |||
123 | */ | 135 | */ |
124 | public function renderPage($page) | 136 | public function renderPage($page) |
125 | { | 137 | { |
126 | // Lazy initialization | 138 | if ($this->tpl === false) { |
127 | if ($this->tpl===false) { | ||
128 | $this->initialize(); | 139 | $this->initialize(); |
129 | } | 140 | } |
141 | |||
130 | $this->tpl->draw($page); | 142 | $this->tpl->draw($page); |
131 | } | 143 | } |
132 | 144 | ||