Merge pull request #3423 from Hypolite/improvement/move-app-to-src-2

Move App to `src` redux
This commit is contained in:
Michael Vogel 2017-05-07 19:37:50 +02:00 committed by GitHub
commit fa3fa42d96
319 changed files with 2509 additions and 2156 deletions

1220
boot.php

File diff suppressed because it is too large Load Diff

6
composer.lock generated
View File

@ -226,10 +226,10 @@
},
{
"name": "pear-pear.php.net/PEAR",
"version": "1.10.3",
"version": "1.10.4",
"dist": {
"type": "file",
"url": "https://pear.php.net/get/PEAR-1.10.3.tgz",
"url": "https://pear.php.net/get/PEAR-1.10.4.tgz",
"reference": null,
"shasum": null
},
@ -247,7 +247,7 @@
"pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
},
"replace": {
"pear-pear/pear": "== 1.10.3.0"
"pear-pear/pear": "== 1.10.4.0"
},
"type": "pear-library",
"autoload": {

View File

@ -113,3 +113,8 @@ For Composer, this would be:
````
$> COMPOSER_HOME=/var/tmp/composer sudo -u [web user] util/composer.phar [mode]
````
## Related
* [Class autoloading](help/autoloader)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)

View File

@ -0,0 +1,108 @@
How To Move Classes to `src`
==============
* [Home](help)
* [Developer Intro](help/Developers-Intro)
Friendica uses [Composer](help/Composer) to manage autoloading.
This means that all the PHP class files moved to the `src` folder will be [automatically included](help/autoloader) when the class it defines is first used in the flow.
This is an improvement over the current `require` usage since files will be included on an actual usage basis instead of the presence of a `require` call.
However, there are a significant number of items to check when moving a class file from the `include` folder to the `src` folder, and this page is there to list them.
## Decide the namespace
This isn't the most technical decision of them all, but it has long lasting consequences as it will be the name that will be used to refer to this class from now on.
There is [a shared Ethercalc sheet](https://ethercalc.org/friendica_classes) to suggest namespace/class names that lists all the already moved class files for inspiration.
A few pointers though:
* `Friendica` is the base namespace for all classes in the `src` folder
* Namespaces match the directory structure, with `Friendica` namespace being the base `src` directory. The `Config` class set in the `Friendica\Core` namespace is expected to be found at `src/Core/Config.php`.
* Namespaces can help group classes with a similar purpose or relevant to a particular feature
When you're done deciding the namespace, it's time to use it.
Let's say we choose `Friendica\Core` for the `Config` class.
## Use the namespace
To declare the namespace, the file `src/Core/Config.php` must start with the following statement:
````php
namespace Friendica\Core;
````
From now on, the `Config` class can be referred to as `Friendica\Core\Config`, however it isn't very practical, especially when the class was previously used as `Config`.
Thankfully, PHP provides namespace shortcuts through `use`.
This language construct just provides a different naming scheme for a namespace or a class, but doesn't trigger the autoload mechanism on its own.
Here are the different ways you can use `use`:
````php
// No use
$config = new Friendica\Core\Config();
````
````php
// Namespace shortcut
use Friendica\Core;
$config = new Core\Config();
````
````php
// Class name shortcut
use Friendica\Core\Config;
$config = new Config();
````
````php
// Aliasing
use Friendica\Core\Config as Cfg;
$config = new Cfg();
````
Whatever the style chosen, a repository-wide search has to be done to find all the class name usage and either use the fully-qualified class name (including the namespace) or add a `use` statement at the start of each relevant file.
## Escape non-namespace classes
The class file you just moved is now in the `Friendica` namespace, but it probably isn't the case for all the classes referenced in this file.
Since we added a `namespace Friendica\Core;` to the file, all the class names still declared in `include` will be implicitly understood as `Friendica\Core\ClassName`, which is rarely what we expect.
To avoid `Class Friendica\Core\ClassName not found` errors, all the `include`-declared class names have to be prepended with a `\`, it tells the autoloader not to look for the class in the namespace but in the global space where non-namespaced classes are set.
If there are only a handful of references to a single non-namespaced class, just prepending `\` is enough. However, if there are many instance, we can use `use` again.
````php
namespace Friendica\Core;
...
if (\dbm::is_result($r)) {
...
}
````
````php
namespace Friendica\Core;
use \dbm;
if (dbm::is_result($r)) {
...
}
````
## Remove any useless `require`
Now that you successfully moved your class to the autoloaded `src` folder, there's no need to include this file anywhere in the app ever again.
Please remove all the `require_once` mentions of the former file, as they will provoke a Fatal Error even if the class isn't used.
## Miscellaneous tips
When you are done with moving the class, please run `php util/typo.php` from the Friendica base directory to check for obvious mistakes.
Howevever, this tool isn't bullet-proof, and a staging install of Friendica is recommended to test your class move without impairing your production server if you host one.
Most of Friendica processes are run in the background, so make sure to turn on your debug log to check for errors that wouldn't show up while simply browsing Friendica.
Check the class file for any magic constant `__FILE__` or `__DIR__`, as their value changed since you moved the class in the file tree.
Most of the time it's used for debugging purposes but there can be instances where it's used to create cache folders for example.
## Related
* [Class autoloading](help/autoloader)
* [Using Composer](help/Composer)

View File

@ -52,7 +52,9 @@ Friendica uses [Composer](https://getcomposer.org) to manage dependencies librar
It's a command-line tool that downloads required libraries into the `vendor` folder and makes any namespaced class in `src` available through the whole application through `boot.php`.
* [Class autoloading](help/autoloader)
* [Using Composer](help/Composer)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
###Coding standards

View File

@ -36,21 +36,25 @@ Friendica Documentation and Resources
**Developer Manual**
* [Where to get started?](help/Developers-Intro)
* [Help on Github](help/Github)
* [Help on Vagrant](help/Vagrant)
* [How to translate Friendica](help/translations)
* [Bugs and Issues](help/Bugs-and-Issues)
* [Plugin Development](help/Plugins)
* [Theme Development](help/themes)
* [Smarty 3 Templates](help/smarty3-templates)
* [Protocol Documentation](help/Protocol)
* [Database schema documantation](help/database)
* [Class Autoloading](help/autoloader)
* [Using Composer](help/Composer)
* [Code - Reference(Doxygen generated - sets cookies)](doc/html/)
* [Twitter/GNU Social API Functions](help/api)
* [Get started](help/Developers-Intro)
* Set up development environment
* [Help on Github](help/Github)
* [Help on Vagrant](help/Vagrant)
* [Bugs and Issues](help/Bugs-and-Issues)
* Code structure
* [Plugin Development](help/Plugins)
* [Theme Development](help/themes)
* [Smarty 3 Templates](help/smarty3-templates)
* How To
* [Translate Friendica](help/translations)
* [Use Composer](help/Composer)
* [Move classes to `src`](help/Developer-How-To-Move-Classes-to-src)
* Reference
* [Twitter/GNU Social API Functions](help/api)
* [Code (Doxygen generated - sets cookies)](doc/html/)
* [Protocol Documentation](help/Protocol)
* [Database schema documantation](help/database)
* [Class Autoloading](help/autoloader)
**External Resources**

View File

@ -24,14 +24,14 @@ For more info about PHP autoloading, please refer to the [official PHP documenta
Let's say you have a PHP file in `src/` that define a very useful class:
```php
// src/ItemsManager.php
<?php
namespace \Friendica;
// src/ItemsManager.php
<?php
namespace Friendica;
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
The class `ItemsManager` has been declared in the `Friendica` namespace.
@ -43,16 +43,16 @@ In order for the Composer autoloader to work, it must first be included. In Frie
The code will be something like:
```php
// mod/network.php
<?php
// mod/network.php
<?php
function network_content(App $a) {
$itemsmanager = new \Friendica\ItemsManager();
$items = $itemsmanager->getAll();
function network_content(App $a) {
$itemsmanager = new Friendica\ItemsManager();
$items = $itemsmanager->getAll();
// pass $items to template
// return result
}
// pass $items to template
// return result
}
```
That's a quite simple example, but look: no `require()`!
@ -61,132 +61,137 @@ If you need to use a class, you can simply use it and you don't need to do anyth
Going further: now we have a bunch of `*Manager` classes that cause some code duplication, let's define a `BaseManager` class, where we move all common code between all managers:
```php
// src/BaseManager.php
<?php
namespace \Friendica;
// src/BaseManager.php
<?php
namespace Friendica;
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
```
and then let's change the ItemsManager class to use this code
```php
// src/ItemsManager.php
<?php
namespace \Friendica;
// src/ItemsManager.php
<?php
namespace Friendica;
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
Even though we didn't explicitly include the `src/BaseManager.php` file, the autoloader will when this class is first defined, because it is referenced as a parent class.
It works with the "BaseManager" example here and it works when we need to call static methods:
```php
// src/Dfrn.php
<?php
namespace \Friendica;
// src/Dfrn.php
<?php
namespace Friendica;
class Dfrn {
public static function mail($item, $owner) { ... }
}
class Dfrn {
public static function mail($item, $owner) { ... }
}
```
```php
// mod/mail.php
<?php
// mod/mail.php
<?php
mail_post($a){
...
\Friendica\dfrn::mail($item, $owner);
...
}
mail_post($a){
...
Friendica\dfrn::mail($item, $owner);
...
}
```
If your code is in same namespace as the class you need, you don't need to prepend it:
```php
// include/delivery.php
<?php
// include/delivery.php
<?php
namespace \Friendica;
namespace Friendica;
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
$atom = Dfrn::mail($item, $owner);
} elseif ($fsuggest) {
$atom = Dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate)
$atom = Dfrn::relocate($owner, $uid);
[...]
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
$atom = Dfrn::mail($item, $owner);
} elseif ($fsuggest) {
$atom = Dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate)
$atom = Dfrn::relocate($owner, $uid);
[...]
```
This is the current code of `include/delivery.php`, and since the code is declared to be in the "Friendica" namespace, you don't need to write it when you need to use the "Dfrn" class.
But if you want to use classes from another library, you need to use the full namespace, e.g.
```php
// src/Diaspora.php
<?php
// src/Diaspora.php
<?php
namespace \Friendica;
namespace Friendica;
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
}
```
if you use that class in many places of the code and you don't want to write the full path to the class every time, you can use the "use" PHP keyword
```php
// src/Diaspora.php
<?php
namespace \Friendica;
// src/Diaspora.php
<?php
namespace Friendica;
use \Michelf\MarkdownExtra;
use \Michelf\MarkdownExtra;
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
}
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
}
}
```
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope.
You can go deeper if you want to, like:
```
// src/Network/Dfrn.php
<?php
namespace \Friendica\Network;
// src/Network/Dfrn.php
<?php
namespace Friendica\Network;
class Dfrn {
}
class Dfrn {
}
```
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `\Friendica`.
Please note that the location of the file defining the class must be placed in the appropriate sub-folders of `src` if the namespace isn't plain `Friendica`.
or
```
// src/Dba/Mysql
<?php
namespace \Friendica\Dba;
// src/Dba/Mysql
<?php
namespace Friendica\Dba;
class Mysql {
}
class Mysql {
}
```
So you can think of namespaces as folders in a Unix file system, with global scope as the root ("\").
## Related
* [Using Composer](help/Composer)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
// Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and
// authorisation to do this.
@ -852,4 +854,3 @@ function account_type($contact) {
return $account_type;
}
?>

View File

@ -81,4 +81,3 @@ class Emailer {
return $res;
}
}
?>

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
/**
* @file include/ForumManager.php
* @brief ForumManager class with its methods related to forum functionality *

View File

@ -24,7 +24,7 @@ class NotificationsManager {
*
* @param array $notes array of note arrays from db
* @return array Copy of input array with added properties
*
*
* Set some extra properties to note array from db:
* - timestamp as int in default TZ
* - date_rel : relative date string
@ -143,8 +143,7 @@ class NotificationsManager {
/**
* @brief List of pages for the Notifications TabBar
*
* @param app $a The
*
* @return array with with notifications TabBar data
*/
public function getTabs() {
@ -191,7 +190,7 @@ class NotificationsManager {
/**
* @brief Format the notification query in an usable array
*
*
* @param array $notifs The array from the db query
* @param string $ident The notifications identifier (e.g. network)
* @return array
@ -360,7 +359,7 @@ class NotificationsManager {
}
/**
* @brief Total number of network notifications
* @brief Total number of network notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -388,13 +387,13 @@ class NotificationsManager {
/**
* @brief Get network notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available network notifications
@ -436,7 +435,7 @@ class NotificationsManager {
}
/**
* @brief Total number of system notifications
* @brief Total number of system notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -460,13 +459,13 @@ class NotificationsManager {
/**
* @brief Get system notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available system notifications
@ -502,7 +501,7 @@ class NotificationsManager {
/**
* @brief Addional SQL query string for the personal notifications
*
*
* @return string The additional sql query
*/
private function _personal_sql_extra() {
@ -520,7 +519,7 @@ class NotificationsManager {
}
/**
* @brief Total number of personal notifications
* @brief Total number of personal notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -550,13 +549,13 @@ class NotificationsManager {
/**
* @brief Get personal notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available personal notifications
@ -573,13 +572,13 @@ class NotificationsManager {
$sql_seen = " AND `item`.`unseen` = 1 ";
$r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`, `item`.`unseen`,
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`,
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid`
`item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object` AS `object`,
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`, `pitem`.`guid` AS `pguid`
FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id`=`item`.`parent`
WHERE `item`.`visible` = 1
$sql_extra
$sql_seen
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
AND `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
ORDER BY `item`.`created` DESC LIMIT %d, %d " ,
intval(local_user()),
intval($start),
@ -588,7 +587,7 @@ class NotificationsManager {
if (dbm::is_result($r))
$notifs = $this->formatNotifs($r, $ident);
$arr = array (
'notifications' => $notifs,
'ident' => $ident,
@ -599,7 +598,7 @@ class NotificationsManager {
}
/**
* @brief Total number of home notifications
* @brief Total number of home notifications
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
@ -626,13 +625,13 @@ class NotificationsManager {
/**
* @brief Get home notifications
*
*
* @param int|string $seen
* If 0 only include notifications into the query
* which aren't marked as "seen"
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available home notifications
@ -673,7 +672,7 @@ class NotificationsManager {
}
/**
* @brief Total number of introductions
* @brief Total number of introductions
* @param bool $all
* If false only include introductions into the query
* which aren't marked as ignored
@ -698,13 +697,13 @@ class NotificationsManager {
/**
* @brief Get introductions
*
*
* @param bool $all
* If false only include introductions into the query
* which aren't marked as ignored
* @param int $start Start the query at this point
* @param int $limit Maximum number of query results
*
*
* @return array with
* string 'ident' => Notification identifier
* int 'total' => Total number of available introductions
@ -749,7 +748,7 @@ class NotificationsManager {
/**
* @brief Format the notification query in an usable array
*
*
* @param array $intros The array from the db query
* @return array with the introductions
*/

View File

@ -4,6 +4,8 @@
* @brief This file contains the Photo class for image processing
*/
use Friendica\App;
require_once("include/photos.php");
class Photo {

View File

@ -5,8 +5,9 @@
*
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
require_once("include/feed.php");
require_once('include/email.php');
@ -1261,4 +1262,3 @@ class Probe {
}
}
?>

View File

@ -5,6 +5,8 @@
* @brief This file contains the Smilies class which contains functions to handle smiles
*/
use Friendica\App;
/**
* This class contains functions to handle smiles
*/
@ -13,13 +15,13 @@ class Smilies {
/**
* @brief Function to list all smilies
*
*
* Get an array of all smilies, both internal and from addons.
*
*
* @return array
* 'texts' => smilie shortcut
* 'icons' => icon in html
*
*
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/
public static function get_list() {
@ -64,41 +66,41 @@ class Smilies {
);
$icons = array(
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . app::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . app::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" title="&lt;3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;/3" title="&lt;/3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-brokenheart.gif" alt="&lt;\\3" title="&lt;\\3" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-smile.gif" alt=":-)" title=":-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-wink.gif" alt=";-)" title=";-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-frown.gif" alt=":-(" title=":-(" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-P" title=":-P" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-tongue-out.gif" alt=":-p" title=":-P" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-\" title=":-\" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-x" title=":-x" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-kiss.gif" alt=":-X" title=":-X" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-laughing.gif" alt=":-D" title=":-D" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-|" title="8-|" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt="8-O" title="8-O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-surprised.gif" alt=":-O" title="8-O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-thumbsup.gif" alt="\\o/" title="\\o/" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o.O" title="o.O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O.o" title="O.o" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="o_O" title="o_O" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-Oo.gif" alt="O_o" title="O_o" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cry.gif" alt=":\'(" title=":\'("/>',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-foot-in-mouth.gif" alt=":-!" title=":-!" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-undecided.gif" alt=":-/" title=":-/" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-embarassed.gif" alt=":-[" title=":-[" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-cool.gif" alt="8-)" title="8-)" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":beer" title=":beer" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/beer_mug.gif" alt=":homebrew" title=":homebrew" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/coffee.gif" alt=":coffee" title=":coffee" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" title=":facepalm" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . App::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />',
'<a href="http://friendica.com">~friendica <img class="smiley" src="' . App::get_baseurl() . '/images/friendica-16.png" alt="~friendica" title="~friendica" /></a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#" title="red#" />matrix</a>',
'<a href="http://redmatrix.me/">red<img class="smiley" src="' . App::get_baseurl() . '/images/rm-16.png" alt="red#matrix" title="red#matrix" />matrix</a>'
);
$params = array('texts' => $texts, 'icons' => $icons);
@ -121,7 +123,7 @@ class Smilies {
*
* @param string $s
* @param boolean $sample
*
*
* @return string HML Output of the Smilie
*/
public static function replace($s, $sample = false) {
@ -166,7 +168,7 @@ class Smilies {
*
* @param string $x
* @return string HTML Output
*
*
* @todo: Rework because it doesn't work correctly
*/
private function preg_heart($x) {
@ -174,7 +176,7 @@ class Smilies {
return $x[0];
$t = '';
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++)
$t .= '<img class="smiley" src="' . app::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
$t .= '<img class="smiley" src="' . App::get_baseurl() . '/images/smiley-heart.gif" alt="&lt;3" />';
$r = str_replace($x[0],$t,$x[0]);
return $r;
}

View File

@ -4,6 +4,8 @@
* @file include/acl_selectors.php
*/
use Friendica\App;
require_once "include/contact_selectors.php";
require_once "include/contact_widgets.php";
require_once "include/DirSearch.php";

View File

@ -6,7 +6,8 @@
* @todo Automatically detect if incoming data is HTML or BBCode
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/HTTPExceptions.php';
require_once 'include/bbcode.php';

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/security.php');
require_once('include/datetime.php');

View File

@ -32,6 +32,8 @@
*
*/
use Friendica\App;
if (sizeof($_SERVER["argv"]) == 0)
die();
@ -47,8 +49,9 @@ require_once("boot.php");
global $a, $db;
if (is_null($a))
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {
@include(".htconfig.php");
@ -332,4 +335,3 @@ class exAuth {
fclose($this->rLogFile);
}
}
?>

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
use League\HTMLToMarkdown\HtmlConverter;
require_once "include/oembed.php";

View File

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/oembed.php';
require_once 'include/event.php';

View File

@ -5,8 +5,8 @@
* @brief Class for storing data for a short time
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
class Cache {
/**
@ -121,9 +121,9 @@ class Cache {
/**
* @brief Put data in the cache according to the key
*
*
* The input $value can have multiple formats.
*
*
* @param string $key The key to the cached data
* @param mixed $valie The value that is about to be stored
* @param integer $duration The cache lifespan

View File

@ -1,6 +1,7 @@
<?php /** @file */
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('boot.php');
@ -11,7 +12,7 @@ function cli_startup() {
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View File

@ -1,7 +1,7 @@
<?php
/**
* @file include/config.php
*
*
* @brief (Deprecated) Arbitrary configuration storage
* Note:
* Please do not store booleans - convert to 0/1 integer values
@ -12,8 +12,8 @@
* configurations need to be fixed as of 10/08/2011.
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
/**
* @brief (Deprecated) Loads all configuration values of family into a cached storage.

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function follow_widget($value = "") {
return replace_macros(get_markup_template('follow.tpl'), array(

View File

@ -1,9 +1,10 @@
<?php
use Friendica\App;
require_once "include/bbcode.php";
require_once "include/acl_selectors.php";
/*
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images'
* is identical to the code in mod/message.php for 'item_extract_images' and

View File

@ -17,4 +17,3 @@ function create_shadowentry_run($argv, $argc) {
add_shadow_entry($message_id);
}
?>

View File

@ -1,5 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function cron_run(&$argv, &$argc){
global $a;

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function cronhooks_run(&$argv, &$argc) {
global $a;

View File

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function cronjobs_run(&$argv, &$argc){
global $a;

View File

@ -4,7 +4,7 @@
* @brief Some functions for date and time related tasks.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
/**
* @brief Two-level sort for timezones.
@ -34,7 +34,7 @@ function timezone_cmp($a, $b) {
/**
* @brief Emit a timezone selector grouped (primarily) by continent
*
*
* @param string $current Timezone
* @return string Parsed HTML output
*/
@ -81,17 +81,17 @@ function select_timezone($current = 'America/Los_Angeles') {
/**
* @brief Generating a Timezone selector
*
*
* Return a select using 'field_select_raw' template, with timezones
* groupped (primarily) by continent
* arguments follow convetion as other field_* template array:
* 'name', 'label', $value, 'help'
*
*
* @param string $name Name of the selector
* @param string $label Label for the selector
* @param string $current Timezone
* @param string $help Help text
*
*
* @return string Parsed HTML
*/
function field_timezone($name='timezone', $label='', $current = 'America/Los_Angeles', $help){
@ -114,7 +114,7 @@ function field_timezone($name='timezone', $label='', $current = 'America/Los_Ang
* @param string $s Some parseable date/time string
* @param string $fmt Output format recognised from php's DateTime class
* http://www.php.net/manual/en/datetime.format.php
*
*
* @return string Formatted date according to given format
*/
function datetime_convert($from = 'UTC', $to = 'UTC', $s = 'now', $fmt = "Y-m-d H:i:s") {
@ -212,7 +212,7 @@ function dob($dob) {
/**
* @brief Returns a date selector
*
*
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param string $min
@ -223,7 +223,7 @@ function dob($dob) {
* Unix timestamp of default date
* @param string $id
* ID and name of datetimepicker (defaults to "datetimepicker")
*
*
* @return string Parsed HTML output.
*/
function datesel($format, $min, $max, $default, $id = 'datepicker') {
@ -232,7 +232,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
/**
* @brief Returns a time selector
*
*
* @param string $format
* Format string, e.g. 'ymd' or 'mdy'. Not currently supported
* @param $h
@ -241,7 +241,7 @@ function datesel($format, $min, $max, $default, $id = 'datepicker') {
* Already selected minute
* @param string $id
* ID and name of datetimepicker (defaults to "timepicker")
*
*
* @return string Parsed HTML output.
*/
function timesel($format, $h, $m, $id = 'timepicker') {
@ -270,7 +270,7 @@ function timesel($format, $h, $m, $id = 'timepicker') {
* @param $maxfrom
* set maximum date from picker with id $maxfrom (none by default)
* @param bool $required default false
*
*
* @return string Parsed HTML output.
*
* @todo Once browser support is better this could probably be replaced with
@ -417,7 +417,7 @@ function relative_date($posted_date, $format = null) {
* @param string $dob Date of Birth
* @param string $owner_tz (optional) Timezone of the person of interest
* @param string $viewer_tz (optional) Timezone of the person viewing
*
*
* @return int Age in years
*/
function age($dob, $owner_tz = '', $viewer_tz = '') {
@ -452,7 +452,7 @@ function age($dob, $owner_tz = '', $viewer_tz = '') {
*
* @param int $y Year
* @param int $m Month (1=January, 12=December)
*
*
* @return int Number of days in the given month
*/
function get_dim($y, $m) {
@ -477,7 +477,7 @@ function get_dim($y, $m) {
*
* @param int $y Year
* @param int $m Month (1=January, 12=December)
*
*
* @return string day 0 = Sunday through 6 = Saturday
*/
function get_first_dim($y,$m) {
@ -498,7 +498,7 @@ function get_first_dim($y,$m) {
* @param int $m Month
* @param bool $links (default false)
* @param string $class
*
*
* @return string
*
* @todo Provide (prev,next) links, define class variations for different size calendars

View File

@ -4,7 +4,7 @@
* @brief The script is called from time to time to clean the database entries and remove orphaned data.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
function dbclean_run(&$argv, &$argc) {
if (!Config::get('system', 'dbclean', false)) {
@ -149,4 +149,3 @@ function remove_orphans($stage = 0) {
}
}
?>

View File

@ -110,4 +110,3 @@ class dbm {
return date('Y-m-d H:i:s', $timestamp);
}
}
?>

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("boot.php");
require_once("include/text.php");
@ -1745,7 +1746,7 @@ function dbstructure_run(&$argv, &$argc) {
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function dbupdate_run(&$argv, &$argc) {
global $a;

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');

View File

@ -7,6 +7,8 @@
* https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/
use Friendica\App;
require_once("include/Contact.php");
require_once("include/ostatus.php");
require_once("include/enotify.php");
@ -370,7 +372,7 @@ class dfrn {
$ext = Photo::supportedTypes();
foreach ($rp as $p) {
$photos[$p['scale']] = app::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
$photos[$p['scale']] = App::get_baseurl().'/photo/'.$p['resource-id'].'-'.$p['scale'].'.'.$ext[$p['type']];
}
unset($rp, $ext);
@ -431,7 +433,7 @@ class dfrn {
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET);
xml::add_element($doc, $root, "id", app::get_baseurl()."/profile/".$owner["nick"]);
xml::add_element($doc, $root, "id", App::get_baseurl()."/profile/".$owner["nick"]);
xml::add_element($doc, $root, "title", $owner["name"]);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION);
@ -448,13 +450,13 @@ class dfrn {
// DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
ostatus::hublinks($doc, $root);
$attributes = array("rel" => "salmon", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "salmon", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-replies", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => app::get_baseurl()."/salmon/".$owner["nick"]);
$attributes = array("rel" => "http://salmon-protocol.org/ns/salmon-mention", "href" => App::get_baseurl()."/salmon/".$owner["nick"]);
xml::add_element($doc, $root, "link", "", $attributes);
}
@ -511,7 +513,7 @@ class dfrn {
}
xml::add_element($doc, $author, "name", $owner["name"], $attributes);
xml::add_element($doc, $author, "uri", app::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
xml::add_element($doc, $author, "uri", App::get_baseurl().'/profile/'.$owner["nickname"], $attributes);
xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg",
@ -812,7 +814,7 @@ class dfrn {
$parent = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$attributes = array("ref" => $parent_item, "type" => "text/html",
"href" => app::get_baseurl().'/display/'.$parent[0]['guid'],
"href" => App::get_baseurl().'/display/'.$parent[0]['guid'],
"dfrn:diaspora_guid" => $parent[0]['guid']);
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes);
}
@ -854,7 +856,7 @@ class dfrn {
// We save this value in "plink". Maybe we should read it from there as well?
xml::add_element($doc, $entry, "link", "", array("rel" => "alternate", "type" => "text/html",
"href" => app::get_baseurl()."/display/".$item["guid"]));
"href" => App::get_baseurl()."/display/".$item["guid"]));
// "comment-allow" is some old fashioned stuff for old Friendica versions.
// It is included in the rewritten code for completeness

View File

@ -8,7 +8,8 @@
* This will change in the future.
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once 'include/items.php';
require_once 'include/bb2diaspora.php';
@ -3819,4 +3820,3 @@ class Diaspora {
return true;
}
}
?>

View File

@ -1,9 +1,9 @@
<?php
/// @TODO no longer used?
use \Friendica\Core\Config;
use Friendica\Core\Config;
function directory_run(&$argv, &$argc){
$dir = get_config('system', 'directory');
$dir = Config::get('system', 'directory');
if (!strlen($dir)) {
return;

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/socgraph.php');
require_once('include/datetime.php');

View File

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once('include/Emailer.php');
require_once('include/email.php');
require_once('include/bbcode.php');

View File

@ -4,6 +4,8 @@
* @brief functions specific to event handling
*/
use Friendica\App;
require_once 'include/bbcode.php';
require_once 'include/map.php';
require_once 'include/datetime.php';
@ -535,7 +537,7 @@ function get_event_strings() {
*
* @param array $dates Array of possibly duplicated events
* @return array Cleaned events
*
*
* @todo We should replace this with a separate update function if there is some time left
*/
function event_remove_duplicates($dates) {

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function expire_run(&$argv, &$argc){
global $a;

View File

@ -366,4 +366,3 @@ function feed_import($xml,$importer,&$contact, &$hub, $simulate = false) {
return array("header" => $author, "items" => $items);
}
}
?>

View File

@ -47,4 +47,3 @@ function update_files_for_items() {
create_files_from_item($message["id"]);
}
}
?>

View File

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/Scrape.php");
require_once("include/socgraph.php");
require_once('include/group.php');

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/Scrape.php');
require_once('include/socgraph.php');

View File

@ -325,4 +325,3 @@ function html2bbcode($message)
return $message;
}
?>

View File

@ -233,4 +233,3 @@ function html2plain($html, $wraplength = 75, $compact = false)
return(trim($message));
}
?>

View File

@ -3,6 +3,8 @@
* @file include/identity.php
*/
use Friendica\App;
require_once('include/ForumManager.php');
require_once('include/bbcode.php');
require_once("mod/proxy.php");

View File

@ -4,7 +4,8 @@
* @file include/items.php
*/
use \Friendica\ParseUrl;
use Friendica\App;
use Friendica\ParseUrl;
require_once 'include/bbcode.php';
require_once 'include/oembed.php';
@ -339,7 +340,7 @@ function add_page_info_to_body($body, $texturl = false, $no_photos = false) {
* Adds a "lang" specification in a "postopts" element of given $arr,
* if possible and not already present.
* Expects "body" element to exist in $arr.
*
*
* @todo Add a parameter to request forcing override
*/
function item_add_language_opt(&$arr) {

View File

@ -1,4 +1,7 @@
<?php
use Friendica\App;
require_once("include/diaspora.php");
/**

View File

@ -1,9 +1,8 @@
<?php
// send a private message
// send a private message
use Friendica\App;
function send_message($recipient=0, $body='', $subject='', $replyto=''){

View File

@ -187,7 +187,7 @@ function removelinebreak($message)
(substr(trim($nextline), 0, 7) == 'http://') or
(substr(trim($nextline), 0, 8) == 'https://'));
if (!$specialchars)
if (!$specialchars)
$specialchars = ((substr(rtrim($line), -1) == '-') or
(substr(rtrim($line), -1) == '=') or
(substr(rtrim($line), -1) == '*') or
@ -222,4 +222,3 @@ function removelinebreak($message)
return(implode("\n", $lines));
}
?>

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function nav(App $a) {
/*

View File

@ -4,7 +4,8 @@
* @file include/network.php
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/xml.php");
require_once('include/Probe.php');

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/html2plain.php');

View File

@ -5,6 +5,8 @@
*
*/
use Friendica\App;
define('REQUEST_TOKEN_DURATION', 300);
define('ACCESS_TOKEN_DURATION', 31536000);
@ -61,13 +63,13 @@ class FKOAuthDataStore extends OAuthDataStore {
logger(__function__.":".$consumer.", ". $callback);
$key = $this->gen_token();
$sec = $this->gen_token();
if ($consumer->key){
$k = $consumer->key;
} else {
$k = $consumer;
}
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d)",
dbesc($key),
dbesc($sec),
@ -80,19 +82,19 @@ class FKOAuthDataStore extends OAuthDataStore {
function new_access_token($token, $consumer, $verifier = null) {
logger(__function__.":".$token.", ". $consumer.", ". $verifier);
// return a new access token attached to this consumer
// for the user associated with this token if the request token
// is authorized
// should also invalidate the request token
$ret=Null;
// get user for this verifier
$uverifier = get_config("oauth", $verifier);
logger(__function__.":".$verifier.",".$uverifier);
if (is_null($verifier) || ($uverifier!==false)){
$key = $this->gen_token();
$sec = $this->gen_token();
$r = q("INSERT INTO tokens (id, secret, client_id, scope, expires, uid) VALUES ('%s','%s','%s','%s', UNIX_TIMESTAMP()+%d, %d)",
@ -103,13 +105,13 @@ class FKOAuthDataStore extends OAuthDataStore {
intval(ACCESS_TOKEN_DURATION),
intval($uverifier));
if ($r)
$ret = new OAuthToken($key,$sec);
$ret = new OAuthToken($key,$sec);
}
q("DELETE FROM tokens WHERE id='%s'", $token->key);
if (!is_null($ret) && $uverifier!==false){
del_config("oauth", $verifier);
/* $apps = get_pconfig($uverifier, "oauth", "apps");
@ -117,9 +119,9 @@ class FKOAuthDataStore extends OAuthDataStore {
$apps[] = $consumer->key;
set_pconfig($uverifier, "oauth", "apps", $apps);*/
}
return $ret;
}
}
@ -172,9 +174,9 @@ class FKOAuth1 extends OAuthServer {
intval($_SESSION['uid'])
);
call_hooks('logged_in', $a->user);
call_hooks('logged_in', $a->user);
}
}
/*
class FKOAuth2 extends OAuth2 {
@ -190,13 +192,13 @@ class FKOAuth2 extends OAuth2 {
dbesc($client_secret),
dbesc($redirect_uri)
);
return $r;
}
protected function checkClientCredentials($client_id, $client_secret = NULL) {
$client_secret = $this->db_secret($client_secret);
$r = q("SELECT pw FROM clients WHERE client_id = '%s'",
dbesc($client_id));
@ -218,21 +220,21 @@ class FKOAuth2 extends OAuth2 {
protected function getAccessToken($oauth_token) {
$r = q("SELECT client_id, expires, scope FROM tokens WHERE id = '%s'",
dbesc($oauth_token));
if (dbm::is_result($r))
return $r[0];
return null;
}
protected function setAccessToken($oauth_token, $client_id, $expires, $scope = NULL) {
$r = q("INSERT INTO tokens (id, client_id, expires, scope) VALUES ('%s', '%s', %d, '%s')",
dbesc($oauth_token),
dbesc($client_id),
intval($expires),
dbesc($scope));
return $r;
}
@ -246,23 +248,23 @@ class FKOAuth2 extends OAuth2 {
protected function getAuthCode($code) {
$r = q("SELECT id, client_id, redirect_uri, expires, scope FROM auth_codes WHERE id = '%s'",
dbesc($code));
if (dbm::is_result($r))
return $r[0];
return null;
}
protected function setAuthCode($code, $client_id, $redirect_uri, $expires, $scope = NULL) {
$r = q("INSERT INTO auth_codes
(id, client_id, redirect_uri, expires, scope) VALUES
$r = q("INSERT INTO auth_codes
(id, client_id, redirect_uri, expires, scope) VALUES
('%s', '%s', '%s', %d, '%s')",
dbesc($code),
dbesc($client_id),
dbesc($redirect_uri),
intval($expires),
dbesc($scope));
return $r;
}
return $r;
}
}
*/

View File

@ -4,8 +4,9 @@
* @file include/oembed.php
*/
use \Friendica\ParseUrl;
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\ParseUrl;
use Friendica\Core\Config;
function oembed_replacecb($matches){
$embedurl=$matches[1];

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/follow.php');

View File

@ -3,7 +3,8 @@
* @file include/ostatus.php
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/Contact.php");
require_once("include/threads.php");
@ -2192,7 +2193,7 @@ class ostatus {
/**
* @brief Creates the XML feed for a given nickname
*
* @param app $a The application class
* @param App $a The application class
* @param string $owner_nick Nickname of the feed owner
* @param string $last_update Date of the last update
*
@ -2288,4 +2289,3 @@ class ostatus {
return(trim($doc->saveXML()));
}
}
?>

View File

@ -10,7 +10,7 @@
*
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once("include/dba.php");

View File

@ -4,8 +4,8 @@
* @brief Functions related to photo handling.
*/
use \Friendica\Core\Config;
use \Friendica\Core\PConfig;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0;

View File

@ -38,4 +38,3 @@ class pidfile {
return(posix_kill(file_get_contents($this->_file), SIGTERM));
}
}
?>

View File

@ -4,7 +4,8 @@
* @file include/plaintext.php
*/
use \Friendica\ParseUrl;
use Friendica\App;
use Friendica\ParseUrl;
require_once("include/Photo.php");
require_once("include/bbcode.php");
@ -431,4 +432,3 @@ function plaintext(App $a, $b, $limit = 0, $includedlinks = false, $htmlmode = 2
return($post);
}
?>

View File

@ -1,10 +1,11 @@
<?php
/**
* @file include/plugin.php
*
*
* @brief Some functions to handle addons and themes.
*/
use Friendica\App;
/**
* @brief uninstalls an addon.
@ -164,7 +165,7 @@ function register_hook($hook,$file,$function,$priority=0) {
/**
* @brief unregisters a hook.
*
*
* @param string $hook the name of the hook
* @param string $file the name of the file that hooks into
* @param string $function the name of the function that the hook called
@ -325,7 +326,7 @@ function get_plugin_info($plugin){
/**
* @brief Parse theme comment in search of theme infos.
*
*
* like
* \code
* ..* Name: My Theme
@ -545,11 +546,11 @@ function upgrade_bool_message($bbcode = false) {
/**
* @brief Get the full path to relevant theme files by filename
*
*
* This function search in the theme directory (and if not present in global theme directory)
* if there is a directory with the file extension and for a file with the given
* filename.
*
* filename.
*
* @param string $file Filename
* @param string $root Full root path
* @return string Path to the file or empty string if the file isn't found

View File

@ -1,4 +1,8 @@
<?php
use Friendica\App;
use Friendica\Core\Config;
if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
$directory = dirname($_SERVER["argv"][0]);
@ -10,15 +14,13 @@ if (!file_exists("boot.php") AND (sizeof($_SERVER["argv"]) != 0)) {
chdir($directory);
}
use \Friendica\Core\Config;
require_once("boot.php");
function poller_run($argv, $argc){
global $a, $db;
if(is_null($a)) {
$a = new App;
if (is_null($a)) {
$a = new App(dirname(__DIR__));
}
if(is_null($db)) {
@ -89,7 +91,6 @@ function poller_run($argv, $argc){
if (time() > ($starttime + 3600))
return;
}
}
/**
@ -687,4 +688,3 @@ if (array_search(__file__,get_included_files())===0){
killme();
}
?>

View File

@ -258,5 +258,3 @@ function post_update_1206() {
logger("Done", LOGGER_DEBUG);
return true;
}
?>

View File

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/items.php');
require_once('include/ostatus.php');

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once('include/queue_fn.php');
require_once('include/dfrn.php');

View File

@ -129,4 +129,3 @@ function removetofu($message)
return($message);
}
?>

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
function auto_redir(App $a, $contact_nick) {
// prevent looping

View File

@ -4,7 +4,7 @@
* @brief Removes orphaned data from deleted contacts
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
function remove_contact_run($argv, $argc) {
if ($argc != 2) {
@ -22,4 +22,3 @@ function remove_contact_run($argv, $argc) {
// Now we delete all the depending table entries
dba::delete('contact', array('id' => $id));
}
?>

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
/**
* @brief Calculate the hash that is needed for the "Friendica" cookie
*

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("boot.php");
require_once("include/threads.php");
@ -9,7 +10,7 @@ function shadowupdate_run(&$argv, &$argc){
global $a, $db;
if (is_null($a)) {
$a = new App;
$a = new App(dirname(__DIR__));
}
if (is_null($db)) {

View File

@ -1,13 +1,14 @@
<?php
/**
* @file include/socgraph.php
*
*
* @todo Move GNU Social URL schemata (http://server.tld/user/number) to http://server.tld/username
* @todo Fetch profile data from profile page for Redmatrix users
* @todo Detect if it is a forum
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('include/datetime.php');
require_once("include/Scrape.php");
@ -1425,7 +1426,7 @@ function common_friends_zcid($uid,$zcid,$start = 0, $limit = 9999,$shuffle = fal
$r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
and `gcontact`.`nurl` in (select nurl from contact where uid = %d and self = 0 and blocked = 0 and hidden = 0 )
$sql_extra limit %d, %d",
intval($zcid),
intval($uid),
@ -2340,4 +2341,3 @@ function poco_serverlist() {
}
return $r;
}
?>

View File

@ -4,7 +4,7 @@
* @brief Posts items that wer spooled because they couldn't be posted.
*/
use \Friendica\Core\Config;
use Friendica\Core\Config;
require_once("include/items.php");
@ -55,4 +55,3 @@ function spool_post_run($argv, $argc) {
}
}
}
?>

View File

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function create_tags_from_item($itemid) {
$profile_base = App::get_baseurl();
$profile_data = parse_url($profile_base);
@ -145,4 +148,3 @@ function update_items() {
dba::close($messages);
}
?>

View File

@ -1,12 +1,13 @@
<?php
use Friendica\App;
require_once("include/template_processor.php");
require_once("include/friendica_smarty.php");
require_once("include/Smilies.php");
require_once("include/map.php");
require_once("mod/proxy.php");
if(! function_exists('replace_macros')) {
/**
* This is our template processor

View File

@ -1,4 +1,7 @@
<?php
use Friendica\App;
function add_thread($itemid, $onlyshadow = false) {
$items = q("SELECT `uid`, `created`, `edited`, `commented`, `received`, `changed`, `wall`, `private`, `pubmail`,
`moderated`, `visible`, `spam`, `starred`, `bookmark`, `contact-id`, `gcontact-id`,
@ -293,4 +296,3 @@ function update_shadow_copy() {
dba::close($messages);
}
?>

View File

@ -1,11 +1,7 @@
<?php
/**
* import account file exported from mod/uexport
* args:
* $a App Friendica App Class
* $file Array array from $_FILES
*/
use Friendica\App;
require_once("include/Photo.php");
define("IMPORT_DEBUG", False);
@ -75,6 +71,12 @@ function import_cleanup($newuid) {
q("DELETE FROM `pconfig` WHERE uid = %d", $newuid);
}
/**
* @brief Import account file exported from mod/uexport
*
* @param App $a Friendica App Class
* @param array $file array from $_FILES
*/
function import_account(App $a, $file) {
logger("Start user import from " . $file['tmp_name']);
/*
@ -255,10 +257,6 @@ function import_account(App $a, $file) {
}
}
foreach ($account['photo'] as &$photo) {
$photo['uid'] = $newuid;
$photo['data'] = hex2bin($photo['data']);

View File

@ -1,6 +1,6 @@
<?php
use \Friendica\Core\Config;
use Friendica\Core\Config;
function update_gcontact_run(&$argv, &$argc) {
global $a;

View File

@ -13,12 +13,13 @@
*
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once('boot.php');
require_once('object/BaseObject.php');
require_once 'boot.php';
require_once 'object/BaseObject.php';
$a = new App;
$a = new App(__DIR__);
BaseObject::set_app($a);
// We assume that the index.php is called by a frontend process
@ -73,7 +74,7 @@ if (!$install) {
exit();
}
require_once("include/session.php");
require_once 'include/session.php';
load_hooks();
call_hooks('init_1');
@ -486,7 +487,7 @@ header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8");
/*
* We use $_GET["mode"] for special page templates. So we will check if we have
* We use $_GET["mode"] for special page templates. So we will check if we have
* to load another page template than the default one.
* The page templates are located in /view/php/ or in the theme directory.
*/

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("mod/hostxrd.php");
require_once("mod/nodeinfo.php");

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Scrape.php');
function acctlink_init(App $a) {

View File

@ -1,6 +1,8 @@
<?php
/* ACL selector json backend */
use Friendica\App;
require_once 'include/acl_selectors.php';
function acl_init(App $a) {

View File

@ -6,7 +6,8 @@
* @brief Friendica admin
*/
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
require_once("include/enotify.php");
require_once("include/text.php");

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');

View File

@ -1,8 +1,9 @@
<?php
use Friendica\App;
function amcd_content(App $a) {
//header("Content-type: text/json");
echo <<< EOT
echo <<< JSON
{
"version":1,
"sessionstatus":{
@ -44,6 +45,6 @@ echo <<< EOT
}
}
}
EOT;
killme();
JSON;
killme();
}

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/api.php');
function oauth_get_client($request){
@ -106,8 +108,6 @@ function api_content(App $a) {
'$no' => t('No'),
));
//echo "<pre>"; var_dump($app); killme();
return $o;
}

View File

@ -1,25 +1,25 @@
<?php
use Friendica\App;
function apps_content(App $a) {
$privateaddons = get_config('config','private_addons');
if ($privateaddons === "1") {
if((! (local_user()))) {
info( t("You must be logged in to use addons. "));
return;};
}
$privateaddons = get_config('config', 'private_addons');
if ($privateaddons === "1") {
if (! local_user()) {
info(t('You must be logged in to use addons. '));
return;
};
}
$title = t('Applications');
$title = t('Applications');
if(count($a->apps)==0)
notice( t('No installed applications.') . EOL);
if (count($a->apps) == 0) {
notice(t('No installed applications.') . EOL);
}
$tpl = get_markup_template("apps.tpl");
$tpl = get_markup_template('apps.tpl');
return replace_macros($tpl, array(
'$title' => $title,
'$apps' => $a->apps,
));
}

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/security.php');
function attach_init(App $a) {

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once 'include/bbcode.php';
require_once 'library/markdown.php';
require_once 'include/bb2diaspora.php';

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/conversation.php');
require_once('include/items.php');

View File

@ -6,6 +6,8 @@
* of the profile owner
*/
use Friendica\App;
require_once('include/event.php');
require_once('include/redir.php');

View File

@ -4,6 +4,7 @@
* General purpose landing page for plugins/addons
*/
use Friendica\App;
function cb_init(App $a) {
call_hooks('cb_init');

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/socgraph.php');
require_once('include/Contact.php');
require_once('include/contact_selectors.php');

View File

@ -1,6 +1,7 @@
<?php
use \Friendica\Core\Config;
use Friendica\App;
use Friendica\Core\Config;
function community_init(App $a) {
if (! local_user()) {
@ -9,7 +10,6 @@ function community_init(App $a) {
}
}
function community_content(App $a, $update = 0) {
$o = '';

View File

@ -1,10 +1,10 @@
<?php
use Friendica\App;
require_once('include/group.php');
function contactgroup_content(App $a) {
if (! local_user()) {
killme();
}

View File

@ -1,5 +1,7 @@
<?php
use Friendica\App;
require_once('include/Contact.php');
require_once('include/socgraph.php');
require_once('include/contact_selectors.php');
@ -828,7 +830,7 @@ function contacts_content(App $a) {
*
* Available Pages are 'Status', 'Profile', 'Contacts' and 'Common Friends'
*
* @param app $a
* @param App $a
* @param int $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active
*

View File

@ -15,6 +15,7 @@
// fast - e.g. one or two milliseconds to fetch parent items for the current content,
// and 10-20 milliseconds to fetch all the child items.
use Friendica\App;
function content_content(App $a, $update = 0) {

Some files were not shown because too many files have changed in this diff Show More