Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
en:entwickler:programmierrichtlinien [2015/10/30 15:59] – [Comments] thomas-rcv | en:entwickler:programmierrichtlinien [2021/11/15 14:28] (current) – fasse | ||
---|---|---|---|
Line 7: | Line 7: | ||
You should exercise some discipline during programming. This includes the avoidance of German umlauts characters, unified | You should exercise some discipline during programming. This includes the avoidance of German umlauts characters, unified | ||
- | This document is mainly directed at developers who want to install their code like in the official Admidio release, but also for the private development these guidelines can be helpfull. The document is actually not finished yet. Who like to add own chapter or comments is welcome. | + | This document is mainly directed at developers who want to install their code like in the official Admidio release, but also for the private development these guidelines can be helpful. The document is actually not finished yet. Who like to add own chapter or comments is welcome. |
===== Code spacing ===== | ===== Code spacing ===== | ||
Line 27: | Line 27: | ||
* while | * while | ||
* switch | * switch | ||
- | It should be ensured that the braces are always at the height of the associated | + | The open parenthesis is set after the control structure with a space between. The closing parenthesis is always |
Here is an example of a nested if statement: | Here is an example of a nested if statement: | ||
- | <code php> | + | <code php>if ((condition1) |
- | { | + | |
action1; | action1; | ||
- | if(condition3) | + | if (condition3) { |
- | | + | |
action2; | action2; | ||
} | } | ||
- | } | + | } elseif ((condition4) or (condition5)) { |
- | elseif((condition4) or (condition5)) | + | |
- | { | + | |
action3; | action3; | ||
action4; | action4; | ||
- | } | + | } else { |
- | else | + | |
- | { | + | |
defaultaction; | defaultaction; | ||
}</ | }</ | ||
Line 53: | Line 47: | ||
Here is an example of a switch / case statement: | Here is an example of a switch / case statement: | ||
- | <code php> | + | <code php> |
- | { | + | |
case 1: | case 1: | ||
action1; | action1; | ||
Line 76: | Line 69: | ||
As shown above, on the left and right side of the equal sign where is one blank respectively. If several function calls and thus variable assignments in the block are under each other, in order to ensure the readability of the code, you may deviate from it: | As shown above, on the left and right side of the equal sign where is one blank respectively. If several function calls and thus variable assignments in the block are under each other, in order to ensure the readability of the code, you may deviate from it: | ||
<code php> | <code php> | ||
- | $longer_name | + | $longerName |
===== Defining functions ===== | ===== Defining functions ===== | ||
Line 82: | Line 75: | ||
<code php> | <code php> | ||
{ | { | ||
- | $result= $value1 + $value2 + $value3; | + | $result = $value1 + $value2 + $value3; |
return $result; | return $result; | ||
Line 105: | Line 98: | ||
You should put your PHP code within the tags **<? | You should put your PHP code within the tags **<? | ||
- | ===== Header | + | ===== Header |
- | Each file of Admidio project should have a documantation | + | Each file of Admidio project should have a documentation |
Here is an example from the file dates_function.php: | Here is an example from the file dates_function.php: | ||
- | <code php>/ | + | <code php> |
- | | + | /** |
+ | | ||
+ | | ||
* | * | ||
- | | + | |
- | | + | |
- | | + | |
- | * License | + | |
* | * | ||
* Uebergaben: | * Uebergaben: | ||
Line 124: | Line 118: | ||
| | ||
| | ||
- | * | + | |
- | *****************************************************************************/</ | + | */ |
+ | </ | ||
- | ===== SVN Requirements ===== | + | ===== Git Requirements ===== |
- | When files are checked into SVN, a commit message must be drawn up. In a bugfix the commit message definitely should belong to the associated | + | When files are checked into Git, a commit message must be drawn up. In a bugfix the commit message definitely should belong to the associated |
===== Name Convention ===== | ===== Name Convention ===== | ||
Line 141: | Line 136: | ||
**Variables**\\ | **Variables**\\ | ||
- | Variables should be similar to the function name written in camel style (many also known as [[http:// | + | Variables should be similar to the function name written in camel style (many also known as [[http:// |
Example: | Example: | ||
<code php> | <code php> | ||
- | gCurrentUser | + | gCurrentUser |
getUserId | getUserId | ||
Line 158: | Line 153: | ||
* Charset **UTF-8** | * Charset **UTF-8** | ||
- | * Newline **Windows | + | * Newline **LF** |
+ | |||
+ | If you checkout the code with GIT you could configure if you want it in LF (Linux) or CRLF (Windows). | ||
- | In UTF-8 is still too aware that the Editor the byte order flag (BOM) must not set. This flag is actually establishing the exact identity of the UTF used encoding (UTF-8, UTF-16 or UTF-32). If using this in PHP, it will simply output the script at the beginning in the browser and then itmostly | + | In UTF-8 is still too aware that the Editor the byte order flag (BOM) must not set. This flag is actually establishing the exact identity of the UTF used encoding (UTF-8, UTF-16 or UTF-32). If using this in PHP, it will simply output the script at the beginning in the browser and then it mostly |
===== File Name ===== | ===== File Name ===== | ||
Line 176: | Line 173: | ||
$sql = ' | $sql = ' | ||
- | Within JavaScript, however, the double quotation marks should be used, so that as less as possible characters need to be escaped. This Javascript | + | Within JavaScript, however, the double quotation marks should be used, so that as less as possible characters need to be escaped. This JavaScript |
<code php> | <code php> | ||
echo '< | echo '< |