-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomingsoon.php
140 lines (122 loc) · 3.5 KB
/
comingsoon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* @package comingsoon
* @author Brian Teeman
* @copyright (C) 2022 - Brian Teeman
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Uri\Uri;
\defined('_JEXEC') or die;
/**
* Comingsoon Plugin by Brian Teeman
*
* @since 1.0.0
*/
class plgSystemComingsoon extends CMSPlugin
{
/**
* Application object.
*
* @var CMSApplicationInterface
* @since 1.0.0
*/
protected $app;
/**
* Load plugin language files automatically
*
* @var boolean
* @since 1.0.0
*/
protected $autoloadLanguage = true;
/**
* Display the Comingsoon
*
* @var boolean
* @since 1.0.0
*/
protected $displayComingsoon = false;
/**
* Display the Comingsoon
*
* @return void
*
* @since 1.0.0
*/
private function displayComingsoon()
{
$secret = trim($this->params->get('secret', ''));
$whitelist = trim($this->params->get('whitelist', ''));
if ($secret)
{
$storedSecret = $this->app->getUserState($this->_name . '.secret', 0);
if ($storedSecret === $secret)
{
$this->displayComingsoon = true;
}
else
{
$this->app->setUserState($this->_name . '.secret', 0);
$secretRequest = $this->app->getUserStateFromRequest($this->_name . '.secret', $secret, 0);
if ($secretRequest == 1)
{
$this->app->setUserState($this->_name . '.secret', $secret);
$this->displayComingsoon = true;
}
}
}
if (!$this->displayComingsoon && $whitelist)
{
$whitelist = preg_split('/\s*\n\s*/', $whitelist);
$this->displayComingsoon = in_array($this->app->input->server->get('REMOTE_ADDR'), $whitelist);
}
if (!$this->displayComingsoon)
{
$bgimageUrl = Uri::base() . 'media/plg_comingsoon/images/' . $this->params->get('bgimage', 'comingsoon.jpg');
$caption = $this->params->get('caption', '');
$countdown = $this->params->get('countdown', 1);
$countdown_date = $this->params->get('countdown_date', '');
$fonts = $this->params->get('fonts', 'Roboto+Slab|Roboto');
$font = explode('|', $fonts);
$fontcss = str_replace('+',' ', $font);
$text = $this->params->get('text', '<p>' . Text::_('PLG_SYSTEM_COMINGSOON_COMING_SOON') . '</p>');
// Meta
$metaDesc = $this->params->get('meta_desc', $this->app->get('MetaDesc'));
$title = $this->params->get('title', $this->app->get('sitename'));
$robots = $this->params->get('robots', $this->app->get('robots'));
// Social Media
$facebook = $this->params->get('facebook', '');
$instagram = $this->params->get('instagram', '');
$twitter = $this->params->get('twitter', '');
$youtube = $this->params->get('youtube', '');
$github = $this->params->get('github', '');
// Social Media URL's
$facebook_url = 'https://facebook.com/' . $facebook;
$instagram_url = 'https://instagram.com/' . $instagram;
$twitter_url = 'https://twitter.com/' . $twitter;
$youtube_url = 'https://youtube.com/' . $youtube;
$github_url = 'https://github.com/' . $github;
$path = PluginHelper::getLayoutPath('system', 'comingsoon');
include $path;
$this->app->close();
}
}
/**
* Listener for the `onAfterInitialise` event
*
* @return void
*
* @since 1.0.0
*/
public function onAfterInitialise()
{
// Only run in the frontend
if ($this->app->isClient('site'))
{
$this->displayComingsoon();
}
}
}