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