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