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", "name": "pear-pear.php.net/PEAR",
"version": "1.10.3", "version": "1.10.4",
"dist": { "dist": {
"type": "file", "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, "reference": null,
"shasum": null "shasum": null
}, },
@ -247,7 +247,7 @@
"pear-pear.php.net/pear_frontend_web": "<=0.4.0.0" "pear-pear.php.net/pear_frontend_web": "<=0.4.0.0"
}, },
"replace": { "replace": {
"pear-pear/pear": "== 1.10.3.0" "pear-pear/pear": "== 1.10.4.0"
}, },
"type": "pear-library", "type": "pear-library",
"autoload": { "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] $> 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`. 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) * [Using Composer](help/Composer)
* [How To Move Classes to `src`](help/Developer-How-To-Move-Classes-to-src)
###Coding standards ###Coding standards

View file

@ -36,21 +36,25 @@ Friendica Documentation and Resources
**Developer Manual** **Developer Manual**
* [Where to get started?](help/Developers-Intro) * [Get started](help/Developers-Intro)
* [Help on Github](help/Github) * Set up development environment
* [Help on Vagrant](help/Vagrant) * [Help on Github](help/Github)
* [How to translate Friendica](help/translations) * [Help on Vagrant](help/Vagrant)
* [Bugs and Issues](help/Bugs-and-Issues) * [Bugs and Issues](help/Bugs-and-Issues)
* [Plugin Development](help/Plugins) * Code structure
* [Theme Development](help/themes) * [Plugin Development](help/Plugins)
* [Smarty 3 Templates](help/smarty3-templates) * [Theme Development](help/themes)
* [Protocol Documentation](help/Protocol) * [Smarty 3 Templates](help/smarty3-templates)
* [Database schema documantation](help/database) * How To
* [Class Autoloading](help/autoloader) * [Translate Friendica](help/translations)
* [Using Composer](help/Composer) * [Use Composer](help/Composer)
* [Code - Reference(Doxygen generated - sets cookies)](doc/html/) * [Move classes to `src`](help/Developer-How-To-Move-Classes-to-src)
* [Twitter/GNU Social API Functions](help/api) * 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** **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: Let's say you have a PHP file in `src/` that define a very useful class:
```php ```php
// src/ItemsManager.php // src/ItemsManager.php
<?php <?php
namespace \Friendica; namespace Friendica;
class ItemsManager { class ItemsManager {
public function getAll() { ... } public function getAll() { ... }
public function getByID($id) { ... } public function getByID($id) { ... }
} }
``` ```
The class `ItemsManager` has been declared in the `Friendica` namespace. 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: The code will be something like:
```php ```php
// mod/network.php // mod/network.php
<?php <?php
function network_content(App $a) { function network_content(App $a) {
$itemsmanager = new \Friendica\ItemsManager(); $itemsmanager = new Friendica\ItemsManager();
$items = $itemsmanager->getAll(); $items = $itemsmanager->getAll();
// pass $items to template // pass $items to template
// return result // return result
} }
``` ```
That's a quite simple example, but look: no `require()`! 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: 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 ```php
// src/BaseManager.php // src/BaseManager.php
<?php <?php
namespace \Friendica; namespace Friendica;
class BaseManager { class BaseManager {
public function thatFunctionEveryManagerUses() { ... } public function thatFunctionEveryManagerUses() { ... }
} }
``` ```
and then let's change the ItemsManager class to use this code and then let's change the ItemsManager class to use this code
```php ```php
// src/ItemsManager.php // src/ItemsManager.php
<?php <?php
namespace \Friendica; namespace Friendica;
class ItemsManager extends BaseManager { class ItemsManager extends BaseManager {
public function getAll() { ... } public function getAll() { ... }
public function getByID($id) { ... } 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. 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: It works with the "BaseManager" example here and it works when we need to call static methods:
```php ```php
// src/Dfrn.php // src/Dfrn.php
<?php <?php
namespace \Friendica; namespace Friendica;
class Dfrn { class Dfrn {
public static function mail($item, $owner) { ... } public static function mail($item, $owner) { ... }
} }
``` ```
```php ```php
// mod/mail.php // mod/mail.php
<?php <?php
mail_post($a){ mail_post($a){
... ...
\Friendica\dfrn::mail($item, $owner); Friendica\dfrn::mail($item, $owner);
... ...
} }
``` ```
If your code is in same namespace as the class you need, you don't need to prepend it: If your code is in same namespace as the class you need, you don't need to prepend it:
```php ```php
// include/delivery.php // include/delivery.php
<?php <?php
namespace \Friendica; namespace Friendica;
// this is the same content of current include/delivery.php, // this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace // but has been declared to be in "Friendica" namespace
[...] [...]
switch($contact['network']) { switch($contact['network']) {
case NETWORK_DFRN: case NETWORK_DFRN:
if ($mail) { if ($mail) {
$item['body'] = ... $item['body'] = ...
$atom = Dfrn::mail($item, $owner); $atom = Dfrn::mail($item, $owner);
} elseif ($fsuggest) { } elseif ($fsuggest) {
$atom = Dfrn::fsuggest($item, $owner); $atom = Dfrn::fsuggest($item, $owner);
q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id'])); q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id']));
} elseif ($relocate) } elseif ($relocate)
$atom = Dfrn::relocate($owner, $uid); $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. 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. But if you want to use classes from another library, you need to use the full namespace, e.g.
```php ```php
// src/Diaspora.php // src/Diaspora.php
<?php <?php
namespace \Friendica; namespace Friendica;
class Diaspora { class Diaspora {
public function md2bbcode() { public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text); $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 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 ```php
// src/Diaspora.php // src/Diaspora.php
<?php <?php
namespace \Friendica; namespace Friendica;
use \Michelf\MarkdownExtra; use \Michelf\MarkdownExtra;
class Diaspora { class Diaspora {
public function md2bbcode() { public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text); $html = MarkdownExtra::defaultTransform($text);
}
} }
}
``` ```
Note that namespaces are like paths in filesystem, separated by "\", with the first "\" being the global scope. 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: You can go deeper if you want to, like:
``` ```
// src/Network/Dfrn.php // src/Network/Dfrn.php
<?php <?php
namespace \Friendica\Network; 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 or
``` ```
// src/Dba/Mysql // src/Dba/Mysql
<?php <?php
namespace \Friendica\Dba; 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 ("\"). 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 <?php
use Friendica\App;
// Included here for completeness, but this is a very dangerous operation. // Included here for completeness, but this is a very dangerous operation.
// It is the caller's responsibility to confirm the requestor's intent and // It is the caller's responsibility to confirm the requestor's intent and
// authorisation to do this. // authorisation to do this.
@ -852,4 +854,3 @@ function account_type($contact) {
return $account_type; return $account_type;
} }
?>

View file

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

View file

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

View file

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

View file

@ -5,8 +5,9 @@
* *
*/ */
use \Friendica\Core\Config; use Friendica\App;
use \Friendica\Core\PConfig; use Friendica\Core\Config;
use Friendica\Core\PConfig;
require_once("include/feed.php"); require_once("include/feed.php");
require_once('include/email.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 * @brief This file contains the Smilies class which contains functions to handle smiles
*/ */
use Friendica\App;
/** /**
* This class contains functions to handle smiles * This class contains functions to handle smiles
*/ */
@ -13,13 +15,13 @@ class Smilies {
/** /**
* @brief Function to list all smilies * @brief Function to list all smilies
* *
* Get an array of all smilies, both internal and from addons. * Get an array of all smilies, both internal and from addons.
* *
* @return array * @return array
* 'texts' => smilie shortcut * 'texts' => smilie shortcut
* 'icons' => icon in html * 'icons' => icon in html
* *
* @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array) * @hook smilie ('texts' => smilies texts array, 'icons' => smilies html array)
*/ */
public static function get_list() { public static function get_list() {
@ -64,41 +66,41 @@ class Smilies {
); );
$icons = array( $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-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-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-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-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-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-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=":-\" 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-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-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-|" 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="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-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-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-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-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-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-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-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/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=":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/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/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/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/like.gif" alt=":like" title=":like" />',
'<img class="smiley" src="' . app::get_baseurl() . '/images/dislike.gif" alt=":dislike" title=":dislike" />', '<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://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#" 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>' '<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); $params = array('texts' => $texts, 'icons' => $icons);
@ -121,7 +123,7 @@ class Smilies {
* *
* @param string $s * @param string $s
* @param boolean $sample * @param boolean $sample
* *
* @return string HML Output of the Smilie * @return string HML Output of the Smilie
*/ */
public static function replace($s, $sample = false) { public static function replace($s, $sample = false) {
@ -166,7 +168,7 @@ class Smilies {
* *
* @param string $x * @param string $x
* @return string HTML Output * @return string HTML Output
* *
* @todo: Rework because it doesn't work correctly * @todo: Rework because it doesn't work correctly
*/ */
private function preg_heart($x) { private function preg_heart($x) {
@ -174,7 +176,7 @@ class Smilies {
return $x[0]; return $x[0];
$t = ''; $t = '';
for($cnt = 0; $cnt < strlen($x[1]); $cnt ++) 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]); $r = str_replace($x[0],$t,$x[0]);
return $r; return $r;
} }

View file

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

View file

@ -6,7 +6,8 @@
* @todo Automatically detect if incoming data is HTML or BBCode * @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/HTTPExceptions.php';
require_once 'include/bbcode.php'; require_once 'include/bbcode.php';

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,10 @@
<?php <?php
use Friendica\App;
require_once "include/bbcode.php"; require_once "include/bbcode.php";
require_once "include/acl_selectors.php"; require_once "include/acl_selectors.php";
/* /*
* Note: the code in 'item_extract_images' and 'item_redir_and_replace_images' * 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 * 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); add_shadow_entry($message_id);
} }
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -7,6 +7,8 @@
* https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf * https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/ */
use Friendica\App;
require_once("include/Contact.php"); require_once("include/Contact.php");
require_once("include/ostatus.php"); require_once("include/ostatus.php");
require_once("include/enotify.php"); require_once("include/enotify.php");
@ -370,7 +372,7 @@ class dfrn {
$ext = Photo::supportedTypes(); $ext = Photo::supportedTypes();
foreach ($rp as $p) { 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); unset($rp, $ext);
@ -431,7 +433,7 @@ class dfrn {
$root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS); $root->setAttribute("xmlns:ostatus", NAMESPACE_OSTATUS);
$root->setAttribute("xmlns:statusnet", NAMESPACE_STATUSNET); $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"]); xml::add_element($doc, $root, "title", $owner["name"]);
$attributes = array("uri" => "https://friendi.ca", "version" => FRIENDICA_VERSION."-".DB_UPDATE_VERSION); $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. // DFRN itself doesn't uses this. But maybe someone else wants to subscribe to the public feed.
ostatus::hublinks($doc, $root); 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); 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); 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); 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, "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); xml::add_element($doc, $author, "dfrn:handle", $owner["addr"], $attributes);
$attributes = array("rel" => "photo", "type" => "image/jpeg", $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 = q("SELECT `guid` FROM `item` WHERE `id` = %d", intval($item["parent"]));
$parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']); $parent_item = (($item['thr-parent']) ? $item['thr-parent'] : $item['parent-uri']);
$attributes = array("ref" => $parent_item, "type" => "text/html", $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']); "dfrn:diaspora_guid" => $parent[0]['guid']);
xml::add_element($doc, $entry, "thr:in-reply-to", "", $attributes); 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? // 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", 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. // "comment-allow" is some old fashioned stuff for old Friendica versions.
// It is included in the rewritten code for completeness // It is included in the rewritten code for completeness

View file

@ -8,7 +8,8 @@
* This will change in the future. * 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/items.php';
require_once 'include/bb2diaspora.php'; require_once 'include/bb2diaspora.php';
@ -3819,4 +3820,3 @@ class Diaspora {
return true; return true;
} }
} }
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,9 +1,8 @@
<?php <?php
// send a private message // send a private message
use Friendica\App;
function send_message($recipient=0, $body='', $subject='', $replyto=''){ 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, 7) == 'http://') or
(substr(trim($nextline), 0, 8) == 'https://')); (substr(trim($nextline), 0, 8) == 'https://'));
if (!$specialchars) if (!$specialchars)
$specialchars = ((substr(rtrim($line), -1) == '-') or $specialchars = ((substr(rtrim($line), -1) == '-') or
(substr(rtrim($line), -1) == '=') or (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)); return(implode("\n", $lines));
} }
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -4,8 +4,8 @@
* @brief Functions related to photo handling. * @brief Functions related to photo handling.
*/ */
use \Friendica\Core\Config; use Friendica\Core\Config;
use \Friendica\Core\PConfig; use Friendica\Core\PConfig;
function getGps($exifCoord, $hemi) { function getGps($exifCoord, $hemi) {
$degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; $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)); return(posix_kill(file_get_contents($this->_file), SIGTERM));
} }
} }
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,14 @@
<?php <?php
/** /**
* @file include/socgraph.php * @file include/socgraph.php
* *
* @todo Move GNU Social URL schemata (http://server.tld/user/number) to http://server.tld/username * @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 Fetch profile data from profile page for Redmatrix users
* @todo Detect if it is a forum * @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/datetime.php');
require_once("include/Scrape.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`.* $r = q("SELECT `gcontact`.*
FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id` FROM `glink` INNER JOIN `gcontact` on `glink`.`gcid` = `gcontact`.`id`
where `glink`.`zcid` = %d 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", $sql_extra limit %d, %d",
intval($zcid), intval($zcid),
intval($uid), intval($uid),
@ -2340,4 +2341,3 @@ function poco_serverlist() {
} }
return $r; return $r;
} }
?>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,6 +1,6 @@
<?php <?php
use \Friendica\Core\Config; use Friendica\Core\Config;
function update_gcontact_run(&$argv, &$argc) { function update_gcontact_run(&$argv, &$argc) {
global $a; 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 'boot.php';
require_once('object/BaseObject.php'); require_once 'object/BaseObject.php';
$a = new App; $a = new App(__DIR__);
BaseObject::set_app($a); BaseObject::set_app($a);
// We assume that the index.php is called by a frontend process // We assume that the index.php is called by a frontend process
@ -73,7 +74,7 @@ if (!$install) {
exit(); exit();
} }
require_once("include/session.php"); require_once 'include/session.php';
load_hooks(); load_hooks();
call_hooks('init_1'); call_hooks('init_1');
@ -486,7 +487,7 @@ header("X-Friendica-Version: " . FRIENDICA_VERSION);
header("Content-type: text/html; charset=utf-8"); 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. * to load another page template than the default one.
* The page templates are located in /view/php/ or in the theme directory. * The page templates are located in /view/php/ or in the theme directory.
*/ */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,7 @@
<?php <?php
use Friendica\App;
require_once('include/Contact.php'); require_once('include/Contact.php');
require_once('include/socgraph.php'); require_once('include/socgraph.php');
require_once('include/contact_selectors.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' * 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 $contact_id The ID of the contact
* @param int $active_tab 1 if tab should be marked as active * @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, // 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. // and 10-20 milliseconds to fetch all the child items.
use Friendica\App;
function content_content(App $a, $update = 0) { function content_content(App $a, $update = 0) {

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