Skip to content

Commit 635f8ff

Browse files
committed
Use function to get the public URL
1 parent f1ebf6d commit 635f8ff

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

README.md

+2-13
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ That page is accessed by including a placeholder, [ARCHIVE] or [ARCHIVEURL], in
1616

1717
### Dependencies ###
1818

19-
Requires phplist release 3.3.0 or later and php version 5.5 or later.
19+
Requires phplist release 3.3.0 or later and php version 7 or later.
2020

21-
This plugin requires the Common Plugin v3.10.7 or later to be installed, and will not work without that.
21+
This plugin requires the Common Plugin v3.29.0 or later to be installed, and will not work without that.
2222
phplist now includes Common Plugin so you should only need to enable it on the Manage Plugins page.
2323

2424
Requires the XSL extension to be included in php. You can verify this through phpinfo.
@@ -27,17 +27,6 @@ Requires the XSL extension to be included in php. You can verify this through ph
2727
Install on the Plugins page (menu Config > Manage Plugins) using the package URL `https://github.com/bramley/phplist-plugin-viewbrowser/archive/master.zip`.
2828
Then click the button to enable the plugin.
2929

30-
### Install manually ###
31-
Download the plugin zip file from <https://github.com/bramley/phplist-plugin-viewbrowser/archive/master.zip>
32-
33-
Expand the zip file, then copy the contents of the plugins directory to your phplist plugins directory.
34-
This should contain
35-
36-
* the file ViewBrowserPlugin.php
37-
* the directory ViewBrowserPlugin
38-
39-
Then click the button to enable the plugin.
40-
4130
## Usage ##
4231

4332
For guidance on using the plugin see the plugin's page within the phplist documentation site <https://resources.phplist.com/plugin/viewinbrowser>

plugins/ViewBrowserPlugin.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
/**
2424
* Registers the plugin with phplist.
2525
*/
26+
use function phpList\plugin\Common\publicBaseUrl;
27+
2628
class ViewBrowserPlugin extends phplistPlugin
2729
{
2830
const VERSION_FILE = 'version.txt';
@@ -170,11 +172,11 @@ public function dependencyCheck()
170172
return array(
171173
'phpList version 3.3.0 or later' => version_compare(VERSION, '3.3') >= 0,
172174
'XSL extension installed' => extension_loaded('xsl'),
173-
'Common Plugin v3.10.7 or later installed' => (
175+
'Common Plugin v3.29.0 or later installed' => (
174176
phpListPlugin::isEnabled('CommonPlugin')
175-
&& version_compare($plugins['CommonPlugin']->version, '3.10.7') >= 0
177+
&& version_compare($plugins['CommonPlugin']->version, '3.29.0') >= 0
176178
),
177-
'PHP version 5.5 or greater' => version_compare(PHP_VERSION, '5.5') > 0,
179+
'PHP version 7 or greater' => version_compare(PHP_VERSION, '7') > 0,
178180
);
179181
}
180182

@@ -257,12 +259,10 @@ public function __construct()
257259

258260
public function activate()
259261
{
260-
global $public_scheme, $pageroot;
261-
262262
parent::activate();
263263
$this->linkText = getConfig('viewbrowser_link');
264264
$this->archiveLinkText = getConfig('viewbrowser_archive_link');
265-
$this->rootUrl = sprintf('%s://%s%s/', $public_scheme, getConfig('website'), $pageroot);
265+
$this->rootUrl = publicBaseUrl() . '/';
266266
}
267267

268268
/**

plugins/ViewBrowserPlugin/ArchiveCreator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
use phpList\plugin\Common\Populator;
2929
use phpList\plugin\Common\View;
3030

31+
use function phpList\plugin\Common\publicBaseUrl;
32+
3133
/**
3234
* Class to create an archive page.
3335
*/
@@ -54,16 +56,14 @@ private function urlPattern()
5456
*/
5557
private function archiveItems($uid, $campaigns)
5658
{
57-
global $pageroot;
58-
5959
foreach ($campaigns as $c) {
6060
$params = ['pi' => $_GET['pi'], 'p' => 'view', 'm' => $c['messageid']];
6161

6262
if ($uid) {
6363
$params['uid'] = $uid;
6464
}
6565
$query = http_build_query($params, '', '&');
66-
$url = sprintf('%s/?%s', $pageroot, $query);
66+
$url = sprintf('%s/?%s', publicBaseUrl(), $query);
6767
$link = new PageLink($url, $c['subject'], ['target' => '_blank']);
6868

6969
yield [

plugins/ViewBrowserPlugin/ContentCreator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
use Iterator;
2626
use phpList\plugin\Common;
2727

28+
use function phpList\plugin\Common\publicBaseUrl;
29+
2830
/**
2931
* Class to create the content of a campaign email.
3032
*/
@@ -279,12 +281,10 @@ public function __construct(
279281
Common\DAO\Attribute $daoAttr,
280282
$clickTrack
281283
) {
282-
global $public_scheme, $pageroot;
283-
284284
$this->dao = $dao;
285285
$this->daoAttr = $daoAttr;
286286
$this->clickTrack = $clickTrack;
287-
$this->rootUrl = sprintf('%s://%s%s/', $public_scheme, getConfig('website'), $pageroot);
287+
$this->rootUrl = publicBaseUrl() . '/';
288288
}
289289

290290
/**

0 commit comments

Comments
 (0)