--- /dev/null
+<?php
+$ts = time();
+$token = generate_action_token($ts);
+
+echo json_encode(array('__elgg_ts' => $ts, '__elgg_token' => $token));
\ No newline at end of file
--- /dev/null
+/**
+ * Create a new ElggEntity
+ *
+ * @class Represents an ElggEntity
+ * @property {number} guid
+ * @property {string} type
+ * @property {string} subtype
+ * @property {number} owner_guid
+ * @property {number} site_guid
+ * @property {number} container_guid
+ * @property {number} access_id
+ * @property {number} time_created
+ * @property {number} time_updated
+ * @property {number} last_action
+ * @property {string} enabled
+ *
+ */
+elgg.ElggEntity = function(o) {
+ $.extend(this, o);
+};
\ No newline at end of file
* @property {string} username
*/
elgg.ElggUser = function(o) {
- //elgg.ElggEntity.call(this, o);
- this = o;
+ elgg.ElggEntity.call(this, o);
};
-//elgg.inherit(elgg.ElggUser, elgg.ElggEntity);
-
-/**
- * @return {boolean} Whether the user is an admin
- */
-elgg.ElggUser.prototype.isAdmin = function() {
- return this.admin === 'yes';
-};
\ No newline at end of file
+elgg.inherit(elgg.ElggUser, elgg.ElggEntity);
\ No newline at end of file
* @param {Function} parentCtor Parent class.\r
*/\r
elgg.inherit = function(Child, Parent) {\r
- Child.prototype = Parent;\r
+ Child.prototype = new Parent();\r
+ Child.prototype.constructor = Child;\r
};\r
\r
/**\r
delay = 6000;\r
}\r
\r
- var messages_class = 'messages';\r
+ classes = ['elgg_system_message', 'radius8'];\r
if (type == 'error') {\r
- messages_class = 'messages_error';\r
+ classes.push('messages_error');\r
}\r
\r
//Handle non-arrays\r
msgs = [msgs];\r
}\r
\r
- var messages_html = '<div class="' + messages_class + '">' \r
- + '<span class="closeMessages">'\r
- + '<a href="#">' \r
- + elgg.echo('systemmessages:dismiss')\r
- + '</a>'\r
- + '</span>'\r
- + '<p>' + msgs.join('</p><p>') + '</p>'\r
- + '</div>';\r
+ var messages_html = [];\r
\r
- $(messages_html).appendTo('#elgg_system_messages').show().animate({opacity:'1.0'},delay).fadeOut('slow');\r
+ for (var i in msgs) {\r
+ messages_html.push('<div class="' + classes.join(' ') + '">' \r
+ + '<span class="closeMessages">'\r
+ + '<a href="#">' \r
+ + elgg.echo('systemmessages:dismiss')\r
+ + '</a>'\r
+ + '</span>'\r
+ + '<p>' + msgs[i] + '</p>'\r
+ + '</div>');\r
+ }\r
+ \r
+ $(messages_html.join('')).appendTo('#elgg_system_messages').animate({opacity:'1.0'},delay).fadeOut('slow');\r
};\r
\r
/**\r
elgg.add_translation = function(lang, translations) {\r
elgg.provide('elgg.config.translations.' + lang);\r
\r
- var t = elgg.config.translations;\r
- \r
- t[lang] = $.extend(t[lang], translations);\r
+ $.extend(elgg.config.translations[lang], translations);\r
}\r
\r
/**\r
assertNoException(function(){ elgg.require('elgg.security'); });\r
};\r
\r
+ElggLibTest.prototype.testInherit = function() {\r
+ function Base() {}\r
+ function Child() {}\r
+ \r
+ elgg.inherit(Child, Base);\r
+ \r
+ \r
+ assertInstanceOf(Base, new Child());\r
+ assertEquals(Child, Child.prototype.constructor);\r
+};\r
+\r
ElggLibTest.prototype.testExtendUrl = function() {\r
var url;\r
elgg.config.wwwroot = "http://www.elgg.org/";\r
load:\r
- vendors/jquery/jquery-1.4.2.min.js\r
- engine/js/lib/elgglib.js\r
+ - engine/js/classes/*.js\r
- engine/js/lib/*.js\r
- engine/js/tests/*.js
\ No newline at end of file
+<?php
+/**
+ * Bootstrap Elgg javascript
+ */
+global $CONFIG;
+
+//Include library files
+$lib_files = array(
+ //core
+ 'elgglib',
+
+ //libraries
+ 'security',
+ 'languages',
+ 'ajax',
+ 'session',
+
+ //ui
+ 'ui',
+ 'ui.widgets',
+);
+
+foreach($lib_files as $file) {
+ include("{$CONFIG->path}engine/js/lib/$file.js");
+}
+
+//Include classes
+$model_files = array(
+ 'ElggEntity',
+
+ 'ElggUser',
+);
+
+foreach($model_files as $file) {
+ include("{$CONFIG->path}engine/js/classes/$file.js");
+}
+
+/**
+ * Finally, set some values that are cacheable
+ */
+?>
+
+elgg.version = '<?php echo get_version(); ?>';
+elgg.release = '<?php echo get_version(true); ?>';
+elgg.config.wwwroot = '<?php echo elgg_get_site_url(); ?>';
+elgg.security.interval = 5 * 60 * 1000; <?php //TODO make this configurable ?>
+
$(document).ready(function () {
// COLLAPSABLE WIDGETS (on Dashboard? & Profile pages)
$(this).next(".likes_list").animate({opacity: "toggle", top: topPosition}, 500);
}
});
+
+ elgg_system_message();
}); /* end document ready function */
});
};
-// COOKIES
-jQuery.cookie = function(name, value, options) {
- if (typeof value != 'undefined') { // name and value given, set cookie
- options = options || {};
- if (value === null) {
- value = '';
- options.expires = -1;
- }
- var expires = '';
- if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
- var date;
- if (typeof options.expires == 'number') {
- date = new Date();
- date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
- } else {
- date = options.expires;
- }
- expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
- }
- // CAUTION: Needed to parenthesize options.path and options.domain
- // in the following expressions, otherwise they evaluate to undefined
- // in the packed version for some reason.
- var path = options.path ? '; path=' + (options.path) : '';
- var domain = options.domain ? '; domain=' + (options.domain) : '';
- var secure = options.secure ? '; secure' : '';
- document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
-
- } else { // only name given, get cookie
- var cookieValue = null;
- if (document.cookie && document.cookie != '') {
- var cookies = document.cookie.split(';');
- for (var i = 0; i < cookies.length; i++) {
- var cookie = jQuery.trim(cookies[i]);
- // Does this cookie string begin with the name we want?
- if (cookie.substring(0, name.length + 1) == (name + '=')) {
- cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
- break;
- }
- }
- }
- return cookieValue;
- }
-};
-
// ELGG DROP DOWN MENU
$.fn.elgg_dropdownmenu = function(options) {
--- /dev/null
+<?php\r
+/**\r
+ * @uses $vars['language']\r
+ */\r
+global $CONFIG;\r
+\r
+$language = $vars['language'];\r
+\r
+echo json_encode($CONFIG->translations[$language]);
\ No newline at end of file
--- /dev/null
+<?php\r
+echo elgg_view('js/languages', array('language' => 'en'));
\ No newline at end of file
<script type="text/javascript" src="<?php echo elgg_get_site_url(); ?>_css/js.php?lastcache=<?php echo $vars['config']->lastcache; ?>&js=initialise_elgg&viewtype=<?php echo $vars['view']; ?>"></script>
<?php
+ echo elgg_view('scripts/initialize_elgg');
echo $feedref;
-
?>
<?php
<script type="text/javascript" src="<?php echo elgg_get_site_url(); ?>_css/js.php?lastcache=<?php echo $vars['config']->lastcache; ?>&js=initialise_elgg&viewtype=<?php echo $vars['view']; ?>"></script>
<?php
+ echo elgg_view('scripts/initialize_elgg');
echo $feedref;
+
if (elgg_view_exists('metatags')) {
echo elgg_view('metatags', $vars);
}
--- /dev/null
+<?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