Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:entwickler:programmierrichtlinien [2015/11/26 13:27] – [File Formats] ximexen: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  Code spacing and much more. It applies to all programming languages that are used in Admidio (PHP, JavaScript). You should exercise some discipline during programming. This includes the avoidance of German umlauts characters, unified  Code spacing and much more. It applies to all programming languages that are used in Admidio (PHP, JavaScript).
  
-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 control structure in a separate line!+The open parenthesis is set after the control structure with a space between. The closing parenthesis is always set at the height of the control structure.
  
 Here is an example of a nested if statement: Here is an example of a nested if statement:
-<code php>if((condition1) and (condition2)) +<code php>if ((condition1) && (condition2)) {
-{+
     action1;     action1;
-    if(condition3) +    if (condition3) {
-    {+
         action2;         action2;
     }     }
-} +} elseif ((condition4) or (condition5)) {
-elseif((condition4) or (condition5)) +
-{+
     action3;     action3;
     action4;     action4;
-} +} else {
-else +
-{+
     defaultaction;     defaultaction;
 }</code> }</code>
Line 53: Line 47:
  
 Here is an example of a switch / case statement: Here is an example of a switch / case statement:
-<code php>switch(condition) +<code php>switch (condition) {
-{+
     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>$test        = foo($para1); <code php>$test        = foo($para1);
-$longer_name = foo($para2);</code>+$longerName = foo($para2);</code>
  
 ===== Defining functions ===== ===== Defining functions =====
Line 82: Line 75:
 <code php>function addition($value1, $value2, $value3 = 0) <code php>function addition($value1, $value2, $value3 = 0)
 { {
-    $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 **<?php** and **?>** and not use the short form **<? ?> **. This is the only way to ensure that the code is interpreted across all platforms well as PHP code. You should put your PHP code within the tags **<?php** and **?>** and not use the short form **<? ?> **. This is the only way to ensure that the code is interpreted across all platforms well as PHP code.
  
-===== Header von files ===== +===== Header of files ===== 
-Each file of Admidio project should have a documantation block at the beginning of the file.This block must have an short explanation of PHP the script. In addition, all possible parmeters that may be passed from other scripts are here to neatly listed ...+Each file of Admidio project should have a documentation block at the beginning of the file.This block must have an short explanation of PHP the script. In addition, all possible parmeters that may be passed from other scripts are here to neatly listed ...
 Here is an example from the file dates_function.php: Here is an example from the file dates_function.php:
    
Line 129: Line 122:
  </code>  </code>
  
-===== 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 bow number and a short description of the activities done in the script ...+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 issue number e.g. **#123** and a short description of the activities done in the script ...
  
 ===== Name Convention ===== ===== Name Convention =====
Line 143: Line 136:
  
 **Variables**\\  **Variables**\\ 
-Variables should be similar to the function name written in camel style (many also known as [[http://de.wikipedia.org/wiki/CamelCaps|camelCaps]] or laOlaStyle). Global variables are system-wide get a **g** prefix, passed variables get in a script a **get** or **post** as a prefix so that always is directly clear that the content of Varialben can be manipulated. \\+Variables should be similar to the function name written in camel style (many also known as [[http://de.wikipedia.org/wiki/CamelCaps|camelCaps]] or laOlaStyle). Global variables are system-wide get a **g** prefix, passed variables get in a script a **get** or **post** as a prefix so that always is directly clear that the content of variables can be manipulated. \\
 Example: Example:
  
 <code php>numberRows  // Description of the variable <code php>numberRows  // Description of the variable
-gCurrentUser  // global Varialbe+gCurrentUser  // global variable
 getUserId  // passed variable to a script</code> getUserId  // passed variable to a script</code>
  
Line 164: Line 157:
 If you checkout the code with GIT you could configure if you want it in LF (Linux) or CRLF (Windows). 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 leads to an error message in the script.+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 leads to an error message in the script.
  
 ===== File Name ===== ===== File Name =====
Line 180: Line 173:
 $sql = 'SELECT * FROM '. TBL_TEXT. ' WHERE txt_value = "example" ';</code> $sql = 'SELECT * FROM '. TBL_TEXT. ' WHERE txt_value = "example" ';</code>
  
-Within JavaScript, however, the double quotation marks should be used, so that as less as possible characters need to be escaped. This Javascript code can be copied easily between the scripts, we should take the double quotes even in pure JavaScript files.+Within JavaScript, however, the double quotation marks should be used, so that as less as possible characters need to be escaped. This JavaScript code can be copied easily between the scripts, we should take the double quotes even in pure JavaScript files.
 <code php> <code php>
 echo '<script type="text/javascript"><!-- echo '<script type="text/javascript"><!--
  • en/entwickler/programmierrichtlinien.1448540840.txt.gz
  • Last modified: 2015/11/26 13:27
  • by ximex