forked from gruz/NotificationAry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotificationary.php
More file actions
102 lines (82 loc) · 3.19 KB
/
Copy pathnotificationary.php
File metadata and controls
102 lines (82 loc) · 3.19 KB
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
<?php
namespace NotificationAry;
/**
* A plugin which sends notifications when an article is added or modified at a Joomla web-site
*
* @package NotificationAry
* @subpackage com_teaching
*
* @author Gruz <arygroup@gmail.com>
* @copyright Copyleft (є) 2016 - All rights reversed
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
// TODO include in new ALPHA this change: self::shouldShowSwitchCheckFlag
// No direct access
defined('_JEXEC') or die;
// Do not enter here if it's a com_dump call to avoid duplicate plugin call with jdump
if (\Joomla\CMS\Factory::getApplication()->input->get('option', null) === 'com_dump') {
return;
}
// Check if the latest needed version of GJFields installed
\JLoader::registerNamespace('NotificationAry', __DIR__, false, false, 'psr4');
if (!(new HelperClasses\GJFieldsChecker('1.2.16', 'NotificationAry'))->check()) {
return;
}
use Joomla\Registry\Registry;
use Joomla\CMS\Plugin\PluginHelper;
use NotificationAry\HelperClasses\NotificationAryHelper;
NotificationAryHelper::loadPluginDependencies();
// Generate and empty object
$plgParams = new Registry;
// Get plugin details
$plugin = PluginHelper::getPlugin('system', 'notificationary');
// Load params into our params object
$plgParams->loadString($plugin->params);
$notificationgroup = $plgParams->get('{notificationgroup');
$custom_templates = array();
if (!empty($notificationgroup->context_or_contenttype)) {
$context_or_contenttype = $notificationgroup->context_or_contenttype;
$enabled = $plgParams->get('{notificationgroup')->isenabled;
foreach ($context_or_contenttype as $k => $v) {
if ($v == 'context' && $enabled[$k] == 1) {
// $custom_templates[] = $plgParams->get('{notificationgroup')->context[$k];
$custom_template = $plgParams->get('{notificationgroup')->context[$k];
$custom_template = NotificationAryHelper::_parseManualContextTemplate($custom_template);
if (!empty($custom_template['Context'])) {
$custom_templates[$custom_template['Context']] = $custom_template;
}
}
}
if (!isset($predefined_context_templates)) {
include dirname(__FILE__) . '/helpers/predefined_contexts.php';
}
}
$temp_alias_functions = [];
foreach ($custom_templates as $context => $array) {
foreach ($functionsToBeAliased as $functionName) {
if (empty($array[$functionName])) {
continue;
}
$array[$functionName] = trim($array[$functionName]);
if (strpos($array[$functionName], 'function ') === 0 || strpos($array[$functionName], 'static function ') === 0) {
$temp_alias_functions[$array[$functionName]] = 'public ' . $array[$functionName];
} else {
// Prevent error if custom file doesn't exists'
if (strpos($array[$functionName], '/') === false) {
$temp_alias_functions[$array[$functionName]] = '
public function ' . $array[$functionName] . ' ($context, $contentItem, $isNew) {
return $this->' . $functionName . '($context, $contentItem, $isNew);
}
';
}
}
}
}
$class_dynamic = '
class plgSystemNotificationary extends NotificationAry\HelperClasses\NotificationaryCore {
public function __construct(& $subject, $config) {
parent::__construct($subject, $config);
}
' . implode(PHP_EOL, $temp_alias_functions) . '
}';
eval($class_dynamic);