This part of the documentation is not meant for end users of Coppermine, but only for developers. There is no support for this section, it comes as-is.
End users who wish to modify their copy of coppermine are encouraged to stick to these guidelines as well.
As Coppermine is a team effort, the team members who contribute code need to make sure that the code remains easy to read, understand and maintain. That's why there is a set of rules defined on this page that should be taken into account when working with the coppermine core code. Although this part of the documentation is aimed at dev team members, users who plan to contribute their code in any form are requested to respect the rules as well if possible (i.e. if you understand them fully).
The coding guidelines on this page are not set in stone - if you (as a dev team member) find during development that one of the guidelines needs review or change, start a thread on the dev board for discussion.
$pic_title = 'My picture'; $album = 'lastup'; $update_time = true;Good Example:
$pic_title = 'My picture'; $album = 'lastup'; $update_time = true;
$foo = array('one', 'two', 'three'); $bar = array( 'one' => 1, 'two' => 3, 'three' => 3 ); $multi = array('first' => 'one', 'second' => array('2'), 'third' => array('foo' => 'bar', 'hello' => 'world'));Good Examples:
$foo = array( 'one', 'two', 'three', ); $bar = array( 'one' => 1, 'two' => 2, 'three' => 3, ); $multi = array( 'first' => 'one', 'second' => array('2'), // Since it is just one value in array, it can be declared in same line 'third' => array( 'foo' => 'bar', 'hello' => 'world', ), );
$foo_array["bla"] = "whatever";Good:
$foo_array['bla'] = 'whatever';
$bla_array['foo Bar'] = 'some string';Good:
$bla_array['foo_bar'] = 'some string';
These include if, for, while, switch.
if ($foo = 'bar') { echo 'Hello world'; }Bad example:
if ($foo = 'bar') { echo 'Hello world'; }Good example:
if ($foo = 'bar') { echo 'Hello world'; }Good example:
if ($foo = 'bar') { echo 'Hello world'; }
<?php function fooFunction($arg1, $arg2 = '') { if (condition) { statement; } return $val; } ?>
When more than one line of HTML needs to be printed, the heredoc syntax should be used instead of ending the PHP processing and starting it later.
Good:
// PHP content here if ($foo == $bar) { print <<< EOT <h1>Hello {$bla}</h1> EOT; }
Bad:
// PHP content here if ($foo == $bar) { ?> <h1>Hello <?php echo $bla; ?></h1> <?php }
To echo line breaks to the HTML output, use the heredoc syntax or use the variable $LINEBREAK instead of hardcoding line breaks into the code.
Remember to make the variable global inside functions.
Good:
echo '<h1>Hello world</h1>' . $LINEBREAK; echo '<p>foo bar</p>'; }
Bad:
echo "<h1>Hello world</h1>\n"; echo '<p>foo bar</p>'; }
Deprecated HTML tags like <font> mustn't be introduced into Coppermine unless there is a valid, documented reason to do so.
The popular tags <b> and <i> are considered to be deprecated tags as well. Because of their popularity, browsers will probably support them for a long time. However, there are better alternatives. For <b>, the replacement tag is <strong>. For <i>, the replacement tag is <em>. If possible, the replacement tags should be used both in HTML output generated by Coppermine as well as the documentation.
The core rules on this page have been sketched by Dr. Tarique Sani as a subset of the PEAR coding guidelines. HTML output and database sections are based on a thread created by Unknown W. Brackets from Simplemachines.