本文整理汇总了PHP中elgg_format_element函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_format_element函数的具体用法?PHP elgg_format_element怎么用?PHP elgg_format_element使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_format_element函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wrap_list_view_hook
/**
* Wrap list views into a container that can be manipulated
*
* @param string $hook "view"
* @param string $type "page/components/list" or "page/components/gallery"
* @param string $view View
* @param array $params Hook params
* @return string Wrapped view
*/
function wrap_list_view_hook($hook, $type, $view, $params)
{
$viewtype = elgg_extract('viewtype', $params, 'default');
if ($viewtype !== 'default') {
return;
}
$vars = elgg_extract('vars', $params);
$pagination = elgg_extract('pagination', $vars, false);
$pagination_type = elgg_extract('pagination_type', $vars, elgg_get_plugin_setting('pagination_type', 'hypeLists'));
if (!$pagination || !$pagination_type) {
return $view;
}
$no_results = elgg_extract('no_results', $vars, '');
$no_results_str = $no_results instanceof Closure ? $no_results() : $no_results;
$list_classes = $type == 'page/components/gallery' ? ['elgg-gallery'] : ['elgg-list'];
if (isset($vars['list_class'])) {
$list_classes[] = $vars['list_class'];
}
$list_id = isset($vars['list_id']) ? $vars['list_id'] : '';
if (!$list_id) {
$list_id = md5(serialize(array(elgg_extract('container_class', $vars), implode(' ', $list_classes), elgg_extract('item_class', $vars), $no_results_str, elgg_extract('pagination', $vars), elgg_extract('base_url', $vars))));
}
$container_class = array_filter(array('elgg-list-container', elgg_extract('container_class', $vars)));
$wrapper_params = array('class' => implode(' ', $container_class), 'data-list-id' => $list_id, 'data-base-url' => elgg_extract('base_url', $vars), 'data-count' => elgg_extract('count', $vars, 0), 'data-pagination' => $pagination_type, 'data-pagination-position' => elgg_extract('position', $vars, $pagination_type === 'infinite' ? 'both' : 'after'), 'data-pagination-num-pages' => (int) elgg_extract('num_pages', $vars, 10), 'data-text-no-results' => $no_results_str, 'data-limit' => elgg_extract('limit', $vars, 10), 'data-offset' => elgg_extract('offset', $vars, 0), 'data-offset-key' => elgg_extract('offset_key', $vars, 'offset'), 'data-lazy-load' => (int) elgg_extract('lazy_load', $vars, 6), 'data-auto-refresh' => elgg_extract('auto_refresh', $vars, false), 'data-reversed' => elgg_extract('reversed', $vars, false), 'data-list-time' => get_input('list_time', time()), 'data-list-classes' => implode(' ', $list_classes));
foreach ($vars as $key => $val) {
if (substr($key, 0, 5) === 'data-' && !array_key_exists($key, $wrapper_params)) {
$wrapper_params[$key] = $val;
}
}
$view .= elgg_view('js/framework/lists/require');
return elgg_format_element('div', $wrapper_params, $view);
}
示例2: viewBody
/**
* Returns form body HTML
* @return string
*/
public function viewBody()
{
// Get sticky values
$sticky_values = hypePrototyper()->prototype->getStickyValues($this->action);
hypePrototyper()->prototype->clearStickyValues($this->action);
// Get validation errors and messages
$validation_status = hypePrototyper()->prototype->getValidationStatus($this->action);
hypePrototyper()->prototype->clearValidationStatus($this->action);
// Prepare fields
$i = 0;
foreach ($this->fields as $field) {
if (!$field instanceof Field) {
continue;
}
if ($field->getInputView() === false) {
continue;
}
$shortname = $field->getShortname();
if (isset($sticky_values[$shortname])) {
$field->setStickyValue($sticky_values[$shortname]);
}
if (isset($validation_status[$shortname])) {
$field->setValidation($validation_status[$shortname]['status'], $validation_status[$shortname]['messages']);
}
$output .= $field->viewInput(array('index' => $i, 'entity' => $this->entity));
$i++;
}
$submit = elgg_view('prototyper/input/submit', array('entity' => $this->entity, 'action' => $this->action));
$output .= elgg_format_element('div', array('class' => 'elgg-foot'), $submit);
return $output;
}
示例3: testElggFormatElement
/**
* Test elgg_format_element()
*/
public function testElggFormatElement()
{
$tests = array('<span>a&b</span>' => array('tag_name' => 'span', 'text' => 'a&b', 'encode_text' => true), '<img src="a&b">' => array('tag_name' => 'img', 'src' => 'a&b', 'text' => 'ignored'), '<foo />' => array('tag_name' => 'foo', 'is_void' => true, 'is_xml' => true));
foreach ($tests as $expected => $vars) {
$this->assertEqual(elgg_format_element($vars), $expected);
}
try {
elgg_format_element(array());
$this->fail('Failed to throw exception');
} catch (InvalidArgumentException $e) {
$this->pass();
}
}
示例4: showGroupHiddenIndicator
/**
* Show the group access status indicator
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param \ElggMenuItem[] $return_value current return vaue
* @param array $params supplied params
*
* @return void|\ElggMenuItem[]
*/
public static function showGroupHiddenIndicator($hook, $type, $return_value, $params)
{
$entity = elgg_extract('entity', $params);
if (!$entity instanceof \ElggGroup) {
return;
}
if (!group_tools_show_hidden_indicator($entity)) {
return;
}
$access_id_string = get_readable_access_level($entity->access_id);
$text = elgg_format_element('span', ['title' => $access_id_string], elgg_view_icon('eye'));
$return_value[] = \ElggMenuItem::factory(['name' => 'hidden_indicator', 'text' => $text, 'href' => false, 'priority' => 1]);
return $return_value;
}
示例5: register
/**
* Add menu items to the topbar
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param \ElggMenuItem[] $return_value the current return value
* @param array $params supplied params
*
* @return void|\ElggMenuItem[]
*/
public static function register($hook, $type, $return_value, $params)
{
$user = elgg_get_logged_in_user_entity();
if (empty($user)) {
return;
}
$options = ['type' => 'user', 'count' => true, 'relationship' => 'friendrequest', 'relationship_guid' => $user->getGUID(), 'inverse_relationship' => true];
$count = elgg_get_entities_from_relationship($options);
if (empty($count)) {
return;
}
$return_value[] = \ElggMenuItem::factory(['name' => 'friend_request', 'href' => "friend_request/{$user->username}", 'text' => elgg_view_icon('user') . elgg_format_element('span', ['class' => 'friend-request-new'], $count), 'title' => elgg_echo('friend_request:menu'), 'priority' => 301]);
return $return_value;
}
示例6: pages_tools_render_index
/**
* Render the index in the export for every page below the provided page
*
* @param ElggObject $page the page to render for
*
* @return false|string
*/
function pages_tools_render_index(ElggObject $page)
{
if (!pages_tools_is_valid_page($page)) {
return false;
}
$children = pages_tools_get_ordered_children($page);
if (empty($children)) {
return false;
}
$result = "";
foreach ($children as $child) {
$content = elgg_view("output/url", array("text" => $child->title, "href" => "#page_" . $child->getGUID(), "title" => $child->title));
$child_index = pages_tools_render_index($child);
if (!empty($child_index)) {
$content .= elgg_format_element('ul', array(), $child_index);
}
$result .= elgg_format_element('li', array(), $content);
}
return $result;
}
示例7: longtextMenuPrepare
/**
* Change menu item in the longtext menu
*
* @param string $hook 'prepare'
* @param string $type 'menu:longtext'
* @param ElggMenuItem[] $return_value the current menu items
* @param array $params supplied params
*
* @return ElggMenuItem[]
*/
public static function longtextMenuPrepare($hook, $type, $return_value, $params)
{
if (!is_array($return_value)) {
return;
}
foreach ($return_value as $section => $menu_items) {
if (!is_array($menu_items)) {
continue;
}
foreach ($menu_items as $menu_item) {
if ($menu_item->getName() !== 'embed') {
continue;
}
echo elgg_format_element('script', [], 'require(["embed_extended/site"]);');
$link_class = $menu_item->getLinkClass();
$link_class = str_ireplace('elgg-lightbox', 'elgg-embed-lightbox', $link_class);
$menu_item->setLinkClass($link_class);
$menu_item->setHref('embed');
}
}
}
示例8: searchAdvancedAutocomplete
/**
* Adds static pages to the search advanced autocomplete dropdown
*
* @param string $hook 'autocomplete'
* @param string $type 'search_advanced'
* @param array $return_value current search results
* @param array $params supplied params
*
* @return array
*/
public static function searchAdvancedAutocomplete($hook, $type, $return_value, $params)
{
$query = elgg_extract('query', $params);
if (empty($query)) {
return;
}
$limit = (int) elgg_extract('limit', $params, 5);
$options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => $limit, 'joins' => ['JOIN ' . elgg_get_config('dbprefix') . 'objects_entity oe ON e.guid = oe.guid'], 'wheres' => ["(oe.title LIKE '%{$query}%' OR oe.description LIKE '%{$query}%')"]];
$entities = elgg_get_entities($options);
if (empty($entities)) {
return;
}
if (count($entities) >= $limit) {
$options['count'] = true;
$static_count = elgg_get_entities($options);
} else {
$static_count = count($entities);
}
$return_value[] = ['type' => 'placeholder', 'content' => elgg_format_element('label', [], elgg_echo('item:object:static') . ' (' . $static_count . ')'), 'href' => elgg_normalize_url('search?entity_subtype=static&entity_type=object&search_type=entities&q=' . $query)];
foreach ($entities as $entity) {
$return_value[] = ['type' => 'object', 'value' => $entity->title, 'href' => $entity->getURL(), 'content' => elgg_view('static/search_advanced/item', ['entity' => $entity])];
}
return $return_value;
}
示例9: view
/**
* Render an entity profile
*
* @param array $vars Vars to pass to teach field view
* @return string HTML
*/
public function view($vars = array())
{
$output = '';
$vars['entity'] = $this->entity;
foreach ($this->fields as $field) {
if (!$field instanceof Field) {
continue;
}
if ($field->getOutputView() === false) {
continue;
}
if ($field->getType() == 'hidden' || $field->getValueType() == 'hidden') {
continue;
}
if ($field->isHiddenOnProfile()) {
continue;
}
$field_view = $field->viewOutput($vars);
if ($field_view) {
$output .= elgg_format_element('div', array('class' => 'prototyper-output'), $field_view);
}
}
return $output;
}
示例10: callbackEmail
/**
* Callback function for username preg_replace_callback
*
* @param array $matches An array of matches
* @return string
*/
public static function callbackEmail($matches)
{
if (empty($matches[2])) {
return $matches[0];
}
return $matches[1] . elgg_format_element('a', array('class' => 'scraper-email', 'href' => "mailto:{$matches[2]}", 'data-qualifier' => 'email'), $matches[2]);
}
示例11: elgg_get_entities_from_relationship
}
// count members
$member_count = $group->getMembers(['count' => true]);
// count how manyu members are notified by email
$notification_options = ['type' => 'user', 'count' => true, 'relationship' => 'notifyemail', 'relationship_guid' => $group->getGUID(), 'inverse_relationship' => true];
$notification_count = elgg_get_entities_from_relationship($notification_options);
if (elgg_is_active_plugin('site_notifications')) {
// maybe more members are being notified by site
$notification_options['relationship'] = 'notifysite';
$site_notification_count = elgg_get_entities_from_relationship($notification_options);
if (!empty($site_notification_count)) {
if ($site_notification_count > $notification_count) {
$notification_count = $site_notification_count;
}
}
}
// start building content
$title = elgg_echo('group_tools:notifications:title');
$content = elgg_format_element('div', ['class' => 'mbm'], elgg_echo('group_tools:notifications:description', [$member_count, $notification_count]));
// enable notification for everyone
if ($member_count > $notification_count) {
$content .= elgg_view('output/url', ['href' => "action/group_tools/notifications?toggle=enable&guid={$group->getGUID()}", 'text' => elgg_echo('group_tools:notifications:enable'), 'class' => 'elgg-button elgg-button-submit mrm', 'confirm' => true]);
}
// disable notification
if ($notification_count > 0) {
$content .= elgg_view('output/url', ['href' => "action/group_tools/notifications?toggle=disable&guid={$group->getGUID()}", 'text' => elgg_echo('group_tools:notifications:disable'), 'class' => 'elgg-button elgg-button-submit', 'confirm' => true]);
}
// disclaimer about timing
$content .= elgg_format_element('div', ['class' => 'elgg-quiet mtm'], elgg_echo('group_tools:notifications:disclaimer'));
// echo content
echo elgg_view_module('info', $title, $content);
示例12: profile_manager_profile_completeness
<?php
$owner = $vars['entity']->getOwnerEntity();
$tips = '';
if ($owner->getGUID() === elgg_get_logged_in_user_guid()) {
$completeness = profile_manager_profile_completeness($owner);
$percentage_complete = $completeness['percentage_completeness'];
// save the percentage
$owner->profile_completeness_percentage = $percentage_complete;
$missing_fields = $completeness['missing_fields'];
if (count($missing_fields) > 0) {
$rand_key = array_rand($missing_fields);
$field = $missing_fields[$rand_key];
$tips = elgg_echo('widgets:profile_completeness:view:tips', ['<b>' . $field->getTitle() . '</b>']);
} else {
$tips = elgg_echo('widgets:profile_completeness:view:complete');
}
} else {
if ($owner->profile_completeness_percentage) {
$percentage_complete = $owner->profile_completeness_percentage;
} else {
$completeness = profile_manager_profile_completeness($owner);
$percentage_complete = $completeness["percentage_completeness"];
}
}
$progress = elgg_format_element('div', ['id' => 'widget_profile_completeness_progress'], "{$percentage_complete}%");
$progress .= elgg_format_element('div', ['id' => 'widget_profile_completeness_progress_bar', 'style' => "width: {$percentage_complete}%;"]);
echo elgg_format_element('div', ['id' => 'widget_profile_completeness_container'], $progress);
echo $tips;
示例13: array_merge
if ($auto_save_annotations) {
$revisions[] = $auto_save_annotations[0];
}
$saved_revisions = $blog->getAnnotations(['annotation_name' => 'blog_revision', 'reverse_order_by' => true, 'limit' => false]);
$revisions = array_merge($revisions, $saved_revisions);
if (empty($revisions)) {
return;
}
$load_base_url = "blog/edit/{$blog->getGUID()}";
// show the "published revision"
$published_item = '';
if ($blog->status == 'published') {
$load = elgg_view('output/url', ['href' => $load_base_url, 'text' => elgg_echo('status:published'), 'is_trusted' => true]);
$time = elgg_format_element('span', ['class' => 'elgg-subtext'], elgg_view_friendly_time($blog->time_created));
$published_item = elgg_format_element('li', [], "{$load}: {$time}");
}
$n = count($revisions);
$revisions_list = '';
foreach ($revisions as $revision) {
$time = elgg_format_element('span', ['class' => 'elgg-subtext'], elgg_view_friendly_time($revision->time_created));
if ($revision->name == 'blog_auto_save') {
$revision_lang = elgg_echo('blog:auto_saved_revision');
} else {
$revision_lang = elgg_echo('blog:revision') . " {$n}";
}
$load = elgg_view('output/url', array('href' => "{$load_base_url}/{$revision->id}", 'text' => $revision_lang, 'is_trusted' => true));
$revisions_list .= elgg_format_element('li', ['class' => 'auto-saved'], "{$load}: {$time}");
$n--;
}
$body = elgg_format_element('ul', ['class' => 'blog-revisions'], $published_item . $revisions_list);
echo elgg_view_module('aside', elgg_echo('blog:revisions'), $body);
示例14: elgg_extract
<?php
$group = elgg_extract('entity', $vars);
$subgroup = elgg_extract('subgroup', $vars);
if (!$group instanceof ElggGroup || !$subgroup instanceof ElggGroup) {
return;
}
elgg_push_context('widgets');
// use widgets context so no entity menu is used
if (\AU\SubGroups\can_move_subgroup($subgroup, $group)) {
$class = 'au-subgroups-parentable';
} else {
$class = 'au-subgroups-non-parentable';
}
$action_url = elgg_normalize_url("action/au_subgroups/move?parent_guid={$group->guid}");
$action_url = elgg_add_action_tokens_to_url($action_url);
$view = elgg_view_entity($group, array('full_view' => false));
echo elgg_format_element('div', ['class' => \AU\SubGroups\can_move_subgroup($subgroup, $group) ? 'au-subgroups-parentable' : 'au-subgroups-non-parentable', 'data-action' => $action_url], $view);
elgg_pop_context();
示例15: array
$list_class = "elgg-categories";
if (isset($vars['list_class'])) {
$list_class = "{$list_class} {$vars['list_class']}";
}
$item_class = "elgg-category";
if (isset($vars['item_class'])) {
$item_class = "{$item_class} {$vars['item_class']}";
}
$list_items = array();
foreach ($vars['categories'] as $category) {
if (!hypeCategories()->categories->instanceOfCategory($category)) {
continue;
}
$children = hypeCategories()->categories->getSubcategories($category, array('count' => true));
if ($children > 0) {
continue;
}
$crumbs = array();
$hierarchy = hypeCategories()->categories->getHierarchy($category, false, true);
foreach ($hierarchy as $h) {
$crumbs[] = $h->getDisplayName();
}
$list_items[] = elgg_format_element('li', array('class' => $item_class), elgg_view('output/url', array('href' => $category->getURL(), 'title' => implode(" ‣ ", $crumbs), 'text' => $category->getDisplayName())));
}
if (empty($list_items)) {
return;
}
$icon = elgg_format_element('li', array(), elgg_view_icon('categories', $icon_class));
$list = implode('', $list_items);
echo elgg_format_element('ul', array('class' => $list_class), $icon . $list);