diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-06 11:11:27 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-11-06 11:11:27 -0500 |
commit | 87ea50948ea53c0d1beab5b44badebeae4292d1a (patch) | |
tree | dbc99fde4dfc62b84bae60c7e4ab5c02ddbe8a3c /phpBB/docs/coding-guidelines.html | |
parent | 5b48df41685da785b082612318ebe7a8012c4149 (diff) | |
parent | 44ff9d020fd218cbdb2f07a0d7f85a630367e3c2 (diff) | |
download | forums-87ea50948ea53c0d1beab5b44badebeae4292d1a.tar forums-87ea50948ea53c0d1beab5b44badebeae4292d1a.tar.gz forums-87ea50948ea53c0d1beab5b44badebeae4292d1a.tar.bz2 forums-87ea50948ea53c0d1beab5b44badebeae4292d1a.tar.xz forums-87ea50948ea53c0d1beab5b44badebeae4292d1a.zip |
Merge remote-tracking branch 'upstream/develop' into feature/prune-users
* upstream/develop: (2171 commits)
[ticket/11164] Update composer.phar
[ticket/10933] Use inheritDoc, eliminate copy pasted docblocks.
[ticket/10933] Dependency inject template context.
[ticket/10933] Expanded prose documentation for phpbb_extension_provider.
[ticket/10933] Specify empty template path for absolute includephp test.
[ticket/10933] Useful documentation for template locate function
[ticket/10933] Typo fixes
[ticket/10933] Initialize template context when template is constructed.
[ticket/11099] Mark acp_ban::display_ban_options() as static.
[ticket/11158] Require acl_u_sig for ucp signature module.
[ticket/11158] Revert old fix in PHPBB3-10186.
[ticket/11159] static public is the currently approved order.
[ticket/11157] static public is the currently approved order.
[ticket/11157] Fix remaining captcha spam.
[ticket/11157] get_captcha_types is an instance method.
[ticket/11156] Delete "Misc" tab of forum based permissions + move items
[ticket/10848] Move include up.
[ticket/11014] Fix old pagination assignment
[ticket/11018] Fix several paginations in ACP
[ticket/11014] Fix IF statements for new template pagination
...
Conflicts:
phpBB/includes/functions_user.php
Diffstat (limited to 'phpBB/docs/coding-guidelines.html')
-rw-r--r-- | phpBB/docs/coding-guidelines.html | 248 |
1 files changed, 112 insertions, 136 deletions
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 8365e3c301..ae4655e094 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -1,16 +1,9 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en"> +<!DOCTYPE html> +<html dir="ltr" lang="en"> <head> - -<meta http-equiv="content-type" content="text/html; charset=utf-8" /> -<meta http-equiv="content-style-type" content="text/css" /> -<meta http-equiv="content-language" content="en" /> -<meta http-equiv="imagetoolbar" content="no" /> -<meta name="resource-type" content="document" /> -<meta name="distribution" content="global" /> -<meta name="copyright" content="phpBB Group" /> +<meta charset="utf-8"> <meta name="keywords" content="" /> -<meta name="description" content="Olympus coding guidelines document" /> +<meta name="description" content="Ascraeus coding guidelines document" /> <title>phpBB3 • Coding Guidelines</title> <link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen, projection" /> @@ -28,7 +21,7 @@ <div id="doc-description"> <a href="../index.php" id="logo"><img src="site_logo.gif" alt="" /></a> <h1>Coding Guidelines</h1> - <p>Olympus coding guidelines document</p> + <p>Ascraeus coding guidelines document</p> <p style="display: none;"><a href="#start_here">Skip</a></p> </div> @@ -42,7 +35,7 @@ <!-- BEGIN DOCUMENT --> -<p>These are the phpBB Coding Guidelines for Olympus, all attempts should be made to follow them as closely as possible.</p> +<p>These are the phpBB Coding Guidelines for Ascraeus, all attempts should be made to follow them as closely as possible.</p> <h1>Coding Guidelines</h1> @@ -78,7 +71,7 @@ <li><a href="#templating">Templating</a> <ol style="list-style-type: lower-roman;"> <li><a href="#templates">General Templating</a></li> - <li><a href="#inheritance">Template Inheritance</a></li> + <li><a href="#stylestree">Styles Tree</a></li> </ol></li> <li><a href="#charsets">Character Sets and Encodings</a></li> <li><a href="#translation">Translation (<abbr title="Internationalisation">i18n</abbr>/<abbr title="Localisation">L10n</abbr>) Guidelines</a> @@ -88,12 +81,6 @@ <li><a href="#writingstyle">Writing Style</a></li> </ol> </li> - <li><a href="#vcs">VCS Guidelines</a> - <ol style="list-style-type: lower-roman;"> - <li><a href="#repostruct">Repository structure</a></li> - <li><a href="#commitmessage">Commit Messages and Repository Rules</a></li> - </ol> - </li> <li><a href="#disclaimer">Copyright and disclaimer</a></li> </ol> @@ -136,9 +123,8 @@ /** * * @package {PACKAGENAME} -* @version $Id: $ * @copyright (c) 2007 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ </pre></div> @@ -262,13 +248,14 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c <p>If the <code>PHPBB_USE_BOARD_URL_PATH</code> constant is set to true, phpBB uses generate_board_url() (this will return the boards url with the script path included) on all instances where web-accessible images are loaded. The exact locations are:</p> <ul> - <li>/includes/session.php - user::img()</li> + <li>/includes/user.php - phpbb_user::img()</li> <li>/includes/functions_content.php - smiley_text()</li> </ul> <p>Path locations for the following template variables are affected by this too:</p> <ul> + <li>{T_ASSETS_PATH} - assets (non-style specific, static resources)</li> <li>{T_THEME_PATH} - styles/xxx/theme</li> <li>{T_TEMPLATE_PATH} - styles/xxx/template</li> <li>{T_SUPER_TEMPLATE_PATH} - styles/xxx/template</li> @@ -308,11 +295,17 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c <p>We will not be using any form of hungarian notation in our naming conventions. Many of us believe that hungarian naming is one of the primary code obfuscation techniques currently in use.</p> <h4>Variable Names:</h4> - <p>Variable names should be in all lowercase, with words separated by an underscore, example:</p> + <p>In PHP, variable names should be in all lowercase, with words separated by an underscore, example:</p> <div class="indent"> <p><code>$current_user</code> is right, but <code>$currentuser</code> and <code> $currentUser</code> are not.</p> </div> + + <p>In JavaScript, variable names should use camel case:</p> + + <div class="indent"> + <p><code>currentUser</code> is right, but <code>currentuser</code> and <code>current_user</code> are not.</p> + </div> <p>Names should be descriptive, but concise. We don't want huge sentences as our variable names, but typing an extra couple of characters is always better than wondering what exactly a certain variable is for. </p> @@ -330,7 +323,7 @@ for ($i = 0; $i < $outer_size; $i++) </pre></div> <h4>Function Names:</h4> - <p>Functions should also be named descriptively. We're not programming in C here, we don't want to write functions called things like "stristr()". Again, all lower-case names with words separated by a single underscore character. Function names should preferably have a verb in them somewhere. Good function names are <code>print_login_status()</code>, <code>get_user_data()</code>, etc. </p> + <p>Functions should also be named descriptively. We're not programming in C here, we don't want to write functions called things like "stristr()". Again, all lower-case names with words separated by a single underscore character in PHP, and camel caps in JavaScript. Function names should preferably have a verb in them somewhere. Good function names are <code>print_login_status()</code>, <code>get_user_data()</code>, etc. Constructor functions in JavaScript should begin with a capital letter.</p> <h4>Function Arguments:</h4> <p>Arguments are subject to the same guidelines as variable names. We don't want a bunch of functions like: <code>do_stuff($a, $b, $c)</code>. In most cases, we'd like to be able to tell how to use a function by just looking at its declaration. </p> @@ -369,7 +362,7 @@ phpbb_dir_subdir_class_name - includes/dir/subdir/class_name.php <p>The basic philosophy here is to not hurt code clarity for the sake of laziness. This has to be balanced by a little bit of common sense, though; <code>print_login_status_for_a_given_user()</code> goes too far, for example -- that function would be better named <code>print_user_login_status()</code>, or just <code>print_login_status()</code>.</p> <h4>Special Namings: </h4> - <p>For all emoticons use the term <code>smiley</code> in singular and <code>smilies</code> in plural.</p> + <p>For all emoticons use the term <code>smiley</code> in singular and <code>smilies</code> in plural. For emails we use the term <code>email</code> (without dash between “e” and “m”).</p> <a name="codelayout"></a><h3>2.ii. Code Layout</h3> @@ -410,7 +403,7 @@ for ($i = 0; $i < size; $i++) </pre></div> <h4>Where to put the braces:</h4> - <p>This one is a bit of a holy war, but we're going to use a style that can be summed up in one sentence: Braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:</p> + <p>In PHP code, braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:</p> <div class="codebox"><pre> if (condition) @@ -440,6 +433,30 @@ function do_stuff() ... } </pre></div> + + <p>In JavaScript code, braces always go on the same line:</p> + + <div class="codebox"><pre> +if (condition) { + while (condition2) { + ... + } +} else { + ... +} + +for (var i = 0; i < size; i++) { + ... +} + +while (condition) { + ... +} + +function do_stuff() { + ... +} + </pre></div> <h4>Use spaces between tokens:</h4> <p>This is another simple, easy step that helps keep code readable without much effort. Whenever you write an assignment, expression, etc.. Always leave <em>one</em> space between the tokens. Basically, write code as if it was English. Put spaces between variable names and operators. Don't put spaces just after an opening bracket or before a closing bracket. Don't put spaces just before a comma or a semicolon. This is best shown with a few examples, examples:</p> @@ -507,15 +524,15 @@ do_stuff($str); $post_url = $phpbb_root_path . 'posting.' . $phpEx . '?mode=' . $mode . '&amp;start=' . $start; </pre></div> - <p class="good">// Double quotes are sometimes needed to not overcroud the line with concentinations</p> + <p class="good">// Double quotes are sometimes needed to not overcrowd the line with concatenations.</p> <div class="codebox"><pre> $post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&amp;start=$start"; </pre></div> - <p>In SQL Statements mixing single and double quotes is partly allowed (following the guidelines listed here about SQL Formatting), else it should be tryed to only use one method - mostly single quotes.</p> + <p>In SQL statements mixing single and double quotes is partly allowed (following the guidelines listed here about SQL formatting), else one should try to only use one method - mostly single quotes.</p> <h4>Commas after every array element:</h4> - <p>If an array is defined with each element on its own line, you still have to modify the previous line to add a comma when appending a new element. PHP allows for trailing (useless) commas in array definitions. These should always be used so each element including the comma can be appended with a single line</p> + <p>If an array is defined with each element on its own line, you still have to modify the previous line to add a comma when appending a new element. PHP allows for trailing (useless) commas in array definitions. These should always be used so each element including the comma can be appended with a single line. In JavaScript, do not use the trailing comma, as it causes browsers to throw errors.</p> <p class="bad">// wrong</p> <div class="codebox"><pre> @@ -561,7 +578,7 @@ $foo = $assoc_array[$var]; <p>Each complex function should be preceded by a comment that tells a programmer everything they need to know to use that function. The meaning of every parameter, the expected input, and the output are required as a minimal comment. The function's behaviour in error conditions (and what those error conditions are) should also be present - but mostly included within the comment about the output.<br /><br />Especially important to document are any assumptions the code makes, or preconditions for its proper operation. Any one of the developers should be able to look at any part of the application and figure out what's going on in a reasonable amount of time.<br /><br />Avoid using <code>/* */</code> comment blocks for one-line comments, <code>//</code> should be used for one/two-liners.</p> <h4>Magic numbers:</h4> - <p>Don't use them. Use named constants for any literal value other than obvious special cases. Basically, it's ok to check if an array has 0 elements by using the literal 0. It's not ok to assign some special meaning to a number and then use it everywhere as a literal. This hurts readability AND maintainability. The constants <code>true</code> and <code>false</code> should be used in place of the literals 1 and 0 -- even though they have the same values (but not type!), it's more obvious what the actual logic is when you use the named constants. Typecast variables where it is needed, do not rely on the correct variable type (PHP is currently very loose on typecasting which can lead to security problems if a developer does not have a very close eye to it).</p> + <p>Don't use them. Use named constants for any literal value other than obvious special cases. Basically, it's ok to check if an array has 0 elements by using the literal 0. It's not ok to assign some special meaning to a number and then use it everywhere as a literal. This hurts readability AND maintainability. The constants <code>true</code> and <code>false</code> should be used in place of the literals 1 and 0 -- even though they have the same values (but not type!), it's more obvious what the actual logic is when you use the named constants. Typecast variables where it is needed, do not rely on the correct variable type (PHP is currently very loose on typecasting which can lead to security problems if a developer does not keep a very close eye on it).</p> <h4>Shortcut operators:</h4> <p>The only shortcut operators that cause readability problems are the shortcut increment <code>$i++</code> and decrement <code>$j--</code> operators. These operators should not be used as part of an expression. They can, however, be used on their own line. Using them in expressions is just not worth the headaches when debugging, examples:</p> @@ -750,7 +767,7 @@ $sql = 'SELECT * </pre></div> <h4>SQL Quotes: </h4> - <p>Double quotes where applicable (The variables in these examples are typecasted to integers before) ... examples: </p> + <p>Use double quotes where applicable. (The variables in these examples are typecasted to integers beforehand.) Examples: </p> <p class="bad">// These are wrong.</p> <div class="codebox"><pre> @@ -911,7 +928,7 @@ SELECT FROM phpbb_forums WHERE forum_id <strong><></strong> 1 <h4>sql_build_query():</h4> - <p>The <code>$db->sql_build_query()</code> function is responsible for building sql statements for select and select distinct queries if you need to JOIN on more than one table or retrieving data from more than one table while doing a JOIN. This needs to be used to make sure the resulting statement is working on all supported db's. Instead of explaining every possible combination, i will give a short example:</p> + <p>The <code>$db->sql_build_query()</code> function is responsible for building sql statements for SELECT and SELECT DISTINCT queries if you need to JOIN on more than one table or retrieve data from more than one table while doing a JOIN. This needs to be used to make sure the resulting statement is working on all supported db's. Instead of explaining every possible combination, I will give a short example:</p> <div class="codebox"><pre> $sql_array = array( @@ -996,7 +1013,7 @@ for ($i = 0, $size = sizeof($post_data); $i < $size; $i++) </pre></div> <h4>Use of in_array(): </h4> - <p>Try to avoid using in_array() on huge arrays, and try to not place them into loops if the array to check consist of more than 20 entries. in_array() can be very time consuming and uses a lot of cpu processing time. For little checks it is not noticable, but if checked against a huge array within a loop those checks alone can be a bunch of seconds. If you need this functionality, try using isset() on the arrays keys instead, actually shifting the values into keys and vice versa. A call to <code>isset($array[$var])</code> is a lot faster than <code>in_array($var, array_keys($array))</code> for example.</p> + <p>Try to avoid using in_array() on huge arrays, and try to not place them into loops if the array to check consist of more than 20 entries. in_array() can be very time consuming and uses a lot of cpu processing time. For little checks it is not noticeable, but if checked against a huge array within a loop those checks alone can take several seconds. If you need this functionality, try using isset() on the arrays keys instead, actually shifting the values into keys and vice versa. A call to <code>isset($array[$var])</code> is a lot faster than <code>in_array($var, array_keys($array))</code> for example.</p> <a name="general"></a><h3>2.v. General Guidelines</h3> @@ -1009,7 +1026,7 @@ for ($i = 0, $size = sizeof($post_data); $i < $size; $i++) <p>No attempt should be made to remove any copyright information (either contained within the source or displayed interactively when the source is run/compiled), neither should the copyright information be altered in any way (it may be added to).</p> <h4>Variables: </h4> - <p>Make use of the <code>request_var()</code> function for anything except for submit or single checking params. </p> + <p>Make use of the <code>request_var()</code> function for anything except for submit or single checking params.</p> <p>The request_var function determines the type to set from the second parameter (which determines the default value too). If you need to get a scalar variable type, you need to tell this the request_var function explicitly. Examples:</p> <p class="bad">// Old method, do not use it</p> @@ -1076,7 +1093,7 @@ $user->setup(); <p>The <code>$user->setup()</code> call can be used to pass on additional language definition and a custom style (used in viewforum).</p> <h4>Errors and messages: </h4> - <p>All messages/errors should be outputed by calling <code>trigger_error()</code> using the appropriate message type and language string. Example:</p> + <p>All messages/errors should be outputted by calling <code>trigger_error()</code> using the appropriate message type and language string. Example:</p> <div class="codebox"><pre> trigger_error('NO_FORUM'); @@ -1094,7 +1111,7 @@ trigger_error('NO_MODE', E_USER_ERROR); <p>All urls pointing to internal files need to be prepended by the <code>$phpbb_root_path</code> variable. Within the administration control panel all urls pointing to internal files need to be prepended by the <code>$phpbb_admin_path</code> variable. This makes sure the path is always correct and users being able to just rename the admin folder and the acp still working as intended (though some links will fail and the code need to be slightly adjusted).</p> - <p>The <code>append_sid()</code> function from 2.0.x is available too, though does not handle url alterations automatically. Please have a look at the code documentation if you want to get more details on how to use append_sid(). A sample call to append_sid() can look like this:</p> + <p>The <code>append_sid()</code> function from 2.0.x is available too, though it does not handle url alterations automatically. Please have a look at the code documentation if you want to get more details on how to use append_sid(). A sample call to append_sid() can look like this:</p> <div class="codebox"><pre> append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp;g=' . $row['group_id']) @@ -1102,7 +1119,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <h4>General function usage: </h4> - <p>Some of these functions are only chosen over others because of personal preference and having no other benefit than to be consistent over the code.</p> + <p>Some of these functions are only chosen over others because of personal preference and have no benefit other than maintaining consistency throughout the code.</p> <ul> <li> @@ -1157,18 +1174,22 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <div class="content"> <a name="cfgfiles"></a><h3>3.i. Style Config Files</h3> - <p>Style cfg files are simple name-value lists with the information necessary for installing a style. Similar cfg files exist for templates, themes and imagesets. These follow the same principle and will not be introduced individually. Styles can use installed components by using the required_theme/required_template/required_imageset entries. The important part of the style configuration file is assigning an unique name.</p> + <p>Style cfg files are simple name-value lists with the information necessary for installing a style. The important part of the style configuration file is assigning an unique name.</p> <div class="codebox"><pre> - # General Information about this style - name = prosilver_duplicate - copyright = © phpBB Group, 2007 - version = 3.0.3 - required_template = prosilver - required_theme = prosilver - required_imageset = prosilver +# General Information about this style +name = prosilver_duplicate +copyright = © phpBB Group, 2007 +version = 3.1.0 + +# Defining a different template bitfield +# template_bitfield = lNg= + +# Parent style +# Set value to empty or to this style's name if this style does not have a parent style +parent = prosilver </pre></div> <a name="genstyling"></a><h3>3.2. General Styling Rules</h3> -<p>Templates should be produced in a consistent manner. Where appropriate they should be based off an existing copy, e.g. index, viewforum or viewtopic (the combination of which implement a range of conditional and variable forms). Please also note that the intendation and coding guidelines also apply to templates where possible.</p> +<p>Templates should be produced in a consistent manner. Where appropriate they should be based off an existing copy, e.g. index, viewforum or viewtopic (the combination of which implement a range of conditional and variable forms). Please also note that the indentation and coding guidelines also apply to templates where possible.</p> <p>The outer table class <code>forumline</code> has gone and is replaced with <code>tablebg</code>.</p> <p>When writing <code><table></code> the order <code><table class="" cellspacing="" cellpadding="" border="" align=""></code> creates consistency and allows everyone to easily see which table produces which "look". The same applies to most other tags for which additional parameters can be set, consistency is the major aim here.</p> @@ -1188,7 +1209,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <p>Row colours/classes are now defined by the template, use an <code>IF S_ROW_COUNT</code> switch, see viewtopic or viewforum for an example.</p> -<p>Remember block level ordering is important ... while not all pages validate as XHTML 1.0 Strict compliant it is something we're trying to work too.</p> +<p>Remember block level ordering is important.</p> <p>Use a standard cellpadding of 2 and cellspacing of 0 on outer tables. Inner tables can vary from 0 to 3 or even 4 depending on the need.</p> @@ -1237,12 +1258,12 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <a name="templates"></a><h3>4.i. General Templating</h3> <h4>File naming</h4> -<p>Firstly templates now take the suffix ".html" rather than ".tpl". This was done simply to make the lifes of some people easier wrt syntax highlighting, etc.</p> +<p>Firstly templates now take the suffix ".html" rather than ".tpl". This was done simply to make the lives of some people easier wrt syntax highlighting, etc.</p> <h4>Variables</h4> <p>All template variables should be named appropriately (using underscores for spaces), language entries should be prefixed with L_, system data with S_, urls with U_, javascript urls with UA_, language to be put in javascript statements with LA_, all other variables should be presented 'as is'.</p> -<p>L_* template variables are automatically tried to be mapped to the corresponding language entry if the code does not set (and therefore overwrite) this variable specifically. For example <code>{L_USERNAME}</code> maps to <code>$user->lang['USERNAME']</code>. The LA_* template variables are handled within the same way, but properly escaped to be put in javascript code. This should reduce the need to assign loads of new lang vars in Modifications. +<p>L_* template variables are automatically mapped to the corresponding language entry if the code does not set (and therefore overwrite) this variable specifically and if the language entry exists. For example <code>{L_USERNAME}</code> maps to <code>$user->lang['USERNAME']</code>. The LA_* template variables are handled within the same way, but properly escaped so they can be put in javascript code. This should reduce the need to assign loads of new language variables in MODifications. </p> <h4>Blocks/Loops</h4> @@ -1256,13 +1277,13 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <p>A bit later loops will be explained further. To not irritate you we will explain conditionals as well as other statements first.</p> <h4>Including files</h4> -<p>Something that existed in 2.0.x which no longer exists in 3.0.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:</p> +<p>Something that existed in 2.0.x which no longer exists in 3.x is the ability to assign a template to a variable. This was used (for example) to output the jumpbox. Instead (perhaps better, perhaps not but certainly more flexible) we now have INCLUDE. This takes the simple form:</p> <div class="codebox"><pre> <span class="comment"><!-- INCLUDE filename --></span> </pre></div> -<p>You will note in the 3.0 templates the major sources start with <code><!-- INCLUDE overall_header.html --></code> or <code><!-- INCLUDE simple_header.html --></code>, etc. In 2.0.x control of "which" header to use was defined entirely within the code. In 3.0.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common "menu" bar or some such. No need to modify loads of files as with 2.0.x.</p> +<p>You will note in the 3.x templates the major sources start with <code><!-- INCLUDE overall_header.html --></code> or <code><!-- INCLUDE simple_header.html --></code>, etc. In 2.0.x control of "which" header to use was defined entirely within the code. In 3.x the template designer can output what they like. Note that you can introduce new templates (i.e. other than those in the default set) using this system and include them as you wish ... perhaps useful for a common "menu" bar or some such. No need to modify loads of files as with 2.0.x.</p> <p>Added in <strong>3.0.6</strong> is the ability to include a file using a template variable to specify the file, this functionality only works for root variables (i.e. not block variables).</p> <div class="codebox"><pre> @@ -1294,7 +1315,7 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <p>it will be included and executed inline.<br /><br />A note, it is very much encouraged that template designers do not include PHP. The ability to include raw PHP was introduced primarily to allow end users to include banner code, etc. without modifying multiple files (as with 2.0.x). It was not intended for general use ... hence <!-- w --><a href="http://www.phpbb.com">www.phpbb.com</a><!-- w --> will <strong>not</strong> make available template sets which include PHP. And by default templates will have PHP disabled (the admin will need to specifically activate PHP for a template).</p> <h4>Conditionals/Control structures</h4> -<p>The most significant addition to 3.0.x are conditions or control structures, "if something then do this else do that". The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:</p> +<p>The most significant addition to 3.x are conditions or control structures, "if something then do this else do that". The system deployed is very similar to Smarty. This may confuse some people at first but it offers great potential and great flexibility with a little imagination. In their most simple form these constructs take the form:</p> <div class="codebox"><pre> <span class="comment"><!-- IF expr --></span> @@ -1365,7 +1386,7 @@ div <span class="comment"><!-- ENDIF --></span> </pre></div> -<p>Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match "everything else".<br /><br />So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.0.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:</p> +<p>Each statement will be tested in turn and the relevant output generated when a match (if a match) is found. It is not necessary to always use ELSEIF, ELSE can be used alone to match "everything else".<br /><br />So what can you do with all this? Well take for example the colouration of rows in viewforum. In 2.0.x row colours were predefined within the source as either row color1, row color2 or row class1, row class2. In 3.x this is moved to the template, it may look a little daunting at first but remember control flows from top to bottom and it's not too difficult:</p> <div class="codebox"><pre> <table> @@ -1525,9 +1546,9 @@ div <span class="comment"><!-- END l_block1 --></span> </pre></div> -<p>Here we open the loop l_block1 and doing some things if the value S_SELECTED within the current loop iteration is true, else we write the blocks link and title. Here, you see <code>{l_block1.L_TITLE}</code> referenced - you remember that L_* variables get automatically assigned the corresponding language entry? This is true, but not within loops. The L_TITLE variable within the loop l_block1 is assigned within the code itself.</p> +<p>Here we open the loop l_block1 and do some things if the value S_SELECTED within the current loop iteration is true, else we write the blocks link and title. Here, you see <code>{l_block1.L_TITLE}</code> referenced - you remember that L_* variables get automatically assigned the corresponding language entry? This is true, but not within loops. The L_TITLE variable within the loop l_block1 is assigned within the code itself.</p> -<p>Let's have a closer look to the markup:</p> +<p>Let's have a closer look at the markup:</p> <div class="codebox"><pre> <span class="comment"><!-- BEGIN l_block1 --></span> @@ -1621,7 +1642,7 @@ div </ul> <span class="comment"><!-- written on third iteration --></span> </pre></div> -<p>Just always remember that processing is taking place from up to down.</p> +<p>Just always remember that processing is taking place from top to bottom.</p> <h4>Forms</h4> <p>If a form is used for a non-trivial operation (i.e. more than a jumpbox), then it should include the <code>{S_FORM_TOKEN}</code> template variable.</p> @@ -1636,26 +1657,25 @@ div </form> </pre></div><br /> - <a name="inheritance"></a><h3>4.ii. Template Inheritance</h3> - <p>When basing a new template on an existing one, it is not necessary to provide all template files. By declaring the template to be "<strong>inheriting</strong>" in the template configuration file.</p> + <a name="stylestree"></a><h3>4.ii. Styles Tree</h3> + <p>When basing a new style on an existing one, it is not necessary to provide all the template files. By declaring the base style name in the <strong>parent</strong> field in the style configuration file, the style can be set to reuse template files from the parent style.</p> - <p>The limitation on this is that the base style has to be installed and complete, meaning that it is not itself inheriting.</p> + <p>The effect of doing so is that the template engine will use the template files in the new style where they exist, but fall back to files in the parent style otherwise.</p> - <p>The effect of doing so is that the template engine will use the files in the new template where they exist, but fall back to files in the base template otherwise. Declaring a style to be inheriting also causes it to use some of the configuration settings of the base style, notably database storage.</p> - - <p>We strongly encourage the use of inheritance for styles based on the bundled styles, as it will ease the update procedure.</p> + <p>We strongly encourage the use of parent styles for styles based on the bundled styles, as it will ease the update procedure.</p> <div class="codebox"><pre> - # General Information about this template - name = inherits - copyright = © phpBB Group, 2007 - version = 3.0.3 +# General Information about this style +name = Custom Style +copyright = &copy; phpBB Group, 2007 +version = 3.1.0 - # Defining a different template bitfield - template_bitfield = lNg= +# Defining a different template bitfield +# template_bitfield = lNg= - # Are we inheriting? - inherit_from = prosilver +# Parent style +# Set value to empty or to this style's name if this style does not have a parent style +parent = prosilver </pre></div> </div> @@ -1768,9 +1788,9 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <h4>Encoding:</h4> - <p>With phpBB3, the output encoding for the forum in now UTF-8, a Universal Character Encoding by the Unicode Consortium that is by design a superset to US-ASCII and ISO-8859-1. By using one character set which simultaenously supports all scripts which previously would have required different encodings (eg: ISO-8859-1 to ISO-8859-15 (Latin, Greek, Cyrillic, Thai, Hebrew, Arabic); GB2312 (Simplified Chinese); Big5 (Traditional Chinese), EUC-JP (Japanese), EUC-KR (Korean), VISCII (Vietnamese); et cetera), this removes the need to convert between encodings and improves the accessibility of multilingual forums.</p> + <p>With phpBB3, the output encoding for the forum in now UTF-8, a Universal Character Encoding by the Unicode Consortium that is by design a superset to US-ASCII and ISO-8859-1. By using one character set which simultaenously supports all scripts which previously would have required different encodings (eg: ISO-8859-1 to ISO-8859-15 (Latin, Greek, Cyrillic, Thai, Hebrew, Arabic); GB2312 (Simplified Chinese); Big5 (Traditional Chinese), EUC-JP (Japanese), EUC-KR (Korean), VISCII (Vietnamese); et cetera), we remove the need to convert between encodings and improves the accessibility of multilingual forums.</p> - <p>The impact is that the language files for phpBB must now also be encoded as UTF-8, with a caveat that the files must <strong>not contain</strong> a <acronym title="Byte-Order-Mark">BOM</acronym> for compatibility reasons with non-Unicode aware versions of PHP. For those with forums using the Latin character set (ie: most European languages), this change is transparent since UTF-8 is superset to US-ASCII and ISO-8859-1.</p> + <p>The impact is that the language files for phpBB must now also be encoded as UTF-8, with a caveat that the files must <strong>not contain</strong> a <abbr title="Byte-Order-Mark">BOM</abbr> for compatibility reasons with non-Unicode aware versions of PHP. For those with forums using the Latin character set (ie: most European languages), this change is transparent since UTF-8 is superset to US-ASCII and ISO-8859-1.</p> <h4>Language Tag:</h4> @@ -1780,8 +1800,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>Most language tags consist of a two- or three-letter language subtag (from <a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO 639-1/ISO 639-2</a>). Sometimes, this is followed by a two-letter or three-digit region subtag (from <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a> or <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a>). Some examples are:</p> - <table summary="Examples of various possible language tags as described by RFC 4646 and RFC 4647"> - <caption>Language tag examples</caption> + <table> + <caption>Examples of various possible language tags as described by RFC 4646 and RFC 4647</caption> <thead> <tr> <th scope="col">Language tag</th> @@ -1832,8 +1852,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>Next is the <a href="http://www.unicode.org/iso15924/iso15924-codes.html">ISO 15924</a> language script code and when one should or shouldn't use it. For example, whilst <code>en-Latn</code> is syntaxically correct for describing English written with Latin script, real world English writing is <strong>more-or-less exclusively in the Latin script</strong>. For such languages like English that are written in a single script, the <a href="http://www.iana.org/assignments/language-subtag-registry"><abbr title="Internet Assigned Numbers Authority">IANA</abbr> Language Subtag Registry</a> has a "Suppress-Script" field meaning the script code <strong>should be ommitted</strong> unless a specific language tag requires a specific script code. Some languages are <strong>written in more than one script</strong> and in such cases, the script code <strong>is encouraged</strong> since an end-user may be able to read their language in one script, but not the other. Some examples are:</p> - <table summary="Examples of using a language subtag in combination with a script subtag"> - <caption>Language subtag + script subtag examples</caption> + <table> + <caption>Examples of using a language subtag in combination with a script subtag</caption> <thead> <tr> <th scope="col">Language tag</th> @@ -1899,8 +1919,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>Examples of English using marco-geographical regions:</p> - <table summary="Examples for English of ISO 3166-1 alpha-2 vs. UN M.49 code"> - <caption>Coding for English using macro-geographical regions</caption> + <table> + <caption>Coding for English using macro-geographical regions (examples for English of ISO 3166-1 alpha-2 vs. UN M.49 code)</caption> <thead> <tr> <th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th> @@ -1925,8 +1945,8 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>Examples of Spanish using marco-geographical regions:</p> - <table summary="Examples for Spanish of ISO 3166-1 alpha-2 vs. UN M.49 code"> - <caption>Coding for Spanish macro-geographical regions</caption> + <table> + <caption>Coding for Spanish macro-geographical regions (examples for Spanish of ISO 3166-1 alpha-2 vs. UN M.49 code)</caption> <thead> <tr> <th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th> @@ -1954,7 +1974,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>Example of where the <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a> is ambiguous and why <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a> might be preferred:</p> - <table summary="Example where the ISO 3166-1 alpha-2 is ambiguous"> + <table> <caption>Coding for ambiguous ISO 3166-1 alpha-2 regions</caption> <thead> <tr> @@ -2010,7 +2030,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p><a href="http://tools.ietf.org/html/rfc4646">RFC 4646</a> anticipates features which shall be available in (currently draft) <a href="http://www.sil.org/iso639-3/">ISO 639-3</a> which aims to provide as complete enumeration of languages as possible, including living, extinct, ancient and constructed languages, whether majour, minor or unwritten. A new feature of <a href="http://www.sil.org/iso639-3/">ISO 639-3</a> compared to the previous two revisions is the concept of <a href="http://www.sil.org/iso639-3/macrolanguages.asp">macrolanguages</a> where Arabic and Chinese are two such examples. In such cases, their respective codes of <code>ar</code> and <code>zh</code> is very vague as to which dialect/topolect is used or perhaps some terse classical variant which may be difficult for all but very educated users. For such macrolanguages, it is recommended that the sub-language tag is used as a suffix to the macrolanguage tag, eg:</p> - <table summary="Examples of macrolanguages used with sub-language subtags"> + <table> <caption>Macrolanguage subtag + sub-language subtag examples</caption> <thead> <tr> @@ -2054,7 +2074,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>For phpBB, the language tags are <strong>not</strong> used in their raw form and instead converted to all lower-case and have the hyphen <code>-</code> replaced with an underscore <code>_</code> where appropriate, with some examples below:</p> - <table summary="Normalisation of language tags for usage in phpBB"> + <table> <caption>Language tag normalisation examples</caption> <thead> <tr> @@ -2108,7 +2128,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>For the English language description, the language name is always first and any additional attributes required to describe the subtags within the language code are then listed in order separated with commas and enclosed within parentheses, eg:</p> - <table summary="English language description examples of iso.txt for usage in phpBB"> + <table> <caption>English language description examples for iso.txt</caption> <thead> <tr> @@ -2160,7 +2180,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>The various Unicode control characters for bi-directional text and their HTML enquivalents where appropriate are as follows:</p> - <table summary="Table of the various Unicode bidirectional control characters"> + <table> <caption>Unicode bidirectional control characters & HTML elements/entities</caption> <thead> <tr> @@ -2226,7 +2246,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <p>For <code>iso.txt</code>, the directionality of the text can be explicitly set using special Unicode characters via any of the three methods provided by left-to-right/right-to-left markers/embeds/overrides, as without them, the ordering of characters will be incorrect, eg:</p> - <table summary="Effect of using Unicode bidirectional control characters within iso.txt"> + <table> <caption>Unicode bidirectional control characters iso.txt</caption> <thead> <tr> @@ -2362,7 +2382,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <div class="codebox"><pre> ... -'FOO_BAR' => 'PHP version < 4.3.3.<br /> +'FOO_BAR' => 'PHP version < 5.3.2.<br /> Visit "Downloads" at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> @@ -2371,7 +2391,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <div class="codebox"><pre> ... -'FOO_BAR' => 'PHP version &lt; 4.3.3.<br /> +'FOO_BAR' => 'PHP version &lt; 5.3.2.<br /> Visit &quot;Downloads&quot; at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> @@ -2380,7 +2400,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <div class="codebox"><pre> ... -'FOO_BAR' => 'PHP version &lt; 4.3.3.<br /> +'FOO_BAR' => 'PHP version &lt; 5.3.2.<br /> Visit “Downloads” at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> @@ -2418,58 +2438,14 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <hr /> -<a name="vcs"></a><h2>7. VCS Guidelines</h2> - - <div class="paragraph"> - <div class="inner"><span class="corners-top"><span></span></span> - - <div class="content"> - - <p>The version control system for phpBB3 is git. The repository is available at <a href="http://github.com/phpbb/phpbb3" title="repository">http://github.com/phpbb/phpbb3</a>.</p> - - <a name="repostruct"></a><h3>7.i. Repository Structure</h3> - - <ul> - <li><strong>develop</strong><br />The latest unstable development version with new features etc.</li> - <li><strong>develop-*</strong><br />Development branches of stable phpBB releases. Branched off of <code>develop</code> at the time of feature freeze. - <ul> - <li><strong>phpBB3.0</strong><code>develop-olympus</code><br />Development branch of the stable 3.0 line. Bug fixes are applied here.</li> - <li><strong>phpBB3.1</strong><code>develop-ascraeus</code><br />Development branch of the stable 3.1 line. Bug fixes are applied here.</li> - </ul> - </li> - <li><strong>master</strong><br />A branch containing all stable phpBB3 release points</li> - <li><strong>tags</strong><br />Released versions. Stable ones get merged into the master branch. - <ul> - <li><code>release-3.Y-BX</code><br />Beta release X of the 3.Y line.</li> - <li><code>release-3.Y-RCX</code><br />Release candidate X of the 3.Y line.</li> - <li><code>release-3.Y.Z-RCX</code><br />Release candidate X of the stable 3.Y.Z release.</li> - <li><code>release-3.0.X</code><br />Stable <strong>3.0.X</strong> release.</li> - <li><code>release-2.0.X</code><br />Old stable 2.0.X release.</li> - </ul> - </li> - </ul> - - <a name="commitmessage"></a><h3>7.ii. Commit Messages and Repository Rules</h3> - - <p>Information on repository rules, such as commit messages can be found at <a href="http://wiki.phpbb.com/display/DEV/Git" title="phpBB Git Information">http://wiki.phpbb.com/display/DEV/Git</a>.</p> - - </div> - - <div class="back2top"><a href="#wrap" class="top">Back to Top</a></div> - - <span class="corners-bottom"><span></span></span></div> - </div> - - <hr /> - -<a name="disclaimer"></a><h2>9. Copyright and disclaimer</h2> +<a name="disclaimer"></a><h2>8. Copyright and disclaimer</h2> <div class="paragraph"> <div class="inner"><span class="corners-top"><span></span></span> <div class="content"> - <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-license.php">GPL</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p> + <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-2.0.php">GNU General Public License v2</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p> </div> |