-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
executable file
·312 lines (267 loc) · 8.86 KB
/
controller.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
<?php
/**
* Facebook Feed Controller File.
*
* @author Oliver Green <[email protected]>
* @license See attached license file
*/
namespace Concrete\Package\FacebookFeed;
use BlockType;
use Concrete\Core\Asset\Asset;
use Concrete\Core\Asset\AssetList;
use Concrete\Core\Attribute\Key\CollectionKey;
use Concrete\Core\Attribute\Type;
use Concrete\Core\Foundation\Service\ProviderList;
use Concrete\Core\Package\Package;
use Concrete\Core\Page\Single as SinglePage;
use Core;
use Illuminate\Filesystem\Filesystem;
defined('C5_EXECUTE') or die('Access Denied.');
/**
* Package Controller Class.
*
* Automatically share pages to Facebook & Twitter.
*
* @author Oliver Green <[email protected]>
* @license See attached license file
*/
class Controller extends Package
{
/**
* Minimum version of concrete5 required to use this package.
*
* @var string
*/
protected $appVersionRequired = '5.7.5';
/**
* Does the package provide a full content swap?
* This feature is often used in theme packages to install 'sample' content on the site.
*
* @see https://goo.gl/C4m6BG
* @var bool
*/
protected $pkgAllowsFullContentSwap = false;
/**
* Does the package provide thumbnails of the files
* imported via the full content swap above?
*
* @see https://goo.gl/C4m6BG
* @var bool
*/
protected $pkgContentProvidesFileThumbnails = false;
/**
* Should we remove 'Src' from classes that are contained
* ithin the packages 'src/Concrete' directory automatically?
*
* '\Concrete\Package\MyPackage\Src\MyNamespace' becomes '\Concrete\Package\MyPackage\MyNamespace'
*
* @see https://goo.gl/4wyRtH
* @var bool
*/
protected $pkgAutoloaderMapCoreExtensions = false;
/**
* Package class autoloader registrations
* The package install helper class, included with this boilerplate,
* is activated by default.
*
* @see https://goo.gl/4wyRtH
* @var array
*/
protected $pkgAutoloaderRegistries = [
//'src/MyVendor/Statistics' => '\MyVendor\ConcreteStatistics'
];
/**
* The packages handle.
* Note that this must be unique in the
* entire concrete5 package ecosystem.
*
* @var string
*/
protected $pkgHandle = 'facebook-feed';
/**
* The packages version.
*
* @var string
*/
protected $pkgVersion = '0.9.6';
/**
* The packages name.
*
* @var string
*/
protected $pkgName = 'Facebook Feed';
/**
* The packages description.
*
* @var string
*/
protected $pkgDescription = 'Shows a persons or pages Facebook posts in an elegant way.';
/**
* Package service providers to register.
*
* @var array
*/
protected $providers = [
// Register your concrete5 service providers here
'Concrete\Package\FacebookFeed\Src\Providers\AuthifyServiceProvider',
];
/**
* Register the packages defined service providers.
*
* @return void
*/
protected function registerServiceProviders()
{
$list = new ProviderList(Core::getFacadeRoot());
foreach ($this->providers as $provider) {
$list->registerProvider($provider);
if (method_exists($provider, 'boot')) {
Core::make($provider)->boot($this);
}
}
}
/**
* Boot the packages composer autoloader if it's present.
*
* @return void
*/
protected function bootComposer()
{
$filesystem = new Filesystem();
$path = __DIR__.'/vendor/autoload.php';
if ($filesystem->exists($path)) {
$filesystem->getRequire($path);
}
}
/**
* The packages on start hook that is fired as the CMS is booting up.
*
* @return void
*/
public function on_start()
{
// Boot composer
$this->bootComposer();
// Register defined service providers
$this->registerServiceProviders();
// Register our assets with the pipeline.
$this->registerAssets();
// Add custom logic here that needs to be executed during CMS boot, things
// such as registering services, assets, etc.
}
/**
* The packages install routine.
*
* @return \Concrete\Core\Package\Package
*/
public function install()
{
// Boot composer
$this->bootComposer();
// Add your custom logic here that needs to be executed BEFORE package install.
$pkg = parent::install();
// Register defined service providers
$this->registerServiceProviders();
// Install settings pages.
$basePage = SinglePage::add('/dashboard/system/facebook_feed', $pkg);
$basePage->update(array('cName'=>t('Facebook Feed'), 'cDescription'=>''));
$settingsPage = SinglePage::add('/dashboard/system/facebook_feed/settings', $pkg);
$settingsPage->update(array('cName'=>t('Facebook Feed Settings'), 'cDescription'=>''));
$facebookPage = SinglePage::add('/dashboard/system/facebook_feed/facebook', $pkg);
$facebookPage->update(array('cName'=>t('Connect Facebook'), 'cDescription'=>''));
$facebookPage->setAttribute('exclude_nav', true);
$bt = BlockType::installBlockType('facebook_feed', $pkg);
return $pkg;
}
/**
* The packages upgrade routine.
*
* @return void
*/
public function upgrade()
{
// Add your custom logic here that needs to be executed BEFORE package install.
parent::upgrade();
\Concrete\Core\Support\Facade\Application::clearCaches();
// Add your custom logic here that needs to be executed AFTER package upgrade.
}
/**
* The packages uninstall routine.
*
* @return void
*/
public function uninstall()
{
// Add your custom logic here that needs to be executed BEFORE package uninstall.
$configurationRepository = Core::make(
\Concrete\Core\Config\Repository\Repository::class
);
if (count($configurationRepository->get('concrete.authify.credentials')) > 1) {
$configurationRepository->save('concrete.authify.credentials.facebook-feed', null);
} else {
$configurationRepository->save('concrete.authify', null);
}
parent::uninstall();
// Add your custom logic here that needs to be executed AFTER package uninstall.
}
protected function registerAssets()
{
$al = AssetList::getInstance();
// Container player
$al->register(
'css', 'container.player/css', 'node_modules/container.player/dist/container.player.min.css',
array(
'version' => '0.9.1', 'position' => Asset::ASSET_POSITION_HEADER,
'minify' => true, 'combine' => false
), $this
);
$al->register(
'javascript', 'container.player/js', 'node_modules/container.player/dist/container.player.min.js',
array(
'version' => '0.9.1', 'position' => Asset::ASSET_POSITION_FOOTER,
'minify' => true, 'combine' => false
), $this
);
$al->registerGroup(
'container.player',
array(
array('css', 'container.player/css'),
array('javascript', 'container.player/js'),
array('javascript', 'jquery')
)
);
// Owl Carousel
$al->register(
'css', 'owl.carousel/css/core',
'node_modules/owl.carousel/dist/assets/owl.carousel.min.css',
array(
'version' => '2.2.0', 'position' => Asset::ASSET_POSITION_HEADER,
'minify' => true, 'combine' => false
), $this
);
$al->register(
'css', 'owl.carousel/css/theme',
'node_modules/owl.carousel/dist/assets/owl.theme.default.min.css',
array(
'version' => '2.2.0', 'position' => Asset::ASSET_POSITION_HEADER,
'minify' => true, 'combine' => false
), $this
);
$al->register(
'javascript', 'owl.carousel/js', 'node_modules/owl.carousel/dist/owl.carousel.min.js',
array(
'version' => '2.2.0', 'position' => Asset::ASSET_POSITION_FOOTER,
'minify' => true, 'combine' => false
), $this
);
$al->registerGroup(
'owl.carousel',
array(
array('css', 'owl.carousel/css/core'),
array('css', 'owl.carousel/css/theme'),
array('javascript', 'owl.carousel/js'),
array('javascript', 'jquery')
)
);
}
}