Elgg  Version 1.11
initialize_elgg.php
Go to the documentation of this file.
1 <?php
6 $elgg = array(
7  'config' => array(
8  'lastcache' => (int)elgg_get_config('lastcache'),
9  'viewtype' => elgg_get_viewtype(),
10  'simplecache_enabled' => (int)elgg_is_simplecache_enabled(),
11  ),
12  'security' => array(
13  'token' => array(
14  '__elgg_ts' => $ts = time(),
15  '__elgg_token' => generate_action_token($ts),
16  ),
17  ),
18  'session' => array(
19  'user' => null,
20  'token' => _elgg_services()->session->get('__elgg_session'),
21  ),
22 );
23 
25 if ($page_owner instanceof ElggEntity) {
26  $elgg['page_owner'] = $page_owner->toObject();
27 }
28 
30 if ($user instanceof ElggUser) {
31  $user_object = $user->toObject();
32  $user_object->admin = $user->isAdmin();
33  $elgg['session']['user'] = $user_object;
34 }
35 
36 ?>
37 
38 var elgg = <?php echo json_encode($elgg); ?>;
39 <?php
40 // note: elgg.session.user needs to be wrapped with elgg.ElggUser, but this class isn't
41 // defined yet. So this is delayed until after the classes are defined, in js/lib/session.js
elgg
Definition: install.js:23
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$elgg
Initialize Elgg&#39;s js lib with the uncacheable data.
$page_owner
generate_action_token($timestamp)
Generate an action token.
Definition: actions.php:167
elgg_get_viewtype()
Return the current view type.
Definition: views.php:91
if($page_owner instanceof ElggEntity) $user
_elgg_services()
Definition: autoloader.php:14
elgg echo
Translates a string.
Definition: languages.js:43
elgg_get_page_owner_entity()
Gets the owner entity for the current page.
Definition: pageowner.php:53
elgg_is_simplecache_enabled()
Is simple cache enabled.
Definition: cache.php:162
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32