Elgg  Version 3.0
elgglib.php
Go to the documentation of this file.
1 <?php
2 
4 
19 function elgg() {
20  return _elgg_services()->dic;
21 }
22 
37 function forward($location = "", $reason = 'system') {
38  if (headers_sent($file, $line)) {
39  throw new \SecurityException("Redirect could not be issued due to headers already being sent. Halting execution for security. "
40  . "Output started in file $file at line $line. Search http://learn.elgg.org/ for more information.");
41  }
42 
43  _elgg_services()->responseFactory->redirect($location, $reason);
44  exit;
45 }
46 
57 function elgg_set_http_header($header, $replace = true) {
58  if (!preg_match('~^HTTP/\\d\\.\\d~', $header)) {
59  list($name, $value) = explode(':', $header, 2);
60  _elgg_services()->responseFactory->setHeader($name, ltrim($value), $replace);
61  }
62 }
63 
91 function elgg_register_js($name, $url, $location = 'head', $priority = null) {
93 }
94 
120  $src = elgg_extract('src', $config);
121 
122  if ($src) {
124  _elgg_services()->amdConfig->addPath($name, $url);
125  }
126 
127  // shimmed module
128  if (isset($config['deps']) || isset($config['exports'])) {
129  _elgg_services()->amdConfig->addShim($name, $config);
130  }
131 }
132 
142  return elgg_unregister_external_file('js', $name);
143 }
144 
156 function elgg_load_js($name) {
158 }
159 
160 
169  _elgg_services()->amdConfig->addDependency($name);
170 }
171 
182  _elgg_services()->amdConfig->removeDependency($name);
183 }
184 
193 function elgg_get_loaded_js($location = 'head') {
195 }
196 
207 function elgg_register_css($name, $url, $priority = null) {
208  return elgg_register_external_file('css', $name, $url, 'head', $priority);
209 }
210 
220  return elgg_unregister_external_file('css', $name);
221 }
222 
234 function elgg_load_css($name) {
236 }
237 
245  return elgg_get_loaded_external_files('css', 'head');
246 }
247 
261  return _elgg_services()->externalFiles->register($type, $name, $url, $location, $priority);
262 }
263 
274  return _elgg_services()->externalFiles->unregister($type, $name);
275 }
276 
287  _elgg_services()->externalFiles->load($type, $name);
288 }
289 
300  return _elgg_services()->externalFiles->getLoadedFiles($type, $location);
301 }
302 
315 function elgg_get_file_list($directory, $exceptions = [], $list = [], $extensions = null) {
316 
317  $directory = \Elgg\Project\Paths::sanitize($directory);
318  if ($handle = opendir($directory)) {
319  while (($file = readdir($handle)) !== false) {
320  if (!is_file($directory . $file) || in_array($file, $exceptions)) {
321  continue;
322  }
323 
324  if (is_array($extensions)) {
325  if (in_array(strrchr($file, '.'), $extensions)) {
326  $list[] = $directory . $file;
327  }
328  } else {
329  $list[] = $directory . $file;
330  }
331  }
332  closedir($handle);
333  }
334 
335  return $list;
336 }
337 
345 function count_messages($register = "") {
346  return elgg()->system_messages->count($register);
347 }
348 
357  elgg()->system_messages->addSuccessMessage($message);
358  return true;
359 }
360 
369  elgg()->system_messages->addErrorMessage($error);
370  return true;
371 }
372 
380  return elgg()->system_messages->loadRegisters();
381 }
382 
390 function elgg_set_system_messages(\Elgg\SystemMessages\RegisterSet $set) {
391  elgg()->system_messages->saveRegisters($set);
392 }
393 
449 function elgg_register_event_handler($event, $object_type, $callback, $priority = 500) {
450  return _elgg_services()->events->registerHandler($event, $object_type, $callback, $priority);
451 }
452 
463 function elgg_unregister_event_handler($event, $object_type, $callback) {
464  return _elgg_services()->events->unregisterHandler($event, $object_type, $callback);
465 }
466 
476 function elgg_clear_event_handlers($event, $object_type) {
477  _elgg_services()->events->clearHandlers($event, $object_type);
478 }
479 
513 function elgg_trigger_event($event, $object_type, $object = null) {
514  return elgg()->events->trigger($event, $object_type, $object);
515 }
516 
534 function elgg_trigger_before_event($event, $object_type, $object = null) {
535  return elgg()->events->triggerBefore($event, $object_type, $object);
536 }
537 
553 function elgg_trigger_after_event($event, $object_type, $object = null) {
554  return elgg()->events->triggerAfter($event, $object_type, $object);
555 }
556 
570 function elgg_trigger_deprecated_event($event, $object_type, $object = null, $message = null, $version = null) {
571  return elgg()->events->triggerDeprecated($event, $object_type, $object, $message, $version);
572 }
573 
634 function elgg_register_plugin_hook_handler($hook, $type, $callback, $priority = 500) {
635  return elgg()->hooks->registerHandler($hook, $type, $callback, $priority);
636 }
637 
649 function elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback) {
650  elgg()->hooks->unregisterHandler($hook, $entity_type, $callback);
651 }
652 
663  elgg()->hooks->clearHandlers($hook, $type);
664 }
665 
720 function elgg_trigger_plugin_hook($hook, $type, $params = null, $returnvalue = null) {
721  return elgg()->hooks->trigger($hook, $type, $params, $returnvalue);
722 }
723 
739 function elgg_trigger_deprecated_plugin_hook($hook, $type, $params = null, $returnvalue = null, $message = null, $version = null) {
740  return elgg()->hooks->triggerDeprecated($hook, $type, $params, $returnvalue, $message, $version);
741 }
742 
754  return elgg()->hooks->getOrderedHandlers($hook, $type);
755 }
756 
768  return elgg()->events->getOrderedHandlers($event, $type);
769 }
770 
786 function elgg_log($message, $level = \Psr\Log\LogLevel::NOTICE) {
787  return _elgg_services()->logger->log($level, $message);
788 }
789 
802 function elgg_dump($value) {
803  _elgg_services()->logger->dump($value);
804 }
805 
814 function elgg_get_version($human_readable = false) {
815  static $version, $release;
816 
817  if (!isset($version) || !isset($release)) {
818  $path = \Elgg\Application::elggDir()->getPath('version.php');
819  if (!is_file($path)) {
820  return false;
821  }
822  include $path;
823  }
824 
825  return $human_readable ? $release : $version;
826 }
827 
841 function elgg_deprecated_notice($msg, $dep_version, $backtrace_level = 1) {
842  $backtrace_level += 1;
843  return _elgg_services()->deprecation->sendNotice($msg, $dep_version, $backtrace_level);
844 }
845 
859 function elgg_http_build_url(array $parts, $html_encode = true) {
860  // build only what's given to us.
861  $scheme = isset($parts['scheme']) ? "{$parts['scheme']}://" : '';
862  $host = isset($parts['host']) ? "{$parts['host']}" : '';
863  $port = isset($parts['port']) ? ":{$parts['port']}" : '';
864  $path = isset($parts['path']) ? "{$parts['path']}" : '';
865  $query = isset($parts['query']) ? "?{$parts['query']}" : '';
866  $fragment = isset($parts['fragment']) ? "#{$parts['fragment']}" : '';
867 
868  $string = $scheme . $host . $port . $path . $query . $fragment;
869 
870  if ($html_encode) {
871  return htmlspecialchars($string, ENT_QUOTES, 'UTF-8', false);
872  } else {
873  return $string;
874  }
875 }
876 
894 function elgg_add_action_tokens_to_url($url, $html_encode = false) {
896  $components = parse_url($url);
897 
898  if (isset($components['query'])) {
899  $query = elgg_parse_str($components['query']);
900  } else {
901  $query = [];
902  }
903 
904  if (isset($query['__elgg_ts']) && isset($query['__elgg_token'])) {
905  return $url;
906  }
907 
908  // append action tokens to the existing query
909  $query['__elgg_ts'] = time();
910  $query['__elgg_token'] = generate_action_token($query['__elgg_ts']);
911  $components['query'] = http_build_query($query);
912 
913  // rebuild the full url
914  return elgg_http_build_url($components, $html_encode);
915 }
916 
929  return elgg_http_add_url_query_elements($url, [$element => null]);
930 }
931 
942 function elgg_http_add_url_query_elements($url, array $elements) {
943  $url_array = parse_url($url);
944 
945  if (isset($url_array['query'])) {
946  $query = elgg_parse_str($url_array['query']);
947  } else {
948  $query = [];
949  }
950 
951  foreach ($elements as $k => $v) {
952  if ($v === null) {
953  unset($query[$k]);
954  } else {
955  $query[$k] = $v;
956  }
957  }
958 
959  // why check path? A: if no path, this may be a relative URL like "?foo=1". In this case,
960  // the output "" would be interpreted the current URL, so in this case we *must* set
961  // a query to make sure elements are removed.
962  if ($query || empty($url_array['path'])) {
963  $url_array['query'] = http_build_query($query);
964  } else {
965  unset($url_array['query']);
966  }
967  $string = elgg_http_build_url($url_array, false);
968 
969  // Restore relative protocol to url if missing and is provided as part of the initial url (see #9874)
970  if (!isset($url['scheme']) && (substr($url, 0, 2) == '//')) {
971  $string = "//{$string}";
972  }
973 
974  return $string;
975 }
976 
991 function elgg_http_url_is_identical($url1, $url2, $ignore_params = ['offset', 'limit']) {
992  if (!is_string($url1) || !is_string($url2)) {
993  return false;
994  }
995 
996  $url1 = elgg_normalize_url($url1);
997  $url2 = elgg_normalize_url($url2);
998 
999  if ($url1 == $url2) {
1000  return true;
1001  }
1002 
1003  $url1_info = parse_url($url1);
1004  $url2_info = parse_url($url2);
1005 
1006  if (isset($url1_info['path'])) {
1007  $url1_info['path'] = trim($url1_info['path'], '/');
1008  }
1009  if (isset($url2_info['path'])) {
1010  $url2_info['path'] = trim($url2_info['path'], '/');
1011  }
1012 
1013  // compare basic bits
1014  $parts = ['scheme', 'host', 'path'];
1015 
1016  foreach ($parts as $part) {
1017  if ((isset($url1_info[$part]) && isset($url2_info[$part]))
1018  && $url1_info[$part] != $url2_info[$part]) {
1019  return false;
1020  } elseif (isset($url1_info[$part]) && !isset($url2_info[$part])) {
1021  return false;
1022  } elseif (!isset($url1_info[$part]) && isset($url2_info[$part])) {
1023  return false;
1024  }
1025  }
1026 
1027  // quick compare of get params
1028  if (isset($url1_info['query']) && isset($url2_info['query'])
1029  && $url1_info['query'] == $url2_info['query']) {
1030  return true;
1031  }
1032 
1033  // compare get params that might be out of order
1034  $url1_params = [];
1035  $url2_params = [];
1036 
1037  if (isset($url1_info['query'])) {
1038  if ($url1_info['query'] = html_entity_decode($url1_info['query'])) {
1039  $url1_params = elgg_parse_str($url1_info['query']);
1040  }
1041  }
1042 
1043  if (isset($url2_info['query'])) {
1044  if ($url2_info['query'] = html_entity_decode($url2_info['query'])) {
1045  $url2_params = elgg_parse_str($url2_info['query']);
1046  }
1047  }
1048 
1049  // drop ignored params
1050  foreach ($ignore_params as $param) {
1051  if (isset($url1_params[$param])) {
1052  unset($url1_params[$param]);
1053  }
1054  if (isset($url2_params[$param])) {
1055  unset($url2_params[$param]);
1056  }
1057  }
1058 
1059  // array_diff_assoc only returns the items in arr1 that aren't in arrN
1060  // but not the items that ARE in arrN but NOT in arr1
1061  // if arr1 is an empty array, this function will return 0 no matter what.
1062  // since we only care if they're different and not how different,
1063  // add the results together to get a non-zero (ie, different) result
1064  $diff_count = count(array_diff_assoc($url1_params, $url2_params));
1065  $diff_count += count(array_diff_assoc($url2_params, $url1_params));
1066  if ($diff_count > 0) {
1067  return false;
1068  }
1069 
1070  return true;
1071 }
1072 
1084 function elgg_http_get_signed_url($url, $expires = false) {
1085  return _elgg_services()->urlSigner->sign($url, $expires);
1086 }
1087 
1095  return _elgg_services()->urlSigner->isValid($url);
1096 }
1097 
1106 
1107  if (\Elgg\Application::isCli()) {
1108  return;
1109  }
1110 
1112  throw new \Elgg\HttpException(elgg_echo('invalid_request_signature'), ELGG_HTTP_FORBIDDEN);
1113  }
1114 }
1115 
1131 function elgg_extract($key, $array, $default = null, $strict = true) {
1132  if (!is_array($array) && !$array instanceof ArrayAccess) {
1133  return $default;
1134  }
1135 
1136  if ($strict) {
1137  return (isset($array[$key])) ? $array[$key] : $default;
1138  } else {
1139  return (isset($array[$key]) && !empty($array[$key])) ? $array[$key] : $default;
1140  }
1141 }
1142 
1153 function elgg_extract_class(array $array, $existing = [], $extract_key = 'class') {
1154  $existing = empty($existing) ? [] : (array) $existing;
1155 
1156  $merge = (array) elgg_extract($extract_key, $array, []);
1157 
1158  array_splice($existing, count($existing), 0, $merge);
1159 
1160  return array_values(array_unique($existing));
1161 }
1162 
1176 function elgg_call(int $flags, Closure $closure) {
1177  return _elgg_services()->invoker->call($flags, $closure);
1178 }
1179 
1198 function elgg_sort_3d_array_by_value(&$array, $element, $sort_order = SORT_ASC, $sort_type = SORT_LOCALE_STRING) {
1199 
1200  $sort = [];
1201 
1202  foreach ($array as $v) {
1203  if (isset($v[$element])) {
1204  $sort[] = strtolower($v[$element]);
1205  } else {
1206  $sort[] = null;
1207  }
1208  };
1209 
1210  return array_multisort($sort, $sort_order, $sort_type, $array);
1211 }
1212 
1223 function ini_get_bool($ini_get_arg) {
1224  $temp = strtolower(ini_get($ini_get_arg));
1225 
1226  if ($temp == '1' || $temp == 'on' || $temp == 'true') {
1227  return true;
1228  }
1229  return false;
1230 }
1231 
1243 function elgg_get_ini_setting_in_bytes($setting) {
1244  // retrieve INI setting
1245  $val = ini_get($setting);
1246 
1247  // convert INI setting when shorthand notation is used
1248  $last = strtolower($val[strlen($val) - 1]);
1249  if (in_array($last, ['g', 'm', 'k'])) {
1250  $val = substr($val, 0, -1);
1251  }
1252  $val = (int) $val;
1253  switch ($last) {
1254  case 'g':
1255  $val *= 1024;
1256  // fallthrough intentional
1257  case 'm':
1258  $val *= 1024;
1259  // fallthrough intentional
1260  case 'k':
1261  $val *= 1024;
1262  }
1263 
1264  // return byte value
1265  return $val;
1266 }
1267 
1278 function is_not_null($string) {
1279  if (($string === '') || ($string === false) || ($string === null)) {
1280  return false;
1281  }
1282 
1283  return true;
1284 }
1285 
1292 function _elgg_services() {
1293  // This yields a more shallow stack depth in recursive APIs like views. This aids in debugging and
1294  // reduces false positives in xdebug's infinite recursion protection.
1295  return Elgg\Application::$_instance->_services;
1296 }
1297 
1311 function _elgg_ajax_page_handler($segments) {
1313 
1314  if (count($segments) < 2) {
1315  return elgg_error_response("Ajax pagehandler called with invalid segments", REFERRER, ELGG_HTTP_BAD_REQUEST);
1316  }
1317 
1318  if ($segments[0] === 'view' || $segments[0] === 'form') {
1319  if ($segments[0] === 'view') {
1320  if ($segments[1] === 'admin') {
1321  // protect admin views similar to all admin pages that are protected automatically in the admin_page_handler
1323  }
1324  // ignore 'view/'
1325  $view = implode('/', array_slice($segments, 1));
1326  } else {
1327  // form views start with "forms", not "form"
1328  $view = 'forms/' . implode('/', array_slice($segments, 1));
1329  }
1330 
1331  $ajax_api = _elgg_services()->ajax;
1332  $allowed_views = $ajax_api->getViews();
1333 
1334  // cacheable views are always allowed
1335  if (!in_array($view, $allowed_views) && !_elgg_services()->views->isCacheableView($view)) {
1336  return elgg_error_response("Ajax view '$view' was not registered", REFERRER, ELGG_HTTP_FORBIDDEN);
1337  }
1338 
1339  if (!elgg_view_exists($view)) {
1340  return elgg_error_response("Ajax view '$view' was not found", REFERRER, ELGG_HTTP_NOT_FOUND);
1341  }
1342 
1343  // pull out GET parameters through filter
1344  $vars = [];
1345  foreach (_elgg_services()->request->query->keys() as $name) {
1346  $vars[$name] = get_input($name);
1347  }
1348 
1349  if (isset($vars['guid'])) {
1350  $vars['entity'] = get_entity($vars['guid']);
1351  }
1352 
1353  if (isset($vars['river_id'])) {
1354  $vars['item'] = elgg_get_river_item_from_id($vars['river_id']);
1355  }
1356 
1357  $content_type = '';
1358  if ($segments[0] === 'view') {
1360 
1361  // Try to guess the mime-type
1362  switch ($segments[1]) {
1363  case "js":
1364  $content_type = 'text/javascript;charset=utf-8';
1365  break;
1366  case "css":
1367  $content_type = 'text/css;charset=utf-8';
1368  break;
1369  default :
1370  if (_elgg_services()->views->isCacheableView($view)) {
1371  $file = _elgg_services()->views->findViewFile($view, elgg_get_viewtype());
1372  $content_type = (new \Elgg\Filesystem\MimeTypeDetector())->getType($file, 'text/html');
1373  }
1374  break;
1375  }
1376  } else {
1377  $action = implode('/', array_slice($segments, 1));
1379  }
1380 
1381  if ($content_type) {
1382  elgg_set_http_header("Content-Type: $content_type");
1383  }
1384 
1385  return elgg_ok_response($output);
1386  }
1387 
1388  return false;
1389 }
1390 
1402  if (empty($options) || !is_array($options)) {
1403  return false;
1404  }
1405 
1406  // at least one of these is required.
1407  $required = [
1408  // generic restraints
1409  'guid', 'guids'
1410  ];
1411 
1412  switch ($type) {
1413  case 'metadata':
1414  $metadata_required = [
1415  'metadata_name', 'metadata_names',
1416  'metadata_value', 'metadata_values'
1417  ];
1418 
1419  $required = array_merge($required, $metadata_required);
1420  break;
1421 
1422  case 'annotations':
1423  case 'annotation':
1424  $annotations_required = [
1425  'annotation_owner_guid', 'annotation_owner_guids',
1426  'annotation_name', 'annotation_names',
1427  'annotation_value', 'annotation_values'
1428  ];
1429 
1430  $required = array_merge($required, $annotations_required);
1431  break;
1432 
1433  case 'river':
1434  // overriding generic restraints as guids isn't supported in river
1435  $required = [
1436  'id', 'ids',
1437  'subject_guid', 'subject_guids',
1438  'object_guid', 'object_guids',
1439  'target_guid', 'target_guids',
1440  'annotation_id', 'annotation_ids',
1441  'view', 'views',
1442  ];
1443  break;
1444 
1445  default:
1446  return false;
1447  }
1448 
1449  foreach ($required as $key) {
1450  // check that it exists and is something.
1451  if (isset($options[$key]) && $options[$key]) {
1452  return true;
1453  }
1454  }
1455 
1456  return false;
1457 }
1458 
1473  if (!_elgg_config()->walled_garden) {
1474  return;
1475  }
1476 
1477  elgg_register_css('elgg.walled_garden', elgg_get_simplecache_url('walled_garden.css'));
1478 
1479  elgg_register_plugin_hook_handler('register', 'menu:walled_garden', '_elgg_walled_garden_menu');
1480 
1482  elgg_set_config('default_access', ACCESS_LOGGED_IN);
1483  }
1484 
1485  elgg_register_plugin_hook_handler('access:collections:write', 'all', '_elgg_walled_garden_remove_public_access', 9999);
1486 
1487  if (!elgg_is_logged_in()) {
1488  // override the front page
1489  elgg_register_route('index', [
1490  'path' => '/',
1491  'resource' => 'walled_garden',
1492  ]);
1493  }
1494 }
1495 
1508 function _elgg_walled_garden_menu($hook, $type, $return_value, $params) {
1509 
1510  if (current_page_url() === elgg_get_site_url()) {
1511  return;
1512  }
1513 
1514  $return_value[] = \ElggMenuItem::factory([
1515  'name' => 'home',
1516  'href' => '/',
1517  'text' => elgg_echo('walled_garden:home'),
1518  'priority' => 10,
1519  ]);
1520 
1521  return $return_value;
1522 }
1523 
1536  if (isset($accesses[ACCESS_PUBLIC])) {
1537  unset($accesses[ACCESS_PUBLIC]);
1538  }
1539  return $accesses;
1540 }
1541 
1551 function _elgg_init() {
1552 
1553  elgg_register_plugin_hook_handler('head', 'page', function($hook, $type, array $result) {
1554  $result['links']['manifest'] = [
1555  'rel' => 'manifest',
1556  'href' => elgg_normalize_url('/manifest.json'),
1557  ];
1558 
1559  return $result;
1560  });
1561 
1562  if (_elgg_config()->enable_profiling) {
1566  elgg_register_plugin_hook_handler('output', 'page', [\Elgg\Profiler::class, 'handlePageOutput'], 999);
1567  }
1568 
1569  elgg_register_plugin_hook_handler('commands', 'cli', '_elgg_init_cli_commands');
1570 }
1571 
1582 function _elgg_init_cli_commands(\Elgg\Hook $hook) {
1583  $defaults = [
1592  ];
1593 
1594  return array_merge($defaults, (array) $hook->getValue());
1595 }
1596 
1603  $conf = \Elgg\Project\Paths::elgg() . 'engine/routes.php';
1604  $routes = \Elgg\Includer::includeFile($conf);
1605 
1606  foreach ($routes as $name => $def) {
1607  elgg_register_route($name, $def);
1608  }
1609 }
1610 
1617  $conf = \Elgg\Project\Paths::elgg() . 'engine/actions.php';
1619 
1620  $root_path = \Elgg\Project\Paths::elgg();
1621 
1622  foreach ($actions as $action => $action_spec) {
1623  if (!is_array($action_spec)) {
1624  continue;
1625  }
1626 
1627  $access = elgg_extract('access', $action_spec, 'logged_in');
1628  $handler = elgg_extract('controller', $action_spec);
1629  if (!$handler) {
1630  $handler = elgg_extract('filename', $action_spec);
1631  if (!$handler) {
1632  $handler = "$root_path/actions/{$action}.php";
1633  }
1634  }
1635 
1637  }
1638 }
1639 
1653 function _elgg_api_test($hook, $type, $value, $params) {
1658  return $value;
1659 }
1660 
1664 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
1665  $events->registerHandler('init', 'system', '_elgg_init');
1666  $events->registerHandler('init', 'system', '_elgg_walled_garden_init', 1000);
1667 
1668  $hooks->registerHandler('unit_test', 'system', '_elgg_api_test');
1669 };
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
Definition: elgglib.php:1176
elgg_http_add_url_query_elements($url, array $elements)
Sets elements in a URL&#39;s query string.
Definition: elgglib.php:942
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:205
static includeFile($file)
Include a file with as little context as possible.
Definition: Includer.php:18
elgg_get_loaded_css()
Get the loaded CSS URLs.
Definition: elgglib.php:244
elgg_is_logged_in()
Returns whether or not the user is currently logged in.
Definition: sessions.php:48
$query
Definition: groups.php:8
$action
Definition: full.php:111
const ELGG_HTTP_FORBIDDEN
Definition: constants.php:82
if(!$item instanceof ElggRiverItem) $object
Definition: responses.php:23
elgg_unregister_plugin_hook_handler($hook, $entity_type, $callback)
Unregister a callback as a plugin hook.
Definition: elgglib.php:649
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
if(!array_key_exists($filename, $text_files)) $file
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
Definition: elgglib.php:894
static elgg()
Get the Elgg codebase path with "/".
Definition: Paths.php:44
$params
Saves global plugin settings.
Definition: save.php:13
_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:1401
_elgg_register_routes()
Register core routes.
Definition: elgglib.php:1602
elgg_set_http_header($header, $replace=true)
Set a response HTTP header.
Definition: elgglib.php:57
elgg_register_external_file($type, $name, $url, $location, $priority=500)
Core registration function for external files.
Definition: elgglib.php:260
elgg_unrequire_js($name)
Cancel a request to load an AMD module onto the page.
Definition: elgglib.php:181
elgg_normalize_url($url)
Definition: output.php:186
elgg_define_js($name, $config)
Defines a JS lib as an AMD module.
Definition: elgglib.php:119
static $_instance
Reference to the loaded Application.
Definition: Application.php:75
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:1198
elgg_clear_plugin_hook_handlers($hook, $type)
Clears all callback registrations for a plugin hook.
Definition: elgglib.php:662
$defaults
$extensions
elgg_get_ordered_event_handlers($event, $type)
Returns an ordered array of event handlers registered for $event and $type.
Definition: elgglib.php:767
elgg_unregister_external_file($type, $name)
Unregister an external file.
Definition: elgglib.php:273
elgg_get_simplecache_url($view, $subview= '')
Get the URL for the cached view.
Definition: cache.php:141
$CONFIG walled_garden
Is current site in walled garden mode?
Definition: config.php:156
elgg()
Get a reference to the global Application object.
Definition: elgglib.php:19
_elgg_register_actions()
Register core actions.
Definition: elgglib.php:1616
$path
Definition: details.php:89
Events service.
elgg_register_css($name, $url, $priority=null)
Register a CSS file for inclusion in the HTML head.
Definition: elgglib.php:207
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:1105
current_page_url()
Returns the current page&#39;s complete URL.
Definition: input.php:94
elgg_trigger_deprecated_plugin_hook($hook, $type, $params=null, $returnvalue=null, $message=null, $version=null)
Trigger an plugin hook normally, but send a notice about deprecated use if any handlers are registere...
Definition: elgglib.php:739
$src
Definition: iframe.php:11
elgg parse_url
Parse a URL into its parts.
Definition: elgglib.js:442
elgg_get_system_messages()
Get a copy of the current system messages.
Definition: elgglib.php:379
$type
Definition: delete.php:21
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:634
catch(LoginException $e) if($request->isXhr()) $output
Definition: login.php:56
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
elgg_trigger_before_event($event, $object_type, $object=null)
Trigger a "Before event" indicating a process is about to begin.
Definition: elgglib.php:534
$options
Elgg admin footer.
Definition: footer.php:6
register_error($error)
Display an error on next page load.
Definition: elgglib.php:368
elgg_get_loaded_external_files($type, $location)
Get external resource descriptors.
Definition: elgglib.php:299
elgg_get_viewtype()
Return the current view type.
Definition: views.php:78
$config
Advanced site settings, debugging section.
Definition: debugging.php:6
is_not_null($string)
Returns true is string is not empty, false, or null.
Definition: elgglib.php:1278
static factory($options)
Create an ElggMenuItem from an associative array.
elgg_unregister_css($name)
Unregister a CSS file.
Definition: elgglib.php:219
$CONFIG default_access
Default access as defined in the config table for the current site.
Definition: config.php:142
$error
Bad request error.
Definition: 400.php:6
elgg_require_js($name)
Request that Elgg load an AMD module onto the page.
Definition: elgglib.php:168
elgg_get_ini_setting_in_bytes($setting)
Returns a PHP INI setting in bytes.
Definition: elgglib.php:1243
Configuration exception.
_elgg_api_test($hook, $type, $value, $params)
Adds unit tests for the general API.
Definition: elgglib.php:1653
elgg_load_css($name)
Load a CSS file for this page.
Definition: elgglib.php:234
elgg_register_js($name, $url, $location= 'head', $priority=null)
Register a JavaScript file for inclusion.
Definition: elgglib.php:91
if(!$owner||!$owner->canEdit()) if(!$owner->hasIcon('master')) if(!$owner->saveIconFromElggFile($owner->getIcon('master'), 'icon', $coords)) $view
Definition: crop.php:30
elgg_http_url_is_identical($url1, $url2, $ignore_params=['offset', 'limit'])
Test if two URLs are functionally identical.
Definition: elgglib.php:991
const REFERRER
Definition: constants.php:42
Base class for events and hooks.
elgg_http_remove_url_query_element($url, $element)
Removes an element from a URL&#39;s query string.
Definition: elgglib.php:928
$header
Definition: numentities.php:30
const ACCESS_LOGGED_IN
Definition: constants.php:13
elgg_trigger_deprecated_event($event, $object_type, $object=null, $message=null, $version=null)
Trigger an event normally, but send a notice about deprecated use if any handlers are registered...
Definition: elgglib.php:570
elgg_view_form($action, $form_vars=[], $body_vars=[])
Definition: views.php:1318
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_set_config($name, $value)
Set an Elgg configuration value.
_elgg_ajax_page_handler($segments)
Serve individual views for Ajax.
Definition: elgglib.php:1311
elgg_load_external_file($type, $name)
Load an external resource for use on this page.
Definition: elgglib.php:286
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
Definition: elgglib.php:786
ini_get_bool($ini_get_arg)
Return the state of a php.ini setting as a bool.
Definition: elgglib.php:1223
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.
$url
Definition: default.php:33
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Definition: elgglib.php:720
elgg_ajax_gatekeeper()
Require that the current request be an XHR.
if(!$menu instanceof\Elgg\Menu\PreparedMenu) $actions
Definition: user_hover.php:16
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
Definition: elgglib.php:841
elgg_register_action($action, $filename="", $access= 'logged_in')
Registers an action.
Definition: actions.php:40
elgg_get_site_url()
Get the URL for the current (or specified) site, ending with "/".
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif(is_callable([$item, 'getType']))
Definition: item.php:39
$default
Definition: checkbox.php:35
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:1131
elgg_register_route($name, array $params=[])
Register a new route.
Definition: pagehandler.php:35
elgg_dump($value)
Logs $value to PHP&#39;s error_log().
Definition: elgglib.php:802
_elgg_init_cli_commands(\Elgg\Hook $hook)
Initialize Cli commands.
Definition: elgglib.php:1582
elgg_register_event_handler($event, $object_type, $callback, $priority=500)
Definition: elgglib.php:449
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:55
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:1535
const ELGG_HTTP_BAD_REQUEST
Definition: constants.php:79
_elgg_config()
Get the Elgg config service.
$value
Definition: debugging.php:7
const ELGG_HTTP_NOT_FOUND
Definition: constants.php:83
elgg_admin_gatekeeper()
Used at the top of a page to mark it as admin only.
forward($location="", $reason= 'system')
Forward to $location.
Definition: elgglib.php:37
elgg_get_version($human_readable=false)
Get the current Elgg version information.
Definition: elgglib.php:814
elgg_load_js($name)
Load a JavaScript resource on this page.
Definition: elgglib.php:156
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:859
$vars['type']
Definition: save.php:11
$required
Definition: label.php:12
elgg_set_system_messages(\Elgg\SystemMessages\RegisterSet $set)
Set the system messages.
Definition: elgglib.php:390
$location
Definition: default.php:42
static elggDir()
Returns a directory that points to the root of Elgg, but not necessarily the install root...
class
Definition: placeholder.php:21
elgg_clear_event_handlers($event, $object_type)
Clears all callback registrations for a event.
Definition: elgglib.php:476
static sanitize($path, $append_slash=true)
Sanitise file paths ensuring that they begin and end with slashes etc.
Definition: Paths.php:76
elgg_get_river_item_from_id($id)
Get river item from its ID.
Definition: river.php:194
_elgg_services()
Get the global service provider.
Definition: elgglib.php:1292
elgg_trigger_after_event($event, $object_type, $object=null)
Trigger an "After event" indicating a process has finished.
Definition: elgglib.php:553
_elgg_init()
Elgg&#39;s main init.
Definition: elgglib.php:1551
const ACCESS_PUBLIC
Definition: constants.php:14
_elgg_walled_garden_menu($hook, $type, $return_value, $params)
Adds home link to walled garden menu.
Definition: elgglib.php:1508
$handler
Definition: add.php:7
elgg_get_ordered_hook_handlers($hook, $type)
Returns an ordered array of hook handlers registered for $hook and $type.
Definition: elgglib.php:753
elgg_http_get_signed_url($url, $expires=false)
Signs provided URL with a SHA256 HMAC key.
Definition: elgglib.php:1084
elgg_trigger_event($event, $object_type, $object=null)
Definition: elgglib.php:513
_elgg_walled_garden_init()
Checks the status of the Walled Garden and forwards to a login page if required.
Definition: elgglib.php:1472
generate_action_token($timestamp)
Generate an action token.
Definition: actions.php:83
elgg_get_file_list($directory, $exceptions=[], $list=[], $extensions=null)
Returns a list of files in $directory.
Definition: elgglib.php:315
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$version
Definition: version.php:14
system_message($message)
Display a system message on next page load.
Definition: elgglib.php:356
elgg_get_loaded_js($location= 'head')
Get the JavaScript URLs that are loaded.
Definition: elgglib.php:193
elgg_unregister_event_handler($event, $object_type, $callback)
Unregisters a callback for an event.
Definition: elgglib.php:463
elgg_http_validate_signed_url($url)
Validates if the HMAC signature of the URL is valid.
Definition: elgglib.php:1094
$priority
elgg_unregister_js($name)
Unregister a JavaScript file.
Definition: elgglib.php:141
count_messages($register="")
Counts the number of messages, either globally or in a particular register.
Definition: elgglib.php:345
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:87
$access
Definition: save.php:18