Elgg  Version 3.0
/root/Elgg/engine/lib/views.php

Convenience function for generating a form from a view in a standard location.This function assumes that the body of the form is located at "forms/$action" and sets the action by default to "action/$action". Automatically wraps the forms/$action view with a <form> tag and inserts the anti-csrf security tokens.

This automatically appends elgg-form-action-name to the form's class. It replaces any slashes with dashes (blog/save becomes elgg-form-blog-save)

echo elgg_view_form('login');

This would assume a "login" form body to be at "forms/login" and would set the action of the form to "http://yoursite.com/action/login".

If elgg_view('forms/login') is: <input type="text" name="username"> <input type="password" name="password">

Then elgg_view_form('login') generates: <form action="http://yoursite.com/action/login" method="post"> ...security tokens... <input type="text" name="username"> <input type="password" name="password"> </form>

Parameters
string$actionThe name of the action. An action name does not include the leading "action/". For example, "login" is an action name.
array$form_vars$vars environment passed to the "input/form" view
  • 'ajax' bool If true, the form will be submitted with an Ajax request
array$body_vars$vars environment passed to the "forms/$action" view
Returns
string The complete form
<?php
function elgg_set_viewtype($viewtype = '') {
return _elgg_services()->views->setViewtype($viewtype);
}
function elgg_get_viewtype() {
return _elgg_services()->views->getViewtype();
}
return _elgg_services()->views->isValidViewtype($viewtype);
}
_elgg_services()->views->registerViewtypeFallback($viewtype);
}
return _elgg_services()->views->doesViewtypeFallback($viewtype);
}
}
}
function elgg_register_external_view($view, $cacheable = false) {
_elgg_services()->ajax->registerView($view);
if ($cacheable) {
_elgg_services()->views->registerCacheableView($view);
}
}
_elgg_services()->ajax->unregisterView($view);
}
_elgg_services()->views->setViewDir($view, $location, $viewtype);
}
function elgg_view_exists($view, $viewtype = '', $recurse = true) {
return _elgg_services()->views->viewExists($view, $viewtype, $recurse);
}
function elgg_list_views($viewtype = 'default') {
return _elgg_services()->views->listViews($viewtype);
}
function elgg_view($view, $vars = [], $viewtype = '') {
if (func_num_args() == 5) {
elgg_log(__FUNCTION__ . ' now has only 3 arguments. Update your usage.', 'ERROR');
$viewtype = func_get_arg(4);
}
return _elgg_services()->views->renderView($view, $vars, $viewtype);
}
function elgg_view_deprecated($view, array $vars, $suggestion, $version) {
return _elgg_services()->views->renderDeprecatedView($view, $vars, $suggestion, $version);
}
function elgg_extend_view($view, $view_extension, $priority = 501) {
_elgg_services()->views->extendView($view, $view_extension, $priority);
}
function elgg_unextend_view($view, $view_extension) {
return _elgg_services()->views->unextendView($view, $view_extension);
}
$list = _elgg_services()->views->getViewList($view);
unset($list[500]);
return $list;
}
return Minify_CSS_UriRewriter::prepend($css, $path);
}
function elgg_view_page($title, $body, $page_shell = 'default', $vars = []) {
$timer = _elgg_services()->timer;
if (!$timer->hasEnded(['build page'])) {
$timer->end(['build page']);
}
$timer->begin([__FUNCTION__]);
$params = [];
$params['identifier'] = _elgg_services()->request->getFirstUrlSegment();
$params['segments'] = _elgg_services()->request->getUrlSegments();
array_shift($params['segments']);
$page_shell = elgg_trigger_plugin_hook('shell', 'page', $params, $page_shell);
$system_messages = _elgg_services()->systemMessages;
$messages = null;
if ($system_messages->count()) {
$messages = $system_messages->dumpRegister();
if (isset($messages['error'])) {
// always make sure error is the first type
$errors = [
'error' => $messages['error']
];
unset($messages['error']);
$messages = array_merge($errors, $messages);
}
}
$vars['title'] = $title;
$vars['body'] = $body;
$vars['sysmessages'] = $messages;
$vars['page_shell'] = $page_shell;
// head has keys 'title', 'metas', 'links'
$vars['head'] = elgg_trigger_plugin_hook('head', 'page', $vars, $head_params);
$vars = elgg_trigger_plugin_hook('output:before', 'page', null, $vars);
$output = elgg_view("page/$page_shell", $vars);
// Allow plugins to modify the output
$timer->end([__FUNCTION__]);
return $output;
}
function elgg_view_resource($name, array $vars = []) {
$view = "resources/$name";
return _elgg_services()->views->renderView($view, $vars);
}
if (elgg_get_viewtype() !== 'default' && elgg_view_exists($view, 'default')) {
return _elgg_services()->views->renderView($view, $vars, 'default');
}
_elgg_services()->logger->error("The view $view is missing.");
// only works for default viewtype
throw new \Elgg\PageNotFoundException();
}
$params = [
'links' => [],
'metas' => [],
];
if (empty($title)) {
$params['title'] = _elgg_config()->sitename;
} else {
$params['title'] = $title . ' : ' . _elgg_config()->sitename;
}
$params['metas']['content-type'] = [
'http-equiv' => 'Content-Type',
'content' => 'text/html; charset=utf-8',
];
$params['metas']['description'] = [
'name' => 'description',
'content' => _elgg_config()->sitedescription
];
// https://developer.chrome.com/multidevice/android/installtohomescreen
$params['metas']['viewport'] = [
'name' => 'viewport',
'content' => 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0',
];
$params['metas']['mobile-web-app-capable'] = [
'name' => 'mobile-web-app-capable',
'content' => 'yes',
];
$params['metas']['apple-mobile-web-app-capable'] = [
'name' => 'apple-mobile-web-app-capable',
'content' => 'yes',
];
// RSS feed link
if (substr_count($url, '?')) {
$url .= "&view=rss";
} else {
$url .= "?view=rss";
}
$params['links']['rss'] = [
'rel' => 'alternative',
'type' => 'application/rss+xml',
'title' => 'RSS',
'href' => $url,
];
}
return $params;
}
function _elgg_views_prepare_favicon_links($hook, $type, $head_params, $params) {
$head_params['links']['apple-touch-icon'] = [
'rel' => 'apple-touch-icon',
'href' => elgg_get_simplecache_url('graphics/favicon-128.png'),
];
// favicons
$head_params['links']['icon-ico'] = [
'rel' => 'icon',
'href' => elgg_get_simplecache_url('graphics/favicon.ico'),
];
$head_params['links']['icon-vector'] = [
'rel' => 'icon',
'sizes' => '16x16 32x32 48x48 64x64 128x128',
'type' => 'image/svg+xml',
'href' => elgg_get_simplecache_url('graphics/favicon.svg'),
];
$head_params['links']['icon-16'] = [
'rel' => 'icon',
'sizes' => '16x16',
'type' => 'image/png',
'href' => elgg_get_simplecache_url('graphics/favicon-16.png'),
];
$head_params['links']['icon-32'] = [
'rel' => 'icon',
'sizes' => '32x32',
'type' => 'image/png',
'href' => elgg_get_simplecache_url('graphics/favicon-32.png'),
];
$head_params['links']['icon-64'] = [
'rel' => 'icon',
'sizes' => '64x64',
'type' => 'image/png',
'href' => elgg_get_simplecache_url('graphics/favicon-64.png'),
];
$head_params['links']['icon-128'] = [
'rel' => 'icon',
'sizes' => '128x128',
'type' => 'image/png',
'href' => elgg_get_simplecache_url('graphics/favicon-128.png'),
];
return $head_params;
}
function elgg_view_layout($layout_name, $vars = []) {
$timer = _elgg_services()->timer;
if (!$timer->hasEnded(['build page'])) {
$timer->end(['build page']);
}
$timer->begin([__FUNCTION__]);
// Help plugins transition without breaking them
switch ($layout_name) {
case 'content' :
$layout_name = 'default';
break;
case 'one_sidebar' :
$layout_name = 'default';
$vars['sidebar'] = elgg_extract('sidebar', $vars, '', false);
$vars['sidebar_alt'] = false;
break;
case 'one_column' :
$layout_name = 'default';
$vars['sidebar'] = false;
$vars['sidebar_alt'] = false;
break;
case 'two_sidebar' :
$layout_name = 'default';
$vars['sidebar'] = elgg_extract('sidebar', $vars, '', false);
$vars['sidebar_alt'] = elgg_extract('sidebar_alt', $vars, '', false);
break;
case 'default' :
$filter_id = elgg_extract('filter_id', $vars, 'filter');
$filter_context = elgg_extract('filter_value', $vars);
if (isset($filter_context) && $filter_id === 'filter') {
$vars['filter'] = elgg_get_filter_tabs($context, $filter_context, null, $vars);
$vars['filter_id'] = $filter_id;
$vars['filter_value'] = $filter_context;
}
break;
}
if (isset($vars['nav'])) {
// Temporary helper until all core views are updated
$vars['breadcrumbs'] = $vars['nav'];
unset($vars['nav']);
}
$vars['identifier'] = _elgg_services()->request->getFirstUrlSegment();
$vars['segments'] = _elgg_services()->request->getUrlSegments();
array_shift($vars['segments']);
$layout_name = elgg_trigger_plugin_hook('layout', 'page', $vars, $layout_name);
$vars['layout'] = $layout_name;
$layout_views = [
"page/layouts/$layout_name",
"page/layouts/default",
];
$output = '';
foreach ($layout_views as $layout_view) {
if (elgg_view_exists($layout_view)) {
$output = elgg_view($layout_view, $vars);
break;
}
}
$timer->end([__FUNCTION__]);
return $output;
}
$vars['title'] = elgg_extract('title', $vars, '');
if (!$vars['title'] && $vars['title'] !== false) {
$vars['title'] = elgg_echo($context);
}
// 1.8 supported 'filter_override'
if (isset($vars['filter_override'])) {
$vars['filter'] = $vars['filter_override'];
}
// register the default content filters
if (!isset($vars['filter']) && $context) {
$selected = elgg_extract('filter_context', $vars);
$vars['filter'] = elgg_get_filter_tabs($context, $selected, null, $vars);
$vars['filter_id'] = $context;
$vars['filter_value'] = $selected;
}
return $vars;
}
function elgg_view_menu($menu, array $vars = []) {
$menu_view = elgg_extract('menu_view', $vars);
unset($vars['menu_view']);
if (is_string($menu)) {
$menu = _elgg_services()->menus->getMenu($menu, $vars);
} elseif ($menu instanceof UnpreparedMenu) {
$menu = _elgg_services()->menus->prepareMenu($menu);
}
if (!$menu instanceof Menu) {
throw new \InvalidArgumentException('$menu must be a menu name, a Menu, or UnpreparedMenu');
}
$name = $menu->getName();
$params = $menu->getParams();
$views = [
"navigation/menu/$name",
'navigation/menu/default',
];
foreach ($views as $view) {
if (elgg_view_exists($view)) {
return elgg_view($view, $params);
}
}
}
function elgg_view_menu_item(\ElggMenuItem $item, array $vars = []) {
$vars = array_merge($item->getValues(), $vars);
$vars['class'] = elgg_extract_class($vars, ['elgg-menu-content']);
if ($item->getLinkClass()) {
$vars['class'][] = $item->getLinkClass();
}
if ($item->getHref() === false || $item->getHref() === null) {
$vars['class'][] = 'elgg-non-link';
}
if (!isset($vars['rel']) && !isset($vars['is_trusted'])) {
$vars['is_trusted'] = true;
}
if ($item->getConfirmText()) {
$vars['confirm'] = $item->getConfirmText();
}
return elgg_view('output/url', $vars);
}
function elgg_view_entity(\ElggEntity $entity, array $vars = []) {
'full_view' => true,
];
$vars = array_merge($defaults, $vars);
if (elgg_extract('register_rss_link', $vars, elgg_extract('full_view', $vars))) {
}
$vars['entity'] = $entity;
$entity_type = $entity->getType();
$entity_subtype = $entity->getSubtype();
$entity_views = [
elgg_extract('item_view', $vars, ''),
"$entity_type/$entity_subtype",
"$entity_type/default",
];
$contents = '';
foreach ($entity_views as $view) {
if (elgg_view_exists($view)) {
break;
}
}
// Marcus Povey 20090616 : Speculative and low impact approach for fixing #964
if ($vars['full_view']) {
$annotations = elgg_view_entity_annotations($entity, $vars['full_view']);
if ($annotations) {
$contents .= $annotations;
}
}
return $contents;
}
function elgg_view_entity_icon(\ElggEntity $entity, $size = 'medium', $vars = []) {
$vars['entity'] = $entity;
$vars['size'] = $size;
$entity_type = $entity->getType();
$subtype = $entity->getSubtype();
$contents = '';
if (elgg_view_exists("icon/$entity_type/$subtype")) {
$contents = elgg_view("icon/$entity_type/$subtype", $vars);
}
if (empty($contents) && elgg_view_exists("icon/$entity_type/default")) {
$contents = elgg_view("icon/$entity_type/default", $vars);
}
if (empty($contents)) {
$contents = elgg_view("icon/default", $vars);
}
return $contents;
}
'full_view' => true,
];
$vars = array_merge($defaults, $vars);
$vars['annotation'] = $annotation;
$name = $annotation->name;
if (empty($name)) {
return false;
}
$annotation_views = [
elgg_extract('item_view', $vars, ''),
"annotation/$name",
"annotation/default",
];
$contents = '';
foreach ($annotation_views as $view) {
if (elgg_view_exists($view)) {
break;
}
}
return $contents;
}
function elgg_view_entity_list($entities, array $vars = []) {
$offset = (int) get_input('offset', 0);
// list type can be passed as request parameter
$list_type = get_input('list_type', 'list');
'items' => $entities,
'list_class' => 'elgg-list-entity',
'full_view' => true,
'pagination' => true,
'list_type' => $list_type,
'list_type_toggle' => false,
'offset' => $offset,
'limit' => null,
];
$vars = array_merge($defaults, $vars);
if (!$vars["limit"] && !$vars["offset"]) {
// no need for pagination if listing is unlimited
$vars["pagination"] = false;
}
$view = "page/components/{$vars['list_type']}";
$view = 'page/components/list';
}
return elgg_view($view, $vars);
}
function elgg_view_annotation_list($annotations, array $vars = []) {
'items' => $annotations,
'offset' => null,
'limit' => null,
'list_class' => 'elgg-list-annotation elgg-annotation-list', // @todo remove elgg-annotation-list in Elgg 1.9
'full_view' => true,
'offset_key' => 'annoff',
];
$vars = array_merge($defaults, $vars);
if (!$vars["limit"] && !$vars["offset"]) {
// no need for pagination if listing is unlimited
$vars["pagination"] = false;
}
return elgg_view('page/components/list', $vars);
}
$entity_type = $entity->getType();
$annotations = elgg_trigger_plugin_hook('entity:annotate', $entity_type,
[
'entity' => $entity,
'full_view' => $full_view,
]
);
return $annotations;
}
function elgg_view_title($title, array $vars = []) {
$vars['title'] = $title;
return elgg_view('page/elements/title', $vars);
}
$view = 'output/friendlytime';
$vars = ['time' => $time];
$viewtype = elgg_view_exists($view) ? '' : 'default';
}
function elgg_view_comments($entity, $add_comment = true, array $vars = []) {
if (!$entity instanceof \ElggEntity) {
return false;
}
$vars['entity'] = $entity;
$vars['show_add_form'] = $add_comment;
$vars['class'] = elgg_extract('class', $vars, "{$entity->getSubtype()}-comments");
$output = elgg_trigger_plugin_hook('comments', $entity->getType(), $vars, false);
if ($output !== false) {
return $output;
}
return elgg_view('page/elements/comments', $vars);
}
$vars['image'] = $image;
$vars['body'] = $body;
return elgg_view('page/components/image_block', $vars);
}
function elgg_view_module($type, $title, $body, array $vars = []) {
$vars['type'] = $type;
$vars['title'] = $title;
$vars['body'] = $body;
return elgg_view('page/components/module', $vars);
}
function elgg_view_message($type, $body, array $vars = []) {
$vars['type'] = $type;
$vars['body'] = $body;
return elgg_view('page/components/message', $vars);
}
function elgg_view_river_item($item, array $vars = []) {
if (!($item instanceof \ElggRiverItem)) {
return '';
}
// checking default viewtype since some viewtypes do not have unique views per item (rss)
$view = $item->getView();
$subject = $item->getSubjectEntity();
$object = $item->getObjectEntity();
if (!$subject || !$object) {
// subject is disabled or subject/object deleted
return '';
}
if (elgg_extract('register_rss_link', $vars)) {
}
$vars['item'] = $item;
// create river view logic
$action = $item->action_type;
$river_views = [
elgg_extract('item_view', $vars, ''),
'river/item', // important for other viewtypes, e.g. "rss"
"river/{$type}/{$subtype}/{$action}",
"river/{$type}/{$subtype}/default",
"river/{$type}/{$action}",
"river/{$type}/default",
'river/elements/layout',
];
$contents = '';
foreach ($river_views as $view) {
if (elgg_view_exists($view)) {
break;
}
}
return $contents;
}
return _elgg_services()->forms->render($action, $form_vars, $body_vars);
}
function elgg_set_form_footer($footer = '') {
return _elgg_services()->forms->setFooter($footer);
}
return _elgg_services()->forms->getFooter();
}
function _elgg_split_vars(array $vars = [], array $prefixes = null) {
if (!isset($prefixes)) {
$prefixes = ['#'];
}
$return = [];
foreach ($vars as $key => $value) {
foreach ($prefixes as $prefix) {
if (substr($key, 0, 1) === $prefix) {
$key = substr($key, 1);
$return[$prefix][$key] = $value;
break;
} else {
$return[''][$key] = $value;
}
}
}
return $return;
}
function elgg_view_field(array $params = []) {
if (!empty($params['#html'])) {
return $params['#html'];
}
if (empty($params['#type'])) {
_elgg_services()->logger->error(__FUNCTION__ . '(): $params["#type"] is required.');
return '';
}
$input_type = $params['#type'];
if (!elgg_view_exists("input/$input_type")) {
return '';
}
$hidden_types = ['hidden', 'securitytoken'];
if (in_array($input_type, $hidden_types)) {
return elgg_view("input/$input_type", $params['']);
}
if (!$id) {
$id = "elgg-field-" . base_convert(mt_rand(), 10, 36);
$params['id'] = $id;
}
$make_special_checkbox_label = false;
if ($input_type == 'checkbox' && (isset($params['label']) || isset($params['#label']))) {
if (isset($params['#label']) && isset($params['label'])) {
$params['label_tag'] = 'div';
} else {
$params['#label'] = $label;
unset($params['label']);
// Single checkbox input view gets special treatment
// We don't want the field label to appear a checkbox without a label
$make_special_checkbox_label = true;
}
}
// Need to set defaults to prevent input keys with same name ending up in element vars if not provided
];
$params = array_merge($defaults, $params);
// first pass non-hash keys into both
$split_params = _elgg_split_vars($params);
// $vars passed to input/$input_name
$input_vars = $split_params[''];
// $vars passed to label, help and field wrapper views
$element_vars = array_merge($split_params[''], $split_params['#']);
// field input view needs this
$input_vars['input_type'] = $input_type;
// field views get more data
$element_vars['input_type'] = $input_type;
// wrap if present
$element_vars['label'] = elgg_view('elements/forms/label', $element_vars);
$element_vars['help'] = elgg_view('elements/forms/help', $element_vars);
if ($make_special_checkbox_label) {
$input_vars['label'] = $element_vars['label'];
$input_vars['label_tag'] = 'div';
unset($element_vars['label']);
}
$element_vars['input'] = elgg_view("elements/forms/input", $input_vars);
return elgg_view('elements/forms/field', $element_vars);
}
function elgg_view_tagcloud(array $options = []) {
$type = $subtype = '';
if (isset($options['type'])) {
$type = $options['type'];
}
if (isset($options['subtype'])) {
$subtype = $options['subtype'];
}
$tag_data = elgg_get_tags($options);
return elgg_view("output/tagcloud", [
'value' => $tag_data,
'type' => $type,
'subtype' => $subtype,
]);
}
function elgg_view_list_item($item, array $vars = []) {
if ($item instanceof \ElggEntity) {
return elgg_view_entity($item, $vars);
} else if ($item instanceof \ElggAnnotation) {
return elgg_view_annotation($item, $vars);
} else if ($item instanceof \ElggRiverItem) {
return elgg_view_river_item($item, $vars);
}
$view = elgg_extract('item_view', $vars);
$vars['item'] = $item;
return elgg_view($view, $vars);
}
return '';
}
function elgg_view_icon($name, $vars = []) {
if (empty($vars)) {
$vars = [];
}
if (is_string($vars)) {
$vars = ['class' => $vars];
}
if (!is_array($vars)) {
throw new \InvalidArgumentException('$vars needs to be a string or an array');
}
$vars['class'] = elgg_extract_class($vars, "elgg-icon-$name");
return elgg_view("output/icon", $vars);
}
_elgg_config()->_elgg_autofeed = true;
}
_elgg_config()->_elgg_autofeed = false;
}
function _elgg_has_rss_link() {
if (_elgg_config()->disable_rss) {
return false;
}
return (bool) _elgg_config()->_elgg_autofeed;
}
function autoregister_views($view_base, $folder, $ignored, $viewtype) {
return _elgg_services()->views->autoregisterViews($view_base, $folder, $viewtype);
}
if (preg_match('~[\.-]min\.~', $params['view'])) {
// bypass minification
return;
}
if ($type == 'js') {
if (_elgg_config()->simplecache_minify_js) {
return JSMin::minify($content);
}
} elseif ($type == 'css') {
if (_elgg_config()->simplecache_minify_css) {
$cssmin = new CSSmin();
return $cssmin->run($content);
}
}
}
$options = elgg_extract('compiler_options', $params, []);
return _elgg_services()->cssCompiler->compile($content, $options);
}
function _elgg_views_amd($hook, $type, $content, $params) {
$filter = new \Elgg\Amd\ViewFilter();
return $filter->filter($params['view'], $content);
}
elgg_set_http_header('X-Frame-Options: SAMEORIGIN');
}
$views = _elgg_services()->views;
if ($views->viewIsExtended($view) || $views->viewHasHookHandlers($view)) {
return true;
}
// check location
if (0 === strpos($path, '/') || preg_match('~^([A-Za-z]\:)?\\\\~', $path)) {
// absolute path
$expected_path = $path;
} else {
// relative path
$expected_path = Paths::elgg() . "views/$viewtype/" . ltrim($path, '/\\');
}
$view_path = $views->findViewFile($view, $viewtype);
return realpath($view_path) !== realpath($expected_path);
}
function elgg_views_boot() {
_elgg_services()->viewCacher->registerCoreViews();
// jQuery and UI must come before require. See #9024
elgg_register_js('jquery', elgg_get_simplecache_url('jquery.js'), 'head');
elgg_load_js('jquery');
elgg_register_js('jquery-ui', elgg_get_simplecache_url('jquery-ui.js'), 'head');
elgg_load_js('jquery-ui');
elgg_register_js('elgg.require_config', elgg_get_simplecache_url('elgg/require_config.js'), 'head');
elgg_load_js('elgg.require_config');
elgg_register_js('require', elgg_get_simplecache_url('require.js'), 'head');
elgg_load_js('require');
elgg_register_js('elgg', elgg_get_simplecache_url('elgg.js'), 'head');
elgg_load_js('elgg');
elgg_register_css('font-awesome', elgg_get_simplecache_url('font-awesome/css/all.min.css'));
elgg_load_css('font-awesome');
elgg_load_css('elgg');
elgg_extend_view('elgg.css', 'lightbox/elgg-colorbox-theme/colorbox.css');
elgg_define_js('jquery.ui.autocomplete.html', [
'deps' => ['jquery-ui'],
]);
elgg_register_js('elgg.avatar_cropper', elgg_get_simplecache_url('elgg/ui.avatar_cropper.js'));
// @deprecated 2.2
elgg_register_js('elgg.ui.river', elgg_get_simplecache_url('elgg/ui.river.js'));
elgg_register_js('jquery.imgareaselect', elgg_get_simplecache_url('jquery.imgareaselect.js'));
elgg_register_css('jquery.imgareaselect', elgg_get_simplecache_url('jquery.imgareaselect.css'));
elgg_register_css('jquery.treeview', elgg_get_simplecache_url('jquery-treeview/jquery.treeview.css'));
elgg_define_js('jquery.treeview', [
'src' => elgg_get_simplecache_url('jquery-treeview/jquery.treeview.js'),
'exports' => 'jQuery.fn.treeview',
'deps' => ['jquery'],
]);
elgg_register_ajax_view('languages.js');
// pre-process CSS regardless of simplecache
elgg_register_plugin_hook_handler('cache:generate', 'css', '_elgg_views_preprocess_css');
elgg_register_plugin_hook_handler('simplecache:generate', 'css', '_elgg_views_preprocess_css');
elgg_register_plugin_hook_handler('simplecache:generate', 'js', '_elgg_views_amd');
elgg_register_plugin_hook_handler('cache:generate', 'js', '_elgg_views_amd');
elgg_register_plugin_hook_handler('simplecache:generate', 'css', '_elgg_views_minify');
elgg_register_plugin_hook_handler('simplecache:generate', 'js', '_elgg_views_minify');
elgg_register_plugin_hook_handler('output:before', 'page', '_elgg_views_send_header_x_frame_options');
elgg_register_plugin_hook_handler('view_vars', 'elements/forms/help', '_elgg_views_file_help_upload_limit');
// registered with high priority for BC
// prior to 2.2 registration used to take place in _elgg_views_prepare_head() before the hook was triggered
elgg_register_plugin_hook_handler('head', 'page', '_elgg_views_prepare_favicon_links', 1);
// set default icon sizes - can be overridden with plugin
if (!_elgg_config()->hasValue('icon_sizes')) {
'topbar' => ['w' => 16, 'h' => 16, 'square' => true, 'upscale' => true],
'tiny' => ['w' => 25, 'h' => 25, 'square' => true, 'upscale' => true],
'small' => ['w' => 40, 'h' => 40, 'square' => true, 'upscale' => true],
'medium' => ['w' => 100, 'h' => 100, 'square' => true, 'upscale' => true],
'large' => ['w' => 200, 'h' => 200, 'square' => true, 'upscale' => true],
'master' => ['w' => 10240, 'h' => 10240, 'square' => false, 'upscale' => false, 'crop' => false],
];
elgg_set_config('icon_sizes', $icon_sizes);
}
// Configure lightbox
elgg_register_plugin_hook_handler('elgg.data', 'site', '_elgg_set_lightbox_config');
}
$language = _elgg_config()->language;
if (!$language) {
$language = 'en';
}
return [
'elgg.data' => (object) elgg_trigger_plugin_hook('elgg.data', 'site', null, []),
'elgg.version' => elgg_get_version(),
'elgg.release' => elgg_get_version(true),
'elgg.config.wwwroot' => elgg_get_site_url(),
// refresh token 3 times during its lifetime (in microseconds 1000 * 1/3)
'elgg.security.interval' => (int) elgg()->csrf->getActionTokenTimeout() * 333,
'elgg.config.language' => $language,
];
}
$data = elgg_trigger_plugin_hook('elgg.data', 'page', null, []);
if (!is_array($data)) {
elgg_log('"elgg.data" plugin hook handlers must return an array. Returned ' . gettype($data) . '.', 'ERROR');
$data = [];
}
$elgg = [
'config' => [
'lastcache' => (int) _elgg_config()->lastcache,
'viewtype' => elgg_get_viewtype(),
'simplecache_enabled' => (int) elgg_is_simplecache_enabled(),
'current_language' => get_current_language(),
],
'security' => [
'token' => [
'__elgg_ts' => $ts = time(),
'__elgg_token' => generate_action_token($ts),
],
],
'session' => [
'user' => null,
'token' => _elgg_services()->session->get('__elgg_session'),
],
'_data' => (object) $data,
];
if (_elgg_config()->elgg_load_sync_code) {
$elgg['config']['load_sync_code'] = true;
}
if ($page_owner instanceof ElggEntity) {
$elgg['page_owner'] = $page_owner->toObject();
}
if ($user instanceof ElggUser) {
$user_object = $user->toObject();
$user_object->admin = $user->isAdmin();
$elgg['session']['user'] = $user_object;
}
return $elgg;
}
$current_view_type = null;
if ($viewtype) {
$current_view_type = elgg_get_viewtype();
}
$ret = elgg_view($view, $vars);
if (isset($current_view_type)) {
elgg_set_viewtype($current_view_type);
}
return $ret;
}
function _elgg_set_lightbox_config($hook, $type, $return, $params) {
$return['lightbox'] = [
'current' => elgg_echo('js:lightbox:current', ['{current}', '{total}']),
'previous' => elgg_view_icon('caret-left'),
'next' => elgg_view_icon('caret-right'),
'close' => elgg_view_icon('times'),
'opacity' => 0.5,
'maxWidth' => '990px',
'maxHeight' => '990px',
'initialWidth' => '300px',
'initialHeight' => '300px',
];
return $return;
}
$return = $hook->getValue();
if (elgg_extract('input_type', $return) !== 'file') {
return;
}
if (!elgg_extract('show_upload_limit', $return, true)) {
return;
}
$help = elgg_extract('help', $return, '');
// Get post_max_size and upload_max_filesize
// Determine the correct value
$help .= ' ' . elgg_echo('input:file:upload_limit', [elgg_format_bytes($max_upload)]);
$return['help'] = trim($help);
return $return;
}
function _elgg_map_icon_glyph_class(array $classes, $map_sprites = true) {
// these 'old' Elgg 1.x sprite icons will be converted to the FontAwesome version
$legacy_sprites = [
"arrow-two-head" => "arrows-h",
"attention" => "exclamation-triangle",
"cell-phone" => "mobile",
"checkmark" => "check",
"clip" => "paperclip",
"cursor-drag-arrow" => "arrows",
"drag-arrow" => "arrows", // 'old' admin sprite
"delete-alt" => "times-circle",
"delete" => "times",
"facebook" => "facebook-square",
"grid" => "th",
"hover-menu" => "caret-down",
"info" => "info-circle",
"lock-closed" => "lock",
"lock-open" => "unlock",
"mail" => "envelope-o",
"mail-alt" => "envelope",
"print-alt" => "print",
"push-pin" => "thumb-tack",
"push-pin-alt" => "thumb-tack",
"redo" => "share",
"round-arrow-left" => "arrow-circle-left",
"round-arrow-right" => "arrow-circle-right",
"round-checkmark" => "check-circle",
"round-minus" => "minus-circle",
"round-plus" => "plus-circle",
"rss" => "rss-square",
"search-focus" => "search",
"settings" => "wrench",
"settings-alt" => "cog",
"share" => "share-alt-square",
"shop-cart" => "shopping-cart",
"speech-bubble" => "comment",
"speech-bubble-alt" => "comments",
"star-alt" => "star",
"star-empty" => "star-o",
"thumbs-down-alt" => "thumbs-down",
"thumbs-up-alt" => "thumbs-up",
"trash" => "trash-o",
"twitter" => "twitter-square",
"undo" => "reply",
"video" => "film"
];
$fa5 = [
'address-book-o' => ['address-book', 'far'],
'address-card-o' => ['address-card', 'far'],
'area-chart' => ['chart-area', 'fas'],
'arrow-circle-o-down' => ['arrow-alt-circle-down', 'far'],
'arrow-circle-o-left' => ['arrow-alt-circle-left', 'far'],
'arrow-circle-o-right' => ['arrow-alt-circle-right', 'far'],
'arrow-circle-o-up' => ['arrow-alt-circle-up', 'far'],
'arrows-alt' => ['expand-arrows-alt', 'fas'],
'arrows-h' => ['arrows-alt-h', 'fas'],
'arrows-v' => ['arrows-alt-v', 'fas'],
'arrows' => ['arrows-alt', 'fas'],
'asl-interpreting' => ['american-sign-language-interpreting', 'fas'],
'automobile' => ['car', 'fas'],
'bank' => ['university', 'fas'],
'bar-chart-o' => ['chart-bar', 'far'],
'bar-chart' => ['chart-bar', 'far'],
'bathtub' => ['bath', 'fas'],
'battery-0' => ['battery-empty', 'fas'],
'battery-1' => ['battery-quarter', 'fas'],
'battery-2' => ['battery-half', 'fas'],
'battery-3' => ['battery-three-quarters', 'fas'],
'battery-4' => ['battery-full', 'fas'],
'battery' => ['battery-full', 'fas'],
'bell-o' => ['bell', 'far'],
'bell-slash-o' => ['bell-slash', 'far'],
'bitbucket-square' => ['bitbucket', 'fab'],
'bitcoin' => ['btc', 'fab'],
'bookmark-o' => ['bookmark', 'far'],
'building-o' => ['building', 'far'],
'cab' => ['taxi', 'fas'],
'calendar-check-o' => ['calendar-check', 'far'],
'calendar-minus-o' => ['calendar-minus', 'far'],
'calendar-o' => ['calendar', 'far'],
'calendar-plus-o' => ['calendar-plus', 'far'],
'calendar-times-o' => ['calendar-times', 'far'],
'calendar' => ['calendar-alt', 'fas'],
'caret-square-o-down' => ['caret-square-down', 'far'],
'caret-square-o-left' => ['caret-square-left', 'far'],
'caret-square-o-right' => ['caret-square-right', 'far'],
'caret-square-o-up' => ['caret-square-up', 'far'],
'cc' => ['closed-captioning', 'far'],
'chain-broken' => ['unlink', 'fas'],
'chain' => ['link', 'fas'],
'check-circle-o' => ['check-circle', 'far'],
'check-square-o' => ['check-square', 'far'],
'circle-o-notch' => ['circle-notch', 'fas'],
'circle-o' => ['circle', 'far'],
'circle-thin' => ['circle', 'far'],
'clock-o' => ['clock', 'far'],
'close' => ['times', 'fas'],
'cloud-download' => ['cloud-download-alt', 'fas'],
'cloud-upload' => ['cloud-upload-alt', 'fas'],
'cny' => ['yen-sign', 'fas'],
'code-fork' => ['code-branch', 'fas'],
'comment-o' => ['comment', 'far'],
'commenting-o' => ['comment-alt', 'far'],
'commenting' => ['comment-alt', 'fas'],
'comments-o' => ['comments', 'far'],
'credit-card-alt' => ['credit-card', 'fas'],
'cutlery' => ['utensils', 'fas'],
'dashboard' => ['tachometer-alt', 'fas'],
'deafness' => ['deaf', 'fas'],
'dedent' => ['outdent', 'fas'],
'diamond' => ['gem', 'far'],
'dollar' => ['dollar-sign', 'fas'],
'dot-circle-o' => ['dot-circle', 'far'],
'drivers-license-o' => ['id-card', 'far'],
'drivers-license' => ['id-card', 'fas'],
'eercast' => ['sellcast', 'fab'],
'envelope-o' => ['envelope', 'far'],
'envelope-open-o' => ['envelope-open', 'far'],
'eur' => ['euro-sign', 'fas'],
'euro' => ['euro-sign', 'fas'],
'exchange' => ['exchange-alt', 'fas'],
'external-link-square' => ['external-link-square-alt', 'fas'],
'external-link' => ['external-link-alt', 'fas'],
'eyedropper' => ['eye-dropper', 'fas'],
'fa' => ['font-awesome', 'fab'],
'facebook-f' => ['facebook-f', 'fab'],
'facebook-official' => ['facebook', 'fab'],
'facebook' => ['facebook-f', 'fab'],
'feed' => ['rss', 'fas'],
'file-archive-o' => ['file-archive', 'far'],
'file-audio-o' => ['file-audio', 'far'],
'file-code-o' => ['file-code', 'far'],
'file-excel-o' => ['file-excel', 'far'],
'file-image-o' => ['file-image', 'far'],
'file-movie-o' => ['file-video', 'far'],
'file-o' => ['file', 'far'],
'file-pdf-o' => ['file-pdf', 'far'],
'file-photo-o' => ['file-image', 'far'],
'file-picture-o' => ['file-image', 'far'],
'file-powerpoint-o' => ['file-powerpoint', 'far'],
'file-sound-o' => ['file-audio', 'far'],
'file-text-o' => ['file-alt', 'far'],
'file-text' => ['file-alt', 'fas'],
'file-video-o' => ['file-video', 'far'],
'file-word-o' => ['file-word', 'far'],
'file-zip-o' => ['file-archive', 'far'],
'files-o' => ['copy', 'far'],
'flag-o' => ['flag', 'far'],
'flash' => ['bolt', 'fas'],
'floppy-o' => ['save', 'far'],
'folder-o' => ['folder', 'far'],
'folder-open-o' => ['folder-open', 'far'],
'frown-o' => ['frown', 'far'],
'futbol-o' => ['futbol', 'far'],
'gbp' => ['pound-sign', 'fas'],
'ge' => ['empire', 'fab'],
'gear' => ['cog', 'fas'],
'gears' => ['cogs', 'fas'],
'gittip' => ['gratipay', 'fab'],
'glass' => ['glass-martini', 'fas'],
'google-plus-circle' => ['google-plus', 'fab'],
'google-plus-official' => ['google-plus', 'fab'],
'google-plus' => ['google-plus-g', 'fab'],
'group' => ['users', 'fas'],
'hand-grab-o' => ['hand-rock', 'far'],
'hand-lizard-o' => ['hand-lizard', 'far'],
'hand-o-down' => ['hand-point-down', 'far'],
'hand-o-left' => ['hand-point-left', 'far'],
'hand-o-right' => ['hand-point-right', 'far'],
'hand-o-up' => ['hand-point-up', 'far'],
'hand-paper-o' => ['hand-paper', 'far'],
'hand-peace-o' => ['hand-peace', 'far'],
'hand-pointer-o' => ['hand-pointer', 'far'],
'hand-rock-o' => ['hand-rock', 'far'],
'hand-scissors-o' => ['hand-scissors', 'far'],
'hand-spock-o' => ['hand-spock', 'far'],
'hand-stop-o' => ['hand-paper', 'far'],
'handshake-o' => ['handshake', 'far'],
'hard-of-hearing' => ['deaf', 'fas'],
'hdd-o' => ['hdd', 'far'],
'header' => ['heading', 'fas'],
'heart-o' => ['heart', 'far'],
'hospital-o' => ['hospital', 'far'],
'hotel' => ['bed', 'fas'],
'hourglass-1' => ['hourglass-start', 'fas'],
'hourglass-2' => ['hourglass-half', 'fas'],
'hourglass-3' => ['hourglass-end', 'fas'],
'hourglass-o' => ['hourglass', 'far'],
'id-card-o' => ['id-card', 'far'],
'ils' => ['shekel-sign', 'fas'],
'image' => ['image', 'far'],
'inr' => ['rupee-sign', 'fas'],
'institution' => ['university', 'fas'],
'intersex' => ['transgender', 'fas'],
'jpy' => ['yen-sign', 'fas'],
'keyboard-o' => ['keyboard', 'far'],
'krw' => ['won-sign', 'fas'],
'legal' => ['gavel', 'fas'],
'lemon-o' => ['lemon', 'far'],
'level-down' => ['level-down-alt', 'fas'],
'level-up' => ['level-up-alt', 'fas'],
'life-bouy' => ['life-ring', 'far'],
'life-buoy' => ['life-ring', 'far'],
'life-saver' => ['life-ring', 'far'],
'lightbulb-o' => ['lightbulb', 'far'],
'line-chart' => ['chart-line', 'fas'],
'linkedin-square' => ['linkedin', 'fab'],
'linkedin' => ['linkedin-in', 'fab'],
'long-arrow-down' => ['long-arrow-alt-down', 'fas'],
'long-arrow-left' => ['long-arrow-alt-left', 'fas'],
'long-arrow-right' => ['long-arrow-alt-right', 'fas'],
'long-arrow-up' => ['long-arrow-alt-up', 'fas'],
'mail-forward' => ['share', 'fas'],
'mail-reply-all' => ['reply-all', 'fas'],
'mail-reply' => ['reply', 'fas'],
'map-marker' => ['map-marker-alt', 'fas'],
'map-o' => ['map', 'far'],
'meanpath' => ['font-awesome', 'fab'],
'meh-o' => ['meh', 'far'],
'minus-square-o' => ['minus-square', 'far'],
'mobile-phone' => ['mobile-alt', 'fas'],
'mobile' => ['mobile-alt', 'fas'],
'money' => ['money-bill-alt', 'far'],
'moon-o' => ['moon', 'far'],
'mortar-board' => ['graduation-cap', 'fas'],
'navicon' => ['bars', 'fas'],
'newspaper-o' => ['newspaper', 'far'],
'paper-plane-o' => ['paper-plane', 'far'],
'paste' => ['clipboard', 'far'],
'pause-circle-o' => ['pause-circle', 'far'],
'pencil-square-o' => ['edit', 'far'],
'pencil-square' => ['pen-square', 'fas'],
'pencil' => ['pencil-alt', 'fas'],
'photo' => ['image', 'far'],
'picture-o' => ['image', 'far'],
'pie-chart' => ['chart-pie', 'fas'],
'play-circle-o' => ['play-circle', 'far'],
'plus-square-o' => ['plus-square', 'far'],
'question-circle-o' => ['question-circle', 'far'],
'ra' => ['rebel', 'fab'],
'refresh' => ['sync', 'fas'],
'remove' => ['times', 'fas'],
'reorder' => ['bars', 'fas'],
'repeat' => ['redo', 'fas'],
'resistance' => ['rebel', 'fab'],
'rmb' => ['yen-sign', 'fas'],
'rotate-left' => ['undo', 'fas'],
'rotate-right' => ['redo', 'fas'],
'rouble' => ['ruble-sign', 'fas'],
'rub' => ['ruble-sign', 'fas'],
'ruble' => ['ruble-sign', 'fas'],
'rupee' => ['rupee-sign', 'fas'],
's15' => ['bath', 'fas'],
'scissors' => ['cut', 'fas'],
'send-o' => ['paper-plane', 'far'],
'send' => ['paper-plane', 'fas'],
'share-square-o' => ['share-square', 'far'],
'shekel' => ['shekel-sign', 'fas'],
'sheqel' => ['shekel-sign', 'fas'],
'shield' => ['shield-alt', 'fas'],
'sign-in' => ['sign-in-alt', 'fas'],
'sign-out' => ['sign-out-alt', 'fas'],
'signing' => ['sign-language', 'fas'],
'sliders' => ['sliders-h', 'fas'],
'smile-o' => ['smile', 'far'],
'snowflake-o' => ['snowflake', 'far'],
'soccer-ball-o' => ['futbol', 'far'],
'sort-alpha-asc' => ['sort-alpha-down', 'fas'],
'sort-alpha-desc' => ['sort-alpha-up', 'fas'],
'sort-amount-asc' => ['sort-amount-down', 'fas'],
'sort-amount-desc' => ['sort-amount-up', 'fas'],
'sort-asc' => ['sort-up', 'fas'],
'sort-desc' => ['sort-down', 'fas'],
'sort-numeric-asc' => ['sort-numeric-down', 'fas'],
'sort-numeric-desc' => ['sort-numeric-up', 'fas'],
'spoon' => ['utensil-spoon', 'fas'],
'square-o' => ['square', 'far'],
'star-half-empty' => ['star-half', 'far'],
'star-half-full' => ['star-half', 'far'],
'star-half-o' => ['star-half', 'far'],
'star-o' => ['star', 'far'],
'sticky-note-o' => ['sticky-note', 'far'],
'stop-circle-o' => ['stop-circle', 'far'],
'sun-o' => ['sun', 'far'],
'support' => ['life-ring', 'far'],
'tablet' => ['tablet-alt', 'fas'],
'tachometer' => ['tachometer-alt', 'fas'],
'television' => ['tv', 'fas'],
'thermometer-0' => ['thermometer-empty', 'fas'],
'thermometer-1' => ['thermometer-quarter', 'fas'],
'thermometer-2' => ['thermometer-half', 'fas'],
'thermometer-3' => ['thermometer-three-quarters', 'fas'],
'thermometer-4' => ['thermometer-full', 'fas'],
'thermometer' => ['thermometer-full', 'fas'],
'thumb-tack' => ['thumbtack', 'fas'],
'thumbs-o-down' => ['thumbs-down', 'far'],
'thumbs-o-up' => ['thumbs-up', 'far'],
'ticket' => ['ticket-alt', 'fas'],
'times-circle-o' => ['times-circle', 'far'],
'times-rectangle-o' => ['window-close', 'far'],
'times-rectangle' => ['window-close', 'fas'],
'toggle-down' => ['caret-square-down', 'far'],
'toggle-left' => ['caret-square-left', 'far'],
'toggle-right' => ['caret-square-right', 'far'],
'toggle-up' => ['caret-square-up', 'far'],
'trash-o' => ['trash-alt', 'far'],
'trash' => ['trash-alt', 'fas'],
'try' => ['lira-sign', 'fas'],
'turkish-lira' => ['lira-sign', 'fas'],
'unsorted' => ['sort', 'fas'],
'usd' => ['dollar-sign', 'fas'],
'user-circle-o' => ['user-circle', 'far'],
'user-o' => ['user', 'far'],
'vcard-o' => ['address-card', 'far'],
'vcard' => ['address-card', 'fas'],
'video-camera' => ['video', 'fas'],
'vimeo' => ['vimeo-v', 'fab'],
'volume-control-phone' => ['phone-volume', 'fas'],
'warning' => ['exclamation-triangle', 'fas'],
'wechat' => ['weixin', 'fab'],
'wheelchair-alt' => ['accessible-icon', 'fab'],
'window-close-o' => ['window-close', 'far'],
'won' => ['won-sign', 'fas'],
'y-combinator-square' => ['hacker-news', 'fab'],
'yc-square' => ['hacker-news', 'fab'],
'yc' => ['y-combinator', 'fab'],
'yen' => ['yen-sign', 'fas'],
'youtube-play' => ['youtube', 'fab'],
'youtube-square' => ['youtube', 'fab'],
];
$brands = [
'500px',
'accessible-icon',
'accusoft',
'adn',
'adversal',
'affiliatetheme',
'algolia',
'amazon',
'amazon-pay',
'amilia',
'android',
'angellist',
'angrycreative',
'angular',
'app-store',
'app-store-ios',
'apper',
'apple',
'apple-pay',
'asymmetrik',
'audible',
'autoprefixer',
'avianex',
'aviato',
'aws',
'bandcamp',
'behance',
'behance-square',
'bimobject',
'bitbucket',
'bitcoin',
'bity',
'black-tie',
'blackberry',
'blogger',
'blogger-b',
'bluetooth',
'bluetooth-b',
'btc',
'buromobelexperte',
'buysellads',
'cc-amazon-pay',
'cc-amex',
'cc-apple-pay',
'cc-diners-club',
'cc-discover',
'cc-jcb',
'cc-mastercard',
'cc-paypal',
'cc-stripe',
'cc-visa',
'centercode',
'chrome',
'cloudscale',
'cloudsmith',
'cloudversify',
'codepen',
'codiepie',
'connectdevelop',
'contao',
'cpanel',
'creative-commons',
'css3',
'css3-alt',
'cuttlefish',
'd-and-d',
'dashcube',
'delicious',
'deploydog',
'deskpro',
'deviantart',
'digg',
'digital-ocean',
'discord',
'discourse',
'dochub',
'docker',
'draft2digital',
'dribbble',
'dribbble-square',
'dropbox',
'drupal',
'dyalog',
'earlybirds',
'edge',
'elementor',
'ember',
'empire',
'envira',
'erlang',
'ethereum',
'etsy',
'expeditedssl',
'facebook',
'facebook-f',
'facebook-messenger',
'facebook-square',
'firefox',
'first-order',
'firstdraft',
'flickr',
'flipboard',
'fly',
'font-awesome',
'font-awesome-alt',
'font-awesome-flag',
'fonticons',
'fonticons-fi',
'fort-awesome',
'fort-awesome-alt',
'forumbee',
'foursquare',
'free-code-camp',
'freebsd',
'get-pocket',
'gg',
'gg-circle',
'git',
'git-square',
'github',
'github-alt',
'github-square',
'gitkraken',
'gitlab',
'gitter',
'glide',
'glide-g',
'gofore',
'goodreads',
'goodreads-g',
'google',
'google-drive',
'google-play',
'google-plus',
'google-plus-g',
'google-plus-square',
'google-wallet',
'gratipay',
'grav',
'gripfire',
'grunt',
'gulp',
'hacker-news',
'hacker-news-square',
'hips',
'hire-a-helper',
'hooli',
'hotjar',
'houzz',
'html5',
'hubspot',
'imdb',
'instagram',
'internet-explorer',
'ioxhost',
'itunes',
'itunes-note',
'jenkins',
'joget',
'joomla',
'js',
'js-square',
'jsfiddle',
'keycdn',
'kickstarter',
'kickstarter-k',
'korvue',
'laravel',
'lastfm',
'lastfm-square',
'leanpub',
'less',
'line',
'linkedin',
'linkedin-in',
'linode',
'linux',
'lyft',
'magento',
'maxcdn',
'medapps',
'medium',
'medium-m',
'medrt',
'meetup',
'microsoft',
'mix',
'mixcloud',
'mizuni',
'modx',
'monero',
'napster',
'nintendo-switch',
'node',
'node-js',
'npm',
'ns8',
'nutritionix',
'odnoklassniki',
'odnoklassniki-square',
'opencart',
'openid',
'opera',
'optin-monster',
'osi',
'page4',
'pagelines',
'palfed',
'patreon',
'paypal',
'periscope',
'phabricator',
'phoenix-framework',
'php',
'pied-piper',
'pied-piper-alt',
'pied-piper-pp',
'pinterest',
'pinterest-p',
'pinterest-square',
'playstation',
'product-hunt',
'pushed',
'python',
'qq',
'quinscape',
'quora',
'ravelry',
'react',
'rebel',
'red-river',
'reddit',
'reddit-alien',
'reddit-square',
'rendact',
'renren',
'replyd',
'resolving',
'rocketchat',
'rockrms',
'safari',
'sass',
'schlix',
'scribd',
'searchengin',
'sellcast',
'sellsy',
'servicestack',
'shirtsinbulk',
'simplybuilt',
'sistrix',
'skyatlas',
'skype',
'slack',
'slack-hash',
'slideshare',
'snapchat',
'snapchat-ghost',
'snapchat-square',
'soundcloud',
'speakap',
'spotify',
'stack-exchange',
'stack-overflow',
'staylinked',
'steam',
'steam-square',
'steam-symbol',
'sticker-mule',
'strava',
'stripe',
'stripe-s',
'studiovinari',
'stumbleupon',
'stumbleupon-circle',
'superpowers',
'supple',
'telegram',
'telegram-plane',
'tencent-weibo',
'themeisle',
'trello',
'tripadvisor',
'tumblr',
'tumblr-square',
'twitch',
'twitter',
'twitter-square',
'typo3',
'uber',
'uikit',
'uniregistry',
'untappd',
'usb',
'ussunnah',
'vaadin',
'viacoin',
'viadeo',
'viadeo-square',
'viber',
'vimeo',
'vimeo-square',
'vimeo-v',
'vine',
'vk',
'vnv',
'vuejs',
'weibo',
'weixin',
'whatsapp',
'whatsapp-square',
'whmcs',
'wikipedia-w',
'windows',
'wordpress',
'wordpress-simple',
'wpbeginner',
'wpexplorer',
'wpforms',
'xbox',
'xing',
'xing-square',
'y-combinator',
'yahoo',
'yandex',
'yandex-international',
'yelp',
'yoast',
'youtube',
'youtube-square',
];
foreach ($classes as $index => $c) {
if ($c === 'fa') {
// FontAwesome 5 deprecated the use of fa prefix in favour of fas, far and fab
unset($classes[$index]);
continue;
}
if (preg_match_all('/^elgg-icon-(.+)/i', $c)) {
// convert
$base_icon = preg_replace('/^elgg-icon-(.+)/i', '$1', $c);
if ($map_sprites) {
if (strpos($base_icon, '-hover') !== false) {
$base_icon = str_replace('-hover', '', $base_icon);
$classes[] = 'elgg-state';
$classes[] = 'elgg-state-notice';
}
$base_icon = elgg_extract($base_icon, $legacy_sprites, $base_icon);
}
// map solid/regular/light iconnames to correct classes
if (preg_match('/.*-solid$/', $base_icon)) {
$base_icon = preg_replace('/(.*)-solid$/', '$1', $base_icon);
$classes[] = 'fas';
} elseif (preg_match('/.*-regular$/', $base_icon)) {
$base_icon = preg_replace('/(.*)-regular$/', '$1', $base_icon);
$classes[] = 'far';
} elseif (preg_match('/.*-light$/', $base_icon)) {
// currently light is only available in FontAwesome 5 Pro
$base_icon = preg_replace('/(.*)-light$/', '$1', $base_icon);
$classes[] = 'fal';
} else {
if (array_key_exists($base_icon, $fa5)) {
$classes[] = $fa5[$base_icon][1];
$base_icon = $fa5[$base_icon][0];
} else if (in_array($base_icon, $brands)) {
$classes[] = 'fab';
} else {
$classes[] = 'fas';
}
}
$classes[] = "fa-{$base_icon}";
}
}
$classes = array_unique($classes);
return elgg_trigger_plugin_hook('classes', 'icon', null, $classes);
}