1 $Id: README.coding,v 1.2 2001-12-16 18:33:25 dairiki Exp $
3 Here are the coding guidelines for PhpWiki.
5 !!! Code Indentation Style
7 We follow, for the most part, the PEAR coding standards:
9 * http://www.php.net/manual/en/pear.standards.php
11 There's code snippets for configuring Emacs and Vim as well as several
12 other text editors at the above URL.
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.
24 Use php-mode as well. This is freely available on the net
25 (http://sourceforge.net/projects/php-mode/). Put something like this
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
33 ;; This syntax table mod makes the second line in:
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)))
47 !!! I18N: Using gettext()
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.
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 (").
57 (You can now use _("foo") as an alias for gettext("foo").)
59 OKAY: gettext("This is a message.");
61 OKAY: sprintf(gettext("Hello %s"), $name);
62 OKAY: sprintf(_("Hello %s"), $name);
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);