Elgg  Version 1.11
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  define('elgg', ['jquery', 'languages/' + elgg.get_language()], function($, translations) {
68  elgg.add_translation(elgg.get_language(), translations);
69 
70  $(function() {
71  elgg.trigger_hook('init', 'system');
72  elgg.trigger_hook('ready', 'system');
73  });
74 
75  return elgg;
76  });
77 }();
78 
79 require(['elgg']); // Forces the define() function to always run
80 
81 <?php
82 echo elgg_view_deprecated('js/initialise_elgg', array(), "Use the view js/elgg.", 1.8);
83 ?>
84 
85 elgg.trigger_hook('boot', 'system');
elgg
Definition: install.js:23
$lib_dir
This file is used to make all of Elgg&#39;s code available without going through the boot process...
Definition: load.php:9
$files
Definition: crop.php:36
_elgg_services()
Definition: autoloader.php:14
return function(\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
The function used to get results.
Definition: access.php:603
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
define(function(require){var $=require('jquery');var active=false;var SHOW_DELAY=20;$('body').append('< div class="elgg-spinner">< div class="elgg-ajax-loader"></div ></div >');return{start:function(){active=true;setTimeout(function(){if(active){$('body').addClass('elgg-spinner-active');}}, SHOW_DELAY);}, stop:function(){active=false;$('body').removeClass('elgg-spinner-active');}};})