Browse Source

Merge branch 'develop' into rewrites/coding-convention-split2

pull/3254/head
Hypolite Petovan 4 years ago
committed by GitHub
parent
commit
9237b2611a
  1. 3
      .gitignore
  2. 3
      boot.php
  3. 34
      composer.json
  4. 114
      composer.lock
  5. 98
      doc/Composer.md
  6. 12
      doc/Developers-Intro.md
  7. 1
      doc/Home.md
  8. 251
      doc/autoloader.md
  9. 4
      doc/de/Home.md
  10. 66
      include/Probe.php
  11. 69
      include/autoloader.php
  12. 9
      include/autoloader/autoload_classmap.php
  13. 10
      include/autoloader/autoload_psr4.php
  14. 11
      include/contact_selectors.php
  15. 247
      include/ostatus.php
  16. 11
      library/Mobile_Detect/.gitignore
  17. 3
      library/Mobile_Detect/.gitmodules
  18. 24
      library/Mobile_Detect/.php_cs
  19. 17
      library/Mobile_Detect/.travis.yml
  20. 1
      library/Mobile_Detect/Mobile_Detect.json
  21. 219
      library/Mobile_Detect/README.md
  22. 0
      src/Core/Config.php
  23. 0
      src/Core/PConfig.php
  24. 0
      src/ParseUrl.php
  25. BIN
      util/composer.phar
  26. 7
      vendor/autoload.php
  27. 76
      vendor/composer/ClassLoader.php
  28. 40
      vendor/composer/LICENSE
  29. 243
      vendor/composer/autoload_classmap.php
  30. 2
      vendor/composer/autoload_files.php
  31. 3
      vendor/composer/autoload_namespaces.php
  32. 10
      vendor/composer/autoload_psr4.php
  33. 70
      vendor/composer/autoload_real.php
  34. 291
      vendor/composer/autoload_static.php
  35. 102
      vendor/composer/installed.json
  36. 0
      vendor/ezyang/htmlpurifier/CREDITS
  37. 0
      vendor/ezyang/htmlpurifier/INSTALL
  38. 0
      vendor/ezyang/htmlpurifier/INSTALL.fr.utf8
  39. 0
      vendor/ezyang/htmlpurifier/LICENSE
  40. 0
      vendor/ezyang/htmlpurifier/NEWS
  41. 0
      vendor/ezyang/htmlpurifier/README
  42. 0
      vendor/ezyang/htmlpurifier/TODO
  43. 0
      vendor/ezyang/htmlpurifier/VERSION
  44. 0
      vendor/ezyang/htmlpurifier/WHATSNEW
  45. 0
      vendor/ezyang/htmlpurifier/WYSIWYG
  46. 0
      vendor/ezyang/htmlpurifier/composer.json
  47. 0
      vendor/ezyang/htmlpurifier/extras/ConfigDoc/HTMLXSLTProcessor.php
  48. 0
      vendor/ezyang/htmlpurifier/extras/FSTools.php
  49. 0
      vendor/ezyang/htmlpurifier/extras/FSTools/File.php
  50. 0
      vendor/ezyang/htmlpurifier/extras/HTMLPurifierExtras.auto.php
  51. 0
      vendor/ezyang/htmlpurifier/extras/HTMLPurifierExtras.autoload.php
  52. 0
      vendor/ezyang/htmlpurifier/extras/HTMLPurifierExtras.php
  53. 0
      vendor/ezyang/htmlpurifier/extras/README
  54. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php
  55. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.autoload.php
  56. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.composer.php
  57. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.func.php
  58. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php
  59. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.kses.php
  60. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php
  61. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.php
  62. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php
  63. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php
  64. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php
  65. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php
  66. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php
  67. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php
  68. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php
  69. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php
  70. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php
  71. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php
  72. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php
  73. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php
  74. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php
  75. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php
  76. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php
  77. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php
  78. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ImportantDecorator.php
  79. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php
  80. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php
  81. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php
  82. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php
  83. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php
  84. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php
  85. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php
  86. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php
  87. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php
  88. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php
  89. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php
  90. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php
  91. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php
  92. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php
  93. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php
  94. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php
  95. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php
  96. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Nmtokens.php
  97. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php
  98. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php
  99. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php
  100. 0
      vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php

3
.gitignore

@ -51,3 +51,6 @@ nbproject
#ignore things from transifex-client
venv/
#ignore git projects in vendor
vendor/**/.git

3
boot.php

@ -17,7 +17,7 @@
* easily as email does today.
*/
require_once('include/autoloader.php');
require_once(__DIR__ . DIRECTORY_SEPARATOR. 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
use \Friendica\Core\Config;
@ -29,7 +29,6 @@ require_once('include/datetime.php');
require_once('include/pgettext.php');
require_once('include/nav.php');
require_once('include/cache.php');
require_once('library/Mobile_Detect/Mobile_Detect.php');
require_once('include/features.php');
require_once('include/identity.php');
require_once('update.php');

34
composer.json

@ -0,0 +1,34 @@
{
"name": "friendica/friendica",
"description": "A decentralized social network part of The Federation",
"type": "project",
"keywords": [
"social network",
"dfrn",
"ostatus",
"diaspora"
],
"licence": "GNU-Affero",
"support": {
"issues": "https://github.com/friendica/friendica/issues"
},
"require": {
"ezyang/htmlpurifier": "~4.7.0",
"mobiledetect/mobiledetectlib": "2.8.*"
},
"autoload": {
"psr-4": {
"Friendica\\": "src/"
}
},
"config": {
"autoloader-suffix": "Friendica",
"optimize-autoloader": true,
"preferred-install": "dist"
},
"archive": {
"exclude": [
"log", "cache", "/photo", "/proxy"
]
}
}

114
composer.lock

@ -0,0 +1,114 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "49b00f1ed3192e5173bd5577a3b91ba2",
"packages": [
{
"name": "ezyang/htmlpurifier",
"version": "v4.7.0",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "ae1828d955112356f7677c465f94f7deb7d27a40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/ae1828d955112356f7677c465f94f7deb7d27a40",
"reference": "ae1828d955112356f7677c465f94f7deb7d27a40",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"type": "library",
"autoload": {
"psr-0": {
"HTMLPurifier": "library/"
},
"files": [
"library/HTMLPurifier.composer.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"time": "2015-08-05T01:03:42+00:00"
},
{
"name": "mobiledetect/mobiledetectlib",
"version": "2.8.25",
"source": {
"type": "git",
"url": "https://github.com/serbanghita/Mobile-Detect.git",
"reference": "f0896b5c7274d1450023b0b376240be902c3251c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/f0896b5c7274d1450023b0b376240be902c3251c",
"reference": "f0896b5c7274d1450023b0b376240be902c3251c",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phpunit/phpunit": "*"
},
"type": "library",
"autoload": {
"classmap": [
"Mobile_Detect.php"
],
"psr-0": {
"Detection": "namespaced/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http://mobiledetect.net",
"role": "Developer"
}
],
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"homepage": "https://github.com/serbanghita/Mobile-Detect",
"keywords": [
"detect mobile devices",
"mobile",
"mobile detect",
"mobile detector",
"php mobile detect"
],
"time": "2017-03-29T13:59:30+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": []
}

98
doc/Composer.md

@ -0,0 +1,98 @@
Using Composer
==============
* [Home](help)
* [Developer Intro](help/Developers-Intro)
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
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)
## How to use Composer
If you don't have Composer installed on your system, Friendica ships with a copy of it at `util/composer.phar`.
For the purpose of this help, all examples will use this path to run Composer commands, however feel free to replace them with your own way of calling Composer.
Composer requires PHP CLI and the following examples assume it's available system-wide.
### Installing/Updating Friendica
#### From Archive
If you just unpacked a Friendica release archive, you don't have to use Commposer at all, all the required libraries are already bundled in the archive.
#### Installing with Git
If you prefer to use `git`, you will have to run Composer to fetch the required libraries and build the autoloader before you can run Friendica.
Here are the typical commands you will have to run to do so:
````
~> git clone https://github.com/friendica/friendica.git friendica
~/friendica> cd friendica
~/friendica> util/composer.phar install
````
That's it! Composer will take care of fetching all the required libraries in the `vendor` folder and build the autoloader to make those libraries available to Friendica.
#### Updating with Git
Updating Friendica to the current stable or the latest develop version is easy with Git, just remember to run Composer after every branch pull.
````
~> cd friendica
~/friendica> git pull
~/friendica> util/composer.phar install
````
And that's it. If any library used by Friendica has been upgraded, Composer will fetch the version currently used by Friendica and refresh the autoloader to ensure the best performances.
### Developing Friendica
First of all, thanks for contributing to Friendica!
Composer is meant to be used by developers to maintain third-party libraries required by Friendica.
If you don't need to use any third-party library, then you don't need to use Composer beyond what is above to install/update Friendica.
#### Adding a third-party library to Friendica
Does your shiny new [Plugin](help/Plugins) need to rely on a third-party library not required by Friendica yet?
First of all, this library should be available on [Packagist](https://packagist.org) so that Composer knows how to fetch it directly just by mentioning its name in `composer.json`.
This file is the configuration of Friendica for Composer. It lists details about the Friendica project, but also a list of required dependencies and their target version.
Here's a simplified version of the one we currently use on Friendica:
````json
{
"name": "friendica/friendica",
"description": "A decentralized social network part of The Federation",
"type": "project",
...
"require": {
"ezyang/htmlpurifier": "~4.7.0",
"mobiledetect/mobiledetectlib": "2.8.*"
},
...
}
````
The important part is under the `require` key, this is a list of all the libraries Friendica may need to run.
As you can see, at the moment we only require two, HTMLPurifier and MobileDetect.
Each library has a different target version, and [per Composer documentation about version constraints](https://getcomposer.org/doc/articles/versions.md#writing-basic-version-constraints), this means that:
* We will update HTMLPurifier up to version 4.8.0 excluded
* We will update MobileDetect up to version 2.9.0 excluded
There are other operators you can use to allow Composer to update the package up to the next major version excluded.
Or you can specify the exact version of the library if you code requires it, and Composer will never update it although it isn't recommended.
To add a library, just add its Packagist identifier to the `require` list and set a target version string.
Then you should run `util/composer.phar update` to add it to your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
#### Updating an existing dependency
If a package needs to be updated, whether to the next minor version or to the next major version provided you changed the adequate code in Friendica, simply edit `composer.json` to update the target version string of the relevant library.
Then you should run `util/composer.phar update` to update it in your local `vendor` folder and update the `composer.lock` file that specifies the current versions of the dependencies.
Please note that you should commit both `composer.json` and `composer.lock` with your work every time you make a change to the former.

12
doc/Developers-Intro.md

@ -6,8 +6,7 @@ Where to get started to help improve Friendica?
Do you want to help us improve Friendica?
Here we have compiled some hints on how to get started and some tasks to help you choose.
A project like Friendica is the sum of many different contributions.
**Very different skills are required to make good software.
Some of them involve coding, others do not.**
**Very different skills are required to make good software, not all of them involve coding!**
We are looking for helpers in all areas, whether you write text or code, whether you spread the word to convince people or design new icons.
Whether you feel like an expert or like a newbie - join us with your ideas!
@ -47,6 +46,14 @@ We can't promise we have the right skills in the group but we'll try.
Programming
---
### Composer
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
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`.
* [Using Composer](help/Composer)
###Coding standards
For the sake of consistency between contribution and general code readability, Friendica follows the widespread [PSR-2 coding standards](http://www.php-fig.org/psr/psr-2/) to the exception of a few rules.
@ -120,6 +127,7 @@ Ask us to find out whom to talk to about their experiences.
Do not worry about cross-posting.
###Client software
As Friendica is using a [Twitter/GNU Social compatible API](help/api) any of the clients for those platforms should work with Friendica as well.
Furthermore there are several client projects, especially for use with Friendica.
If you are interested in improving those clients, please contact the developers of the clients directly.

1
doc/Home.md

@ -47,6 +47,7 @@ Friendica Documentation and Resources
* [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)

251
doc/autoloader.md

@ -1,209 +1,192 @@
Autoloader
Autoloader with Composer
==========
* [Home](help)
* [Developer Intro](help/Developers-Intro)
There is some initial support to class autoloading in Friendica core.
Friendica uses [Composer](https://getcomposer.org) to manage dependencies libraries and the class autoloader both for libraries and namespaced Friendica classes.
The autoloader code is in `include/autoloader.php`.
It's derived from composer autoloader code.
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`.
Namespaces and Classes are mapped to folders and files in `library/`,
and the map must be updated by hand, because we don't use composer yet.
The mapping is defined by files in `include/autoloader/` folder.
* [Using Composer](help/Composer)
Currently, only HTMLPurifier library is loaded using autoloader.
## A quick introduction to class autoloading
The autoloader dynamically includes the file defining a class when it is first referenced, either by instantiating an object or simply making sure that it is available, without the need to explicitly use "require_once".
## A quick introdution to class autoloading
Once it is set up you don't have to directly use it, you can directly use any class that is covered by the autoloader (currently `vendor` and `src`)
The autoloader it's a way for php to automagically include the file that define a class when the class is first used, without the need to use "require_once" every time.
Under the hood, Composer registers a callback with [`spl_autoload_register()`](http://php.net/manual/en/function.spl-autoload-register.php) that receives a class name as an argument and includes the corresponding class definition file.
For more info about PHP autoloading, please refer to the [official PHP documentation](http://php.net/manual/en/language.oop5.autoload.php).
Once is setup you don't have to use it in any way. You need a class? you use the class.
### Example
At his basic is a function passed to the "spl_autoload_register()" function, which receive as argument the class name the script want and is it job to include the correct php file where that class is defined.
The best source for documentation is [php site](http://php.net/manual/en/language.oop5.autoload.php).
Let's say you have a PHP file in `src/` that define a very useful class:
One example, based on fictional friendica code.
```php
// src/ItemsManager.php
<?php
namespace \Friendica;
Let's say you have a php file in "include/" that define a very useful class:
```
file: include/ItemsManager.php
<?php
namespace \Friendica;
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
The class "ItemsManager" has been declared in "Friendica" namespace.
Namespaces are useful to keep things separated and avoid names clash (could be that a library you want to use defines a class named "ItemsManager", but as long as is in another namespace, you don't have any problem)
If we were using composer, we had configured it with path where to find the classes of "Friendica" namespace, and then the composer script will generate the autoloader machinery for us.
As we don't use composer, we need check that the autoloader knows the Friendica namespace.
So in "include/autoloader/autoload_psr4.php" there should be something like
```
$vendorDir = dirname(dirname(dirname(__FILE__)))."/library";
$baseDir = dirname($vendorDir);
return array(
"Friendica" => array($baseDir."/include");
);
class ItemsManager {
public function getAll() { ... }
public function getByID($id) { ... }
}
```
The class `ItemsManager` has been declared in the `Friendica` namespace.
Namespaces are useful to keep classes separated and avoid names conflicts (could be that a library you want to use also defines a class named `ItemsManager`, but as long as it is in another namespace, you don't have any problem)
That tells the autoloader code to look for files that defines classes in "Friendica" namespace under "include/" folder. (And btw, that's why the file has the same name as the class it defines.)
*note*: The structure of files in "include/autoloader/" has been copied from the code generated by composer, to ease the work of enable autoloader for external libraries under "library/"
Let's say now that you need to load some items in a view, maybe in a fictional "mod/network.php".
Somewere at the start of the scripts, the autoloader was initialized. In Friendica is done at the top of "boot.php", with "require_once('include/autoloader.php');".
Let's say now that you need to load some items in a view, maybe in a fictional `mod/network.php`.
In order for the Composer autoloader to work, it must first be included. In Friendica this is already done at the top of `boot.php`, with `require_once('vendor/autoload.php');`.
The code will be something like:
```
file: mod/network.php
<?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()"!
You need to use a class, you use the class and you don't need to do anything more.
That's a quite simple example, but look: no `require()`!
If you need to use a class, you can simply use it and you don't need to do anything else.
Going further: now we have a bunch of "*Manager" classes that cause some code duplication, let's define a BaseManager class, where to move all code in common 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:
```
file: include/BaseManager.php
<?php
namespace \Friendica;
```php
// 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
```
file: include/ItemsManager.php
<?php
namespace \Friendica;
```php
// 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) { ... }
}
```
The autoloader don't mind what you need the class for. You need a class, you get the class.
It works with the "BaseManager" example here, it works when we need to call static methods on a 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:
```
file: include/dfrn.php
<?php
namespace \Friendica;
```php
// src/Dfrn.php
<?php
namespace \Friendica;
class dfrn {
public static function mail($item, $owner) { ... }
}
class Dfrn {
public static function mail($item, $owner) { ... }
}
```
```
file: mod/mail.php
<?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:
```
file: include/delivery.php
<?php
namespace \Friendica;
```php
// include/delivery.php
<?php
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
namespace \Friendica;
[...]
switch($contact['network']) {
// this is the same content of current include/delivery.php,
// but has been declared to be in "Friendica" namespace
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 real "include/delivery.php" unchanged, but as the code is declared to be in "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.
```
<?php
namespace \Friendica;
```php
// src/Diaspora.php
<?php
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
}
namespace \Friendica;
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 everytime, 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
namespace \Friendica;
```php
// 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 more deep if you want to, like:
You can go deeper if you want to, like:
```
// 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`.
or
```
// src/Dba/Mysql
<?php
namespace \Friendica\DBA;
namespace \Friendica\Dba;
class MySQL {
class Mysql {
}
```
So you can think of namespaces as folders in a unix filesystem, 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 ("\").

4
doc/de/Home.md

@ -24,7 +24,7 @@ Friendica - Dokumentation und Ressourcen
* [Account löschen](help/Remove-Account)
* [Bugs und Probleme](help/Bugs-and-Issues)
* [Häufig gestellte Fragen (FAQ)](help/FAQ)
**Dokumentation für Administratoren**
* [Installation](help/Install)
@ -49,6 +49,8 @@ Friendica - Dokumentation und Ressourcen
* [Smarty 3 Templates](help/smarty3-templates)
* [Protokoll Dokumentation](help/Protocol) (EN)
* [Datenbank-Schema](help/database)
* [Class Autoloading](help/autoloader) (EN)
* [Using Composer](help/Composer) (EN)
* [Code-Referenz (mit doxygen generiert - setzt Cookies)](doc/html/)
* [Twitter/GNU Social API Functions](help/api) (EN)

66
include/Probe.php

@ -888,33 +888,36 @@ class Probe {
* @return array OStatus data
*/
private function ostatus($webfinger) {
$data = array();
if (is_array($webfinger["aliases"]))
foreach($webfinger["aliases"] AS $alias)
if (strstr($alias, "@"))
if (is_array($webfinger["aliases"])) {
foreach ($webfinger["aliases"] AS $alias) {
if (strstr($alias, "@")) {
$data["addr"] = str_replace('acct:', '', $alias);
}
}
}
if (is_string($webfinger["subject"]) AND strstr($webfinger["subject"], "@"))
if (is_string($webfinger["subject"]) AND strstr($webfinger["subject"], "@")) {
$data["addr"] = str_replace('acct:', '', $webfinger["subject"]);
}
$pubkey = "";
foreach ($webfinger["links"] AS $link) {
if (($link["rel"] == "http://webfinger.net/rel/profile-page") AND
($link["type"] == "text/html") AND ($link["href"] != ""))
($link["type"] == "text/html") AND ($link["href"] != "")) {
$data["url"] = $link["href"];
elseif (($link["rel"] == "salmon") AND ($link["href"] != ""))
} elseif (($link["rel"] == "salmon") AND ($link["href"] != "")) {
$data["notify"] = $link["href"];
elseif (($link["rel"] == NAMESPACE_FEED) AND ($link["href"] != ""))
} elseif (($link["rel"] == NAMESPACE_FEED) AND ($link["href"] != "")) {
$data["poll"] = $link["href"];
elseif (($link["rel"] == "magic-public-key") AND ($link["href"] != "")) {
} elseif (($link["rel"] == "magic-public-key") AND ($link["href"] != "")) {
$pubkey = $link["href"];
if (substr($pubkey, 0, 5) === 'data:') {
if (strstr($pubkey, ','))
if (strstr($pubkey, ',')) {
$pubkey = substr($pubkey, strpos($pubkey, ',') + 1);
else
} else {
$pubkey = substr($pubkey, 5);
}
} elseif (normalise_link($pubkey) == 'http://') {
$ret = z_fetch_url($pubkey);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
@ -930,16 +933,15 @@ class Probe {
$e = base64url_decode($key[2]);
$data["pubkey"] = metopem($m,$e);
}
}
}
if (isset($data["notify"]) AND isset($data["pubkey"]) AND
isset($data["poll"]) AND isset($data["url"])) {
$data["network"] = NETWORK_OSTATUS;
} else
} else {
return false;
}
// Fetch all additional data from the feed
$ret = z_fetch_url($data["poll"]);
if ($ret['errno'] == CURLE_OPERATION_TIMEDOUT) {
@ -947,32 +949,32 @@ class Probe {
}
$feed = $ret['body'];
$feed_data = feed_import($feed,$dummy1,$dummy2, $dummy3, true);
if (!$feed_data)
if (!$feed_data) {
return false;
if ($feed_data["header"]["author-name"] != "")
}
if ($feed_data["header"]["author-name"] != "") {
$data["name"] = $feed_data["header"]["author-name"];
if ($feed_data["header"]["author-nick"] != "")
}
if ($feed_data["header"]["author-nick"] != "") {
$data["nick"] = $feed_data["header"]["author-nick"];
if ($feed_data["header"]["author-avatar"] != "")
$data["photo"] = $feed_data["header"]["author-avatar"];
if ($feed_data["header"]["author-id"] != "")
}
if ($feed_data["header"]["author-avatar"] != "") {
$data["photo"] = ostatus::fix_avatar($feed_data["header"]["author-avatar"], $data["url"]);
}
if ($feed_data["header"]["author-id"] != "") {
$data["alias"] = $feed_data["header"]["author-id"];
if ($feed_data["header"]["author-location"] != "")
}
if ($feed_data["header"]["author-location"] != "") {
$data["location"] = $feed_data["header"]["author-location"];
if ($feed_data["header"]["author-about"] != "")
}
if ($feed_data["header"]["author-about"] != "") {
$data["about"] = $feed_data["header"]["author-about"];
}
// OStatus has serious issues when the the url doesn't fit (ssl vs. non ssl)
// So we take the value that we just fetched, although the other one worked as well
if ($feed_data["header"]["author-link"] != "")
if ($feed_data["header"]["author-link"] != "") {
$data["url"] = $feed_data["header"]["author-link"];
}
/// @todo Fetch location and "about" from the feed as well
return $data;
}

69
include/autoloader.php

@ -1,69 +0,0 @@
<?php
/**
* @file include/autoloader.php
*/
/**
* @brief composer-derived autoloader init
**/
class FriendicaAutoloaderInit
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/autoloader/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('FriendicaAutoloaderInit', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('FriendicaAutoloaderInit', 'loadClassLoader'));
// library
$map = require __DIR__ . '/autoloader/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoloader/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoloader/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
$loader->register(true);
$includeFiles = require __DIR__ . '/autoloader/autoload_files.php';
foreach ($includeFiles as $fileIdentifier => $file) {
friendicaRequire($fileIdentifier, $file);
}
return $loader;
}
}
function friendicaRequire($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}
return FriendicaAutoloaderInit::getLoader();

9
include/autoloader/autoload_classmap.php

@ -1,9 +0,0 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(dirname(__FILE__)))."/library";
$baseDir = dirname($vendorDir);
return array(
);

10
include/autoloader/autoload_psr4.php

@ -1,10 +0,0 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(dirname(__FILE__)))."/library";
$baseDir = dirname($vendorDir);
return array(
'Friendica\\' => array($baseDir . '/include'),
);

11
include/contact_selectors.php

@ -88,7 +88,7 @@ function network_to_name($s, $profile = "") {
NETWORK_PUMPIO => t('pump.io'),
NETWORK_TWITTER => t('Twitter'),
NETWORK_DIASPORA2 => t('Diaspora Connector'),
NETWORK_STATUSNET => t('GNU Social'),
NETWORK_STATUSNET => t('GNU Social Connector'),
NETWORK_PNUT => t('pnut'),
NETWORK_APPNET => t('App.net')
);
@ -98,17 +98,16 @@ function network_to_name($s, $profile = "") {
$search = array_keys($nets);
$replace = array_values($nets);
$networkname = str_replace($search,$replace,$s);
if (($s == NETWORK_DIASPORA) AND ($profile != "") AND Diaspora::is_redmatrix($profile)) {
$networkname = t("Hubzilla/Redmatrix");
$networkname = str_replace($search, $replace, $s);
if ((in_array($s, array(NETWORK_DFRN, NETWORK_DIASPORA, NETWORK_OSTATUS))) AND ($profile != "")) {
$r = q("SELECT `gserver`.`platform` FROM `gcontact`
INNER JOIN `gserver` ON `gserver`.`nurl` = `gcontact`.`server_url`
WHERE `gcontact`.`nurl` = '%s' AND `platform` != ''",
dbesc(normalise_link($profile)));
if ($r)
if (dbm::is_result($r)) {
$networkname = $r[0]["platform"];
}
}
return $networkname;

247
include/ostatus.php

@ -27,6 +27,42 @@ class ostatus {
const OSTATUS_DEFAULT_POLL_TIMEFRAME = 1440; // given in minutes
const OSTATUS_DEFAULT_POLL_TIMEFRAME_MENTIONS = 14400; // given in minutes
/**
* @brief Mix two paths together to possibly fix missing parts
*
* @param string $avatar Path to the avatar
* @param string $base Another path that is hopefully complete
*
* @return string fixed avatar path
*/
public static function fix_avatar($avatar, $base) {
$base_parts = parse_url($base);
// Remove all parts that could create a problem
unset($base_parts['path']);
unset($base_parts['query']);
unset($base_parts['fragment']);
$avatar_parts = parse_url($avatar);
// Now we mix them
$parts = array_merge($base_parts, $avatar_parts);
// And put them together again
$scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '';
$host = isset($parts['host']) ? $parts['host'] : '';
$port = isset($parts['port']) ? ':' . $parts['port'] : '';
$path = isset($parts['path']) ? $parts['path'] : '';
$query = isset($parts['query']) ? '?' . $parts['query'] : '';
$fragment = isset($parts['fragment']) ? '#' . $parts['fragment'] : '';
$fixed = $scheme.$host.$port.$path.$query.$fragment;
logger('Base: '.$base.' - Avatar: '.$avatar.' - Fixed: '.$fixed, LOGGER_DATA);
return $fixed;
}
/**
* @brief Fetches author data
*
@ -77,7 +113,7 @@ class ostatus {
}
if (count($avatarlist) > 0) {
krsort($avatarlist);
$author["author-avatar"] = current($avatarlist);
$author["author-avatar"] = self::fix_avatar(current($avatarlist), $author["author-link"]);
}
$displayname = $xpath->evaluate('atom:author/poco:displayName/text()', $context)->item(0)->nodeValue;
@ -203,6 +239,23 @@ class ostatus {
}
}
/**
* @brief Read attributes from element
*
* @param object $element Element object
*
* @return array attributes
*/
private static function read_attributes($element) {
$attribute = array();
foreach ($element->attributes AS $attributes) {
$attribute[$attributes->name] = $attributes->textContent;
}
return $attribute;
}
/**
* @brief Imports an XML string containing OStatus elements
*
@ -216,9 +269,9 @@ class ostatus {
logger("Import OStatus message", LOGGER_DEBUG);
if ($xml == "")
if ($xml == "") {
return;
}
//$tempfile = tempnam(get_temppath(), "import");
//file_put_contents($tempfile, $xml);
@ -237,13 +290,14 @@ class ostatus {
$gub = "";
$hub_attributes = $xpath->query("/atom:feed/atom:link[@rel='hub']")->item(0)->attributes;
if (is_object($hub_attributes))
foreach($hub_attributes AS $hub_attribute)
if (is_object($hub_attributes)) {
foreach ($hub_attributes AS $hub_attribute) {
if ($hub_attribute->name == "href") {
$hub = $hub_attribute->textContent;
logger("Found hub ".$hub, LOGGER_DEBUG);
}
}
}
$header = array();
$header["uid"] = $importer["uid"];
$header["network"] = NETWORK_OSTATUS;
@ -256,11 +310,11 @@ class ostatus {
// depending on that, the first node is different
$first_child = $doc->firstChild->tagName;
if ($first_child == "feed")
if ($first_child == "feed") {
$entries = $xpath->query('/atom:feed/atom:entry');
else
} else {
$entries = $xpath->query('/atom:entry');
}
$conversation = "";
$conversationlist = array();
$item_id = 0;
@ -268,25 +322,25 @@ class ostatus {
// Reverse the order of the entries
$entrylist = array();
foreach ($entries AS $entry)
foreach ($entries AS $entry) {
$entrylist[] = $entry;
}
foreach (array_reverse($entrylist) AS $entry) {
$mention = false;
// fetch the author
if ($first_child == "feed")
if ($first_child == "feed") {
$author = self::fetchauthor($xpath, $doc->firstChild, $importer, $contact, false);
else
} else {
$author = self::fetchauthor($xpath, $entry, $importer, $contact, false);
}
$value = $xpath->evaluate('atom:author/poco:preferredUsername/text()', $context)->item(0)->nodeValue;
if ($value != "")
if ($value != "") {
$nickname = $value;
else
} else {
$nickname = $author["author-name"];
}
$item = array_merge($header, $author);
// Now get the item
@ -294,7 +348,7 @@ class ostatus {
$r = q("SELECT `id` FROM `item` WHERE `uid` = %d AND `uri` = '%s'",
intval($importer["uid"]), dbesc($item["uri"]));
if ($r) {
if (dbm::is_result($r)) {
logger("Item with uri ".$item["uri"]." for user ".$importer["uid"]." already existed under id ".$r[0]["id"], LOGGER_DEBUG);
continue;
}
@ -305,9 +359,9 @@ class ostatus {
if (($item["object-type"] == ACTIVITY_OBJ_BOOKMARK) OR ($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
$item["body"] = $xpath->query('atom:summary/text()', $entry)->item(0)->nodeValue;
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION)
} elseif ($item["object-type"] == ACTIVITY_OBJ_QUESTION) {
$item["title"] = $xpath->query('atom:title/text()', $entry)->item(0)->nodeValue;
}
$item["object"] = $xml;
$item["verb"] = $xpath->query('activity:verb/text()', $entry)->item(0)->nodeValue;
@ -351,9 +405,9 @@ class ostatus {
}
// http://activitystrea.ms/schema/1.0/rsvp-yes
if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE)))
if (!in_array($item["verb"], array(ACTIVITY_POST, ACTIVITY_LIKE, ACTIVITY_SHARE))) {
logger("Unhandled verb ".$item["verb"]." ".print_r($item, true));
}
$item["created"] = $xpath->query('atom:published/text()', $entry)->item(0)->nodeValue;
$item["edited"] = $xpath->query('atom:updated/text()', $entry)->item(0)->nodeValue;
$conversation = $xpath->query('ostatus:conversation/text()', $entry)->item(0)->nodeValue;
@ -362,28 +416,32 @@ class ostatus {
$inreplyto = $xpath->query('thr:in-reply-to', $entry);
if (is_object($inreplyto->item(0))) {
foreach($inreplyto->item(0)->attributes AS $attributes) {
if ($attributes->name == "ref")
foreach ($inreplyto->item(0)->attributes AS $attributes) {
if ($attributes->name == "ref") {
$item["parent-uri"] = $attributes->textContent;
if ($attributes->name == "href")
}
if ($attributes->name == "href") {
$related = $attributes->textContent;
}
}
}
$georsspoint = $xpath->query('georss:point', $entry);
if ($georsspoint)
if ($georsspoint) {
$item["coord"] = $georsspoint->item(0)->nodeValue;
}
$categories = $xpath->query('atom:category', $entry);
if ($categories) {
foreach ($categories AS $category) {
foreach($category->attributes AS $attributes)
foreach ($category->attributes AS $attributes) {
if ($attributes->name == "term") {
$term = $attributes->textContent;
if(strlen($item["tag"]))
if(strlen($item["tag"])) {
$item["tag"] .= ',';
}
$item["tag"] .= "#[url=".App::get_baseurl()."/search?tag=".$term."]".$term."[/url]";
}
}
}
}
@ -392,64 +450,49 @@ class ostatus {
$links = $xpath->query('atom:link', $entry);
if ($links) {
$rel = "";
$href = "";
$type = "";
$length = "0";
$title = "";
foreach ($links AS $link) {
foreach($link->attributes AS $attributes) {
if ($attributes->name == "href")
$href = $attributes->textContent;
if ($attributes->name == "rel")
$rel = $attributes->textContent;
if ($attributes->name == "type")
$type = $attributes->textContent;
if ($attributes->name == "length")
$length = $attributes->textContent;
if ($attributes->name == "title")
$title = $attributes->textContent;
}
if (($rel != "") AND ($href != "")) {
switch ($rel) {
$attribute = self::read_attributes($link);
if (($attribute['rel'] != "") AND ($attribute['href'] != "")) {
switch ($attribute['rel']) {
case "alternate":
$item["plink"] = $href;
/// @TODO These multi-lines can confuse, let's avoid them
$item["plink"] = $attribute['href'];
if (($item["object-type"] == ACTIVITY_OBJ_QUESTION) OR
($item["object-type"] == ACTIVITY_OBJ_EVENT)) {
$item["body"] .= add_page_info($href);
$item["body"] .= add_page_info($attribute['href']);
}
break;
case "ostatus:conversation":
$conversation = $href;
$conversation = $attribute['href'];
break;
case "enclosure":
$enclosure = $href;
$enclosure = $attribute['href'];
if (strlen($item["attach"])) {
$item["attach"] .= ',';
}
$item["attach"] .= '[attach]href="' . $href . '" length="' . $length . '" type="' . $type . '" title="' . $title . '"[/attach]';
if (!isset($attribute['length'])) {
$attribute['length'] = "0";
}
$item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.$attribute['title'].'"[/attach]';
break;
case "related":
if ($item["object-type"] != ACTIVITY_OBJ_BOOKMARK) {
if (!isset($item["parent-uri"])) {
$item["parent-uri"] = $href;
$item["parent-uri"] = $attribute['href'];
}
if ($related == "") {
$related = $href;
$related = $attribute['href'];
}
} else {
$item["body"] .= add_page_info($href);
$item["body"] .= add_page_info($attribute['href']);
}
break;
case "self":
$self = $href;
$self = $attribute['href'];
break;
case "mentioned":
// Notification check
if ($importer["nurl"] == normalise_link($href)) {
if ($importer["nurl"] == normalise_link($attribute['href'])) {
$mention = true;
}
break;
@ -463,13 +506,16 @@ class ostatus {
$notice_info = $xpath->query('statusnet:notice_info', $entry);
if ($notice_info AND ($notice_info->length > 0)) {
foreach($notice_info->item(0)->attributes AS $attributes) {
if ($attributes->name == "source")
foreach ($notice_info->item(0)->attributes AS $attributes) {
if ($attributes->name == "source") {
$item["app"] = strip_tags($attributes->textContent);
if ($attributes->name == "local_id")
}
if ($attributes->name == "local_id") {
$local_id = $attributes->textContent;
if ($attributes->name == "repeat_of")
}
if ($attributes->name == "repeat_of") {
$repeat_of = $attributes->textContent;
}
}
}
@ -480,25 +526,27 @@ class ostatus {
if (is_object($activityobjects)) {
$orig_uri = $xpath->query("activity:object/atom:id", $activityobjects)->item(0)->nodeValue;
if (!isset($orig_uri))
if (!isset($orig_uri)) {
$orig_uri = $xpath->query('atom:id/text()', $activityobjects)->item(0)->nodeValue;
}
$orig_links = $xpath->query("activity:object/atom:link[@rel='alternate']", $activityobjects);
if ($orig_links AND ($orig_links->length > 0))
foreach($orig_links->item(0)->attributes AS $attributes)
if ($attributes->name == "href")
if ($orig_links AND ($orig_links->length > 0)) {
foreach ($orig_links->item(0)->attributes AS $attributes) {
if ($attributes->name == "href") {
$orig_link = $attributes->textContent;
if (!isset($orig_link))
}
}
}
if (!isset($orig_link)) {
$orig_link = $xpath->query("atom:link[@rel='alternate']", $activityobjects)->item(0)->nodeValue;
if (!isset($orig_link))
}
if (!isset($orig_link)) {
$orig_link = self::convert_href($orig_uri);
}
$orig_body = $xpath->query('activity:object/atom:content/text()', $activityobjects)->item(0)->nodeValue;
if (!isset($orig_body))
if (!isset($orig_body)) {
$orig_body = $xpath->query('atom:content/text()', $activityobjects)->item(0)->nodeValue;
}
$orig_created = $xpath->query('atom:published/text()', $activityobjects)->item(0)->nodeValue;
$orig_edited = $xpath->query('atom:updated/text()', $activityobjects)->item(0)->nodeValue;
@ -508,18 +556,40 @@ class ostatus {
$item["author-name"] = $orig_author["author-name"];
$item["author-link"] = $orig_author["author-link"];
$item["author-avatar"] = $orig_author["author-avatar"];
$item["body"] = add_page_info_to_body(html2bbcode($orig_body));
$item["created"] = $orig_created;
$item["edited"] = $orig_edited;
$item["uri"] = $orig_uri;
$item["plink"] = $orig_link;
if (!isset($item["plink"])) {
$item["plink"] = $orig_link;
}
$item["verb"] = $xpath->query('activity:verb/text()', $activityobjects)->item(0)->nodeValue;
$item["object-type"] = $xpath->query('activity:object/activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
if (!isset($item["object-type"]))
if (!isset($item["object-type"])) {
$item["object-type"] = $xpath->query('activity:object-type/text()', $activityobjects)->item(0)->nodeValue;
}
$enclosures = $xpath->query("atom:link[@rel='alternate']", $activityobjects);
if ($enclosures) {
foreach ($enclosures AS $link) {
$attribute = self::read_attributes($link);
if ($href != "") {
$enclosure = $attribute['href'];
if (strlen($item["attach"])) {
$item["attach"] .= ',';
}
if (!isset($attribute['length'])) {
$attribute['length'] = "0";
}
$item["attach"] .= '[attach]href="'.$attribute['href'].'" length="'.$attribute['length'].'" type="'.$attribute['type'].'" title="'.$attribute['title'].'"[/attach]';
}
}
}
}
}
@ -547,13 +617,13 @@ class ostatus {
intval($importer["uid"]), dbesc($item["parent-uri"]));
}
}
if ($r) {
if (dbm::is_result($r)) {
$item["type"] = 'remote-comment';
$item["gravity"] = GRAVITY_COMMENT;
}
} else
} else {
$item["parent-uri"] = $item["uri"];
}
$item_id = self::completion($conversation, $importer["uid"], $item, $self);
if (!$item_id) {
@ -1076,10 +1146,11 @@ class ostatus {
$arr["owner-name"] = $single_conv->actor->portablecontacts_net->displayName;
$arr["owner-link"] = $actor;
$arr["owner-avatar"] = $single_conv->actor->image->url;
$arr["owner-avatar"] = self::fix_avatar($single_conv->actor->image->url, $arr["owner-link"]);
$arr["author-name"] = $arr["owner-name"];
$arr["author-link"] = $actor;
$arr["author-avatar"] = $single_conv->actor->image->url;
$arr["author-link"] = $arr["owner-link"];
$arr["author-avatar"] = $arr["owner-avatar"];
$arr["body"] = add_page_info_to_body(html2bbcode($single_conv->content));
if (isset($single_conv->status_net->notice_info->source))
@ -1130,11 +1201,11 @@ class ostatus {
$arr["edited"] = $single_conv->object->published;
$arr["author-name"] = $single_conv->object->actor->displayName;
if ($arr["owner-name"] == '')
if ($arr["owner-name"] == '') {
$arr["author-name"] = $single_conv->object->actor->contact->displayName;
}
$arr["author-link"] = $single_conv->object->actor->url;
$arr["author-avatar"] = $single_conv->object->actor->image->url;
$arr["author-avatar"] = self::fix_avatar($single_conv->object->actor->image->url, $arr["author-link"]);
$arr["app"] = $single_conv->object->provider->displayName."#";
//$arr["verb"] = $single_conv->object->verb;

11
library/Mobile_Detect/.gitignore

@ -1,11 +0,0 @@
vendor/
nbproject/
/*.buildpath
/*.project
/.settings
/error.log
/export/nicejson
.idea/
*.iml
/coverage
/phpunit.phar

3
library/Mobile_Detect/.gitmodules

@ -1,3 +0,0 @@
[submodule "export/nicejson"]
path = export/nicejson
url = https://github.com/GerHobbelt/nicejson-php.git

24
library/Mobile_Detect/.php_cs

@ -1,24 +0,0 @@
<?php
use Symfony\CS\FixerInterface;
$finder = Symfony\CS\Finder\DefaultFinder::create()
->notName('LICENSE')
->notName('README.md')
->notName('.php_cs')
->notName('composer.*')
->notName('phpunit.xml*')
->notName('*.phar')
->exclude('vendor')
->exclude('examples')
->exclude('Symfony/CS/Tests/Fixer')
->notName('ElseifFixer.php')
->exclude('data')
->in(__DIR__)
;
return Symfony\CS\Config\Config::create()
->finder($finder)
;

17
library/Mobile_Detect/.travis.yml

@ -1,17 +0,0 @@
language: php
php:
- "5.2"
- "5.3"
- "5.4"
- "5.5"
- "5.6"
branches:
only:
- devel
script:
- phpunit -v -c tests/phpunit.xml
notifications:
email: false

1
library/Mobile_Detect/Mobile_Detect.json
File diff suppressed because it is too large
View File

219
library/Mobile_Detect/README.md

@ -1,219 +0,0 @@
[![Build Status](https://travis-ci.org/serbanghita/Mobile-Detect.svg?branch=devel)](https://travis-ci.org/serbanghita/Mobile-Detect) [![Latest Stable Version](https://poser.pugx.org/mobiledetect/mobiledetectlib/v/stable.svg)](https://packagist.org/packages/mobiledetect/mobiledetectlib) [![Total Downloads](https://poser.pugx.org/mobiledetect/mobiledetectlib/downloads.svg)](https://packagist.org/packages/mobiledetect/mobiledetectlib) [![Daily Downloads](https://poser.pugx.org/mobiledetect/mobiledetectlib/d/daily.png)](https://packagist.org/packages/mobiledetect/mobiledetectlib) [![License](https://poser.pugx.org/mobiledetect/mobiledetectlib/license.svg)](https://packagist.org/packages/mobiledetect/mobiledetectlib)
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/serbanghita/Mobile-Detect?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
![Mobile Detect](http://demo.mobiledetect.net/logo-github.png)
> Motto: "Every business should have a mobile detection script to detect mobile readers."
<i>Mobile_Detect is a lightweight PHP class for detecting mobile devices (including tablets).
It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.</i>
> We're commited to make Mobile_Detect the best open-source mobile detection resource and this is why before each release we're running [unit tests](./tests), we also research and update the detection rules on <b>daily</b> and <b>weekly</b> basis.
Your website's _content strategy_ is important! You need a complete toolkit to deliver an experience that is _optimized_, _fast_ and _relevant_ to your users. Mobile_Detect class is a [server-side detection](http://www.w3.org/TR/mwabp/#bp-devcap-detection) tool that can help you with your RWD strategy, it is not a replacement for CSS3 media queries or other forms of client-side feature detection.
##### This month updates
First of all a **BIG THANK YOU** to our growing community for your continuous support and for all the feedback received! I'm still working my way with the current issues and all the emails.
Nick is almost done with all the code for the upcoming `3.0.0` so that I only have to integrate the new parsing engine. We will release minor `2.8.xx` versions until a feature freeze where we will switch to the new branch. You will all be announced before this and hopefully we can make the transition smooth for everyone.
<a href="http://trycatch.us/"><img align="left" src="http://assets.mobiledetect.net/img/try_catch_logo_80px.jpg" hspace="20"></a> Last but not least, special thanks for supporting us to our friends from [TryCatch.us](http://trycatch.us/) who _are set to carefully curate the most talented developers in Europe_!
Thank you all and we're excited for the new release!