aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/PageBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/PageBuilder.php')
-rw-r--r--application/PageBuilder.php50
1 files changed, 27 insertions, 23 deletions
diff --git a/application/PageBuilder.php b/application/PageBuilder.php
index 82580787..32c7f9f1 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 }
@@ -60,21 +68,18 @@ class PageBuilder
60 $this->tpl->assign('source', index_url($_SERVER)); 68 $this->tpl->assign('source', index_url($_SERVER));
61 $this->tpl->assign('version', shaarli_version); 69 $this->tpl->assign('version', shaarli_version);
62 $this->tpl->assign('scripturl', index_url($_SERVER)); 70 $this->tpl->assign('scripturl', index_url($_SERVER));
63 $this->tpl->assign('pagetitle', 'Shaarli');
64 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links? 71 $this->tpl->assign('privateonly', !empty($_SESSION['privateonly'])); // Show only private links?
65 if (!empty($GLOBALS['title'])) { 72 $this->tpl->assign('pagetitle', $this->conf->get('general.title', 'Shaarli'));
66 $this->tpl->assign('pagetitle', $GLOBALS['title']); 73 if ($this->conf->exists('general.header_link')) {
67 } 74 $this->tpl->assign('titleLink', $this->conf->get('general.header_link'));
68 if (!empty($GLOBALS['titleLink'])) {
69 $this->tpl->assign('titleLink', $GLOBALS['titleLink']);
70 }
71 if (!empty($GLOBALS['pagetitle'])) {
72 $this->tpl->assign('pagetitle', $GLOBALS['pagetitle']);
73 }
74 $this->tpl->assign('shaarlititle', empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title']);
75 if (!empty($GLOBALS['plugin_errors'])) {
76 $this->tpl->assign('plugin_errors', $GLOBALS['plugin_errors']);
77 } 75 }
76 $this->tpl->assign('shaarlititle', $this->conf->get('general.title', 'Shaarli'));
77 $this->tpl->assign('openshaarli', $this->conf->get('security.open_shaarli', false));
78 $this->tpl->assign('showatom', $this->conf->get('feed.show_atom', false));
79 $this->tpl->assign('hide_timestamps', $this->conf->get('privacy.hide_timestamps', false));
80 $this->tpl->assign('token', getToken($this->conf));
81 // To be removed with a proper theme configuration.
82 $this->tpl->assign('conf', $this->conf);
78 } 83 }
79 84
80 /** 85 /**
@@ -85,7 +90,6 @@ class PageBuilder
85 */ 90 */
86 public function assign($placeholder, $value) 91 public function assign($placeholder, $value)
87 { 92 {
88 // Lazy initialization
89 if ($this->tpl === false) { 93 if ($this->tpl === false) {
90 $this->initialize(); 94 $this->initialize();
91 } 95 }
@@ -101,7 +105,6 @@ class PageBuilder
101 */ 105 */
102 public function assignAll($data) 106 public function assignAll($data)
103 { 107 {
104 // Lazy initialization
105 if ($this->tpl === false) { 108 if ($this->tpl === false) {
106 $this->initialize(); 109 $this->initialize();
107 } 110 }
@@ -113,6 +116,7 @@ class PageBuilder
113 foreach ($data as $key => $value) { 116 foreach ($data as $key => $value) {
114 $this->assign($key, $value); 117 $this->assign($key, $value);
115 } 118 }
119 return true;
116 } 120 }
117 121
118 /** 122 /**
@@ -123,10 +127,10 @@ class PageBuilder
123 */ 127 */
124 public function renderPage($page) 128 public function renderPage($page)
125 { 129 {
126 // Lazy initialization 130 if ($this->tpl === false) {
127 if ($this->tpl===false) {
128 $this->initialize(); 131 $this->initialize();
129 } 132 }
133
130 $this->tpl->draw($page); 134 $this->tpl->draw($page);
131 } 135 }
132 136