Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
CODING_CONVENTION.php
Go to the documentation of this file.
1 
2 Coding Convention
3 ----------------
4 
5 We are using the following coding convention
6 
7 Graphically
8 ----------------
9 
10 The classes are structured like that.
11 texts prefixed by "##" are comments to explain the convention with an example. Do not use them in your code.
12 
13 <?php
14 ## The header below is on every head of php file use current year instead of 2012. ##
15 /*
16  ----------------------------------------------------------------------
17  AlternC - Web Hosting System
18  Copyright (C) 2000-2012 by the AlternC Development Team.
19  https://alternc.org/
20  ----------------------------------------------------------------------
21  LICENSE
22 
23  This program is free software; you can redistribute it and/or
24  modify it under the terms of the GNU General Public License (GPL)
25  as published by the Free Software Foundation; either version 2
26  of the License, or (at your option) any later version.
27 
28  This program is distributed in the hope that it will be useful,
29  but WITHOUT ANY WARRANTY; without even the implied warranty of
30  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31  GNU General Public License for more details.
32 
33  To read the license please visit http://www.gnu.org/copyleft/gpl.html
34  ----------------------------------------------------------------------
35  Purpose of file: Manage mailing-lists with Mailman
36  ----------------------------------------------------------------------
37 */
38 ## Enter the purpose of this file up there ^^ ##
39 
40 ## the name of the class is the same as the file (m_dom, m_mailman...) ##
41 class m_mailman {
42 
43 
44 ## 2 blank lines here and between each functions, give it some space ;) ##
45 ## the following line of -- allow you to visually quickly find a function ##
46 ## then the comment after it is using /** notation, so that phpdoc can build a self-made documentation of our classes ##
47  /* ----------------------------------------------------------------- */
48  /** ## here we put a full long description of the function's behavior, in english ##
49  * ## this description may span multiple lines ##
50  * @param $domain string ## each param has its @param line, followed by the param name ($domain) type (string) and description ##
51  * @return array ## a @return line is added when the function returns anything, followed by the returned type and description ##
52  */
53  function enum_ml($domain = null, $order_by = array('domain', 'list')) {
54 ## function which consist of more than one word are separated by _ ##
55 ## private functions are prefixed by "private" and their name starts by "_" ##
56  global $err,$db,$cuid;
57 ## use the globals for $db (database mapper), $cuid (uid of current alternc's user) $err (error/log mapper)
58  $err->log("mailman","enum_ml");
59 ## when calling an important function, log it that way ##
60 ## when raising an error, use the following syntax ##
61  $err->raise("classname",_("text in english"));
62  }
63 }
64 /* at the end of a php-only file, we don't put a ?> */
65 
66 ?>
67 
68 Syntax in code :
69 ----------------
70 
71  function names starting by "hook_" are hooks called that way:
72 
73 global $hooks;
74 $res=$hooks->invoke("hook_class_method_name",array($param1,$param2));
75 
76 $params1 & 2 are sent as parameters to the hooked functions of each files.
77 
78 the hook function name must have the CALLING class name after hook_
79 like hook_admin_del_member for a hook in "admin" class.
80 
81 $res is an array with the returned data as values, for each function called in a class.
82 The key in that array is the classname called.
83