Normalize App parameter declaration (doc-include folders, boot)

This commit is contained in:
Hypolite Petovan 2017-01-09 23:09:01 +11:00
parent ee39aba490
commit 87eb3d5ef2
20 changed files with 142 additions and 142 deletions

View file

@ -40,7 +40,7 @@ Arguments
---
Your hook callback functions will be called with at least one and possibly two arguments
function myhook_function(&$a, &$b) {
function myhook_function(App $a, &$b) {
}
@ -77,9 +77,9 @@ This will include:
$a->argc = 3
$a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
Your module functions will often contain the function plugin_name_content(App &$a), which defines and returns the page body content.
They may also contain plugin_name_post(App &$a) which is called before the _content function and typically handles the results of POST forms.
You may also have plugin_name_init(App &$a) which is called very early on and often does module initialisation.
Your module functions will often contain the function plugin_name_content(App $a), which defines and returns the page body content.
They may also contain plugin_name_post(App $a) which is called before the _content function and typically handles the results of POST forms.
You may also have plugin_name_init(App $a) which is called very early on and often does module initialisation.
Templates
---
@ -285,7 +285,7 @@ $b is an array with:
is called after the other queries have passed.
The registered function can add, change or remove the acl_lookup() variables.
'results' => array of the acl_lookup() vars
'results' => array of the acl_lookup() vars
Complete list of hook callbacks

View file

@ -32,7 +32,7 @@ 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) { ... }
@ -67,11 +67,11 @@ The code will be something like:
```
file: mod/network.php
<?php
function network_content(App &$a) {
function network_content(App $a) {
$itemsmanager = new \Friendica\ItemsManager();
$items = $itemsmanager->getAll();
// pass $items to template
// return result
}
@ -86,7 +86,7 @@ Going further: now we have a bunch of "*Manager" classes that cause some code du
file: include/BaseManager.php
<?php
namespace \Friendica;
class BaseManager {
public function thatFunctionEveryManagerUses() { ... }
}
@ -98,7 +98,7 @@ and then let's change the ItemsManager class to use this code
file: include/ItemsManager.php
<?php
namespace \Friendica;
class ItemsManager extends BaseManager {
public function getAll() { ... }
public function getByID($id) { ... }
@ -110,9 +110,9 @@ It works with the "BaseManager" example here, it works when we need to call stat
```
file: include/dfrn.php
<?php
<?php
namespace \Friendica;
class dfrn {
public static function mail($item, $owner) { ... }
}
@ -121,7 +121,7 @@ It works with the "BaseManager" example here, it works when we need to call stat
```
file: mod/mail.php
<?php
mail_post($a){
...
\Friendica\dfrn::mail($item, $owner);
@ -134,15 +134,15 @@ If your code is in same namespace as the class you need, you don't need to prepe
```
file: include/delivery.php
<?php
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
[...]
switch($contact['network']) {
case NETWORK_DFRN:
if ($mail) {
$item['body'] = ...
@ -161,10 +161,10 @@ But if you want to use classes from another library, you need to use the full na
```
<?php
namespace \Frienidca;
class Diaspora {
public function md2bbcode() {
$html = \Michelf\MarkdownExtra::defaultTransform($text);
$html = \Michelf\MarkdownExtra::defaultTransform($text);
}
}
```
@ -174,12 +174,12 @@ if you use that class in many places of the code and you don't want to write the
```
<?php
namespace \Frienidca;
use \Michelf\MarkdownExtra;
class Diaspora {
public function md2bbcode() {
$html = MarkdownExtra::defaultTransform($text);
$html = MarkdownExtra::defaultTransform($text);
}
}
```
@ -190,7 +190,7 @@ You can go more deep if you want to, like:
```
<?php
namespace \Friendica\Network;
class DFRN {
}
```
@ -200,7 +200,7 @@ or
```
<?php
namespace \Friendica\DBA;
class MySQL {
}
```

View file

@ -40,7 +40,7 @@ Argumente
Deine Hook-Callback-Funktion wird mit mindestens einem und bis zu zwei Argumenten aufgerufen
function myhook_function(&$a, &$b) {
function myhook_function(App $a, &$b) {
}
@ -67,9 +67,9 @@ So würde http://example.com/plugin/arg1/arg2 nach einem Modul "plugin" suchen u
$a->argc = 3
$a->argv = array(0 => 'plugin', 1 => 'arg1', 2 => 'arg2');
Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App &$a), welche den Seiteninhalt definiert und zurückgibt.
Sie können auch plugin_name_post(App &$a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
Du kannst ebenso plugin_name_init(App &$a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
Deine Modulfunktionen umfassen oft die Funktion plugin_name_content(App $a), welche den Seiteninhalt definiert und zurückgibt.
Sie können auch plugin_name_post(App $a) umfassen, welches vor der content-Funktion aufgerufen wird und normalerweise die Resultate der POST-Formulare handhabt.
Du kannst ebenso plugin_name_init(App $a) nutzen, was oft frühzeitig aufgerufen wird und das Modul initialisert.
Derzeitige Hooks
@ -311,7 +311,7 @@ mod/photos.php: call_hooks('photo_post_end',intval($item_id));
mod/photos.php: call_hooks('photo_upload_form',$ret);
mod/friendica.php: call_hooks('about_hook', $o);
mod/friendica.php: call_hooks('about_hook', $o);
mod/editpost.php: call_hooks('jot_tool', $jotplugins);

View file

@ -122,7 +122,7 @@ the 1st part of the line is the name of the CSS file (without the .css) the 2nd
Calling the t() function with the common name makes the string translateable.
The selected 1st part will be saved in the database by the theme_post function.
function theme_post(App &$a){
function theme_post(App $a){
// non local users shall not pass
if (! local_user()) {
return;
@ -168,7 +168,7 @@ The content of this file should be something like
<?php
/* meta informations for the theme, see below */
function duepuntozero_lr_init(App &$a) {
function duepuntozero_lr_init(App $a) {
$a-> theme_info = array(
'extends' => 'duepuntozero'.
);
@ -251,7 +251,7 @@ Next crucial part of the theme.php file is a definition of an init function.
The name of the function is <theme-name>_init.
So in the case of quattro it is
function quattro_init(App &$a) {
function quattro_init(App $a) {
$a->theme_info = array();
set_template_engine($a, 'smarty3');
}