Elgg  Version 1.9
elgg.php
Go to the documentation of this file.
1 <?php
6 
7 // this warning is due to the change in JS boot order in Elgg 1.9
8 echo <<<JS
9 if (typeof elgg != 'object') {
10  throw new Error('elgg configuration object is not defined! You must include the js/initialize_elgg view in html head before JS library files!');
11 }
12 
13 JS;
14 
15 
16 $lib_dir = 'js/lib';
17 $classes_dir = 'js/classes';
18 $files = array(
19  // these must come first
20  'vendors/sprintf',
21  "$lib_dir/elgglib",
22 
23  // class definitions
24  "$classes_dir/ElggEntity",
25  "$classes_dir/ElggUser",
26  "$classes_dir/ElggPriorityList",
27 
28  //libraries
29  "$lib_dir/prototypes",
30  "$lib_dir/hooks",
31  "$lib_dir/security",
32  "$lib_dir/languages",
33  "$lib_dir/ajax",
34  "$lib_dir/session",
35  "$lib_dir/pageowner",
36  "$lib_dir/configuration",
37  "$lib_dir/comments",
38 
39  //ui
40  "$lib_dir/ui",
41  "$lib_dir/ui.widgets",
42 );
43 
44 $root_path = elgg_get_root_path();
45 
46 foreach ($files as $file) {
47  readfile("{$root_path}$file.js");
48  // putting a new line between the files to address https://github.com/elgg/elgg/issues/3081
49  echo "\n";
50 }
51 
55 ?>
56 //<script>
57 
58 elgg.version = '<?php echo elgg_get_version(); ?>';
59 elgg.release = '<?php echo elgg_get_version(true); ?>';
60 elgg.config.wwwroot = '<?php echo elgg_get_site_url(); ?>';
61 
62 // refresh token 3 times during its lifetime (in microseconds 1000 * 1/3)
63 elgg.security.interval = <?php echo (int)_elgg_services()->actions->getActionTokenTimeout() * 333; ?>;
64 elgg.config.language = '<?php echo (empty($CONFIG->language) ? 'en' : $CONFIG->language); ?>';
65 
66 !function () {
67  var languagesUrl = elgg.config.wwwroot + 'ajax/view/js/languages?language=' + elgg.get_language();
68  if (elgg.config.simplecache_enabled) {
69  languagesUrl += '&lc=' + elgg.config.lastcache;
70  }
71 
72  define('elgg', ['jquery', languagesUrl], function($, translations) {
73  elgg.add_translation(elgg.get_language(), translations);
74 
75  $(function() {
76  elgg.trigger_hook('init', 'system');
77  elgg.trigger_hook('ready', 'system');
78  });
79 
80  return elgg;
81  });
82 }();
83 
84 require(['elgg']); // Forces the define() function to always run
85 
86 <?php
87 echo elgg_view_deprecated('js/initialise_elgg', array(), "Use the view js/elgg.", 1.8);
88 ?>
89 
90 elgg.trigger_hook('boot', 'system');
elgg
Definition: install.js:23
$files
Definition: crop.php:36
$lib_dir
Definition: start.php:61
_elgg_services()
Definition: autoloader.php:14
elgg_view_deprecated($view, array $vars, $suggestion, $version)
Display a view with a deprecation notice.
Definition: views.php:371
elgg_get_root_path()
Get the root directory path for this installation.
elgg echo
Translates a string.
Definition: languages.js:43
elgg require
Throw an error if the required package isn&#39;t present.
Definition: elgglib.js:164
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$CONFIG translations
String translations for the current language.
Definition: config.php:48
$CONFIG language
The current language for either the site or the user.
Definition: config.php:108
global $CONFIG
Core Elgg JavaScript file.
Definition: elgg.php:5
< script > function()
The function used to get results.
Definition: collections.php:33