Beispiel #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();
}
Beispiel #2
0
<?php

use Elgg\Filesystem\Directory;
$subject = elgg_extract("subject", $vars);
$message = nl2br(elgg_extract("body", $vars));
$language = elgg_extract("language", $vars, get_current_language());
$recipient = elgg_extract("recipient", $vars);
$site = elgg_get_site_entity();
$site_url = elgg_get_site_url();
$isElggAtRoot = Elgg\Application::elggDir()->getPath() === Directory\Local::root()->getPath();
$elggSubdir = $isElggAtRoot ? '' : 'vendor/elgg/elgg/';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php 
echo $language;
?>
" lang="<?php 
echo $language;
?>
">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<base target="_blank" />
		
		<?php 
if (!empty($subject)) {
    echo elgg_format_element('title', [], $subject);
}
?>
	</head>
	<body>
Beispiel #3
0
    return $inst;
}
/**
 * This is here as a temporary solution only. Instead of adding more global
 * state to this file as we migrate tests, try to refactor the code to be
 * testable without global state.
 */
global $CONFIG;
$CONFIG = (object) ['dbprefix' => 'elgg_', 'boot_complete' => false, 'wwwroot' => 'http://localhost/', 'path' => __DIR__ . '/../../../', 'dataroot' => __DIR__ . '/test_files/dataroot/', 'site_guid' => 1, 'AutoloaderManager_skip_storage' => true, 'simplecache_enabled' => false];
global $_ELGG;
$_ELGG = (object) ['view_path' => __DIR__ . '/../../../views/'];
function _elgg_testing_config(\Elgg\Config $config = null)
{
    static $inst;
    if ($config) {
        $inst = $config;
    }
    return $inst;
}
// PHPUnit will serialize globals between tests, so let's not introduce any globals here.
call_user_func(function () use($CONFIG) {
    $config = new \Elgg\Config($CONFIG);
    _elgg_testing_config($config);
    $sp = new \Elgg\Di\ServiceProvider($config);
    $sp->setValue('mailer', new InMemoryTransport());
    $app = new \Elgg\Application($sp);
    $app->loadCore();
    // persistentLogin service needs this set to instantiate without calling DB
    _elgg_configure_cookies($CONFIG);
    _elgg_testing_application($app);
});
Beispiel #4
0
<?php

/**
 * Elgg front controller entry point
 *
 * @package Elgg
 * @subpackage Core
 */
require_once __DIR__ . '/autoloader.php';
$app = new \Elgg\Application();
return $app->run();
Beispiel #5
0
<?php

/**
 * Elgg file thumbnail
 *
 * @package ElggFile
 */
// Get engine
require_once dirname(dirname(__DIR__)) . '/autoloader.php';
$application = new Elgg\Application();
$application->bootCore();
// Get file GUID
$file_guid = (int) get_input('file_guid', 0);
// Get file thumbnail size
$size = get_input('size', 'small');
$file = get_entity($file_guid);
if (!elgg_instanceof($file, 'object', 'file')) {
    exit;
}
$simpletype = $file->simpletype;
if ($simpletype == "image") {
    // Get file thumbnail
    switch ($size) {
        case "small":
            $thumbfile = $file->thumbnail;
            break;
        case "medium":
            $thumbfile = $file->smallthumb;
            break;
        case "large":
        default:
Beispiel #6
0
$guid = (int) $_GET['guid'];
// If is the same ETag, content didn't changed.
$etag = $last_cache . $guid;
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") {
    header("HTTP/1.1 304 Not Modified");
    exit;
}
$size = "medium";
if (!empty($_GET['size'])) {
    $size = strtolower($_GET['size']);
    if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) {
        $size = "medium";
    }
}
require_once dirname(dirname(__DIR__)) . '/autoloader.php';
$app = new \Elgg\Application();
$app->loadSettings();
$data_root = call_user_func(function () use($app) {
    $dataroot = $app->config->getVolatile('dataroot');
    if ($dataroot) {
        return $dataroot;
    }
    // must get from DB
    $db = $app->getDb();
    try {
        $row = $db->getDataRow("\n\t\t\tSELECT `value`\n\t\t\tFROM {$db->getTablePrefix()}datalists\n\t\t\tWHERE `name` = 'dataroot'\n\t\t");
        if (!$row) {
            return "";
        }
    } catch (\DatabaseException $e) {
        // we're going to let the engine figure out what's happening...