Elgg  Version 1.9
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  ),
21 );
22 
24 if ($page_owner instanceof ElggEntity) {
25  $elgg['page_owner'] = $page_owner->toObject();
26 }
27 
29 if ($user instanceof ElggUser) {
30  $user_object = $user->toObject();
31  $user_object->admin = $user->isAdmin();
32  $elgg['session']['user'] = $user_object;
33 }
34 
35 ?>
36 
37 var elgg = <?php echo json_encode($elgg); ?>;
38 <?php
39 // note: elgg.session.user needs to be wrapped with elgg.ElggUser, but this class isn't
40 // 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:156
elgg_get_viewtype()
Return the current view type.
Definition: views.php:91
if($page_owner instanceof ElggEntity) $user
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:214
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32