1
0
Fork 0

Replace direct accesses to App->config by Config::get/set calls

This commit is contained in:
Hypolite Petovan 2018-07-07 17:46:30 -04:00
commit 762a786611
29 changed files with 180 additions and 190 deletions

View file

@ -124,7 +124,7 @@ class Nav
$nav['home'] = [$homelink, L10n::t('Home'), '', L10n::t('Home Page')];
}
if (($a->config['register_policy'] == REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
if ((Config::get('config', 'register_policy') === REGISTER_OPEN) && (! local_user()) && (! remote_user())) {
$nav['register'] = ['register', L10n::t('Register'), '', L10n::t('Create an account')];
}

View file

@ -1,5 +1,4 @@
<?php
/**
* @file src/Content/Text/BBCode.php
*/
@ -16,7 +15,6 @@ use Friendica\Core\Addon;
use Friendica\Core\Cache;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\Protocol;
use Friendica\Core\System;
use Friendica\Model\Contact;
@ -449,7 +447,7 @@ class BBCode extends BaseObject
*/
public static function limitBodySize($body)
{
$maxlen = get_max_import_size();
$maxlen = Config::get('config', 'max_import_size', 0);
// If the length of the body, including the embedded images, is smaller
// than the maximum, then don't waste time looking for the images

View file

@ -5,8 +5,10 @@ namespace Friendica\Core\Console;
use Asika\SimpleConsole\Console;
use dba;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\Install;
use Friendica\Core\Theme;
use RuntimeException;
require_once 'mod/install.php';
require_once 'include/dba.php';
@ -18,8 +20,8 @@ class AutomaticInstallation extends Console
return <<<HELP
Installation - Install Friendica automatically
Synopsis
bin/console autoinstall [-h|--help|-?] [-v] [-a]
bin/console autoinstall [-h|--help|-?] [-v] [-a]
Description
Installs Friendica with data based on the htconfig.php file
@ -62,7 +64,7 @@ HELP;
$errorMessage = $this->extractErrors($checkResults['basic']);
if ($errorMessage !== '') {
throw new \RuntimeException($errorMessage);
throw new RuntimeException($errorMessage);
}
$this->out(" Complete!\n\n");
@ -75,7 +77,7 @@ HELP;
$errorMessage = $this->extractErrors($checkResults['db']);
if ($errorMessage !== '') {
throw new \RuntimeException($errorMessage);
throw new RuntimeException($errorMessage);
}
$this->out(" Complete!\n\n");
@ -86,15 +88,15 @@ HELP;
$checkResults['data'] = Install::installDatabaseStructure();
if ($checkResults['data'] !== '') {
throw new \RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n");
throw new RuntimeException("ERROR: DB Database creation error. Is the DB empty?\n");
}
$this->out(" Complete!\n\n");
// Install theme
$this->out("Installing theme\n");
if (!empty($a->config['system']['theme'])) {
Theme::install($a->config['system']['theme']);
if (!empty(Config::get('system', 'theme'))) {
Theme::install(Config::get('system', 'theme'));
$this->out(" Complete\n\n");
} else {
$this->out(" Theme setting is empty. Please check the file htconfig.php\n\n");
@ -103,7 +105,7 @@ HELP;
// Copy config file
$this->out("Saving config file...\n");
if ($config_file != '.htconfig.php' && !copy($config_file, '.htconfig.php')) {
throw new \RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '.htconfig.php' manually.\n");
throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '.htconfig.php' manually.\n");
}
$this->out(" Complete!\n\n");
$this->out("\nInstallation is finished\n");
@ -125,10 +127,10 @@ HELP;
Install::checkSmarty3($checks);
Install::checkKeys($checks);
if (!empty($app->config['php_path'])) {
Install::checkPHP($app->config['php_path'], $checks);
if (!empty(Config::get('config', 'php_path'))) {
Install::checkPHP(Config::get('config', 'php_path'), $checks);
} else {
throw new \RuntimeException(" ERROR: The php_path is not set in the config. Please check the file .htconfig.php.\n");
throw new RuntimeException(" ERROR: The php_path is not set in the config.\n");
}
$this->out(" NOTICE: Not checking .htaccess/URL-Rewrite during CLI installation.\n");

View file

@ -53,7 +53,7 @@ class DBStructure
$a = get_app();
//send the administrators an e-mail
$admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", $a->config['admin_email']))))."'";
$admin_mail_list = "'".implode("','", array_map('dbesc', explode(",", str_replace(" ", "", Config::get('config', 'admin_email')))))."'";
$adminlist = q("SELECT uid, language, email FROM user WHERE email IN (%s)",
$admin_mail_list
);

View file

@ -138,7 +138,7 @@ class Profile
$a->profile['mobile-theme'] = PConfig::get($a->profile['profile_uid'], 'system', 'mobile_theme');
$a->profile['network'] = NETWORK_DFRN;
$a->page['title'] = $a->profile['name'] . ' @ ' . $a->config['sitename'];
$a->page['title'] = $a->profile['name'] . ' @ ' . Config::get('config', 'sitename');
if (!$profiledata && !PConfig::get(local_user(), 'system', 'always_my_theme')) {
$_SESSION['theme'] = $a->profile['theme'];

View file

@ -454,8 +454,8 @@ class User
// Disallow somebody creating an account using openid that uses the admin email address,
// since openid bypasses email verification. We'll allow it if there is not yet an admin account.
if (x($a->config, 'admin_email') && strlen($openid_url)) {
$adminlist = explode(',', str_replace(' ', '', strtolower($a->config['admin_email'])));
if (Config::get('config', 'admin_email') && strlen($openid_url)) {
$adminlist = explode(',', str_replace(' ', '', strtolower(Config::get('config', 'admin_email'))));
if (in_array(strtolower($email), $adminlist)) {
throw new Exception(L10n::t('Cannot use that email.'));
}

View file

@ -43,7 +43,7 @@ class Login extends BaseModule
goaway(self::getApp()->get_baseurl());
}
return self::form(self::getApp()->get_baseurl(), $a->config['register_policy'] != REGISTER_CLOSED);
return self::form(self::getApp()->get_baseurl(), Config::get('config', 'register_policy') !== REGISTER_CLOSED);
}
public static function post()
@ -266,7 +266,7 @@ class Login extends BaseModule
* @param string $return_url The url relative to the base the user should be sent
* back to after login completes
* @param bool $register If $register == true provide a registration link.
* This will most always depend on the value of $a->config['register_policy'].
* This will most always depend on the value of config.register_policy.
* @param array $hiddens optional
*
* @return string Returns the complete html for inserting into the page

View file

@ -1269,7 +1269,7 @@ class OStatus
XML::addElement($doc, $root, "generator", FRIENDICA_PLATFORM, $attributes);
XML::addElement($doc, $root, "id", System::baseUrl() . "/profile/" . $owner["nick"]);
XML::addElement($doc, $root, "title", $title);
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], $a->config["sitename"]));
XML::addElement($doc, $root, "subtitle", sprintf("Updates from %s on %s", $owner["name"], Config::get('config', 'sitename')));
XML::addElement($doc, $root, "logo", $owner["photo"]);
XML::addElement($doc, $root, "updated", DateTimeFormat::utcNow(DateTimeFormat::ATOM));