mirror of
https://github.com/friendica/friendica
synced 2025-04-27 14:30:11 +00:00
Remove get_app() in favor of DI::app()
This commit is contained in:
parent
5d20cd7e16
commit
f0eea6f875
26 changed files with 110 additions and 97 deletions
|
@ -88,7 +88,7 @@ abstract class BaseModule
|
|||
*/
|
||||
public static function getFormSecurityToken($typename = '')
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$timestamp = time();
|
||||
$sec_hash = hash('whirlpool', $a->user['guid'] . $a->user['prvkey'] . session_id() . $timestamp . $typename);
|
||||
|
@ -116,7 +116,7 @@ abstract class BaseModule
|
|||
|
||||
$max_livetime = 10800; // 3 hours
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$x = explode('.', $hash);
|
||||
if (time() > (intval($x[0]) + $max_livetime)) {
|
||||
|
@ -136,7 +136,7 @@ abstract class BaseModule
|
|||
public static function checkFormSecurityTokenRedirectOnError($err_redirect, $typename = '', $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
|
||||
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
|
||||
notice(self::getFormSecurityStandardErrorMessage());
|
||||
|
@ -147,7 +147,7 @@ abstract class BaseModule
|
|||
public static function checkFormSecurityTokenForbiddenOnError($typename = '', $formname = 'form_security_token')
|
||||
{
|
||||
if (!self::checkFormSecurityToken($typename, $formname)) {
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
Logger::log('checkFormSecurityToken failed: user ' . $a->user['guid'] . ' - form element ' . $typename);
|
||||
Logger::log('checkFormSecurityToken failed: _REQUEST data: ' . print_r($_REQUEST, true), Logger::DATA);
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\App;
|
||||
|
||||
/**
|
||||
* When I installed docblox, I had the experience that it does not generate any output at all.
|
||||
* This script may be used to find that kind of problems with the documentation build process.
|
||||
|
@ -29,6 +31,16 @@ class DocBloxErrorChecker extends \Asika\SimpleConsole\Console
|
|||
|
||||
protected $helpOptions = ['h', 'help', '?'];
|
||||
|
||||
/** @var App */
|
||||
private $app;
|
||||
|
||||
public function __construct(App $app, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -59,7 +71,7 @@ HELP;
|
|||
throw new \RuntimeException('DocBlox isn\'t available.');
|
||||
}
|
||||
|
||||
$dir = \get_app()->getBasePath();
|
||||
$dir = $this->app->getBasePath();
|
||||
|
||||
//stack for dirs to search
|
||||
$dirstack = [];
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Friendica\Console;
|
||||
|
||||
use Friendica\App;
|
||||
|
||||
/**
|
||||
* Read a strings.php file and create messages.po in the same directory
|
||||
*
|
||||
|
@ -15,6 +17,16 @@ class PhpToPo extends \Asika\SimpleConsole\Console
|
|||
private $normBaseMsgIds = [];
|
||||
const NORM_REGEXP = "|[\\\]|";
|
||||
|
||||
/** @var App */
|
||||
private $app;
|
||||
|
||||
public function __construct(App $app, array $argv = null)
|
||||
{
|
||||
parent::__construct($argv);
|
||||
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
protected function getHelp()
|
||||
{
|
||||
$help = <<<HELP
|
||||
|
@ -51,7 +63,7 @@ HELP;
|
|||
throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments');
|
||||
}
|
||||
|
||||
$a = \get_app();
|
||||
$a = $this->app;
|
||||
|
||||
$phpfile = realpath($this->getArgument(0));
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class OEmbed
|
|||
{
|
||||
$embedurl = trim($embedurl, '\'"');
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$cache_key = 'oembed:' . $a->videowidth . ':' . $embedurl;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ use Friendica\Core\Hook;
|
|||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Util\Network;
|
||||
use Friendica\Util\Proxy as ProxyUtils;
|
||||
|
@ -815,7 +816,7 @@ class HTML
|
|||
*/
|
||||
public static function contactBlock()
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
return ContactBlock::getHTML($a->profile);
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ class Widget
|
|||
*/
|
||||
public static function categories($baseurl, $selected = '')
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$uid = intval($a->profile['profile_uid']);
|
||||
|
||||
|
@ -420,7 +420,7 @@ class Widget
|
|||
*/
|
||||
public static function tagCloud($limit = 50)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$uid = intval($a->profile['profile_uid']);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Friendica\Content\Widget;
|
|||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\L10n;
|
||||
use Friendica\Core\Renderer;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
* TagCloud widget
|
||||
|
@ -24,7 +25,7 @@ class CalendarExport
|
|||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
||||
*/
|
||||
public static function getHTML() {
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
if (empty($a->data['user'])) {
|
||||
return;
|
||||
|
|
|
@ -48,8 +48,6 @@ class Worker
|
|||
*/
|
||||
public static function processQueue($run_cron = true)
|
||||
{
|
||||
$a = \get_app();
|
||||
|
||||
// Ensure that all "strtotime" operations do run timezone independent
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
|
@ -372,7 +370,7 @@ class Worker
|
|||
*/
|
||||
private static function execFunction($queue, $funcname, $argv, $method_call)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$argc = count($argv);
|
||||
|
||||
|
@ -1083,7 +1081,7 @@ class Worker
|
|||
|
||||
$args = ['no_cron' => !$do_cron];
|
||||
|
||||
$a = get_app();
|
||||
$a = DI::app();
|
||||
$process = new Core\Process(DI::logger(), DI::mode(), DI::config(), $a->getBasePath());
|
||||
$process->run($command, $args);
|
||||
|
||||
|
|
|
@ -2220,7 +2220,7 @@ class Contact
|
|||
{
|
||||
$result = ['cid' => -1, 'success' => false, 'message' => ''];
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
// remove ajax junk, e.g. Twitter
|
||||
$url = str_replace('/#!/', '/', $url);
|
||||
|
|
|
@ -105,7 +105,7 @@ class Mail
|
|||
*/
|
||||
public static function send($recipient = 0, $body = '', $subject = '', $replyto = '')
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
if (!$recipient) {
|
||||
return -1;
|
||||
|
|
|
@ -461,7 +461,7 @@ class Photo
|
|||
$micro = DI::baseUrl() . "/photo/" . $resource_id . "-6." . $Image->getExt() . $suffix;
|
||||
|
||||
// Remove the cached photo
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$basepath = $a->getBasePath();
|
||||
|
||||
if (is_dir($basepath . "/photo")) {
|
||||
|
|
|
@ -568,7 +568,7 @@ class Profile
|
|||
|
||||
public static function getBirthdays()
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$o = '';
|
||||
|
||||
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
||||
|
@ -665,7 +665,7 @@ class Profile
|
|||
|
||||
public static function getEventsReminderHTML()
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$o = '';
|
||||
|
||||
if (!local_user() || DI::mode()->isMobile() || DI::mode()->isMobile()) {
|
||||
|
@ -1106,7 +1106,7 @@ class Profile
|
|||
*/
|
||||
public static function addVisitorCookieForHandle($handle)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
// Try to find the public contact entry of the visitor.
|
||||
$cid = Contact::getIdForURL($handle);
|
||||
|
@ -1144,7 +1144,7 @@ class Profile
|
|||
*/
|
||||
public static function openWebAuthInit($token)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
// Clean old OpenWebAuthToken entries.
|
||||
OpenWebAuthToken::purge('owt', '3 MINUTE');
|
||||
|
|
|
@ -146,7 +146,7 @@ class DFRN
|
|||
*/
|
||||
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$sitefeed = ((strlen($owner_nick)) ? false : true); // not yet implemented, need to rewrite huge chunks of following logic
|
||||
$public_feed = (($dfrn_id) ? false : true);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Render;
|
||||
|
||||
use Friendica\DI;
|
||||
use Smarty;
|
||||
use Friendica\Core\Renderer;
|
||||
|
||||
|
@ -22,7 +23,7 @@ class FriendicaSmarty extends Smarty
|
|||
{
|
||||
parent::__construct();
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$theme = $a->getCurrentTheme();
|
||||
|
||||
// setTemplateDir can be set to an array, which Smarty will parse in order.
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Friendica\Render;
|
||||
|
||||
use Friendica\Core\Hook;
|
||||
use Friendica\DI;
|
||||
|
||||
/**
|
||||
* Smarty implementation of the Friendica template engine interface
|
||||
|
@ -32,7 +33,7 @@ class FriendicaSmartyEngine implements ITemplateEngine
|
|||
$s = new FriendicaSmarty();
|
||||
}
|
||||
|
||||
$r['$APP'] = \get_app();
|
||||
$r['$APP'] = DI::app();
|
||||
|
||||
// "middleware": inject variables into templates
|
||||
$arr = [
|
||||
|
@ -54,7 +55,7 @@ class FriendicaSmartyEngine implements ITemplateEngine
|
|||
|
||||
public function getTemplateFile($file, $root = '')
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$template = new FriendicaSmarty();
|
||||
|
||||
// Make sure $root ends with a slash /
|
||||
|
|
|
@ -96,7 +96,7 @@ class Network
|
|||
{
|
||||
$stamp1 = microtime(true);
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
if (strlen($url) > 1000) {
|
||||
Logger::log('URL is longer than 1000 characters. Callstack: ' . System::callstack(20), Logger::DEBUG);
|
||||
|
@ -260,7 +260,7 @@ class Network
|
|||
return CurlResult::createErrorCurl($url);
|
||||
}
|
||||
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
$ch = curl_init($url);
|
||||
|
||||
if (($redirects > 8) || (!$ch)) {
|
||||
|
@ -630,7 +630,7 @@ class Network
|
|||
*/
|
||||
public static function finalUrl(string $url, int $depth = 1, bool $fetchbody = false)
|
||||
{
|
||||
$a = \get_app();
|
||||
$a = DI::app();
|
||||
|
||||
$url = self::stripTrackingQueryParams($url);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue