Elgg  Version 2.3
elgglib.php
Go to the documentation of this file.
1 <?php
2 
5 
20 function elgg() {
22 }
23 
35 function elgg_register_library($name, $location) {
36  $config = _elgg_services()->config;
37 
38  $libraries = $config->get('libraries');
39  if ($libraries === null) {
40  $libraries = array();
41  }
42  $libraries[$name] = $location;
43  $config->set('libraries', $libraries);
44 }
45 
58  static $loaded_libraries = array();
59 
60  if (in_array($name, $loaded_libraries)) {
61  return;
62  }
63 
64  $libraries = _elgg_services()->config->get('libraries');
65 
66  if (!isset($libraries[$name])) {
67  $error = "$name is not a registered library";
68  throw new \InvalidParameterException($error);
69  }
70 
71  if (!include_once($libraries[$name])) {
72  $error = "Could not load the $name library from {$libraries[$name]}";
73  throw new \InvalidParameterException($error);
74  }
75 
76  $loaded_libraries[] = $name;
77 }
78 
94 function forward($location = "", $reason = 'system') {
95  if (headers_sent($file, $line)) {
96  throw new \SecurityException("Redirect could not be issued due to headers already being sent. Halting execution for security. "
97  . "Output started in file $file at line $line. Search http://learn.elgg.org/ for more information.");
98  }
99 
100  _elgg_services()->responseFactory->redirect($location, $reason);
101  exit;
102 }
103 
114 function elgg_set_http_header($header, $replace = true) {
115  if (headers_sent($file, $line)) {
116  _elgg_services()->logger->error("Cannot modify header information - headers already sent by
117  (output started at $file:$line)");
118  } else {
119  header($header, $replace);
120  }
121 
122  if (!preg_match('~^HTTP/\\d\\.\\d~', $header)) {
123  list($name, $value) = explode(':', $header, 2);
124  _elgg_services()->responseFactory->setHeader($name, ltrim($value), $replace);
125  }
126 }
127 
155 function elgg_register_js($name, $url, $location = 'head', $priority = null) {
156  return elgg_register_external_file('js', $name, $url, $location, $priority);
157 }
158 
183 function elgg_define_js($name, $config) {
184  $src = elgg_extract('src', $config);
185 
186  if ($src) {
188  _elgg_services()->amdConfig->addPath($name, $url);
189  }
190 
191  // shimmed module
192  if (isset($config['deps']) || isset($config['exports'])) {
193  _elgg_services()->amdConfig->addShim($name, $config);
194  }
195 }
196 
206  return elgg_unregister_external_file('js', $name);
207 }
208 
220 function elgg_load_js($name) {
222 }
223 
224 
233  _elgg_services()->amdConfig->addDependency($name);
234 }
235 
246  _elgg_services()->amdConfig->removeDependency($name);
247 }
248 
257 function elgg_get_loaded_js($location = 'head') {
258  return elgg_get_loaded_external_files('js', $location);
259 }
260 
271 function elgg_register_css($name, $url, $priority = null) {
272  return elgg_register_external_file('css', $name, $url, 'head', $priority);
273 }
274 
284  return elgg_unregister_external_file('css', $name);
285 }
286 
298 function elgg_load_css($name) {
300 }
301 
309  return elgg_get_loaded_external_files('css', 'head');
310 }
311 
324 function elgg_register_external_file($type, $name, $url, $location, $priority = 500) {
325  return _elgg_services()->externalFiles->register($type, $name, $url, $location, $priority);
326 }
327 
338  return _elgg_services()->externalFiles->unregister($type, $name);
339 }
340 
351  return _elgg_services()->externalFiles->load($type, $name);
352 }
353 
363 function elgg_get_loaded_external_files($type, $location) {
364  return _elgg_services()->externalFiles->getLoadedFiles($type, $location);
365 }
366 
379 function elgg_get_file_list($directory, $exceptions = array(), $list = array(),
380 $extensions = null) {
381 
382  $directory = sanitise_filepath($directory);
383  if ($handle = opendir($directory)) {
384  while (($file = readdir($handle)) !== false) {
385  if (!is_file($directory . $file) || in_array($file, $exceptions)) {
386  continue;
387  }
388 
389  if (is_array($extensions)) {
390  if (in_array(strrchr($file, '.'), $extensions)) {
391  $list[] = $directory . $file;
392  }
393  } else {
394  $list[] = $directory . $file;
395  }
396  }
397  closedir($handle);
398  }
399 
400  return $list;
401 }
402 
411 function sanitise_filepath($path, $append_slash = true) {
412  // Convert to correct UNIX paths
413  $path = str_replace('\\', '/', $path);
414  $path = str_replace('../', '/', $path);
415  // replace // with / except when preceeded by :
416  $path = preg_replace("/([^:])\/\//", "$1/", $path);
417 
418  // Sort trailing slash
419  $path = trim($path);
420  // rtrim defaults plus /
421  $path = rtrim($path, " \n\t\0\x0B/");
422 
423  if ($append_slash) {
424  $path = $path . '/';
425  }
426 
427  return $path;
428 }
429 
437 function count_messages($register = "") {
438  return _elgg_services()->systemMessages->count($register);
439 }
440 
451  _elgg_services()->systemMessages->addSuccessMessage($message);
452  return true;
453 }
454 
465  _elgg_services()->systemMessages->addErrorMessage($error);
466  return true;
467 }
468 
476  return _elgg_services()->systemMessages->loadRegisters();
477 }
478 
486 function elgg_set_system_messages(\Elgg\SystemMessages\RegisterSet $set) {
487  _elgg_services()->systemMessages->saveRegisters($set);
488 }
489 
550 function elgg_register_event_handler($event, $object_type, $callback, $priority = 500) {
551  return _elgg_services()->events->registerHandler($event, $object_type, $callback, $priority);
552 }
553 
564 function elgg_unregister_event_handler($event, $object_type, $callback) {
565  return _elgg_services()->events->unregisterHandler($event, $object_type, $callback);
566 }
567 
577 function elgg_clear_event_handlers($event, $object_type) {
578  _elgg_services()->events->clearHandlers($event, $object_type);
579 }
580 
614 function elgg_trigger_event($event, $object_type, $object = null) {
615  return _elgg_services()->events->trigger($event, $object_type, $object);
616 }
617 
635 function elgg_trigger_before_event($event, $object_type, $object = null) {
636  return _elgg_services()->events->triggerBefore($event, $object_type, $object);
637 }
638 
654 function elgg_trigger_after_event($event, $object_type, $object = null) {
655  return _elgg_services()->events->triggerAfter($event, $object_type, $object);
656 }
657 
671 function elgg_trigger_deprecated_event($event, $object_type, $object = null, $message, $version) {
672  return _elgg_services()->events->triggerDeprecated($event, $object_type, $object, $message, $version);
673 }
674 
740 function elgg_register_plugin_hook_handler($hook, $type, $callback, $priority = 500) {
741  return _elgg_services()->hooks->registerHandler($hook, $type, $callback, $priority);
742 }
743 
755 function elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback) {
756  _elgg_services()->hooks->unregisterHandler($hook, $entity_type, $callback);
757 }
758 
769  _elgg_services()->hooks->clearHandlers($hook, $type);
770 }
771 
826 function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
827  return _elgg_services()->hooks->trigger($hook, $type, $params, $returnvalue);
828 }
829 
841  return _elgg_services()->hooks->getOrderedHandlers($hook, $type);
842 }
843 
855  return _elgg_services()->events->getOrderedHandlers($event, $type);
856 }
857 
876  $timestamp = time();
877  error_log("Exception at time $timestamp: $exception");
878 
879  // Wipe any existing output buffer
880  ob_end_clean();
881 
882  // make sure the error isn't cached
883  header("Cache-Control: no-cache, must-revalidate", true);
884  header('Expires: Fri, 05 Feb 1982 00:00:00 -0500', true);
885 
886  // we don't want the 'pagesetup', 'system' event to fire
887  global $CONFIG;
888  $GLOBALS['_ELGG']->pagesetupdone = true;
889 
890  try {
891  // allow custom scripts to trigger on exception
892  // $CONFIG->exception_include can be set locally in settings.php
893  // value should be a system path to a file to include
894  if (!empty($CONFIG->exception_include) && is_file($CONFIG->exception_include)) {
895  ob_start();
896 
897  // don't isolate, these scripts may use the local $exception var.
898  include $CONFIG->exception_include;
899 
900  $exception_output = ob_get_clean();
901 
902  // if content is returned from the custom handler we will output
903  // that instead of our default failsafe view
904  if (!empty($exception_output)) {
905  echo $exception_output;
906  exit;
907  }
908  }
909 
910  if (elgg_is_xhr()) {
911  elgg_set_viewtype('json');
912  $response = new \Symfony\Component\HttpFoundation\JsonResponse(null, 500);
913  } else {
914  elgg_set_viewtype('failsafe');
915  $response = new \Symfony\Component\HttpFoundation\Response('', 500);
916  }
917 
918  if (elgg_is_admin_logged_in()) {
919  $body = elgg_view("messages/exceptions/admin_exception", array(
920  'object' => $exception,
921  'ts' => $timestamp
922  ));
923  } else {
924  $body = elgg_view("messages/exceptions/exception", array(
925  'object' => $exception,
926  'ts' => $timestamp
927  ));
928  }
929 
930  $response->setContent(elgg_view_page(elgg_echo('exception:title'), $body));
931  $response->send();
932  } catch (Exception $e) {
933  $timestamp = time();
934  $message = $e->getMessage();
935  http_response_code(500);
936  echo "Fatal error in exception handler. Check log for Exception at time $timestamp";
937  error_log("Exception at time $timestamp : fatal error in exception handler : $message");
938  }
939 }
940 
964 function _elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars) {
965 
966  // Elgg 2.0 no longer uses ext/mysql, so these warnings are just a nuisance for 1.x site
967  // owners and plugin devs.
968  if (0 === strpos($errmsg, "mysql_connect(): The mysql extension is deprecated")) {
969  // only suppress core's usage
970  if (preg_match('~/classes/Elgg/Database\.php$~', strtr($filename, '\\', '/'))) {
971  return true;
972  }
973  }
974 
975  $error = date("Y-m-d H:i:s (T)") . ": \"$errmsg\" in file $filename (line $linenum)";
976 
977  switch ($errno) {
978  case E_USER_ERROR:
979  if (!elgg_log("PHP: $error", 'ERROR')) {
980  error_log("PHP ERROR: $error");
981  }
982  register_error("ERROR: $error");
983 
984  // Since this is a fatal error, we want to stop any further execution but do so gracefully.
985  throw new \Exception($error);
986  break;
987 
988  case E_WARNING :
989  case E_USER_WARNING :
990  case E_RECOVERABLE_ERROR: // (e.g. type hint violation)
991 
992  // check if the error wasn't suppressed by the error control operator (@)
993  if (error_reporting() && !elgg_log("PHP: $error", 'WARNING')) {
994  error_log("PHP WARNING: $error");
995  }
996  break;
997 
998  default:
999  global $CONFIG;
1000  if (isset($CONFIG->debug) && $CONFIG->debug === 'NOTICE') {
1001  if (!elgg_log("PHP (errno $errno): $error", 'NOTICE')) {
1002  error_log("PHP NOTICE: $error");
1003  }
1004  }
1005  }
1006 
1007  return true;
1008 }
1009 
1010 
1028 function elgg_log($message, $level = 'NOTICE') {
1029  static $levels = array(
1030  'INFO' => 200,
1031  'NOTICE' => 250,
1032  'WARNING' => 300,
1033  'DEBUG' => 300,
1034  'ERROR' => 400,
1035  );
1036 
1037  if ($level == 'DEBUG') {
1038  elgg_deprecated_notice("The 'DEBUG' level for logging has been deprecated.", 1.9);
1039  }
1040 
1041  $level = $levels[$level];
1042  return _elgg_services()->logger->log($message, $level);
1043 }
1044 
1059 function elgg_dump($value, $to_screen = true) {
1060  _elgg_services()->logger->dump($value, $to_screen);
1061 }
1062 
1071 function elgg_get_version($human_readable = false) {
1072  static $version, $release;
1073 
1074  if (!isset($version) || !isset($release)) {
1075  $path = \Elgg\Application::elggDir()->getPath('version.php');
1076  if (!is_file($path)) {
1077  return false;
1078  }
1079  include $path;
1080  }
1081 
1082  return $human_readable ? $release : $version;
1083 }
1084 
1098 function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
1099  $backtrace_level += 1;
1100  return _elgg_services()->deprecation->sendNotice($msg, $dep_version, $backtrace_level);
1101 }
1102 
1116 function elgg_http_build_url(array $parts, $html_encode = true) {
1117  // build only what's given to us.
1118  $scheme = isset($parts['scheme']) ? "{$parts['scheme']}://" : '';
1119  $host = isset($parts['host']) ? "{$parts['host']}" : '';
1120  $port = isset($parts['port']) ? ":{$parts['port']}" : '';
1121  $path = isset($parts['path']) ? "{$parts['path']}" : '';
1122  $query = isset($parts['query']) ? "?{$parts['query']}" : '';
1123  $fragment = isset($parts['fragment']) ? "#{$parts['fragment']}" : '';
1124 
1125  $string = $scheme . $host . $port . $path . $query . $fragment;
1126 
1127  if ($html_encode) {
1128  return elgg_format_url($string);
1129  } else {
1130  return $string;
1131  }
1132 }
1133 
1151 function elgg_add_action_tokens_to_url($url, $html_encode = false) {
1153  $components = parse_url($url);
1154 
1155  if (isset($components['query'])) {
1156  $query = elgg_parse_str($components['query']);
1157  } else {
1158  $query = array();
1159  }
1160 
1161  if (isset($query['__elgg_ts']) && isset($query['__elgg_token'])) {
1162  return $url;
1163  }
1164 
1165  // append action tokens to the existing query
1166  $query['__elgg_ts'] = time();
1167  $query['__elgg_token'] = generate_action_token($query['__elgg_ts']);
1168  $components['query'] = http_build_query($query);
1169 
1170  // rebuild the full url
1171  return elgg_http_build_url($components, $html_encode);
1172 }
1173 
1186  return elgg_http_add_url_query_elements($url, array($element => null));
1187 }
1188 
1199 function elgg_http_add_url_query_elements($url, array $elements) {
1200  $url_array = parse_url($url);
1201 
1202  if (isset($url_array['query'])) {
1203  $query = elgg_parse_str($url_array['query']);
1204  } else {
1205  $query = array();
1206  }
1207 
1208  foreach ($elements as $k => $v) {
1209  if ($v === null) {
1210  unset($query[$k]);
1211  } else {
1212  $query[$k] = $v;
1213  }
1214  }
1215 
1216  // why check path? A: if no path, this may be a relative URL like "?foo=1". In this case,
1217  // the output "" would be interpreted the current URL, so in this case we *must* set
1218  // a query to make sure elements are removed.
1219  if ($query || empty($url_array['path'])) {
1220  $url_array['query'] = http_build_query($query);
1221  } else {
1222  unset($url_array['query']);
1223  }
1224  $string = elgg_http_build_url($url_array, false);
1225 
1226  return $string;
1227 }
1228 
1243 function elgg_http_url_is_identical($url1, $url2, $ignore_params = array('offset', 'limit')) {
1244  $url1 = elgg_normalize_url($url1);
1245  $url2 = elgg_normalize_url($url2);
1246 
1247  // @todo - should probably do something with relative URLs
1248 
1249  if ($url1 == $url2) {
1250  return true;
1251  }
1252 
1253  $url1_info = parse_url($url1);
1254  $url2_info = parse_url($url2);
1255 
1256  if (isset($url1_info['path'])) {
1257  $url1_info['path'] = trim($url1_info['path'], '/');
1258  }
1259  if (isset($url2_info['path'])) {
1260  $url2_info['path'] = trim($url2_info['path'], '/');
1261  }
1262 
1263  // compare basic bits
1264  $parts = array('scheme', 'host', 'path');
1265 
1266  foreach ($parts as $part) {
1267  if ((isset($url1_info[$part]) && isset($url2_info[$part]))
1268  && $url1_info[$part] != $url2_info[$part]) {
1269  return false;
1270  } elseif (isset($url1_info[$part]) && !isset($url2_info[$part])) {
1271  return false;
1272  } elseif (!isset($url1_info[$part]) && isset($url2_info[$part])) {
1273  return false;
1274  }
1275  }
1276 
1277  // quick compare of get params
1278  if (isset($url1_info['query']) && isset($url2_info['query'])
1279  && $url1_info['query'] == $url2_info['query']) {
1280  return true;
1281  }
1282 
1283  // compare get params that might be out of order
1284  $url1_params = array();
1285  $url2_params = array();
1286 
1287  if (isset($url1_info['query'])) {
1288  if ($url1_info['query'] = html_entity_decode($url1_info['query'])) {
1289  $url1_params = elgg_parse_str($url1_info['query']);
1290  }
1291  }
1292 
1293  if (isset($url2_info['query'])) {
1294  if ($url2_info['query'] = html_entity_decode($url2_info['query'])) {
1295  $url2_params = elgg_parse_str($url2_info['query']);
1296  }
1297  }
1298 
1299  // drop ignored params
1300  foreach ($ignore_params as $param) {
1301  if (isset($url1_params[$param])) {
1302  unset($url1_params[$param]);
1303  }
1304  if (isset($url2_params[$param])) {
1305  unset($url2_params[$param]);
1306  }
1307  }
1308 
1309  // array_diff_assoc only returns the items in arr1 that aren't in arrN
1310  // but not the items that ARE in arrN but NOT in arr1
1311  // if arr1 is an empty array, this function will return 0 no matter what.
1312  // since we only care if they're different and not how different,
1313  // add the results together to get a non-zero (ie, different) result
1314  $diff_count = count(array_diff_assoc($url1_params, $url2_params));
1315  $diff_count += count(array_diff_assoc($url2_params, $url1_params));
1316  if ($diff_count > 0) {
1317  return false;
1318  }
1319 
1320  return true;
1321 }
1322 
1334 function elgg_http_get_signed_url($url, $expires = false) {
1335  return _elgg_services()->urlSigner->sign($url, $expires);
1336 }
1337 
1345  return _elgg_services()->urlSigner->isValid($url);
1346 }
1347 
1355  register_error(elgg_echo('invalid_request_signature'));
1356  forward('', '403');
1357  }
1358 }
1359 
1375 function elgg_extract($key, $array, $default = null, $strict = true) {
1376  if (!is_array($array)) {
1377  return $default;
1378  }
1379 
1380  if ($strict) {
1381  return (isset($array[$key])) ? $array[$key] : $default;
1382  } else {
1383  return (isset($array[$key]) && !empty($array[$key])) ? $array[$key] : $default;
1384  }
1385 }
1386 
1396 function elgg_extract_class(array $array, $existing = []) {
1397  $existing = empty($existing) ? [] : (array) $existing;
1398 
1399  $merge = (array) elgg_extract('class', $array, []);
1400 
1401  array_splice($existing, count($existing), 0, $merge);
1402 
1403  return array_values(array_unique($existing));
1404 }
1405 
1426 function elgg_sort_3d_array_by_value(&$array, $element, $sort_order = SORT_ASC,
1427 $sort_type = SORT_LOCALE_STRING) {
1428 
1429  $sort = array();
1430 
1431  foreach ($array as $v) {
1432  if (isset($v[$element])) {
1433  $sort[] = strtolower($v[$element]);
1434  } else {
1435  $sort[] = null;
1436  }
1437  };
1438 
1439  return array_multisort($sort, $sort_order, $sort_type, $array);
1440 }
1441 
1452 function ini_get_bool($ini_get_arg) {
1453  $temp = strtolower(ini_get($ini_get_arg));
1454 
1455  if ($temp == '1' || $temp == 'on' || $temp == 'true') {
1456  return true;
1457  }
1458  return false;
1459 }
1460 
1472 function elgg_get_ini_setting_in_bytes($setting) {
1473  // retrieve INI setting
1474  $val = ini_get($setting);
1475 
1476  // convert INI setting when shorthand notation is used
1477  $last = strtolower($val[strlen($val) - 1]);
1478  if (in_array($last, ['g', 'm', 'k'])) {
1479  $val = substr($val, 0, -1);
1480  }
1481  $val = (int) $val;
1482  switch($last) {
1483  case 'g':
1484  $val *= 1024;
1485  // fallthrough intentional
1486  case 'm':
1487  $val *= 1024;
1488  // fallthrough intentional
1489  case 'k':
1490  $val *= 1024;
1491  }
1492 
1493  // return byte value
1494  return $val;
1495 }
1496 
1508  if (($string === '') || ($string === false) || ($string === null)) {
1509  return false;
1510  }
1511 
1512  return true;
1513 }
1514 
1529  foreach ($singulars as $singular) {
1530  $plural = $singular . 's';
1531 
1532  if (array_key_exists($singular, $options)) {
1533  if ($options[$singular] === ELGG_ENTITIES_ANY_VALUE) {
1534  $options[$plural] = $options[$singular];
1535  } else {
1536  // Test for array refs #2641
1537  if (!is_array($options[$singular])) {
1538  $options[$plural] = array($options[$singular]);
1539  } else {
1540  $options[$plural] = $options[$singular];
1541  }
1542  }
1543  }
1544 
1545  unset($options[$singular]);
1546  }
1547 
1548  return $options;
1549 }
1550 
1569  try {
1570  _elgg_services()->logger->setDisplay(false);
1571  elgg_trigger_event('shutdown', 'system');
1572 
1573  $time = (float)(microtime(true) - $GLOBALS['START_MICROTIME']);
1574  $uri = _elgg_services()->request->server->get('REQUEST_URI', 'CLI');
1575  // demoted to NOTICE from DEBUG so javascript is not corrupted
1576  elgg_log("Page {$uri} generated in $time seconds", 'INFO');
1577  } catch (Exception $e) {
1578  $message = 'Error: ' . get_class($e) . ' thrown within the shutdown handler. ';
1579  $message .= "Message: '{$e->getMessage()}' in file {$e->getFile()} (line {$e->getLine()})";
1580  error_log($message);
1581  error_log("Exception trace stack: {$e->getTraceAsString()}");
1582  }
1583 
1584  // Prevent an APC session bug: https://bugs.php.net/bug.php?id=60657
1585  session_write_close();
1586 }
1587 
1600 function _elgg_js_page_handler($page) {
1601  return _elgg_cacheable_view_page_handler($page, 'js');
1602 }
1603 
1617 function _elgg_ajax_page_handler($segments) {
1619 
1620  if (count($segments) < 2) {
1621  return false;
1622  }
1623 
1624  if ($segments[0] === 'view' || $segments[0] === 'form') {
1625  if ($segments[0] === 'view') {
1626  // ignore 'view/'
1627  $view = implode('/', array_slice($segments, 1));
1628  } else {
1629  // form views start with "forms", not "form"
1630  $view = 'forms/' . implode('/', array_slice($segments, 1));
1631  }
1632 
1633  $ajax_api = _elgg_services()->ajax;
1634  $allowed_views = $ajax_api->getViews();
1635 
1636  // cacheable views are always allowed
1637  if (!in_array($view, $allowed_views) && !_elgg_services()->views->isCacheableView($view)) {
1638  return elgg_error_response("Ajax view '$view' was not registered", REFERRER, ELGG_HTTP_FORBIDDEN);
1639  }
1640 
1641  // pull out GET parameters through filter
1642  $vars = array();
1643  foreach (_elgg_services()->request->query->keys() as $name) {
1644  $vars[$name] = get_input($name);
1645  }
1646 
1647  if (isset($vars['guid'])) {
1648  $vars['entity'] = get_entity($vars['guid']);
1649  }
1650 
1651  $content_type = '';
1652  if ($segments[0] === 'view') {
1654 
1655  // Try to guess the mime-type
1656  switch ($segments[1]) {
1657  case "js":
1658  $content_type = 'text/javascript;charset=utf-8';
1659  break;
1660  case "css":
1661  $content_type = 'text/css;charset=utf-8';
1662  break;
1663  default :
1664  if (_elgg_services()->views->isCacheableView($view)) {
1665  $file = _elgg_services()->views->findViewFile($view, elgg_get_viewtype());
1666  $content_type = (new \Elgg\Filesystem\MimeTypeDetector())->getType($file, 'text/html');
1667  }
1668  break;
1669  }
1670  } else {
1671  $action = implode('/', array_slice($segments, 1));
1672  $output = elgg_view_form($action, array(), $vars);
1673  }
1674 
1675  if ($content_type) {
1676  elgg_set_http_header("Content-Type: $content_type");
1677  }
1678 
1679  return elgg_ok_response($output);
1680  }
1681 
1682  return false;
1683 }
1684 
1696 function _elgg_css_page_handler($page) {
1697  if (!isset($page[0])) {
1698  // default css
1699  $page[0] = 'elgg';
1700  }
1701 
1702  return _elgg_cacheable_view_page_handler($page, 'css');
1703 }
1704 
1713 function _elgg_favicon_page_handler($segments) {
1714  header("HTTP/1.1 404 Not Found", true, 404);
1715 
1716  header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+1 week")), true);
1717  header("Pragma: public", true);
1718  header("Cache-Control: public", true);
1719 
1720  // TODO in next 1.x send our default icon
1721  //header('Content-Type: image/x-icon');
1722  //echo elgg_view('favicon.ico');
1723 
1724  return true;
1725 }
1726 
1740 
1741  switch ($type) {
1742  case 'js':
1743  $content_type = 'text/javascript';
1744  break;
1745 
1746  case 'css':
1747  $content_type = 'text/css';
1748  break;
1749 
1750  default:
1751  return false;
1752  break;
1753  }
1754 
1755  if ($page) {
1756  // the view file names can have multiple dots
1757  // eg: views/default/js/calendars/jquery.fullcalendar.min.php
1758  // translates to the url /js/<ts>/calendars/jquery.fullcalendar.min.js
1759  // and the view js/calendars/jquery.fullcalendar.min
1760  // we ignore the last two dots for the ts and the ext.
1761  // Additionally, the timestamp is optional.
1762  $page = implode('/', $page);
1763  $regex = '|(.+?)\.\w+$|';
1764  if (!preg_match($regex, $page, $matches)) {
1765  return false;
1766  }
1767  $view = "$type/{$matches[1]}";
1768  if (!elgg_view_exists($view)) {
1769  return false;
1770  }
1771 
1772  $msg = 'URLs starting with /js/ and /css/ are deprecated. Use elgg_get_simplecache_url().';
1773  elgg_deprecated_notice($msg, '2.1');
1774 
1775  $return = elgg_view($view);
1776 
1777  header("Content-type: $content_type;charset=utf-8");
1778 
1779  // @todo should js be cached when simple cache turned off
1780  //header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true);
1781  //header("Pragma: public");
1782  //header("Cache-Control: public");
1783  //header("Content-Length: " . strlen($return));
1784 
1785  echo $return;
1786  return true;
1787  }
1788  return false;
1789 }
1790 
1803  $order_by = strtolower($order_by);
1804 
1805  if (strpos($order_by, ' asc') !== false) {
1806  $return = str_replace(' asc', ' desc', $order_by);
1807  } elseif (strpos($order_by, ' desc') !== false) {
1808  $return = str_replace(' desc', ' asc', $order_by);
1809  } else {
1810  // no order specified, so default to desc since mysql defaults to asc
1811  $return = $order_by . ' desc';
1812  }
1813 
1814  return $return;
1815 }
1816 
1829  // our db functions return the number of rows affected...
1830  return $object->enable() ? true : false;
1831 }
1832 
1843  // our db functions return the number of rows affected...
1844  return $object->disable() ? true : false;
1845 }
1846 
1857  // our db functions return the number of rows affected...
1858  return $object->delete() ? true : false;
1859 }
1860 
1871  if (!$options || !is_array($options)) {
1872  return false;
1873  }
1874 
1875  // at least one of these is required.
1876  $required = array(
1877  // generic restraints
1878  'guid', 'guids'
1879  );
1880 
1881  switch ($type) {
1882  case 'metadata':
1883  $metadata_required = array(
1884  'metadata_owner_guid', 'metadata_owner_guids',
1885  'metadata_name', 'metadata_names',
1886  'metadata_value', 'metadata_values'
1887  );
1888 
1889  $required = array_merge($required, $metadata_required);
1890  break;
1891 
1892  case 'annotations':
1893  case 'annotation':
1894  $annotations_required = array(
1895  'annotation_owner_guid', 'annotation_owner_guids',
1896  'annotation_name', 'annotation_names',
1897  'annotation_value', 'annotation_values'
1898  );
1899 
1900  $required = array_merge($required, $annotations_required);
1901  break;
1902 
1903  default:
1904  return false;
1905  }
1906 
1907  foreach ($required as $key) {
1908  // check that it exists and is something.
1909  if (isset($options[$key]) && $options[$key]) {
1910  return true;
1911  }
1912  }
1913 
1914  return false;
1915 }
1916 
1924  return elgg_ok_response(elgg_view_resource('walled_garden'));
1925 }
1926 
1927 
1936  $view = $page[0];
1937  if (!elgg_view_exists("core/walled_garden/$view")) {
1938  return false;
1939  }
1940  $params = array(
1941  'content' => elgg_view("core/walled_garden/$view"),
1942  'class' => 'elgg-walledgarden-single hidden',
1943  'id' => str_replace('_', '-', "elgg-walledgarden-$view"),
1944  );
1945  echo elgg_view_layout('walled_garden', $params);
1946  return true;
1947 }
1948 
1963  global $CONFIG;
1964 
1965  elgg_register_css('elgg.walled_garden', elgg_get_simplecache_url('walled_garden.css'));
1966 
1967  // Deprecated, but registered for BC
1968  // @todo: remove in 3.x
1969  elgg_register_js('elgg.walled_garden', elgg_get_simplecache_url('walled_garden.js'));
1970 
1971  elgg_register_page_handler('walled_garden', '_elgg_walled_garden_ajax_handler');
1972 
1973  // check for external page view
1974  if (isset($CONFIG->site) && $CONFIG->site instanceof \ElggSite) {
1975  $CONFIG->site->checkWalledGarden();
1976  }
1977 
1978  // For BC, we are extending the views to make sure that sites that customized walled garden get the updates
1979  // @todo: in 3.0, move this into the layout view
1980  elgg_extend_view('page/layouts/walled_garden', 'page/layouts/walled_garden/cancel_button');
1981 }
1982 
1994 
1995  if (!elgg_get_config('walled_garden')) {
1996  return;
1997  }
1998 
1999  if (isset($accesses[ACCESS_PUBLIC])) {
2000  unset($accesses[ACCESS_PUBLIC]);
2001  }
2002 
2003  return $accesses;
2004 }
2005 
2015 function _elgg_init() {
2016  elgg_register_action('entity/delete');
2017  elgg_register_action('comment/save');
2018  elgg_register_action('comment/delete');
2019 
2020  elgg_register_page_handler('js', '_elgg_js_page_handler');
2021  elgg_register_page_handler('css', '_elgg_css_page_handler');
2022  elgg_register_page_handler('ajax', '_elgg_ajax_page_handler');
2023  elgg_register_page_handler('favicon.ico', '_elgg_favicon_page_handler');
2024 
2025  elgg_register_page_handler('manifest.json', function() {
2027  $resource = new \Elgg\Http\WebAppManifestResource($site);
2028  header('Content-Type: application/json;charset=utf-8');
2029  echo json_encode($resource->get());
2030  return true;
2031  });
2032 
2033  elgg_register_plugin_hook_handler('head', 'page', function($hook, $type, array $result) {
2034  $result['links']['manifest'] = [
2035  'rel' => 'manifest',
2036  'href' => elgg_normalize_url('/manifest.json'),
2037  ];
2038 
2039  return $result;
2040  });
2041 
2042  elgg_register_plugin_hook_handler('access:collections:write', 'all', '_elgg_walled_garden_remove_public_access', 9999);
2043 
2044  if (_elgg_services()->config->getVolatile('enable_profiling')) {
2048  elgg_register_plugin_hook_handler('output', 'page', [\Elgg\Profiler::class, 'handlePageOutput'], 999);
2049  }
2050 }
2051 
2064 function _elgg_api_test($hook, $type, $value, $params) {
2065  global $CONFIG;
2066  $value[] = $CONFIG->path . 'engine/tests/ElggTravisInstallTest.php';
2067  $value[] = $CONFIG->path . 'engine/tests/ElggCoreHelpersTest.php';
2068  $value[] = $CONFIG->path . 'engine/tests/ElggCoreRegressionBugsTest.php';
2069  $value[] = $CONFIG->path . 'engine/tests/ElggBatchTest.php';
2070  return $value;
2071 }
2072 
2081 define('ACCESS_DEFAULT', -1);
2082 define('ACCESS_PRIVATE', 0);
2083 define('ACCESS_LOGGED_IN', 1);
2084 define('ACCESS_PUBLIC', 2);
2085 define('ACCESS_FRIENDS', -2);
2095 define('ELGG_ENTITIES_ANY_VALUE', null);
2096 
2104 define('ELGG_ENTITIES_NO_VALUE', 0);
2105 
2113 define('REFERRER', -1);
2114 
2123 define('REFERER', -1);
2124 
2128 define('ELGG_HTTP_CONTINUE', 100);
2129 define('ELGG_HTTP_SWITCHING_PROTOCOLS', 101);
2130 define('ELGG_HTTP_PROCESSING', 102);// RFC2518
2131 define('ELGG_HTTP_OK', 200);
2132 define('ELGG_HTTP_CREATED', 201);
2133 define('ELGG_HTTP_ACCEPTED', 202);
2134 define('ELGG_HTTP_NON_AUTHORITATIVE_INFORMATION', 203);
2135 define('ELGG_HTTP_NO_CONTENT', 204);
2136 define('ELGG_HTTP_RESET_CONTENT', 205);
2137 define('ELGG_HTTP_PARTIAL_CONTENT', 206);
2138 define('ELGG_HTTP_MULTI_STATUS', 207); // RFC4918
2139 define('ELGG_HTTP_ALREADY_REPORTED', 208); // RFC5842
2140 define('ELGG_HTTP_IM_USED', 226); // RFC3229
2141 define('ELGG_HTTP_MULTIPLE_CHOICES', 300);
2142 define('ELGG_HTTP_MOVED_PERMANENTLY', 301);
2143 define('ELGG_HTTP_FOUND', 302);
2144 define('ELGG_HTTP_SEE_OTHER', 303);
2145 define('ELGG_HTTP_NOT_MODIFIED', 304);
2146 define('ELGG_HTTP_USE_PROXY', 305);
2147 define('ELGG_HTTP_RESERVED', 306);
2148 define('ELGG_HTTP_TEMPORARY_REDIRECT', 307);
2149 define('ELGG_HTTP_PERMANENTLY_REDIRECT', 308); // RFC7238
2150 define('ELGG_HTTP_BAD_REQUEST', 400);
2151 define('ELGG_HTTP_UNAUTHORIZED', 401);
2152 define('ELGG_HTTP_PAYMENT_REQUIRED', 402);
2153 define('ELGG_HTTP_FORBIDDEN', 403);
2154 define('ELGG_HTTP_NOT_FOUND', 404);
2155 define('ELGG_HTTP_METHOD_NOT_ALLOWED', 405);
2156 define('ELGG_HTTP_NOT_ACCEPTABLE', 406);
2157 define('ELGG_HTTP_PROXY_AUTHENTICATION_REQUIRED', 407);
2158 define('ELGG_HTTP_REQUEST_TIMEOUT', 408);
2159 define('ELGG_HTTP_CONFLICT', 409);
2160 define('ELGG_HTTP_GONE', 410);
2161 define('ELGG_HTTP_LENGTH_REQUIRED', 411);
2162 define('ELGG_HTTP_PRECONDITION_FAILED', 412);
2163 define('ELGG_HTTP_REQUEST_ENTITY_TOO_LARGE', 413);
2164 define('ELGG_HTTP_REQUEST_URI_TOO_LONG', 414);
2165 define('ELGG_HTTP_UNSUPPORTED_MEDIA_TYPE', 415);
2166 define('ELGG_HTTP_REQUESTED_RANGE_NOT_SATISFIABLE', 416);
2167 define('ELGG_HTTP_EXPECTATION_FAILED', 417);
2168 define('ELGG_HTTP_I_AM_A_TEAPOT', 418); // RFC2324
2169 define('ELGG_HTTP_UNPROCESSABLE_ENTITY', 422);// RFC4918
2170 define('ELGG_HTTP_LOCKED', 423); // RFC4918
2171 define('ELGG_HTTP_FAILED_DEPENDENCY', 424); // RFC4918
2172 define('ELGG_HTTP_RESERVED_FOR_WEBDAV_ADVANCED_COLLECTIONS_EXPIRED_PROPOSAL', 425); // RFC2817
2173 define('ELGG_HTTP_UPGRADE_REQUIRED', 426);// RFC2817
2174 define('ELGG_HTTP_PRECONDITION_REQUIRED', 428); // RFC6585
2175 define('ELGG_HTTP_TOO_MANY_REQUESTS', 429); // RFC6585
2176 define('ELGG_HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE', 431); // RFC6585
2177 define('ELGG_HTTP_INTERNAL_SERVER_ERROR', 500);
2178 define('ELGG_HTTP_NOT_IMPLEMENTED', 501);
2179 define('ELGG_HTTP_BAD_GATEWAY', 502);
2180 define('ELGG_HTTP_SERVICE_UNAVAILABLE', 503);
2181 define('ELGG_HTTP_GATEWAY_TIMEOUT', 504);
2182 define('ELGG_HTTP_VERSION_NOT_SUPPORTED', 505);
2183 define('ELGG_HTTP_VARIANT_ALSO_NEGOTIATES_EXPERIMENTAL', 506);// RFC2295
2184 define('ELGG_HTTP_INSUFFICIENT_STORAGE', 507);// RFC4918
2185 define('ELGG_HTTP_LOOP_DETECTED', 508); // RFC5842
2186 define('ELGG_HTTP_NOT_EXTENDED', 510);// RFC2774
2187 define('ELGG_HTTP_NETWORK_AUTHENTICATION_REQUIRED', 511); // RFC6585
2188 
2192 define('ELGG_JSON_ENCODING', JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
2193 
2194 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
2195  $events->registerHandler('boot', 'system', function () {
2196  _elgg_services()->boot->boot();
2197  }, 1);
2198  $events->registerHandler('cache:flush', 'system', function () {
2199  _elgg_services()->boot->invalidateCache();
2200  });
2201 
2202  $events->registerHandler('init', 'system', '_elgg_init');
2203  $events->registerHandler('init', 'system', '_elgg_walled_garden_init', 1000);
2204 
2205  $hooks->registerHandler('unit_test', 'system', '_elgg_api_test');
2206 };
$header
Definition: full.php:21
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:1199
const ELGG_HTTP_FORBIDDEN
Definition: elgglib.php:2153
elgg_parse_str($str)
Parses a string using mb_parse_str() if available.
Definition: mb_wrapper.php:19
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:293
$extensions
Definition: summary.php:41
$object
These two snippets demonstrates triggering an event and how to register for that event.
Definition: trigger.php:7
elgg_get_config($name, $site_guid=0)
Get an Elgg configuration value.
$view
Definition: crop.php:34
elgg_get_loaded_css()
Get the loaded CSS URLs.
Definition: elgglib.php:308
elgg_get_site_entity($site_guid=0)
Get an entity (default is current site)
Definition: sites.php:18
if(!$owner||!($owner instanceof ElggUser)||!$owner->canEdit()) $error
Definition: upload.php:14
$action
Definition: full.php:133
elgg_is_xhr()
Checks whether the request was requested via ajax.
Definition: actions.php:237
elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback)
Unregister a callback as a plugin hook.
Definition: elgglib.php:755
if(!array_key_exists($filename, $text_files)) $file
$version
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
Definition: elgglib.php:1151
_elgg_css_page_handler($page)
Serve CSS.
Definition: elgglib.php:1696
_elgg_is_valid_options_for_batch_operation($options, $type)
Checks if there are some constraints on the options array for potentially dangerous operations...
Definition: elgglib.php:1870
elgg_set_http_header($header, $replace=true)
Set a response HTTP header.
Definition: elgglib.php:114
elgg_register_external_file($type, $name, $url, $location, $priority=500)
Core registration function for external files.
Definition: elgglib.php:324
elgg_unrequire_js($name)
Cancel a request to load an AMD module onto the page.
Definition: elgglib.php:245
elgg_is_admin_logged_in()
Returns whether or not the viewer is currently logged in and an admin user.
Definition: sessions.php:60
elgg_normalize_url($url)
Definition: output.php:280
if($guid==elgg_get_logged_in_user_guid()) $name
Definition: delete.php:21
elgg_define_js($name, $config)
Defines a JS lib as an AMD module.
Definition: elgglib.php:183
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_view_form($action, $form_vars=array(), $body_vars=array())
Definition: views.php:1345
elgg_view_resource($name, array $vars=[])
Render a resource view.
Definition: views.php:510
elgg_sort_3d_array_by_value(&$array, $element, $sort_order=SORT_ASC, $sort_type=SORT_LOCALE_STRING)
Sorts a 3d array by specific element.
Definition: elgglib.php:1426
$e
Definition: metadata.php:12
elgg_clear_plugin_hook_handlers($hook, $type)
Clears all callback registrations for a plugin hook.
Definition: elgglib.php:768
elgg_get_ordered_event_handlers($event, $type)
Returns an ordered array of event handlers registered for $event and $type.
Definition: elgglib.php:854
elgg_http_url_is_identical($url1, $url2, $ignore_params=array('offset', 'limit'))
Test if two URLs are functionally identical.
Definition: elgglib.php:1243
elgg_unregister_external_file($type, $name)
Unregister an external file.
Definition: elgglib.php:337
sanitise_filepath($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: elgglib.php:411
elgg_get_simplecache_url($view, $subview= '')
Get the URL for the cached view.
Definition: cache.php:136
elgg()
Get a reference to the global Application object.
Definition: elgglib.php:20
$path
Definition: details.php:88
$value
Definition: longtext.php:42
elgg_register_css($name, $url, $priority=null)
Register a CSS file for inclusion in the HTML head.
Definition: elgglib.php:271
elgg_load_library($name)
Load a PHP library.
Definition: elgglib.php:57
elgg_signed_request_gatekeeper()
Validates if the HMAC signature of the current request is valid Issues 403 response if signature is i...
Definition: elgglib.php:1353
$return
Definition: opendd.php:15
elgg_view_layout($layout_name, $vars=array())
Displays a layout with optional parameters.
Definition: views.php:689
current_page_url()
Returns the current page&#39;s complete URL.
Definition: input.php:65
_elgg_favicon_page_handler($segments)
Handle requests for /favicon.ico.
Definition: elgglib.php:1713
$default
Definition: checkbox.php:34
$src
Definition: iframe.php:11
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:450
elgg_get_system_messages()
Get a copy of the current system messages.
Definition: elgglib.php:475
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:740
$timestamp
Definition: date.php:33
_elgg_sql_reverse_order_by_clause($order_by)
Reverses the ordering in an ORDER BY clause.
Definition: elgglib.php:1802
elgg_extract_class(array $array, $existing=[])
Extract class names from an array with key "class", optionally merging into a preexisting set...
Definition: elgglib.php:1396
elgg_trigger_before_event($event, $object_type, $object=null)
Trigger a "Before event" indicating a process is about to begin.
Definition: elgglib.php:635
$url
Definition: exceptions.php:24
$vars['entity']
_elgg_shutdown_hook()
Emits a shutdown:system event upon PHP shutdown, but before database connections are dropped...
Definition: elgglib.php:1568
_elgg_php_exception_handler($exception)
Intercepts, logs, and displays uncaught exceptions.
Definition: elgglib.php:875
$options
Elgg admin footer.
Definition: footer.php:6
register_error($error)
Display an error on next page load.
Definition: elgglib.php:464
$string
elgg_get_loaded_external_files($type, $location)
Get external resource descriptors.
Definition: elgglib.php:363
elgg_get_viewtype()
Return the current view type.
Definition: views.php:95
$params
Definition: login.php:72
const REFERRER
Definition: elgglib.php:2113
is_not_null($string)
Returns true is string is not empty, false, or null.
Definition: elgglib.php:1507
elgg_batch_delete_callback($object)
Delete objects with a delete() method.
Definition: elgglib.php:1856
_elgg_js_page_handler($page)
Serve javascript pages.
Definition: elgglib.php:1600
$exception
elgg_unregister_css($name)
Unregister a CSS file.
Definition: elgglib.php:283
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:232
elgg_get_file_list($directory, $exceptions=array(), $list=array(), $extensions=null)
Returns a list of files in $directory.
Definition: elgglib.php:379
elgg_get_ini_setting_in_bytes($setting)
Returns a PHP INI setting in bytes.
Definition: elgglib.php:1472
Save menu items.
_elgg_api_test($hook, $type, $value, $params)
Adds unit tests for the general API.
Definition: elgglib.php:2064
elgg_load_css($name)
Load a CSS file for this page.
Definition: elgglib.php:298
elgg_register_js($name, $url, $location= 'head', $priority=null)
Register a JavaScript file for inclusion.
Definition: elgglib.php:155
generate_action_token($timestamp)
Generate an action token.
Definition: actions.php:177
elgg_http_remove_url_query_element($url, $element)
Removes an element from a URL&#39;s query string.
Definition: elgglib.php:1185
$key
Definition: summary.php:34
elgg_trigger_deprecated_event($event, $object_type, $object=null, $message, $version)
Trigger an event normally, but send a notice about deprecated use if any handlers are registered...
Definition: elgglib.php:671
static static $_instance
Reference to the loaded Application returned by elgg()
Definition: Application.php:53
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
_elgg_ajax_page_handler($segments)
Serve individual views for Ajax.
Definition: elgglib.php:1617
elgg_load_external_file($type, $name)
Load an external resource for use on this page.
Definition: elgglib.php:350
_elgg_walled_garden_index()
Intercepts the index page when Walled Garden mode is enabled.
Definition: elgglib.php:1923
global $CONFIG
_elgg_cacheable_view_page_handler($page, $type)
Serves a JS or CSS view with headers for caching.
Definition: elgglib.php:1739
ini_get_bool($ini_get_arg)
Return the state of a php.ini setting as a bool.
Definition: elgglib.php:1452
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
elgg_dump($value, $to_screen=true)
Logs or displays $value.
Definition: elgglib.php:1059
elgg_set_viewtype($viewtype="")
Manually set the viewtype.
Definition: views.php:74
const ELGG_ENTITIES_ANY_VALUE
Definition: elgglib.php:2095
elgg echo
Translates a string.
Definition: languages.js:48
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:826
elgg_register_page_handler($identifier, $function)
Registers a page handler for a particular identifier.
Definition: pagehandler.php:34
elgg_ajax_gatekeeper()
Require that the current request be an XHR.
_elgg_walled_garden_ajax_handler($page)
Serve walled garden sections.
Definition: elgglib.php:1935
elgg_view($view, $vars=array(), $ignore1=false, $ignore2=false, $viewtype= '')
Return a parsed view.
Definition: views.php:336
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:1098
elgg global
Pointer to the global context.
Definition: elgglib.js:12
clearfix elgg elgg elgg elgg page header
Definition: admin.css.php:127
elgg_register_library($name, $location)
Register a PHP file as a library.
Definition: elgglib.php:35
elgg_extend_view($view, $view_extension, $priority=501)
Extends a view with another view.
Definition: views.php:380
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
Definition: autoloader.php:17
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1375
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Definition: elgglib.php:550
elgg_log($message, $level= 'NOTICE')
Display or log a message.
Definition: elgglib.php:1028
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
_elgg_walled_garden_remove_public_access($hook, $type, $accesses)
Remove public access for walled gardens.
Definition: elgglib.php:1993
const ACCESS_PUBLIC
Definition: elgglib.php:2084
elgg subtext time
forward($location="", $reason= 'system')
Forward to $location.
Definition: elgglib.php:94
elgg_get_version($human_readable=false)
Get the current Elgg version information.
Definition: elgglib.php:1071
elgg_load_js($name)
Load a JavaScript resource on this page.
Definition: elgglib.php:220
elgg_http_build_url(array $parts, $html_encode=true)
Builds a URL from the a parts array like one returned by parse_url().
Definition: elgglib.php:1116
$required
Definition: label.php:12
elgg_set_system_messages(\Elgg\SystemMessages\RegisterSet $set)
Set the system messages.
Definition: elgglib.php:486
elgg_batch_disable_callback($object)
Disable objects with a disable() method.
Definition: elgglib.php:1842
elgg_format_url($url)
Handles formatting of ampersands in urls.
Definition: output.php:81
static elggDir()
Returns a directory that points to the root of Elgg, but not necessarily the install root...
$filename
class
Definition: placeholder.php:21
elgg_clear_event_handlers($event, $object_type)
Clears all callback registrations for a event.
Definition: elgglib.php:577
elgg_trigger_after_event($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
Definition: elgglib.php:654
_elgg_init()
Elgg&#39;s main init.
Definition: elgglib.php:2015
define(function(require){var $=require('jquery');$(document).on('change', '#elgg-river-selector', function(){var url=window.location.href;if(window.location.search.length){url=url.substring(0, url.indexOf('?'));}url+= '?'+$(this).val();window.location.href=url;});})
Initiates page reload when river selector value changes core/river/filter.
exit
Definition: autoloader.php:34
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:96
elgg_get_ordered_hook_handlers($hook, $type)
Returns an ordered array of hook handlers registered for $hook and $type.
Definition: elgglib.php:840
$output
Definition: item.php:10
_elgg_normalize_plural_options_array($options, $singulars)
Normalise the singular keys in an options array to plural keys.
Definition: elgglib.php:1528
elgg_http_get_signed_url($url, $expires=false)
Signs provided URL with a SHA256 HMAC key.
Definition: elgglib.php:1334
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:614
_elgg_walled_garden_init()
Checks the status of the Walled Garden and forwards to a login page if required.
Definition: elgglib.php:1962
_elgg_php_error_handler($errno, $errmsg, $filename, $linenum, $vars)
Intercepts catchable PHP errors.
Definition: elgglib.php:964
system_message($message)
Display a system message on next page load.
Definition: elgglib.php:450
http free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:5
elgg_get_loaded_js($location= 'head')
Get the JavaScript URLs that are loaded.
Definition: elgglib.php:257
elgg_batch_enable_callback($object)
Enable objects with an enable() method.
Definition: elgglib.php:1828
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
Definition: elgglib.php:564
elgg_http_validate_signed_url($url)
Validates if the HMAC signature of the URL is valid.
Definition: elgglib.php:1344
$priority
elgg_unregister_js($name)
Unregister a JavaScript file.
Definition: elgglib.php:205
count_messages($register="")
Counts the number of messages, either globally or in a particular register.
Definition: elgglib.php:437
if($composer===null) if(!isset($composer->version)) $release
Definition: version.php:30
get_entity($guid)
Loads and returns an entity object from a guid.
Definition: entities.php:204
elgg_view_page($title, $body, $page_shell= 'default', $vars=array())
Assembles and outputs a full page.
Definition: views.php:447
if(!$display_name) $type
Definition: delete.php:27