-
Notifications
You must be signed in to change notification settings - Fork 1
/
stream.php
164 lines (124 loc) · 4.57 KB
/
stream.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
<?php
defined('_JEXEC') or die('Restricted access');
global $_PROFILER;
include_once __DIR__ . '/loaders/generic.php';
JFactory::getDbo()->setQuery("SELECT 'com_stream::start'")->execute(); // Query progress mark
// During ajax calls, the following constant might not be called
defined('JPATH_COMPONENT') or define('JPATH_COMPONENT', dirname(__FILE__));
require_once JPATH_ROOT.'/components/com_community/defines.community.php';
// Require the base controller
require_once COMMUNITY_COM_PATH.'/libraries/error.php';
require_once COMMUNITY_COM_PATH.'/controllers/controller.php';
require_once COMMUNITY_COM_PATH.'/libraries/apps.php' ;
require_once COMMUNITY_COM_PATH.'/libraries/core.php';
require_once COMMUNITY_COM_PATH.'/libraries/template.php';
require_once COMMUNITY_COM_PATH.'/views/views.php';
require_once COMMUNITY_COM_PATH.'/helpers/url.php';
require_once COMMUNITY_COM_PATH.'/helpers/ajax.php';
require_once COMMUNITY_COM_PATH.'/helpers/time.php';
require_once COMMUNITY_COM_PATH.'/helpers/owner.php';
require_once COMMUNITY_COM_PATH.'/helpers/azrul.php';
require_once COMMUNITY_COM_PATH.'/helpers/string.php';
require_once COMMUNITY_COM_PATH.'/events/router.php';
JTable::addIncludePath(COMMUNITY_COM_PATH.'/tables');
jimport('joomla.utilities.date');
$provider = new \Grisgris\Provider\Provider;
$provider->set('builder', CFactory::getBuilder());
$provider->set('database', JFactory::getDbo());
$provider->set('registry', new \Grisgris\Builder\Registry($provider->get('builder')));
/*
array
'actid' => null
'actor' => string '' (length=0)
'target' => string '' (length=0)
'date' => null
'app' => null
'cid' => null
'groupid' => null
'eventid' => null
'maxList' => string '100' (length=3)
'type' => string 'frontpage' (length=9)
'exclusions' => null
'displayArchived' => boolean false
*/
JFactory::getDbo()->setQuery("SELECT 'com_stream::jomsocial_loaded'")->execute(); // Query progress mark
$activitiesModel = CFactory::getModel('activities');
$appModel = CFactory::getModel('apps');
JFactory::getDbo()->setQuery("SELECT 'com_stream::activityModel'")->execute(); // Query progress mark
// This triggers 6 (!) queries to get the config.
$config = CFactory::getConfig();
$respectActivityPrivacy = $config->get('respectactivityprivacy');
JFactory::getDbo()->setQuery("SELECT 'com_stream::getConfig'")->execute(); // Query progress mark
$act = new CActivityStream();
JFactory::getDbo()->setQuery("SELECT 'com_stream::activityStream'")->execute(); // Query progress mark
// getHTML($actor, $target, $date = null, $maxEntry = 0, $type = '', $idprefix = '', $showActivityContent = true, $showMoreActivity = false, $exclusions = null, $displayArchived = false, $filter = 'all', $latestId = 0) {
//file_put_contents('/tmp/activitystream.html', $act->getHTML('', '', null, 0, $view, '', true, $showMore));
//var_dump(JTable::getInstance('Activity', 'CTable')->getFields());
$actid = null;
$view = '';
$showMore = true;
$date = null;
$maxList = 100;
$type = 'frontpage';
$exclusions = null;
$displayArchived = false;
$actor = '';
$target = '';
$rows = $activitiesModel->getActivities($actor, $target, $date, $maxList, $respectActivityPrivacy, $exclusions, $displayArchived, $actid);
JFactory::getDbo()->setQuery("SELECT 'com_stream::getActivities'")->execute(); // Query progress mark
echo '<ul>';
foreach ($rows as $row)
{
$row->details = resolveLoader('jomsocial.' . $row->app, $provider, $row);
// echo '<li>';
// var_dump($result);
// var_dump($row->app);
// var_dump($row->params);
// echo '</li>';
}
echo '</ul>';
$apps = array();
foreach ($rows as $row)
{
if (method_exists($row->details, 'resolve'))
{
$row->details->resolve();
}
$apps[] = $row->app;
//var_dump($row);
}
var_dump(array_unique($apps));
JFactory::getDbo()->setQuery("SELECT 'com_stream::postResolve'")->execute(); // Query progress mark
/*
$data = $act->_getData(
array(
'actid' => $actid,
'actor' => $actor,
'target' => $target,
'date' => $date,
'maxList' => $maxList,
'type' => $type,
'exclusions' => $exclusions,
'displayArchived' => $displayArchived)
);
var_dump($data);
//*/
function resolveLoader($app, &$provider, &$row)
{
$parts = array_map('ucfirst', explode('.', $app));
$path = __DIR__ . '/loaders/' . strtolower(implode('/', $parts)) . '.php';
if (file_exists($path))
{
include_once $path;
$class = '\Stream\Loader\\' . implode('', $parts);
return new $class($provider, $row);
}
if (count($parts) == 1)
{
return new \Stream\Loader\Generic($provider, $row);
}
else
{
return resolveLoader(implode('.', array_slice($parts, 0, -1)), $provider, $row);
}
}