*** CODING STYLE ***

To keep something easily readable, coders have to follow a same coding style.
Currently we only have a few rules, inspired by GNU Coding Standards.


INDENTATION
-----------

Keeping the brackets on a same column
        function ($var)
          {
                if (1 != 0)
                  {
                        print 'a';
                  }
          }


COMMENTS
--------

Use # as comment character, to have something uniform with all scripts, shell
perl and PHP.

Use easily 'grepable' tags in the comments like DEPRECATED: or FIXME:


PHP/HTML MIXTURE
----------------

Do not mix different languages. It means that <?php ?> can occurs only
one time in a file. If you need to print some HTML, use print();


PHP REQUIRE
-----------

Use only double-quotes for require statements

require "../include/pre.php";


ESCAPE USER INPUT
-----------------

It is important to always escape user input (post, get, cookie). 
Use safe_input() to achieve that.

Please replace addslashes() by safe_input().


FEEDBACK
--------

Providing feedback on top of the page is the better way to return feedback
to user. It means that actions must fed the $feedback variable and ideally
all these actions should be done _before_ the page header function call.

Feedback messages should be more or less similar, you should use the function
fb() (aliases: utils_feedback(), feedback())
        fb(_("Bla bla bla"));

For error messages should, the second argument of this function should be
set to 1, something like
        fb(_("Bla failed due to crappy coding"), 1);


Providing help about specific words is something nice to. It should be used
using help() (alias: utils_help())

        help(_("My sentence with words unclear"),
                array(
                      _("sentence")=>_("sentence is ...")
                     ));


GETTEXT SUPPORT
---------------

Savannah being internationalized, do not insert strings without call to the
gettext "_()" function. And do not insert html tags inside (use printf/sprintf
if you need to put variables inside the gettext function). If you want to
print numbers, please consider using the "ngettext()" function instead of the
simple "_()" function.

If you need to make the meaning of a string clear, so that translators know
how to translate that word/sentence, you are encouraged to use the special
comment tag "I18N". Any comment marked this way will be included in the
savane.pot file for easy lookup.

Example:
# I18N
# This comment will be included in the potfile
print _("This is a sentence with a difficult meaning.");

Please see also the README in the po/ directory for some important
considerations.



JAVASCRIPT
----------

We cannot assume that all users have javascript support activated.
So the policy is that javascript must never be mandatory to perform
some action.


EOF

_______________________________________________
Savane-dev mailing list
[email protected]
https://mail.gna.org/listinfo/savane-dev

Reply via email to