Exemple #1
0
/**
 * Get/set an Application for testing purposes
 *
 * @param \Elgg\Application $app Elgg Application
 * @return \Elgg\Application
 * @deprecated 2.3 Use elgg() instead
 */
function _elgg_testing_application(\Elgg\Application $app = null)
{
    if ($app) {
        \Elgg\Application::$_instance = $app;
    }
    return elgg();
}
Exemple #2
0
 function testElggReturnsApp()
 {
     $this->assertInstanceOf(Application::class, elgg());
 }
Exemple #3
0
<?php

/**
 * Form body for setting up site menu
 */
$num_featured_items = elgg_extract('num_featured_items', $vars, 6);
// get site menu items
$menu = elgg()->menus->getUnpreparedMenu('site', ['sort_by' => 'name']);
$menu_items = $menu->getItems();
$featured_menu_names = elgg_get_config('site_featured_menu_names');
$dropdown_values = [];
foreach ($menu_items as $item) {
    $dropdown_values[$item->getName()] = $item->getText();
}
$dropdown_values[' '] = elgg_echo('none');
$configure = elgg_view('output/longtext', ['value' => elgg_echo('admin:menu_items:description')]);
for ($i = 0; $i < $num_featured_items; $i++) {
    if ($featured_menu_names && array_key_exists($i, $featured_menu_names)) {
        $current_value = $featured_menu_names[$i];
    } else {
        $current_value = ' ';
    }
    $configure .= elgg_view('input/select', ['options_values' => $dropdown_values, 'name' => 'featured_menu_names[]', 'value' => $current_value]);
}
echo elgg_view_module('inline', elgg_echo('admin:menu_items:configure'), $configure);
$custom_items = elgg_get_config('site_custom_menu_items');
$name_str = elgg_echo('name');
$url_str = elgg_echo('admin:plugins:label:website');
$add_menu_items = '';
if (is_array($custom_items)) {
    foreach ($custom_items as $title => $url) {
Exemple #4
0
/**
 * Register menu items for the title menu
 *
 * @param string $hook   Hook
 * @param string $type   Type
 * @param array  $return Current return value
 * @param array  $params Hook parameters
 * @return array
 *
 * @access private
 *
 * @since 3.0
 */
function _profile_title_menu($hook, $type, $return, $params)
{
    if (!elgg_in_context('profile') || elgg_in_context('profile_edit')) {
        return;
    }
    $user = elgg_get_page_owner_entity();
    // grab the actions and admin menu items from user hover
    $menu = elgg()->menus->getMenu('user_hover', ['entity' => $user, 'username' => $user->username]);
    $actions = $menu->getSection('action', []);
    foreach ($actions as $action) {
        $action->addLinkClass('elgg-button elgg-button-action');
        $return[] = $action;
    }
    return $return;
}
Exemple #5
0
 public function setUp()
 {
     $app = elgg();
     $config = _elgg_services()->config;
     $this->handler = new CacheHandler($app, $config, []);
 }
Exemple #6
0
 /**
  * Build a JsonResponse based on an API response object
  *
  * @param AjaxResponse $api_response           The API Response
  * @param bool         $allow_removing_headers Alter PHP's global headers to allow caching
  *
  * @return JsonResponse
  * @throws RuntimeException
  */
 private function buildHttpResponse(AjaxResponse $api_response, $allow_removing_headers = null)
 {
     if ($api_response->isCancelled()) {
         return new JsonResponse(['error' => "The response was cancelled"], 400);
     }
     $response = new JsonResponse($api_response->getData());
     $ttl = $api_response->getTtl();
     if ($ttl > 0) {
         // Required to remove headers set by PHP session
         if (!isset($allow_removing_headers)) {
             $allow_removing_headers = !elgg()->isTestingApplication();
         }
         if ($allow_removing_headers) {
             header_remove('Expires');
             header_remove('Pragma');
             header_remove('Cache-Control');
         }
         // JsonRequest sets a default Cache-Control header we don't want
         $response->headers->remove('Cache-Control');
         $response->setClientTtl($ttl);
         // if we don't set Expires, Apache will add a far-off max-age and Expires for us.
         $response->headers->set('Expires', gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $ttl));
     }
     return $response;
 }
Exemple #7
0
 function testElggReturnsApp()
 {
     $app = _elgg_testing_application();
     $this->assertSame($app, elgg());
 }
Exemple #8
0
<?php

elgg_load_css('admin/users/newest.css');
// newest users
$users = elgg_list_entities(['type' => 'user', 'subtype' => null, 'full_view' => false, 'list_type' => 'table', 'columns' => [elgg()->table_columns->user(), elgg()->table_columns->username(), elgg()->table_columns->email(), elgg()->table_columns->time_created(null, ['format' => 'friendly'])], 'list_class' => 'elgg-newest-users']);
echo elgg_view_module('inline', elgg_echo('admin:users:newest'), $users);
Exemple #9
0
<?php

/**
 * Profile owner block
 *
 * @uses $vars['entity'] The user entity
 */
$user = elgg_extract('entity', $vars);
if (!$user instanceof \ElggUser) {
    // no user so we quit view
    echo elgg_echo('viewfailure', array(__FILE__));
    return true;
}
$icon = elgg_view_entity_icon($user, 'large', array('use_hover' => false, 'use_link' => false, 'img_class' => 'photo u-photo'));
// grab the actions and admin menu items from user hover
$menu = elgg()->menus->getMenu('user_hover', ['entity' => $user, 'username' => $user->username]);
$admin = $menu->getSection('admin', []);
// if admin, display admin links
$admin_links = '';
if (elgg_is_admin_logged_in() && elgg_get_logged_in_user_guid() != $user->guid) {
    $text = elgg_echo('admin:options');
    $admin_links = '<ul class="profile-admin-menu-wrapper">';
    $admin_links .= "<li><a rel=\"toggle\" href=\"#profile-menu-admin\">{$text}&hellip;</a>";
    $admin_links .= '<ul class="elgg-menu profile-admin-menu hidden" id="profile-menu-admin">';
    foreach ($admin as $menu_item) {
        $admin_links .= elgg_view('navigation/menu/elements/item', array('item' => $menu_item));
    }
    $admin_links .= '</ul>';
    $admin_links .= '</li>';
    $admin_links .= '</ul>';
}