]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - doc/README.coding
o Corrected a mistake in file path for Apache alias directive (the ? incorrectly...
[SourceForge/phpwiki.git] / doc / README.coding
1 $Id: README.coding,v 1.2 2001-12-16 18:33:25 dairiki Exp $
2
3 Here are the coding guidelines for PhpWiki.
4
5 !!! Code Indentation Style
6
7 We follow, for the most part, the PEAR coding standards:
8
9 * http://www.php.net/manual/en/pear.standards.php
10
11 There's code snippets for configuring Emacs and Vim as well as several
12 other text editors at the above URL.
13
14 !! Emacs Users
15
16 For editing files in Emacs, set indent-tabs-mode to nil. Some people
17 argue that it's better to use tabs and let people set their tab width,
18 but I think we're better off using just spaces because aligned
19 comments in the right region will not align correctly. For a detailed
20 argument see http://www.jwz.org/doc/tabs-vs-spaces.html.
21 Also use a tab-width of eight, so that just in case tabs do creep
22 into the source code, they have a standard width.
23
24 Use php-mode as well. This is freely available on the net
25 (http://sourceforge.net/projects/php-mode/). Put something like this
26 in your .emacs file:
27
28  (autoload 'php-mode "php-mode" "PHP editing mode" t)
29  (add-to-list 'auto-mode-alist '("\\.php\\d?$" . php-mode))
30  (add-hook 'php-mode-hook
31            (lambda ()
32              (c-set-style "gnu")
33              ;; This syntax table mod makes the second line in:
34              ;; 
35              ;;   function( $arg1,
36              ;;             $arg2 );
37              ;;
38              ;; Line up correctly.
39              ;;
40              (modify-syntax-entry ?$ "'" php-mode-syntax-table)
41              (set (make-local-variable 'tab-width) 8)
42              (set (make-local-variable 'c-basic-offset) 4)
43              (set (make-local-variable 'c-hanging-comment-ender-p) 'nil)
44              (set (make-local-variable 'indent-tabs-mode) 'nil)))
45
46
47 !!! I18N: Using gettext()
48
49 String literals which end up making it into the HTML output should be wrapped
50 with a call to ''gettext()''.  This allows translations to be substituted when 
51 PhpWiki is run in non-english environments.
52
53 Since xgettext (part of the "GNU gettext utilities") is used to find strings
54 for translation, It is important that the argument of ''gettext()'' be a constant
55 string literal, in double quotes (").
56
57 (You can now use _("foo") as an alias for gettext("foo").)
58
59  OKAY:  gettext("This is a message.");
60  OKAY:  _("Fazool."); 
61  OKAY:  sprintf(gettext("Hello %s"), $name);
62  OKAY:  sprintf(_("Hello %s"), $name);
63
64  BAD:   gettext('This will be ignored by xgettext.');
65  BAD:   _("Howdy" . ", wazoo");
66  BAD:   gettext("Hello $name");
67  BAD:   define("MES", "howdy");  gettext(MES);
68  BAD:   gettext($string);