diff options
Diffstat (limited to 'phpBB/docs/coding-guidelines.html')
-rw-r--r-- | phpBB/docs/coding-guidelines.html | 310 |
1 files changed, 243 insertions, 67 deletions
diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index f3d161589b..6cd2627f43 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> @@ -62,11 +55,12 @@ </li> <li><a href="#code">Code Layout/Guidelines</a> <ol style="list-style-type: lower-roman;"> - <li><a href="#namingvars">Variable/Function Naming</a></li> + <li><a href="#namingvars">Variable/Function/Class Naming</a></li> <li><a href="#codelayout">Code Layout</a></li> <li><a href="#sql">SQL/SQL Layout</a></li> <li><a href="#optimizing">Optimizations</a></li> <li><a href="#general">General Guidelines</a></li> + <li><a href="#phprestrictions">Restrictions on the Use of PHP</a></li> </ol> </li> <li><a href="#styling">Styling</a> @@ -77,7 +71,8 @@ <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> + <li><a href="#template-events">Template Events</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> @@ -120,7 +115,7 @@ <h3>Linefeeds:</h3> <p>Ensure that your editor is saving files in the UNIX (LF) line ending format. This means that lines are terminated with a newline, not with Windows Line endings (CR/LF combo) as they are on Win32 or Classic Mac (CR) Line endings. Any decent editor should be able to do this, but it might not always be the default setting. Know your editor. If you want advice for an editor for your Operating System, just ask one of the developers. Some of them do their editing on Win32.</p> - <a name="fileheader"></a><h3>1.ii. File Header</h3> + <a name="fileheader"></a><h3>1.ii. File Layout</h3> <h4>Standard header for new files:</h4> <p>This template of the header must be included at the start of all phpBB files: </p> @@ -137,6 +132,14 @@ <p>Please see the <a href="#locations">File Locations section</a> for the correct package name.</p> + <h4>PHP closing tags</h4> + + <p>A file containg only PHP code should not end with the optional PHP closing tag <strong>?></strong> to avoid issues with whitespace following it.</p> + + <h4>Newline at end of file</h4> + + <p>All files should end in a newline so the last line does not appear as modified in diffs, when a line is appended to the file.</p> + <h4>Files containing inline code:</h4> <p>For those files you have to put an empty comment directly after the header to prevent the documentor assigning the header to the first code element found.</p> @@ -187,7 +190,7 @@ class ... <ul> <li><strong>phpBB3</strong><br />Core files and all files not assigned to a separate package</li> - <li><strong>acm</strong><br /><code>/includes/acm</code>, <code>/includes/cache.php</code><br />Cache System</li> + <li><strong>acm</strong><br /><code>/includes/cache</code><br />Cache System</li> <li><strong>acp</strong><br /><code>/adm</code>, <code>/includes/acp</code>, <code>/includes/functions_admin.php</code><br />Administration Control Panel</li> <li><strong>dbal</strong><br /><code>/includes/db</code><br />Database Abstraction Layer.<br />Base class is <code>dbal</code> <ul> @@ -246,13 +249,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> @@ -287,16 +291,22 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c <p>Please note that these guidelines apply to all php, html, javascript and css files.</p> - <a name="namingvars"></a><h3>2.i. Variable/Function Naming</h3> + <a name="namingvars"></a><h3>2.i. Variable/Function/Class Naming</h3> <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> @@ -314,16 +324,46 @@ 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> + <h4>Class Names:</h4> + + <p>Apart from following the rules for function names, all classes should meet the following conditions:</p> + <ul> + <li>Every class must be defined in a separate file.</li> + <li>The classes have to be located in a subdirectory of <code>includes/</code>.</li> + <li>Classnames to be prefixed with <code>phpbb_</code> to avoid name clashes, the filename should not contain the prefix.</li> + <li>Class names have to reflect the location of the file they are defined in. The longest list of prefixes, separated by underscores, which is a valid path must be the directory in which the file is located. So the directory names must not contain any underscores, but the filename may. If the filename would be empty the last directory name is used for the filename as well.</li> + <li>Directories should typically be a singular noun (e.g. <code>dir</code> in the example below, not <code>dirs</code>.</li> + </ul> + + <p>So given the following example directory structure you would result in the below listed lookups</p> + <div class="codebox"><pre> +includes/ + class_name.php + dir/ + class_name.php + dir.php + subdir/ + class_name.php + </pre></div> + + <div class="codebox"><pre> +phpbb_class_name - includes/class_name.php +phpbb_dir_class_name - includes/dir/class_name.php +phpbb_dir - includes/dir/dir.php +phpbb_dir_subdir_class_name - includes/dir/subdir/class_name.php + </pre></div> + + <h4>Summary:</h4> <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> @@ -364,7 +404,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) @@ -394,6 +434,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> @@ -468,6 +532,26 @@ $post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&amp;start=$start"; <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. 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> +$foo = array( + 'bar' => 42, + 'boo' => 23 +); + </pre></div> + + <p class="good">// right </p> + <div class="codebox"><pre> +$foo = array( + 'bar' => 42, + 'boo' => 23, +); + </pre></div> + + <h4>Associative array keys:</h4> <p>In PHP, it's legal to use a literal string as a key to an associative array without quoting that string. We don't want to do this -- the string should always be quoted to avoid confusion. Note that this is only when we're using a literal, not when we're using a variable, examples:</p> @@ -634,10 +718,30 @@ switch ($mode) } </pre></div> + <h4>Class Members</h4> + <p>Use the explicit visibility qualifiers <code>public</code>, <code>private</code> and <code>protected</code> for all properties instead of <code>var</code>. + + <p>Place the <code>static</code> qualifier before the visibility qualifiers.</p> + + <p class="bad">//Wrong </p> + <div class="codebox"><pre> +var $x; +private static function f() + </pre></div> + + <p class="good">// Right </p> + <div class="codebox"><pre> +public $x; +static private function f() + </pre></div> + + <h4>Constants</h4> + <p>Prefer class constants over global constants created with <code>define()</code>.</p> + <a name="sql"></a><h3>2.iii. SQL/SQL Layout</h3> <h4>Common SQL Guidelines: </h4> - <p>All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (7.0+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).</p> + <p>All SQL should be cross-DB compatible, if DB specific SQL is used alternatives must be provided which work on all supported DB's (MySQL3/4/5, MSSQL (7.0 and 2000), PostgreSQL (8.3+), Firebird, SQLite, Oracle8, ODBC (generalised if possible)).</p> <p>All SQL commands should utilise the DataBase Abstraction Layer (DBAL)</p> <h4>SQL code layout:</h4> @@ -1042,6 +1146,22 @@ append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=group&amp; <p>Your page should either call <code>page_footer()</code> in the end to trigger output through the template engine and terminate the script, or alternatively at least call the <code>exit_handler()</code>. That call is necessary because it provides a method for external applications embedding phpBB to be called at the end of the script.</p> + <a name="phprestrictions"></a><h3>2.vi. Restrictions on the Use of PHP</h3> + + <h4>Dynamic code execution:</h4> + + <p>Never execute dynamic PHP code (generated or in a constant string) using any of the following PHP functions:</p> + + <ul> + <li><strong>eval</strong></li> + <li><strong>create_function</strong></li> + <li><strong>preg_replace</strong> with the <strong>e</strong> modifier in the pattern</li> + </ul> + + <p>If absolutely necessary a file should be created, and a mechanism for creating this file prior to running phpBB should be provided as a setup process.</p> + + <p>The <strong>e</strong> modifier in <strong>preg_replace</strong> can be replaced by <strong>preg_replace_callback</strong> and objects to encapsulate state that is needed in the callback code.</p> + </div> <div class="back2top"><a href="#wrap" class="top">Back to Top</a></div> @@ -1057,15 +1177,19 @@ 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 indentation and coding guidelines also apply to templates where possible.</p> @@ -1088,7 +1212,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 on.</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> @@ -1156,13 +1280,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> @@ -1194,7 +1318,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="https://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> @@ -1265,7 +1389,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> @@ -1536,26 +1660,78 @@ div </form> </pre></div><br /> - <a name="inheritance"></a><h3>4.ii. Template Inheritance</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>inherit_from</strong> field in the template configuration file, the style can be set to inherit template files from the base style. The limitation on this is that the base style has to be installed and complete, meaning that it is not itself inheriting.</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 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 base style otherwise. Declaring a style to inherit from another also causes it to use some of the configuration settings of the base style, notably database storage.</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>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> + <a name="template-events"></a><h3>4.iii. Template Events</h3> + <p>Template events must follow this format: <code><!-- EVENT event_name --></code></p> + <p>Using the above example, files named <code>event_name.html</code> located within extensions will be injected into the location of the event.</p> + + <h4>Template event naming guidelines:</h4> + <ul> + <li>An event name must be all lowercase, with each word separated by an underscore.</li> + <li>An event name must briefly describe the location and purpose of the event.</li> + <li>An event name must end with one of the following suffixes:</li> + <ul> + <li><code>_prepend</code> - This event adds an item to the beginning of a block of related items, or adds to the beginning of individual items in a block.</li> + <li><code>_append</code> - This event adds an item to the end of a block of related items, or adds to the end of individual items in a block.</li> + <li><code>_before</code> - This event adds content directly before the specified block</li> + <li><code>_after</code> - This event adds content directly after the specified block</li> + </ul> + </ul> + + <h4>Template event documentation</h4> + <p>Events must be documented in <code>phpBB/docs/events.md</code> in alphabetical order based on the event name. The format is as follows:</p> + + <ul><li>An event found in only one template file: + <div class="codebox"><pre>event_name +=== +* Location: styles/<style_name>/template/filename.html +* Purpose: A brief description of what this event should be used for. +This may span multiple lines. +</pre></div></li> + <li>An event found in multiple template files: + <div class="codebox"><pre>event_name +=== +* Locations: + + first/file/path.html + + second/file/path.html +* Purpose: Same as above. +</pre></div> + <li>An event that is found multiple times in a file should have the number of instances in parenthesis next to the filename. + <div class="codebox"><pre>event_name +=== +* Locations: + + first/file/path.html (2) + + second/file/path.html +* Purpose: Same as above. +</pre></div></li> + <li>An actual example event documentation: + <div class="codebox"><pre>forumlist_body_last_post_title_prepend +==== +* Locations: + + styles/prosilver/template/forumlist_body.html + + styles/subsilver2/template/forumlist_body.html +* Purpose: Add content before the post title of the latest post in a forum on the forum list.</pre></div></ul><br /> + </div> <div class="back2top"><a href="#wrap" class="top">Back to Top</a></div> @@ -1668,7 +1844,7 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2)) <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> @@ -1678,8 +1854,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> @@ -1730,8 +1906,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> @@ -1797,8 +1973,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> @@ -1823,8 +1999,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> @@ -1852,7 +2028,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> @@ -1908,7 +2084,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> @@ -1952,7 +2128,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> @@ -2006,7 +2182,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> @@ -2058,7 +2234,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> @@ -2124,7 +2300,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> @@ -2260,7 +2436,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.3.<br /> Visit "Downloads" at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> @@ -2269,7 +2445,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.3.<br /> Visit &quot;Downloads&quot; at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> @@ -2278,7 +2454,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.3.<br /> Visit “Downloads” at <a href="http://www.php.net/">www.php.net</a>.', ... </pre></div> |