9 elgg.assertTypeOf =
function(type, val) {
10 if (typeof val !== type) {
11 throw new TypeError(
"Expecting param of " + arguments.caller +
"to be a(n) " + type +
". Was actually a(n) " + typeof val +
".");
29 elgg.normalize_url =
function(url) {
31 elgg.assertTypeOf(
'string', url);
33 function validate(url) {
34 url =
elgg.parse_url(url);
36 url.scheme = url.scheme.toLowerCase();
39 if (url.scheme ==
'http' || url.scheme ==
'https') {
45 if (!(
new RegExp(
"^([a-zA-Z0-9][a-zA-Z0-9\\-\\.]*)$",
"i")).test(url.host) || url.host.charAt(-1) ==
'.') {
51 if (!url.scheme || !url.host && url.scheme !=
'mailto' && url.scheme !=
'news' && url.scheme !=
'file') {
59 if (url.indexOf(
'http:') === 0 || url.indexOf(
'https:') === 0 || url.indexOf(
'javascript:') === 0 || url.indexOf(
'mailto:') === 0) {
61 }
else if (validate(url)) {
64 }
else if ((
new RegExp(
"^(\\#|\\?|//)",
"i")).test(url)) {
68 }
else if ((
new RegExp(
"^[^\/]*\\.php(\\?.*)?$",
"i")).test(url)) {
71 if (url.indexOf(
'/') === 0) {
72 url = url.substring(1);
75 return elgg.config.wwwroot + url;
76 }
else if ((
new RegExp(
"^[^/\\?\\#]*\\.",
"i")).test(url)) {
78 return 'http://' + url;
83 if (url.indexOf(
'/') === 0) {
84 url = url.substring(1);
87 return elgg.config.wwwroot + url;
99 elgg.deprecated_notice =
function(msg, dep_version) {
100 if (
elgg.is_admin_logged_in()) {
101 msg =
"Deprecated in Elgg " + dep_version +
": " + msg;
102 if (typeof console !==
"undefined") {
115 var dest =
elgg.normalize_url(url);
117 if (dest == location.href) {
123 $(window).
on(
'hashchange',
function () {
127 location.href = dest;
139 elgg.parse_url =
function(url, component, expand) {
143 expand = expand ||
false;
144 component = component ||
false;
146 var re_str =
'^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?';
147 re_str +=
'((?:(([^:@]*)(?::([^:@]*))?)?@)?';
148 re_str +=
'([^:/?#]*)(?::(\\d*))?)';
149 re_str +=
'(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))';
150 re_str +=
'(?:\\?([^#]*))?';
151 re_str +=
'(?:#(.*))?)';
165 if (url.indexOf(
'mailto:') === 0) {
166 results[
'scheme'] =
'mailto';
167 results[
'path'] = url.replace(
'mailto:',
'');
171 if (url.indexOf(
'javascript:') === 0) {
172 results[
'scheme'] =
'javascript';
173 results[
'path'] = url.replace(
'javascript:',
'');
177 var re =
new RegExp(re_str);
178 var matches = re.exec(url);
180 for (var i in keys) {
182 results[keys[i]] = matches[i];
186 if (expand && typeof(results[
'query']) !=
'undefined') {
187 results[
'query'] =
elgg.parse_str(results[
'query']);
191 if (typeof(results[component]) !=
'undefined') {
192 return results[component];
208 elgg.parse_str =
function(string) {
213 re = /([^&=]+)=?([^&]*)/g,
217 while (result = re.exec(
string)) {
218 key = decodeURIComponent(result[1].replace(/\+/g,
' '));
219 value = decodeURIComponent(result[2].replace(/\+/g,
' '));
222 key = key.replace(re2,
'');
227 params[key].push(value);
249 elgg.getSelectorFromUrlFragment =
function(url) {
250 var fragment = url.split(
'#')[1];
254 if (fragment.indexOf(
'.') > -1) {
258 return '#' + fragment;
270 elgg.get_logged_in_user_guid =
function() {
271 return elgg.user ?
elgg.user.guid : 0;
279 elgg.is_logged_in =
function() {
280 return elgg.get_logged_in_user_guid() > 0;
288 elgg.is_admin_logged_in =
function() {
289 return elgg.user ?
elgg.user.admin :
false;
297 elgg.get_site_url =
function() {
298 return elgg.config.wwwroot;
309 elgg.get_simplecache_url =
function(view, subview) {
310 elgg.assertTypeOf(
'string', view);
314 if (
elgg.config.simplecache_enabled) {
315 lastcache =
elgg.config.lastcache;
321 path =
'/cache/' + lastcache +
'/' +
elgg.config.viewtype +
'/' + view;
323 elgg.assertTypeOf(
'string', subview);
325 if ((view ===
'js' || view ===
'css') && 0 === subview.indexOf(view +
'/')) {
326 subview = subview.substring(view.length + 1);
329 path =
'/cache/' + lastcache +
'/' +
elgg.config.viewtype +
'/' + view +
'/' + subview;
332 return elgg.normalize_url(path);
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on