aboutsummaryrefslogtreecommitdiff
path: root/views/default/scripts/initialize_elgg.php
diff options
context:
space:
mode:
authorewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-01 22:11:20 +0000
committerewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-11-01 22:11:20 +0000
commit4a2721032e5adb4ad2460befd9af77be4996d2a0 (patch)
treec635a38df6406055a1a0d111bdc02d4dcb41b71b /views/default/scripts/initialize_elgg.php
parent7e4cc929919f05e5b31c6ff7d1ed9b8e53e8a95a (diff)
downloadelgg-4a2721032e5adb4ad2460befd9af77be4996d2a0.tar.gz
elgg-4a2721032e5adb4ad2460befd9af77be4996d2a0.tar.bz2
Refs #2538: Added some models, inheritance, more bootstrapping code
git-svn-id: http://code.elgg.org/elgg/trunk@7183 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/scripts/initialize_elgg.php')
-rw-r--r--views/default/scripts/initialize_elgg.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/views/default/scripts/initialize_elgg.php b/views/default/scripts/initialize_elgg.php
new file mode 100644
index 000000000..03d5adc5a
--- /dev/null
+++ b/views/default/scripts/initialize_elgg.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ *
+ */
+
+?>
+<script type="text/javascript">
+/**
+ * Don't want to cache these -- they could change for every request
+ */
+elgg.config.lastcache = <?php echo (int)($vars['config']->lastcache); ?>;
+
+elgg.security.token.__elgg_ts = <?php echo $ts = time(); ?>;
+elgg.security.token.__elgg_token = '<?php echo generate_action_token($ts); ?>';
+
+<?php
+$page_owner = elgg_get_page_owner();
+
+if ($page_owner instanceof ElggEntity) {
+ $page_owner_json = array();
+ foreach ($page_owner->getExportableValues() as $v) {
+ $page_owner_json[$v] = $page_owner->$v;
+ }
+
+ $page_owner_json['subtype'] = $page_owner->getSubtype();
+ $page_owner_json['url'] = $page_owner->getURL();
+
+ echo 'elgg.page_owner = '.json_encode($page_owner_json).';';
+}
+
+$user = get_loggedin_user();
+
+if ($user instanceof ElggUser) {
+ $user_json = array();
+ foreach ($user->getExportableValues() as $v) {
+ $user_json[$v] = $user->$v;
+ }
+
+ $user_json['subtype'] = $user->getSubtype();
+ $user_json['url'] = $user->getURL();
+
+ echo 'elgg.session.user = new elgg.ElggUser('.json_encode($user_json).');';
+}
+?>;
+</script> \ No newline at end of file