docs/coding-guidelines.html
author indvdum (gotoindvdum[at]gmail[dot]com)
Sat, 10 Mar 2012 00:53:57 +0400
changeset 17 049ab39a9b9c
parent 0 ceef6d64c21d
permissions -rw-r--r--
Show gamers online everywhere
indvdum@0
     1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
indvdum@0
     2
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en" xml:lang="en">
indvdum@0
     3
<head>
indvdum@0
     4
indvdum@0
     5
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
indvdum@0
     6
<meta http-equiv="content-style-type" content="text/css" />
indvdum@0
     7
<meta http-equiv="content-language" content="en" />
indvdum@0
     8
<meta http-equiv="imagetoolbar" content="no" />
indvdum@0
     9
<meta name="resource-type" content="document" />
indvdum@0
    10
<meta name="distribution" content="global" />
indvdum@0
    11
<meta name="copyright" content="phpBB Group" />
indvdum@0
    12
<meta name="keywords" content="" />
indvdum@0
    13
<meta name="description" content="Olympus coding guidelines document" />
indvdum@0
    14
<title>phpBB3 &bull; Coding Guidelines</title>
indvdum@0
    15
indvdum@0
    16
<link href="stylesheet.css" rel="stylesheet" type="text/css" media="screen, projection" />
indvdum@0
    17
indvdum@0
    18
</head>
indvdum@0
    19
indvdum@0
    20
<body id="phpbb" class="section-docs">
indvdum@0
    21
indvdum@0
    22
<div id="wrap">
indvdum@0
    23
	<a id="top" name="top" accesskey="t"></a>
indvdum@0
    24
	<div id="page-header">
indvdum@0
    25
		<div class="headerbar">
indvdum@0
    26
			<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
    27
indvdum@0
    28
			<div id="doc-description">
indvdum@0
    29
				<a href="../index.php" id="logo"><img src="site_logo.gif" alt="" /></a>
indvdum@0
    30
				<h1>Coding Guidelines</h1>
indvdum@0
    31
				<p>Olympus coding guidelines document</p>
indvdum@0
    32
				<p style="display: none;"><a href="#start_here">Skip</a></p>
indvdum@0
    33
			</div>
indvdum@0
    34
indvdum@0
    35
			<span class="corners-bottom"><span></span></span></div>
indvdum@0
    36
		</div>
indvdum@0
    37
	</div>
indvdum@0
    38
indvdum@0
    39
	<a name="start_here"></a>
indvdum@0
    40
indvdum@0
    41
	<div id="page-body">
indvdum@0
    42
indvdum@0
    43
<!-- BEGIN DOCUMENT -->
indvdum@0
    44
indvdum@0
    45
<p>These are the phpBB Coding Guidelines for Olympus, all attempts should be made to follow them as closely as possible.</p>
indvdum@0
    46
indvdum@0
    47
<h1>Coding Guidelines</h1>
indvdum@0
    48
indvdum@0
    49
	<div class="paragraph menu">
indvdum@0
    50
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
    51
indvdum@0
    52
		<div class="content">
indvdum@0
    53
indvdum@0
    54
<ol>
indvdum@0
    55
	<li><a href="#defaults">Defaults</a>
indvdum@0
    56
	<ol style="list-style-type: lower-roman;">
indvdum@0
    57
		<li><a href="#editorsettings">Editor Settings</a></li>
indvdum@0
    58
		<li><a href="#fileheader">File Header</a></li>
indvdum@0
    59
		<li><a href="#locations">File Locations</a></li>
indvdum@0
    60
		<li><a href="#constants">Special Constants</a></li>
indvdum@0
    61
	</ol>
indvdum@0
    62
	</li>
indvdum@0
    63
	<li><a href="#code">Code Layout/Guidelines</a>
indvdum@0
    64
	<ol style="list-style-type: lower-roman;">
indvdum@0
    65
		<li><a href="#namingvars">Variable/Function Naming</a></li>
indvdum@0
    66
		<li><a href="#codelayout">Code Layout</a></li>
indvdum@0
    67
		<li><a href="#sql">SQL/SQL Layout</a></li>
indvdum@0
    68
		<li><a href="#optimizing">Optimizations</a></li>
indvdum@0
    69
		<li><a href="#general">General Guidelines</a></li>
indvdum@0
    70
	</ol>
indvdum@0
    71
	</li>
indvdum@0
    72
	<li><a href="#styling">Styling</a>
indvdum@0
    73
	<ol style="list-style-type: lower-roman;">
indvdum@0
    74
		<li><a href="#cfgfiles">Style Config Files</a></li>
indvdum@0
    75
		<li><a href="#genstyling">General Styling Rules</a></li>
indvdum@0
    76
	</ol></li>
indvdum@0
    77
	<li><a href="#templating">Templating</a>
indvdum@0
    78
	<ol style="list-style-type: lower-roman;">
indvdum@0
    79
		<li><a href="#templates">General Templating</a></li>
indvdum@0
    80
		<li><a href="#inheritance">Template Inheritance</a></li>
indvdum@0
    81
	</ol></li>
indvdum@0
    82
	<li><a href="#charsets">Character Sets and Encodings</a></li>
indvdum@0
    83
	<li><a href="#translation">Translation (<abbr title="Internationalisation">i18n</abbr>/<abbr title="Localisation">L10n</abbr>) Guidelines</a>
indvdum@0
    84
	<ol style="list-style-type: lower-roman;">
indvdum@0
    85
		<li><a href="#standardisation">Standardisation</a></li>
indvdum@0
    86
		<li><a href="#otherconsiderations">Other considerations</a></li>
indvdum@0
    87
		<li><a href="#writingstyle">Writing Style</a></li>
indvdum@0
    88
	</ol>
indvdum@0
    89
	</li>
indvdum@0
    90
	<li><a href="#disclaimer">Copyright and disclaimer</a></li>
indvdum@0
    91
</ol>
indvdum@0
    92
indvdum@0
    93
		</div>
indvdum@0
    94
indvdum@0
    95
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
    96
	</div>
indvdum@0
    97
indvdum@0
    98
	<hr />
indvdum@0
    99
indvdum@0
   100
<a name="defaults"></a><h2>1. Defaults</h2>
indvdum@0
   101
indvdum@0
   102
	<div class="paragraph">
indvdum@0
   103
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
   104
indvdum@0
   105
		<div class="content">
indvdum@0
   106
indvdum@0
   107
<a name="editorsettings"></a><h3>1.i. Editor Settings</h3>
indvdum@0
   108
indvdum@0
   109
	<h4>Tabs vs Spaces:</h4>
indvdum@0
   110
	<p>In order to make this as simple as possible, we will be using tabs, not spaces. We enforce 4 (four) spaces for one tab - therefore you need to set your tab width within your editor to 4 spaces. Make sure that when you <strong>save</strong> the file, it's saving tabs and not spaces. This way, we can each have the code be displayed the way we like it, without breaking the layout of the actual files.</p>
indvdum@0
   111
	<p>Tabs in front of lines are no problem, but having them within the text can be a problem if you do not set it to the amount of spaces every one of us uses. Here is a short example of how it should look like:</p>
indvdum@0
   112
indvdum@0
   113
	<div class="codebox"><pre>
indvdum@0
   114
{TAB}$mode{TAB}{TAB}= request_var('mode', '');
indvdum@0
   115
{TAB}$search_id{TAB}= request_var('search_id', '');
indvdum@0
   116
	</pre></div>
indvdum@0
   117
indvdum@0
   118
	<p>If entered with tabs (replace the {TAB}) both equal signs need to be on the same column.</p>
indvdum@0
   119
indvdum@0
   120
	<h3>Linefeeds:</h3>
indvdum@0
   121
	<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>
indvdum@0
   122
indvdum@0
   123
	<a name="fileheader"></a><h3>1.ii. File Header</h3>
indvdum@0
   124
indvdum@0
   125
	<h4>Standard header for new files:</h4>
indvdum@0
   126
	<p>This template of the header must be included at the start of all phpBB files: </p>
indvdum@0
   127
indvdum@0
   128
	<div class="codebox"><pre>
indvdum@0
   129
/**
indvdum@0
   130
*
indvdum@0
   131
* @package {PACKAGENAME}
indvdum@0
   132
* @version &#36;Id: &#36;
indvdum@0
   133
* @copyright (c) 2007 phpBB Group
indvdum@0
   134
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
indvdum@0
   135
*
indvdum@0
   136
*/
indvdum@0
   137
	</pre></div>
indvdum@0
   138
indvdum@0
   139
	<p>Please see the <a href="#locations">File Locations section</a> for the correct package name.</p>
indvdum@0
   140
indvdum@0
   141
	<h4>Files containing inline code:</h4>
indvdum@0
   142
indvdum@0
   143
	<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>
indvdum@0
   144
indvdum@0
   145
	<div class="codebox"><pre>
indvdum@0
   146
/**
indvdum@0
   147
* {HEADER}
indvdum@0
   148
*/
indvdum@0
   149
indvdum@0
   150
/**
indvdum@0
   151
*/
indvdum@0
   152
{CODE}
indvdum@0
   153
	</pre></div>
indvdum@0
   154
indvdum@0
   155
	<h4>Files containing only functions:</h4>
indvdum@0
   156
indvdum@0
   157
	<p>Do not forget to comment the functions (especially the first function following the header). Each function should have at least a comment of what this function does. For more complex functions it is recommended to document the parameters too.</p>
indvdum@0
   158
indvdum@0
   159
	<h4>Files containing only classes:</h4>
indvdum@0
   160
indvdum@0
   161
	<p>Do not forget to comment the class. Classes need a separate @package definition, it is the same as the header package name. Apart from this special case the above statement for files containing only functions needs to be applied to classes and it's methods too.</p>
indvdum@0
   162
indvdum@0
   163
	<h4>Code following the header but only functions/classes file:</h4>
indvdum@0
   164
indvdum@0
   165
	<p>If this case is true, the best method to avoid documentation confusions is adding an ignore command, for example:</p>
indvdum@0
   166
indvdum@0
   167
	<div class="codebox"><pre>
indvdum@0
   168
/**
indvdum@0
   169
* {HEADER}
indvdum@0
   170
*/
indvdum@0
   171
indvdum@0
   172
/**
indvdum@0
   173
* @ignore
indvdum@0
   174
*/
indvdum@0
   175
Small code snipped, mostly one or two defines or an if statement
indvdum@0
   176
indvdum@0
   177
/**
indvdum@0
   178
* {DOCUMENTATION}
indvdum@0
   179
*/
indvdum@0
   180
class ...
indvdum@0
   181
	</pre></div>
indvdum@0
   182
indvdum@0
   183
	<a name="locations"></a><h3>1.iii. File Locations</h3>
indvdum@0
   184
indvdum@0
   185
	<p>Functions used by more than one page should be placed in functions.php, functions specific to one page should be placed on that page (at the bottom) or within the relevant sections functions file. Some files in <code>/includes</code> are holding functions responsible for special sections, for example uploading files, displaying &quot;things&quot;, user related functions and so forth.</p>
indvdum@0
   186
indvdum@0
   187
	<p>The following packages are defined, and related new features/functions should be placed within the mentioned files/locations, as well as specifying the correct package name. The package names are bold within this list:</p>
indvdum@0
   188
indvdum@0
   189
	<ul>
indvdum@0
   190
		<li><strong>phpBB3</strong><br />Core files and all files not assigned to a separate package</li>
indvdum@0
   191
		<li><strong>acm</strong><br /><code>/includes/acm</code>, <code>/includes/cache.php</code><br />Cache System</li>
indvdum@0
   192
		<li><strong>acp</strong><br /><code>/adm</code>, <code>/includes/acp</code>, <code>/includes/functions_admin.php</code><br />Administration Control Panel</li>
indvdum@0
   193
		<li><strong>dbal</strong><br /><code>/includes/db</code><br />Database Abstraction Layer.<br />Base class is <code>dbal</code>
indvdum@0
   194
			<ul>
indvdum@0
   195
				<li><code>/includes/db/dbal.php</code><br />Base DBAL class, defining the overall framework</li>
indvdum@0
   196
				<li><code>/includes/db/firebird.php</code><br />Firebird/Interbase Database Abstraction Layer</li>
indvdum@0
   197
				<li><code>/includes/db/msssql.php</code><br />MSSQL Database Abstraction Layer</li>
indvdum@0
   198
				<li><code>/includes/db/mssql_odbc.php</code><br />MSSQL ODBC Database Abstraction Layer for MSSQL</li>
indvdum@0
   199
				<li><code>/includes/db/mysql.php</code><br />MySQL Database Abstraction Layer for MySQL 3.x/4.0.x/4.1.x/5.x</li>
indvdum@0
   200
				<li><code>/includes/db/mysqli.php</code><br />MySQLi Database Abstraction Layer</li>
indvdum@0
   201
				<li><code>/includes/db/oracle.php</code><br />Oracle Database Abstraction Layer</li>
indvdum@0
   202
				<li><code>/includes/db/postgres.php</code><br />PostgreSQL Database Abstraction Layer</li>
indvdum@0
   203
				<li><code>/includes/db/sqlite.php</code><br />Sqlite Database Abstraction Layer</li>
indvdum@0
   204
			</ul>
indvdum@0
   205
		</li>
indvdum@0
   206
		<li><strong>diff</strong><br /><code>/includes/diff</code><br />Diff Engine</li>
indvdum@0
   207
		<li><strong>docs</strong><br /><code>/docs</code><br />phpBB Documentation</li>
indvdum@0
   208
		<li><strong>images</strong><br /><code>/images</code><br />All global images not connected to styles</li>
indvdum@0
   209
		<li><strong>install</strong><br /><code>/install</code><br />Installation System</li>
indvdum@0
   210
		<li><strong>language</strong><br /><code>/language</code><br />All language files</li>
indvdum@0
   211
		<li><strong>login</strong><br /><code>/includes/auth</code><br />Login Authentication Plugins</li>
indvdum@0
   212
		<li><strong>VC</strong><br /><code>/includes/captcha</code><br />CAPTCHA</li>
indvdum@0
   213
		<li><strong>mcp</strong><br /><code>mcp.php</code>, <code>/includes/mcp</code>, <code>report.php</code><br />Moderator Control Panel</li>
indvdum@0
   214
		<li><strong>ucp</strong><br /><code>ucp.php</code>, <code>/includes/ucp</code><br />User Control Panel</li>
indvdum@0
   215
		<li><strong>utf</strong><br /><code>/includes/utf</code><br />UTF8-related functions/classes</li>
indvdum@0
   216
		<li><strong>search</strong><br /><code>/includes/search</code>, <code>search.php</code><br />Search System</li>
indvdum@0
   217
		<li><strong>styles</strong><br /><code>/styles</code>, <code>style.php</code><br />phpBB Styles/Templates/Themes/Imagesets</li>
indvdum@0
   218
	</ul>
indvdum@0
   219
indvdum@0
   220
	<a name="constants"></a><h3>1.iv. Special Constants</h3>
indvdum@0
   221
indvdum@0
   222
	<p>There are some special constants application developers are able to utilize to bend some of phpBB's internal functionality to suit their needs.</p>
indvdum@0
   223
indvdum@0
   224
	<div class="codebox"><pre>
indvdum@0
   225
PHPBB_MSG_HANDLER          (overwrite message handler)
indvdum@0
   226
PHPBB_DB_NEW_LINK          (overwrite new_link parameter for sql_connect)
indvdum@0
   227
PHPBB_ROOT_PATH            (overwrite $phpbb_root_path)
indvdum@0
   228
PHPBB_ADMIN_PATH           (overwrite $phpbb_admin_path)
indvdum@0
   229
PHPBB_USE_BOARD_URL_PATH   (use generate_board_url() for image paths instead of $phpbb_root_path)
indvdum@0
   230
PHPBB_DISABLE_ACP_EDITOR   (disable ACP style editor for templates)
indvdum@0
   231
PHPBB_DISABLE_CONFIG_CHECK (disable ACP config.php writeable check)
indvdum@0
   232
indvdum@0
   233
PHPBB_ACM_MEMCACHE_PORT     (overwrite memcached port, default is 11211)
indvdum@0
   234
PHPBB_ACM_MEMCACHE_COMPRESS (overwrite memcached compress setting, default is disabled)
indvdum@0
   235
PHPBB_ACM_MEMCACHE_HOST     (overwrite memcached host name, default is localhost)
indvdum@0
   236
indvdum@0
   237
PHPBB_ACM_REDIS_HOST        (overwrite redis host name, default is localhost)
indvdum@0
   238
PHPBB_ACM_REDIS_PORT        (overwrite redis port, default is 6379)
indvdum@0
   239
PHPBB_ACM_REDIS_PASSWORD    (overwrite redis password, default is empty)
indvdum@0
   240
PHPBB_ACM_REDIS_DB          (overwrite redis default database)
indvdum@0
   241
indvdum@0
   242
PHPBB_QA                   (Set board to QA-Mode, which means the updater also checks for RC-releases)
indvdum@0
   243
</pre></div>
indvdum@0
   244
indvdum@0
   245
<h4>PHPBB_USE_BOARD_URL_PATH</h4>
indvdum@0
   246
indvdum@0
   247
<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>
indvdum@0
   248
indvdum@0
   249
<ul>
indvdum@0
   250
	<li>/includes/session.php - user::img()</li>
indvdum@0
   251
	<li>/includes/functions_content.php - smiley_text()</li>
indvdum@0
   252
</ul>
indvdum@0
   253
indvdum@0
   254
<p>Path locations for the following template variables are affected by this too:</p>
indvdum@0
   255
indvdum@0
   256
<ul>
indvdum@0
   257
	<li>{T_THEME_PATH} - styles/xxx/theme</li>
indvdum@0
   258
	<li>{T_TEMPLATE_PATH} - styles/xxx/template</li>
indvdum@0
   259
	<li>{T_SUPER_TEMPLATE_PATH} - styles/xxx/template</li>
indvdum@0
   260
	<li>{T_IMAGESET_PATH} - styles/xxx/imageset</li>
indvdum@0
   261
	<li>{T_IMAGESET_LANG_PATH} - styles/xxx/imageset/yy</li>
indvdum@0
   262
	<li>{T_IMAGES_PATH} - images/</li>
indvdum@0
   263
	<li>{T_SMILIES_PATH} - $config['smilies_path']/</li>
indvdum@0
   264
	<li>{T_AVATAR_PATH} - $config['avatar_path']/</li>
indvdum@0
   265
	<li>{T_AVATAR_GALLERY_PATH} - $config['avatar_gallery_path']/</li>
indvdum@0
   266
	<li>{T_ICONS_PATH} - $config['icons_path']/</li>
indvdum@0
   267
	<li>{T_RANKS_PATH} - $config['ranks_path']/</li>
indvdum@0
   268
	<li>{T_UPLOAD_PATH} - $config['upload_path']/</li>
indvdum@0
   269
	<li>{T_STYLESHEET_LINK} - styles/xxx/theme/stylesheet.css (or link to style.php if css is parsed dynamically)</li>
indvdum@0
   270
	<li>New template variable {BOARD_URL} for the board url + script path.</li>
indvdum@0
   271
</ul>
indvdum@0
   272
indvdum@0
   273
		</div>
indvdum@0
   274
indvdum@0
   275
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
   276
indvdum@0
   277
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
   278
	</div>
indvdum@0
   279
indvdum@0
   280
	<hr />
indvdum@0
   281
indvdum@0
   282
<a name="code"></a><h2>2. Code Layout/Guidelines</h2>
indvdum@0
   283
indvdum@0
   284
	<div class="paragraph">
indvdum@0
   285
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
   286
indvdum@0
   287
		<div class="content">
indvdum@0
   288
indvdum@0
   289
	<p>Please note that these guidelines apply to all php, html, javascript and css files.</p>
indvdum@0
   290
indvdum@0
   291
	<a name="namingvars"></a><h3>2.i. Variable/Function Naming</h3>
indvdum@0
   292
indvdum@0
   293
	<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>
indvdum@0
   294
indvdum@0
   295
	<h4>Variable Names:</h4>
indvdum@0
   296
	<p>Variable names should be in all lowercase, with words separated by an underscore, example:</p>
indvdum@0
   297
indvdum@0
   298
	<div class="indent">
indvdum@0
   299
		<p><code>$current_user</code> is right, but <code>$currentuser</code> and <code> $currentUser</code> are not.</p>
indvdum@0
   300
	</div>
indvdum@0
   301
indvdum@0
   302
	<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>
indvdum@0
   303
indvdum@0
   304
	<h4>Loop Indices:</h4>
indvdum@0
   305
	<p>The <em>only</em> situation where a one-character variable name is allowed is when it's the index for some looping construct. In this case, the index of the outer loop should always be $i. If there's a loop inside that loop, its index should be $j, followed by $k, and so on. If the loop is being indexed by some already-existing variable with a meaningful name, this guideline does not apply, example:</p>
indvdum@0
   306
indvdum@0
   307
	<div class="codebox"><pre>
indvdum@0
   308
for ($i = 0; $i &lt; $outer_size; $i++)
indvdum@0
   309
{
indvdum@0
   310
   for ($j = 0; $j &lt; $inner_size; $j++)
indvdum@0
   311
   {
indvdum@0
   312
      foo($i, $j);
indvdum@0
   313
   }
indvdum@0
   314
}
indvdum@0
   315
	</pre></div>
indvdum@0
   316
indvdum@0
   317
	<h4>Function Names:</h4>
indvdum@0
   318
	<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>
indvdum@0
   319
indvdum@0
   320
	<h4>Function Arguments:</h4>
indvdum@0
   321
	<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>
indvdum@0
   322
indvdum@0
   323
	<h4>Summary:</h4>
indvdum@0
   324
	<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>
indvdum@0
   325
indvdum@0
   326
	<h4>Special Namings: </h4>
indvdum@0
   327
	<p>For all emoticons use the term <code>smiley</code> in singular and <code>smilies</code> in plural.</p>
indvdum@0
   328
indvdum@0
   329
	<a name="codelayout"></a><h3>2.ii. Code Layout</h3>
indvdum@0
   330
indvdum@0
   331
	<h4>Always include the braces:</h4>
indvdum@0
   332
	<p>This is another case of being too lazy to type 2 extra characters causing problems with code clarity. Even if the body of some construct is only one line long, do <em>not</em> drop the braces. Just don't, examples:</p>
indvdum@0
   333
indvdum@0
   334
	<p class="bad">// These are all wrong. </p>
indvdum@0
   335
indvdum@0
   336
	<div class="codebox"><pre>
indvdum@0
   337
if (condition) do_stuff();
indvdum@0
   338
indvdum@0
   339
if (condition)
indvdum@0
   340
	do_stuff();
indvdum@0
   341
indvdum@0
   342
while (condition)
indvdum@0
   343
	do_stuff();
indvdum@0
   344
indvdum@0
   345
for ($i = 0; $i &lt; size; $i++)
indvdum@0
   346
	do_stuff($i);
indvdum@0
   347
	</pre></div>
indvdum@0
   348
indvdum@0
   349
	<p class="good">// These are all right. </p>
indvdum@0
   350
	<div class="codebox"><pre>
indvdum@0
   351
if (condition)
indvdum@0
   352
{
indvdum@0
   353
	do_stuff();
indvdum@0
   354
}
indvdum@0
   355
indvdum@0
   356
while (condition)
indvdum@0
   357
{
indvdum@0
   358
	do_stuff();
indvdum@0
   359
}
indvdum@0
   360
indvdum@0
   361
for ($i = 0; $i &lt; size; $i++)
indvdum@0
   362
{
indvdum@0
   363
	do_stuff();
indvdum@0
   364
}
indvdum@0
   365
	</pre></div>
indvdum@0
   366
indvdum@0
   367
	<h4>Where to put the braces:</h4>
indvdum@0
   368
	<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>
indvdum@0
   369
indvdum@0
   370
	<div class="codebox"><pre>
indvdum@0
   371
if (condition)
indvdum@0
   372
{
indvdum@0
   373
	while (condition2)
indvdum@0
   374
	{
indvdum@0
   375
		...
indvdum@0
   376
	}
indvdum@0
   377
}
indvdum@0
   378
else
indvdum@0
   379
{
indvdum@0
   380
	...
indvdum@0
   381
}
indvdum@0
   382
indvdum@0
   383
for ($i = 0; $i &lt; $size; $i++)
indvdum@0
   384
{
indvdum@0
   385
	...
indvdum@0
   386
}
indvdum@0
   387
indvdum@0
   388
while (condition)
indvdum@0
   389
{
indvdum@0
   390
	...
indvdum@0
   391
}
indvdum@0
   392
indvdum@0
   393
function do_stuff()
indvdum@0
   394
{
indvdum@0
   395
	...
indvdum@0
   396
}
indvdum@0
   397
	</pre></div>
indvdum@0
   398
indvdum@0
   399
	<h4>Use spaces between tokens:</h4>
indvdum@0
   400
	<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>
indvdum@0
   401
indvdum@0
   402
	<p>// Each pair shows the wrong way followed by the right way. </p>
indvdum@0
   403
indvdum@0
   404
	<div class="codebox"><pre>
indvdum@0
   405
$i=0;
indvdum@0
   406
$i = 0;
indvdum@0
   407
indvdum@0
   408
if($i&lt;7) ...
indvdum@0
   409
if ($i &lt; 7) ...
indvdum@0
   410
indvdum@0
   411
if ( ($i &lt; 7)&amp;&amp;($j &gt; 8) ) ...
indvdum@0
   412
if ($i &lt; 7 &amp;&amp; $j &gt; 8) ...
indvdum@0
   413
indvdum@0
   414
do_stuff( $i, 'foo', $b );
indvdum@0
   415
do_stuff($i, 'foo', $b);
indvdum@0
   416
indvdum@0
   417
for($i=0; $i&lt;$size; $i++) ...
indvdum@0
   418
for ($i = 0; $i &lt; $size; $i++) ...
indvdum@0
   419
indvdum@0
   420
$i=($j &lt; $size)?0:1;
indvdum@0
   421
$i = ($j &lt; $size) ? 0 : 1;
indvdum@0
   422
	</pre></div>
indvdum@0
   423
indvdum@0
   424
	<h4>Operator precedence:</h4>
indvdum@0
   425
	<p>Do you know the exact precedence of all the operators in PHP? Neither do I. Don't guess. Always make it obvious by using brackets to force the precedence of an equation so you know what it does. Remember to not over-use this, as it may harden the readability. Basically, do not enclose single expressions. Examples:</p>
indvdum@0
   426
indvdum@0
   427
	<p class="bad">// what's the result? who knows. </p>
indvdum@0
   428
	<div class="codebox"><pre>
indvdum@0
   429
$bool = ($i &lt; 7 &amp;&amp; $j &gt; 8 || $k == 4);
indvdum@0
   430
	</pre></div>
indvdum@0
   431
indvdum@0
   432
	<p class="bad">// now you can be certain what I'm doing here.</p>
indvdum@0
   433
	<div class="codebox"><pre>
indvdum@0
   434
$bool = (($i &lt; 7) &amp;&amp; (($j &lt; 8) || ($k == 4)));
indvdum@0
   435
	</pre></div>
indvdum@0
   436
indvdum@0
   437
	<p class="good">// But this one is even better, because it is easier on the eye but the intention is preserved</p>
indvdum@0
   438
	<div class="codebox"><pre>
indvdum@0
   439
$bool = ($i &lt; 7 &amp;&amp; ($j &lt; 8 || $k == 4));
indvdum@0
   440
	</pre></div>
indvdum@0
   441
indvdum@0
   442
	<h4>Quoting strings:</h4>
indvdum@0
   443
	<p>There are two different ways to quote strings in PHP - either with single quotes or with double quotes. The main difference is that the parser does variable interpolation in double-quoted strings, but not in single quoted strings. Because of this, you should <em>always</em> use single quotes <em>unless</em> you specifically need variable interpolation to be done on that string. This way, we can save the parser the trouble of parsing a bunch of strings where no interpolation needs to be done.</p>
indvdum@0
   444
	<p>Also, if you are using a string variable as part of a function call, you do not need to enclose that variable in quotes. Again, this will just make unnecessary work for the parser. Note, however, that nearly all of the escape sequences that exist for double-quoted strings will not work with single-quoted strings. Be careful, and feel free to break this guideline if it's making your code easier to read, examples:</p>
indvdum@0
   445
indvdum@0
   446
	<p class="bad">// wrong </p>
indvdum@0
   447
	<div class="codebox"><pre>
indvdum@0
   448
$str = "This is a really long string with no variables for the parser to find.";
indvdum@0
   449
indvdum@0
   450
do_stuff("$str");
indvdum@0
   451
	</pre></div>
indvdum@0
   452
indvdum@0
   453
	<p class="good">// right</p>
indvdum@0
   454
	<div class="codebox"><pre>
indvdum@0
   455
$str = 'This is a really long string with no variables for the parser to find.';
indvdum@0
   456
indvdum@0
   457
do_stuff($str);
indvdum@0
   458
	</pre></div>
indvdum@0
   459
indvdum@0
   460
	<p class="bad">// Sometimes single quotes are just not right</p>
indvdum@0
   461
	<div class="codebox"><pre>
indvdum@0
   462
$post_url = $phpbb_root_path . 'posting.' . $phpEx . '?mode=' . $mode . '&amp;amp;start=' . $start;
indvdum@0
   463
	</pre></div>
indvdum@0
   464
indvdum@0
   465
	<p class="good">// Double quotes are sometimes needed to not overcrowd the line with concatenations.</p>
indvdum@0
   466
	<div class="codebox"><pre>
indvdum@0
   467
$post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&amp;amp;start=$start";
indvdum@0
   468
	</pre></div>
indvdum@0
   469
indvdum@0
   470
	<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>
indvdum@0
   471
indvdum@0
   472
	<h4>Associative array keys:</h4>
indvdum@0
   473
	<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>
indvdum@0
   474
indvdum@0
   475
	<p class="bad">// wrong</p>
indvdum@0
   476
	<div class="codebox"><pre>
indvdum@0
   477
$foo = $assoc_array[blah];
indvdum@0
   478
	</pre></div>
indvdum@0
   479
indvdum@0
   480
	<p class="good">// right </p>
indvdum@0
   481
	<div class="codebox"><pre>
indvdum@0
   482
$foo = $assoc_array['blah'];
indvdum@0
   483
	</pre></div>
indvdum@0
   484
indvdum@0
   485
	<p class="bad">// wrong</p>
indvdum@0
   486
	<div class="codebox"><pre>
indvdum@0
   487
$foo = $assoc_array["$var"];
indvdum@0
   488
	</pre></div>
indvdum@0
   489
indvdum@0
   490
	<p class="good">// right </p>
indvdum@0
   491
	<div class="codebox"><pre>
indvdum@0
   492
$foo = $assoc_array[$var];
indvdum@0
   493
	</pre></div>
indvdum@0
   494
indvdum@0
   495
	<h4>Comments:</h4>
indvdum@0
   496
	<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>
indvdum@0
   497
indvdum@0
   498
	<h4>Magic numbers:</h4>
indvdum@0
   499
	<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>
indvdum@0
   500
indvdum@0
   501
	<h4>Shortcut operators:</h4>
indvdum@0
   502
	<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>
indvdum@0
   503
indvdum@0
   504
	<p class="bad">// wrong </p>
indvdum@0
   505
	<div class="codebox"><pre>
indvdum@0
   506
$array[++$i] = $j;
indvdum@0
   507
$array[$i++] = $k;
indvdum@0
   508
	</pre></div>
indvdum@0
   509
indvdum@0
   510
	<p class="good">// right </p>
indvdum@0
   511
	<div class="codebox"><pre>
indvdum@0
   512
$i++;
indvdum@0
   513
$array[$i] = $j;
indvdum@0
   514
indvdum@0
   515
$array[$i] = $k;
indvdum@0
   516
$i++;
indvdum@0
   517
	</pre></div>
indvdum@0
   518
indvdum@0
   519
	<h4>Inline conditionals:</h4>
indvdum@0
   520
	<p>Inline conditionals should only be used to do very simple things. Preferably, they will only be used to do assignments, and not for function calls or anything complex at all. They can be harmful to readability if used incorrectly, so don't fall in love with saving typing by using them, examples:</p>
indvdum@0
   521
indvdum@0
   522
	<p class="bad">// Bad place to use them</p>
indvdum@0
   523
	<div class="codebox"><pre>
indvdum@0
   524
($i &lt; $size &amp;&amp; $j &gt; $size) ? do_stuff($foo) : do_stuff($bar);
indvdum@0
   525
	</pre></div>
indvdum@0
   526
indvdum@0
   527
	<p class="good">// OK place to use them </p>
indvdum@0
   528
	<div class="codebox"><pre>
indvdum@0
   529
$min = ($i &lt; $j) ? $i : $j;
indvdum@0
   530
	</pre></div>
indvdum@0
   531
indvdum@0
   532
	<h4>Don't use uninitialized variables.</h4>
indvdum@0
   533
	<p>For phpBB3, we intend to use a higher level of run-time error reporting. This will mean that the use of an uninitialized variable will be reported as a warning. These warnings can be avoided by using the built-in isset() function to check whether a variable has been set - but preferably the variable is always existing. For checking if an array has a key set this can come in handy though, examples:</p>
indvdum@0
   534
indvdum@0
   535
	<p class="bad">// Wrong </p>
indvdum@0
   536
	<div class="codebox"><pre>
indvdum@0
   537
if ($forum) ...
indvdum@0
   538
	</pre></div>
indvdum@0
   539
indvdum@0
   540
	<p class="good">// Right </p>
indvdum@0
   541
	<div class="codebox"><pre>
indvdum@0
   542
if (isset($forum)) ...
indvdum@0
   543
	</pre></div>
indvdum@0
   544
indvdum@0
   545
	<p class="good">// Also possible</p>
indvdum@0
   546
	<div class="codebox"><pre>
indvdum@0
   547
if (isset($forum) &amp;&amp; $forum == 5)
indvdum@0
   548
	</pre></div>
indvdum@0
   549
indvdum@0
   550
	<p>The <code>empty()</code> function is useful if you want to check if a variable is not set or being empty (an empty string, 0 as an integer or string, NULL, false, an empty array or a variable declared, but without a value in a class). Therefore empty should be used in favor of <code>isset($array) &amp;&amp; sizeof($array) &gt; 0</code> - this can be written in a shorter way as <code>!empty($array)</code>.</p>
indvdum@0
   551
indvdum@0
   552
	<h4>Switch statements:</h4>
indvdum@0
   553
	<p>Switch/case code blocks can get a bit long sometimes. To have some level of notice and being in-line with the opening/closing brace requirement (where they are on the same line for better readability), this also applies to switch/case code blocks and the breaks. An example:</p>
indvdum@0
   554
indvdum@0
   555
	<p class="bad">// Wrong </p>
indvdum@0
   556
	<div class="codebox"><pre>
indvdum@0
   557
switch ($mode)
indvdum@0
   558
{
indvdum@0
   559
	case 'mode1':
indvdum@0
   560
		// I am doing something here
indvdum@0
   561
		break;
indvdum@0
   562
	case 'mode2':
indvdum@0
   563
		// I am doing something completely different here
indvdum@0
   564
		break;
indvdum@0
   565
}
indvdum@0
   566
	</pre></div>
indvdum@0
   567
indvdum@0
   568
	<p class="good">// Good </p>
indvdum@0
   569
	<div class="codebox"><pre>
indvdum@0
   570
switch ($mode)
indvdum@0
   571
{
indvdum@0
   572
	case 'mode1':
indvdum@0
   573
		// I am doing something here
indvdum@0
   574
	break;
indvdum@0
   575
indvdum@0
   576
	case 'mode2':
indvdum@0
   577
		// I am doing something completely different here
indvdum@0
   578
	break;
indvdum@0
   579
indvdum@0
   580
	default:
indvdum@0
   581
		// Always assume that a case was not caught
indvdum@0
   582
	break;
indvdum@0
   583
}
indvdum@0
   584
	</pre></div>
indvdum@0
   585
indvdum@0
   586
	<p class="good">// Also good, if you have more code between the case and the break </p>
indvdum@0
   587
	<div class="codebox"><pre>
indvdum@0
   588
switch ($mode)
indvdum@0
   589
{
indvdum@0
   590
	case 'mode1':
indvdum@0
   591
indvdum@0
   592
		// I am doing something here
indvdum@0
   593
indvdum@0
   594
	break;
indvdum@0
   595
indvdum@0
   596
	case 'mode2':
indvdum@0
   597
indvdum@0
   598
		// I am doing something completely different here
indvdum@0
   599
indvdum@0
   600
	break;
indvdum@0
   601
indvdum@0
   602
	default:
indvdum@0
   603
indvdum@0
   604
		// Always assume that a case was not caught
indvdum@0
   605
indvdum@0
   606
	break;
indvdum@0
   607
}
indvdum@0
   608
	</pre></div>
indvdum@0
   609
indvdum@0
   610
	<p>Even if the break for the default case is not needed, it is sometimes better to include it just for readability and completeness.</p>
indvdum@0
   611
indvdum@0
   612
	<p>If no break is intended, please add a comment instead. An example:</p>
indvdum@0
   613
indvdum@0
   614
	<p class="good">// Example with no break </p>
indvdum@0
   615
	<div class="codebox"><pre>
indvdum@0
   616
switch ($mode)
indvdum@0
   617
{
indvdum@0
   618
	case 'mode1':
indvdum@0
   619
indvdum@0
   620
		// I am doing something here
indvdum@0
   621
indvdum@0
   622
	// no break here
indvdum@0
   623
indvdum@0
   624
	case 'mode2':
indvdum@0
   625
indvdum@0
   626
		// I am doing something completely different here
indvdum@0
   627
indvdum@0
   628
	break;
indvdum@0
   629
indvdum@0
   630
	default:
indvdum@0
   631
indvdum@0
   632
		// Always assume that a case was not caught
indvdum@0
   633
indvdum@0
   634
	break;
indvdum@0
   635
}
indvdum@0
   636
	</pre></div>
indvdum@0
   637
indvdum@0
   638
	<a name="sql"></a><h3>2.iii. SQL/SQL Layout</h3>
indvdum@0
   639
indvdum@0
   640
	<h4>Common SQL Guidelines: </h4>
indvdum@0
   641
	<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>
indvdum@0
   642
	<p>All SQL commands should utilise the DataBase Abstraction Layer (DBAL)</p>
indvdum@0
   643
indvdum@0
   644
	<h4>SQL code layout:</h4>
indvdum@0
   645
	<p>SQL Statements are often unreadable without some formatting, since they tend to be big at times. Though the formatting of sql statements adds a lot to the readability of code. SQL statements should be formatted in the following way, basically writing keywords: </p>
indvdum@0
   646
indvdum@0
   647
	<div class="codebox"><pre>
indvdum@0
   648
$sql = 'SELECT *
indvdum@0
   649
&lt;-one tab-&gt;FROM ' . SOME_TABLE . '
indvdum@0
   650
&lt;-one tab-&gt;WHERE a = 1
indvdum@0
   651
&lt;-two tabs-&gt;AND (b = 2
indvdum@0
   652
&lt;-three tabs-&gt;OR b = 3)
indvdum@0
   653
&lt;-one tab-&gt;ORDER BY b';
indvdum@0
   654
	</pre></div>
indvdum@0
   655
indvdum@0
   656
	<p>Here the example with the tabs applied:</p>
indvdum@0
   657
indvdum@0
   658
	<div class="codebox"><pre>
indvdum@0
   659
$sql = 'SELECT *
indvdum@0
   660
	FROM ' . SOME_TABLE . '
indvdum@0
   661
	WHERE a = 1
indvdum@0
   662
		AND (b = 2
indvdum@0
   663
			OR b = 3)
indvdum@0
   664
	ORDER BY b';
indvdum@0
   665
	</pre></div>
indvdum@0
   666
indvdum@0
   667
	<h4>SQL Quotes: </h4>
indvdum@0
   668
	<p>Use double quotes where applicable. (The variables in these examples are typecasted to integers beforehand.) Examples: </p>
indvdum@0
   669
indvdum@0
   670
	<p class="bad">// These are wrong.</p>
indvdum@0
   671
	<div class="codebox"><pre>
indvdum@0
   672
"UPDATE " . SOME_TABLE . " SET something = something_else WHERE a = $b";
indvdum@0
   673
indvdum@0
   674
'UPDATE ' . SOME_TABLE . ' SET something = ' . $user_id . ' WHERE a = ' . $something;
indvdum@0
   675
	</pre></div>
indvdum@0
   676
indvdum@0
   677
	<p class="good">// These are right. </p>
indvdum@0
   678
indvdum@0
   679
	<div class="codebox"><pre>
indvdum@0
   680
'UPDATE ' . SOME_TABLE . " SET something = something_else WHERE a = $b";
indvdum@0
   681
indvdum@0
   682
'UPDATE ' . SOME_TABLE . " SET something = $user_id WHERE a = $something";
indvdum@0
   683
	</pre></div>
indvdum@0
   684
indvdum@0
   685
	<p>In other words use single quotes where no variable substitution is required or where the variable involved shouldn't appear within double quotes. Otherwise use double quotes.</p>
indvdum@0
   686
indvdum@0
   687
	<h4>Avoid DB specific SQL: </h4>
indvdum@0
   688
	<p>The &quot;not equals operator&quot;, as defined by the SQL:2003 standard, is &quot;&lt;&gt;&quot;</p>
indvdum@0
   689
indvdum@0
   690
	<p class="bad">// This is wrong.</p>
indvdum@0
   691
	<div class="codebox"><pre>
indvdum@0
   692
$sql = 'SELECT *
indvdum@0
   693
	FROM ' . SOME_TABLE . '
indvdum@0
   694
	WHERE a != 2';
indvdum@0
   695
	</pre></div>
indvdum@0
   696
indvdum@0
   697
	<p class="good">// This is right. </p>
indvdum@0
   698
	<div class="codebox"><pre>
indvdum@0
   699
$sql = 'SELECT *
indvdum@0
   700
	FROM ' . SOME_TABLE . '
indvdum@0
   701
	WHERE a &lt;&gt; 2';
indvdum@0
   702
	</pre></div>
indvdum@0
   703
indvdum@0
   704
	<h4>Common DBAL methods: </h4>
indvdum@0
   705
indvdum@0
   706
	<h4>sql_escape():</h4>
indvdum@0
   707
indvdum@0
   708
	<p>Always use <code>$db-&gt;sql_escape()</code> if you need to check for a string within an SQL statement (even if you are sure the variable cannot contain single quotes - never trust your input), for example:</p>
indvdum@0
   709
indvdum@0
   710
	<div class="codebox"><pre>
indvdum@0
   711
$sql = 'SELECT *
indvdum@0
   712
	FROM ' . SOME_TABLE . "
indvdum@0
   713
	WHERE username = '" . $db-&gt;sql_escape($username) . "'";
indvdum@0
   714
	</pre></div>
indvdum@0
   715
indvdum@0
   716
	<h4>sql_query_limit():</h4>
indvdum@0
   717
indvdum@0
   718
	<p>We do not add limit statements to the sql query, but instead use <code>$db-&gt;sql_query_limit()</code>. You basically pass the query, the total number of lines to retrieve and the offset.</p>
indvdum@0
   719
indvdum@0
   720
	<p><strong>Note: </strong> Since Oracle handles limits differently and because of how we implemented this handling you need to take special care if you use <code>sql_query_limit</code> with an sql query retrieving data from more than one table.</p>
indvdum@0
   721
indvdum@0
   722
	<p>Make sure when using something like "SELECT x.*, y.jars" that there is not a column named jars in x; make sure that there is no overlap between an implicit column and the explicit columns.</p>
indvdum@0
   723
indvdum@0
   724
	<h4>sql_build_array():</h4>
indvdum@0
   725
indvdum@0
   726
	<p>If you need to UPDATE or INSERT data, make use of the <code>$db-&gt;sql_build_array()</code> function. This function already escapes strings and checks other types, so there is no need to do this here. The data to be inserted should go into an array - <code>$sql_ary</code> - or directly within the statement if one or two variables needs to be inserted/updated. An example of an insert statement would be:</p>
indvdum@0
   727
indvdum@0
   728
	<div class="codebox"><pre>
indvdum@0
   729
$sql_ary = array(
indvdum@0
   730
	'somedata'		=&gt; $my_string,
indvdum@0
   731
	'otherdata'		=&gt; $an_int,
indvdum@0
   732
	'moredata'		=&gt; $another_int
indvdum@0
   733
);
indvdum@0
   734
indvdum@0
   735
$db-&gt;sql_query('INSERT INTO ' . SOME_TABLE . ' ' . $db-&gt;sql_build_array('INSERT', $sql_ary));
indvdum@0
   736
	</pre></div>
indvdum@0
   737
indvdum@0
   738
	<p>To complete the example, this is how an update statement would look like:</p>
indvdum@0
   739
indvdum@0
   740
	<div class="codebox"><pre>
indvdum@0
   741
$sql_ary = array(
indvdum@0
   742
	'somedata'		=&gt; $my_string,
indvdum@0
   743
	'otherdata'		=&gt; $an_int,
indvdum@0
   744
	'moredata'		=&gt; $another_int
indvdum@0
   745
);
indvdum@0
   746
indvdum@0
   747
$sql = 'UPDATE ' . SOME_TABLE . '
indvdum@0
   748
	SET ' . $db-&gt;sql_build_array('UPDATE', $sql_ary) . '
indvdum@0
   749
	WHERE user_id = ' . (int) $user_id;
indvdum@0
   750
$db-&gt;sql_query($sql);
indvdum@0
   751
	</pre></div>
indvdum@0
   752
indvdum@0
   753
	<p>The <code>$db-&gt;sql_build_array()</code> function supports the following modes: <code>INSERT</code> (example above), <code>INSERT_SELECT</code> (building query for <code>INSERT INTO table (...) SELECT value, column ...</code> statements), <code>UPDATE</code> (example above) and <code>SELECT</code> (for building WHERE statement [AND logic]).</p>
indvdum@0
   754
indvdum@0
   755
	<h4>sql_multi_insert():</h4>
indvdum@0
   756
indvdum@0
   757
	<p>If you want to insert multiple statements at once, please use the separate <code>sql_multi_insert()</code> method. An example:</p>
indvdum@0
   758
indvdum@0
   759
	<div class="codebox"><pre>
indvdum@0
   760
$sql_ary = array();
indvdum@0
   761
indvdum@0
   762
$sql_ary[] = array(
indvdum@0
   763
	'somedata'		=&gt; $my_string_1,
indvdum@0
   764
	'otherdata'		=&gt; $an_int_1,
indvdum@0
   765
	'moredata'		=&gt; $another_int_1,
indvdum@0
   766
);
indvdum@0
   767
indvdum@0
   768
$sql_ary[] = array(
indvdum@0
   769
	'somedata'		=&gt; $my_string_2,
indvdum@0
   770
	'otherdata'		=&gt; $an_int_2,
indvdum@0
   771
	'moredata'		=&gt; $another_int_2,
indvdum@0
   772
);
indvdum@0
   773
indvdum@0
   774
$db->sql_multi_insert(SOME_TABLE, $sql_ary);
indvdum@0
   775
	</pre></div>
indvdum@0
   776
indvdum@0
   777
	<h4>sql_in_set():</h4>
indvdum@0
   778
indvdum@0
   779
	<p>The <code>$db-&gt;sql_in_set()</code> function should be used for building <code>IN ()</code> and <code>NOT IN ()</code> constructs. Since (specifically) MySQL tend to be faster if for one value to be compared the <code>=</code> and <code>&lt;&gt;</code> operator is used, we let the DBAL decide what to do. A typical example of doing a positive match against a number of values would be:</p>
indvdum@0
   780
indvdum@0
   781
	<div class="codebox"><pre>
indvdum@0
   782
$sql = 'SELECT *
indvdum@0
   783
	FROM ' . FORUMS_TABLE . '
indvdum@0
   784
	WHERE ' . $db-&gt;sql_in_set('forum_id', $forum_ids);
indvdum@0
   785
$db-&gt;sql_query($sql);
indvdum@0
   786
	</pre></div>
indvdum@0
   787
indvdum@0
   788
	<p>Based on the number of values in $forum_ids, the query can look differently.</p>
indvdum@0
   789
indvdum@0
   790
	<p class="good">// SQL Statement if $forum_ids = array(1, 2, 3);</p>
indvdum@0
   791
indvdum@0
   792
	<div class="codebox"><pre>
indvdum@0
   793
SELECT FROM phpbb_forums WHERE forum_id IN (1, 2, 3)
indvdum@0
   794
	</pre></div>
indvdum@0
   795
indvdum@0
   796
	<p class="good">// SQL Statement if $forum_ids = array(1) or $forum_ids = 1</p>
indvdum@0
   797
indvdum@0
   798
	<div class="codebox"><pre>
indvdum@0
   799
SELECT FROM phpbb_forums WHERE forum_id = 1
indvdum@0
   800
	</pre></div>
indvdum@0
   801
indvdum@0
   802
	<p>Of course the same is possible for doing a negative match against a number of values:</p>
indvdum@0
   803
indvdum@0
   804
	<div class="codebox"><pre>
indvdum@0
   805
$sql = 'SELECT *
indvdum@0
   806
	FROM ' . FORUMS_TABLE . '
indvdum@0
   807
	WHERE ' . $db-&gt;sql_in_set('forum_id', $forum_ids, <strong>true</strong>);
indvdum@0
   808
$db-&gt;sql_query($sql);
indvdum@0
   809
	</pre></div>
indvdum@0
   810
indvdum@0
   811
	<p>Based on the number of values in $forum_ids, the query can look differently here too.</p>
indvdum@0
   812
indvdum@0
   813
	<p class="good">// SQL Statement if $forum_ids = array(1, 2, 3);</p>
indvdum@0
   814
indvdum@0
   815
	<div class="codebox"><pre>
indvdum@0
   816
SELECT FROM phpbb_forums WHERE forum_id <strong>NOT</strong> IN (1, 2, 3)
indvdum@0
   817
	</pre></div>
indvdum@0
   818
indvdum@0
   819
	<p class="good">// SQL Statement if $forum_ids = array(1) or $forum_ids = 1</p>
indvdum@0
   820
indvdum@0
   821
	<div class="codebox"><pre>
indvdum@0
   822
SELECT FROM phpbb_forums WHERE forum_id <strong>&lt;&gt;</strong> 1
indvdum@0
   823
	</pre></div>
indvdum@0
   824
indvdum@0
   825
	<p>If the given array is empty, an error will be produced.</p>
indvdum@0
   826
indvdum@0
   827
	<h4>sql_build_query():</h4>
indvdum@0
   828
indvdum@0
   829
	<p>The <code>$db-&gt;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>
indvdum@0
   830
indvdum@0
   831
	<div class="codebox"><pre>
indvdum@0
   832
$sql_array = array(
indvdum@0
   833
	'SELECT'	=&gt; 'f.*, ft.mark_time',
indvdum@0
   834
indvdum@0
   835
	'FROM'		=&gt; array(
indvdum@0
   836
		FORUMS_WATCH_TABLE	=&gt; 'fw',
indvdum@0
   837
		FORUMS_TABLE		=&gt; 'f'
indvdum@0
   838
	),
indvdum@0
   839
indvdum@0
   840
	'LEFT_JOIN'	=&gt; array(
indvdum@0
   841
		array(
indvdum@0
   842
			'FROM'	=&gt; array(FORUMS_TRACK_TABLE =&gt; 'ft'),
indvdum@0
   843
			'ON'	=&gt; 'ft.user_id = ' . $user-&gt;data['user_id'] . ' AND ft.forum_id = f.forum_id'
indvdum@0
   844
		)
indvdum@0
   845
	),
indvdum@0
   846
indvdum@0
   847
	'WHERE'		=&gt; 'fw.user_id = ' . $user-&gt;data['user_id'] . '
indvdum@0
   848
		AND f.forum_id = fw.forum_id',
indvdum@0
   849
indvdum@0
   850
	'ORDER_BY'	=&gt; 'left_id'
indvdum@0
   851
);
indvdum@0
   852
indvdum@0
   853
$sql = $db-&gt;sql_build_query('SELECT', $sql_array);
indvdum@0
   854
	</pre></div>
indvdum@0
   855
indvdum@0
   856
	<p>The possible first parameter for sql_build_query() is SELECT or SELECT_DISTINCT. As you can see, the logic is pretty self-explaining. For the LEFT_JOIN key, just add another array if you want to join on to tables for example. The added benefit of using this construct is that you are able to easily build the query statement based on conditions - for example the above LEFT_JOIN is only necessary if server side topic tracking is enabled; a slight adjustement would be:</p>
indvdum@0
   857
indvdum@0
   858
	<div class="codebox"><pre>
indvdum@0
   859
$sql_array = array(
indvdum@0
   860
	'SELECT'	=&gt; 'f.*',
indvdum@0
   861
indvdum@0
   862
	'FROM'		=&gt; array(
indvdum@0
   863
		FORUMS_WATCH_TABLE	=&gt; 'fw',
indvdum@0
   864
		FORUMS_TABLE		=&gt; 'f'
indvdum@0
   865
	),
indvdum@0
   866
indvdum@0
   867
	'WHERE'		=&gt; 'fw.user_id = ' . $user-&gt;data['user_id'] . '
indvdum@0
   868
		AND f.forum_id = fw.forum_id',
indvdum@0
   869
indvdum@0
   870
	'ORDER_BY'	=&gt; 'left_id'
indvdum@0
   871
);
indvdum@0
   872
indvdum@0
   873
if ($config['load_db_lastread'])
indvdum@0
   874
{
indvdum@0
   875
	$sql_array['LEFT_JOIN'] = array(
indvdum@0
   876
		array(
indvdum@0
   877
			'FROM'	=&gt; array(FORUMS_TRACK_TABLE =&gt; 'ft'),
indvdum@0
   878
			'ON'	=&gt; 'ft.user_id = ' . $user-&gt;data['user_id'] . ' AND ft.forum_id = f.forum_id'
indvdum@0
   879
		)
indvdum@0
   880
	);
indvdum@0
   881
indvdum@0
   882
	$sql_array['SELECT'] .= ', ft.mark_time ';
indvdum@0
   883
}
indvdum@0
   884
else
indvdum@0
   885
{
indvdum@0
   886
	// Here we read the cookie data
indvdum@0
   887
}
indvdum@0
   888
indvdum@0
   889
$sql = $db-&gt;sql_build_query('SELECT', $sql_array);
indvdum@0
   890
	</pre></div>
indvdum@0
   891
indvdum@0
   892
	<a name="optimizing"></a><h3>2.iv. Optimizations</h3>
indvdum@0
   893
indvdum@0
   894
	<h4>Operations in loop definition: </h4>
indvdum@0
   895
	<p>Always try to optimize your loops if operations are going on at the comparing part, since this part is executed every time the loop is parsed through. For assignments a descriptive name should be chosen. Example:</p>
indvdum@0
   896
indvdum@0
   897
	<p class="bad">// On every iteration the sizeof function is called</p>
indvdum@0
   898
	<div class="codebox"><pre>
indvdum@0
   899
for ($i = 0; $i &lt; sizeof($post_data); $i++)
indvdum@0
   900
{
indvdum@0
   901
	do_something();
indvdum@0
   902
}
indvdum@0
   903
	</pre></div>
indvdum@0
   904
indvdum@0
   905
	<p class="good">// You are able to assign the (not changing) result within the loop itself</p>
indvdum@0
   906
	<div class="codebox"><pre>
indvdum@0
   907
for ($i = 0, $size = sizeof($post_data); $i &lt; $size; $i++)
indvdum@0
   908
{
indvdum@0
   909
	do_something();
indvdum@0
   910
}
indvdum@0
   911
	</pre></div>
indvdum@0
   912
indvdum@0
   913
	<h4>Use of in_array(): </h4>
indvdum@0
   914
	<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>
indvdum@0
   915
indvdum@0
   916
indvdum@0
   917
	<a name="general"></a><h3>2.v. General Guidelines</h3>
indvdum@0
   918
indvdum@0
   919
	<h4>General things:</h4>
indvdum@0
   920
	<p>Never trust user input (this also applies to server variables as well as cookies).</p>
indvdum@0
   921
	<p>Try to sanitize values returned from a function.</p>
indvdum@0
   922
	<p>Try to sanitize given function variables within your function.</p>
indvdum@0
   923
	<p>The auth class should be used for all authorisation checking.</p>
indvdum@0
   924
	<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>
indvdum@0
   925
indvdum@0
   926
	<h4>Variables: </h4>
indvdum@0
   927
	<p>Make use of the <code>request_var()</code> function for anything except for submit or single checking params.</p>
indvdum@0
   928
	<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>
indvdum@0
   929
indvdum@0
   930
	<p class="bad">// Old method, do not use it</p>
indvdum@0
   931
	<div class="codebox"><pre>
indvdum@0
   932
$start = (isset($HTTP_GET_VARS['start'])) ? intval($HTTP_GET_VARS['start']) : intval($HTTP_POST_VARS['start']);
indvdum@0
   933
$submit = (isset($HTTP_POST_VARS['submit'])) ? true : false;
indvdum@0
   934
	</pre></div>
indvdum@0
   935
indvdum@0
   936
	<p class="good">// Use request var and define a default variable (use the correct type)</p>
indvdum@0
   937
	<div class="codebox"><pre>
indvdum@0
   938
$start = request_var('start', 0);
indvdum@0
   939
$submit = (isset($_POST['submit'])) ? true : false;
indvdum@0
   940
	</pre></div>
indvdum@0
   941
indvdum@0
   942
	<p class="bad">// $start is an int, the following use of request_var therefore is not allowed</p>
indvdum@0
   943
	<div class="codebox"><pre>
indvdum@0
   944
$start = request_var('start', '0');
indvdum@0
   945
	</pre></div>
indvdum@0
   946
indvdum@0
   947
	<p class="good">// Getting an array, keys are integers, value defaults to 0</p>
indvdum@0
   948
	<div class="codebox"><pre>
indvdum@0
   949
$mark_array = request_var('mark', array(0));
indvdum@0
   950
	</pre></div>
indvdum@0
   951
indvdum@0
   952
	<p class="good">// Getting an array, keys are strings, value defaults to 0</p>
indvdum@0
   953
	<div class="codebox"><pre>
indvdum@0
   954
$action_ary = request_var('action', array('' =&gt; 0));
indvdum@0
   955
	</pre></div>
indvdum@0
   956
indvdum@0
   957
	<h4>Login checks/redirection: </h4>
indvdum@0
   958
	<p>To show a forum login box use <code>login_forum_box($forum_data)</code>, else use the <code>login_box()</code> function.</p>
indvdum@0
   959
indvdum@0
   960
	<p>The <code>login_box()</code> function can have a redirect as the first parameter. As a thumb of rule, specify an empty string if you want to redirect to the users current location, else do not add the <code>$SID</code> to the redirect string (for example within the ucp/login we redirect to the board index because else the user would be redirected to the login screen).</p>
indvdum@0
   961
indvdum@0
   962
	<h4>Sensitive Operations: </h4>
indvdum@0
   963
	<p>For sensitive operations always let the user confirm the action. For the confirmation screens, make use of the <code>confirm_box()</code> function.</p>
indvdum@0
   964
indvdum@0
   965
	<h4>Altering Operations: </h4>
indvdum@0
   966
	<p>For operations altering the state of the database, for instance posting, always verify the form token, unless you are already using <code>confirm_box()</code>. To do so, make use of the <code>add_form_key()</code> and <code>check_form_key()</code> functions. </p>
indvdum@0
   967
	<div class="codebox"><pre>
indvdum@0
   968
	add_form_key('my_form');
indvdum@0
   969
indvdum@0
   970
	if ($submit)
indvdum@0
   971
	{
indvdum@0
   972
		if (!check_form_key('my_form'))
indvdum@0
   973
		{
indvdum@0
   974
			trigger_error('FORM_INVALID');
indvdum@0
   975
		}
indvdum@0
   976
	}
indvdum@0
   977
	</pre></div>
indvdum@0
   978
indvdum@0
   979
	<p>The string passed to <code>add_form_key()</code> needs to match the string passed to <code>check_form_key()</code>. Another requirement for this to work correctly is that all forms include the <code>{S_FORM_TOKEN}</code> template variable.</p>
indvdum@0
   980
indvdum@0
   981
indvdum@0
   982
	<h4>Sessions: </h4>
indvdum@0
   983
	<p>Sessions should be initiated on each page, as near the top as possible using the following code:</p>
indvdum@0
   984
indvdum@0
   985
	<div class="codebox"><pre>
indvdum@0
   986
$user-&gt;session_begin();
indvdum@0
   987
$auth-&gt;acl($user-&gt;data);
indvdum@0
   988
$user-&gt;setup();
indvdum@0
   989
	</pre></div>
indvdum@0
   990
indvdum@0
   991
	<p>The <code>$user-&gt;setup()</code> call can be used to pass on additional language definition and a custom style (used in viewforum).</p>
indvdum@0
   992
indvdum@0
   993
	<h4>Errors and messages: </h4>
indvdum@0
   994
	<p>All messages/errors should be outputted by calling <code>trigger_error()</code> using the appropriate message type and language string. Example:</p>
indvdum@0
   995
indvdum@0
   996
	<div class="codebox"><pre>
indvdum@0
   997
trigger_error('NO_FORUM');
indvdum@0
   998
	</pre></div>
indvdum@0
   999
indvdum@0
  1000
	<div class="codebox"><pre>
indvdum@0
  1001
trigger_error($user-&gt;lang['NO_FORUM']);
indvdum@0
  1002
	</pre></div>
indvdum@0
  1003
indvdum@0
  1004
	<div class="codebox"><pre>
indvdum@0
  1005
trigger_error('NO_MODE', E_USER_ERROR);
indvdum@0
  1006
	</pre></div>
indvdum@0
  1007
indvdum@0
  1008
	<h4>Url formatting</h4>
indvdum@0
  1009
indvdum@0
  1010
	<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>
indvdum@0
  1011
indvdum@0
  1012
	<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>
indvdum@0
  1013
indvdum@0
  1014
	<div class="codebox"><pre>
indvdum@0
  1015
append_sid(&quot;{$phpbb_root_path}memberlist.$phpEx&quot;, 'mode=group&amp;amp;g=' . $row['group_id'])
indvdum@0
  1016
	</pre></div>
indvdum@0
  1017
indvdum@0
  1018
	<h4>General function usage: </h4>
indvdum@0
  1019
indvdum@0
  1020
	<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>
indvdum@0
  1021
indvdum@0
  1022
	<ul>
indvdum@0
  1023
		<li>
indvdum@0
  1024
			<p>Use <code>sizeof</code> instead of <code>count</code></p>
indvdum@0
  1025
		</li>
indvdum@0
  1026
		<li>
indvdum@0
  1027
			<p>Use <code>strpos</code> instead of <code>strstr</code></p>
indvdum@0
  1028
		</li>
indvdum@0
  1029
		<li>
indvdum@0
  1030
			<p>Use <code>else if</code> instead of <code>elseif</code></p>
indvdum@0
  1031
		</li>
indvdum@0
  1032
		<li>
indvdum@0
  1033
			<p>Use <code>false</code> (lowercase) instead of <code>FALSE</code></p>
indvdum@0
  1034
		</li>
indvdum@0
  1035
		<li>
indvdum@0
  1036
			<p>Use <code>true</code> (lowercase) instead of <code>TRUE</code></p>
indvdum@0
  1037
		</li>
indvdum@0
  1038
	</ul>
indvdum@0
  1039
indvdum@0
  1040
	<h4>Exiting</h4>
indvdum@0
  1041
indvdum@0
  1042
	<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>
indvdum@0
  1043
indvdum@0
  1044
		</div>
indvdum@0
  1045
indvdum@0
  1046
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  1047
indvdum@0
  1048
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  1049
	</div>
indvdum@0
  1050
indvdum@0
  1051
	<hr />
indvdum@0
  1052
indvdum@0
  1053
<a name="styling"></a><h2>3. Styling</h2>
indvdum@0
  1054
	<div class="paragraph">
indvdum@0
  1055
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
  1056
indvdum@0
  1057
		<div class="content">
indvdum@0
  1058
	<a name="cfgfiles"></a><h3>3.i. Style Config Files</h3>
indvdum@0
  1059
	<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>
indvdum@0
  1060
	<div class="codebox"><pre>
indvdum@0
  1061
        # General Information about this style
indvdum@0
  1062
        name = prosilver_duplicate
indvdum@0
  1063
        copyright = &copy; phpBB Group, 2007
indvdum@0
  1064
        version = 3.0.3
indvdum@0
  1065
        required_template = prosilver
indvdum@0
  1066
        required_theme = prosilver
indvdum@0
  1067
        required_imageset = prosilver
indvdum@0
  1068
	</pre></div>
indvdum@0
  1069
	<a name="genstyling"></a><h3>3.2. General Styling Rules</h3>
indvdum@0
  1070
<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>
indvdum@0
  1071
indvdum@0
  1072
<p>The outer table class <code>forumline</code> has gone and is replaced with <code>tablebg</code>.</p>
indvdum@0
  1073
<p>When writing <code>&lt;table&gt;</code> the order <code>&lt;table class="" cellspacing="" cellpadding="" border="" align=""&gt;</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>
indvdum@0
  1074
<p>Each block level element should be indented by one tab, same for tabular elements, e.g. <code>&lt;tr&gt;</code> <code>&lt;td&gt;</code> etc., whereby the intendiation of <code>&lt;table&gt;</code> and the following/ending <code>&lt;tr&gt;</code> should be on the same line. This applies not to div elements of course.</p>
indvdum@0
  1075
<p>Don't use <code>&lt;span&gt;</code> more than is essential ... the CSS is such that text sizes are dependent on the parent class. So writing <code>&lt;span class="gensmall"&gt;&lt;span class="gensmall"&gt;TEST&lt;/span&gt;&lt;/span&gt;</code> will result in very very small text. Similarly don't use span at all if another element can contain the class definition, e.g.</p>
indvdum@0
  1076
indvdum@0
  1077
<div class="codebox"><pre>
indvdum@0
  1078
&lt;td&gt;&lt;span class=&quot;gensmall&quot;&gt;TEST&lt;/span&gt;&lt;/td&gt;
indvdum@0
  1079
</pre></div>
indvdum@0
  1080
indvdum@0
  1081
<p>can just as well become:</p>
indvdum@0
  1082
<div class="codebox"><pre>
indvdum@0
  1083
&lt;td class=&quot;gensmall&quot;&gt;TEST&lt;/td&gt;
indvdum@0
  1084
</pre></div>
indvdum@0
  1085
indvdum@0
  1086
<p>Try to match text class types with existing useage, e.g. don't use the nav class where viewtopic uses gensmall for example.</p>
indvdum@0
  1087
indvdum@0
  1088
<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>
indvdum@0
  1089
indvdum@0
  1090
<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>
indvdum@0
  1091
indvdum@0
  1092
<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>
indvdum@0
  1093
indvdum@0
  1094
<p><strong>Use div container/css for styling and table for data representation.</strong></p>
indvdum@0
  1095
indvdum@0
  1096
<p>The separate catXXXX and thXXX classes are gone. When defining a header cell just use <code>&lt;th&gt;</code> rather than <code>&lt;th class="thHead"&gt;</code> etc. Similarly for cat, don't use <code>&lt;td class="catLeft"&gt;</code> use <code>&lt;td class="cat"&gt;</code> etc.</p>
indvdum@0
  1097
indvdum@0
  1098
<p>Try to retain consistency of basic layout and class useage, i.e. _EXPLAIN text should generally be placed below the title it explains, e.g. <code>{L_POST_USERNAME}&lt;br /&gt;&lt;span class="gensmall"&gt;{L_POST_USERNAME_EXPLAIN}&lt;/span&gt;</code> is the typical way of handling this ... there may be exceptions and this isn't a hard and fast rule.</p>
indvdum@0
  1099
indvdum@0
  1100
<p>Try to keep template conditional and other statements tabbed in line with the block to which they refer.</p>
indvdum@0
  1101
indvdum@0
  1102
<p class="good">this is correct</p>
indvdum@0
  1103
<div class="codebox"><pre>
indvdum@0
  1104
<span class="comment">&lt;!-- BEGIN test --&gt;</span>
indvdum@0
  1105
	&lt;tr&gt;
indvdum@0
  1106
		&lt;td&gt;&#123;test.TEXT&#125;&lt;/td&gt;
indvdum@0
  1107
	&lt;/tr&gt;
indvdum@0
  1108
<span class="comment">&lt;!-- END test --&gt;</span>
indvdum@0
  1109
</pre></div>
indvdum@0
  1110
indvdum@0
  1111
<p class="good">this is also correct:</p>
indvdum@0
  1112
<div class="codebox"><pre>
indvdum@0
  1113
<span class="comment">&lt;!-- BEGIN test --&gt;</span>
indvdum@0
  1114
&lt;tr&gt;
indvdum@0
  1115
	&lt;td&gt;&#123;test.TEXT&#125;&lt;/td&gt;
indvdum@0
  1116
&lt;/tr&gt;
indvdum@0
  1117
<span class="comment">&lt;!-- END test --&gt;</span>
indvdum@0
  1118
</pre></div>
indvdum@0
  1119
indvdum@0
  1120
<p>it gives immediate feedback on exactly what is looping - decide which way to use based on the readability.</p>
indvdum@0
  1121
indvdum@0
  1122
		</div>
indvdum@0
  1123
indvdum@0
  1124
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  1125
indvdum@0
  1126
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  1127
	</div>
indvdum@0
  1128
indvdum@0
  1129
	<hr />
indvdum@0
  1130
indvdum@0
  1131
<a name="templating"></a><h2>4. Templating</h2>
indvdum@0
  1132
	<div class="paragraph">
indvdum@0
  1133
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
  1134
indvdum@0
  1135
		<div class="content">
indvdum@0
  1136
	<a name="templates"></a><h3>4.i. General Templating</h3>
indvdum@0
  1137
indvdum@0
  1138
<h4>File naming</h4>
indvdum@0
  1139
<p>Firstly templates now take the suffix &quot;.html&quot; rather than &quot;.tpl&quot;. This was done simply to make the lives of some people easier wrt syntax highlighting, etc.</p>
indvdum@0
  1140
indvdum@0
  1141
<h4>Variables</h4>
indvdum@0
  1142
<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>
indvdum@0
  1143
indvdum@0
  1144
<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-&gt;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.
indvdum@0
  1145
</p>
indvdum@0
  1146
indvdum@0
  1147
<h4>Blocks/Loops</h4>
indvdum@0
  1148
<p>The basic block level loop remains and takes the form:</p>
indvdum@0
  1149
<div class="codebox"><pre>
indvdum@0
  1150
<span class="comment">&lt;!-- BEGIN loopname --&gt;</span>
indvdum@0
  1151
	markup, {loopname&#46;X_YYYYY}, etc&#46;
indvdum@0
  1152
<span class="comment">&lt;!-- END loopname --&gt;</span>
indvdum@0
  1153
</pre></div>
indvdum@0
  1154
indvdum@0
  1155
<p>A bit later loops will be explained further. To not irritate you we will explain conditionals as well as other statements first.</p>
indvdum@0
  1156
indvdum@0
  1157
<h4>Including files</h4>
indvdum@0
  1158
<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>
indvdum@0
  1159
indvdum@0
  1160
<div class="codebox"><pre>
indvdum@0
  1161
<span class="comment">&lt;!-- INCLUDE filename --&gt;</span>
indvdum@0
  1162
</pre></div>
indvdum@0
  1163
indvdum@0
  1164
<p>You will note in the 3.0 templates the major sources start with <code>&lt;!-- INCLUDE overall_header.html --&gt;</code> or <code>&lt;!-- INCLUDE simple_header.html --&gt;</code>, etc. In 2.0.x control of &quot;which&quot; 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 &quot;menu&quot; bar or some such. No need to modify loads of files as with 2.0.x.</p>
indvdum@0
  1165
indvdum@0
  1166
<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>
indvdum@0
  1167
<div class="codebox"><pre>
indvdum@0
  1168
<span class="comment">&lt;!-- INCLUDE {FILE_VAR} --&gt;</span>
indvdum@0
  1169
</pre></div>
indvdum@0
  1170
indvdum@0
  1171
<p>Template defined variables can also be utilised.</p>
indvdum@0
  1172
indvdum@0
  1173
<div class="codebox"><pre>
indvdum@0
  1174
<span class="comment">&lt;!-- DEFINE $SOME_VAR = 'my_file.html' --&gt;</span>
indvdum@0
  1175
<span class="comment">&lt;!-- INCLUDE {$SOME_VAR} --&gt;</span>
indvdum@0
  1176
</pre></div>
indvdum@0
  1177
indvdum@0
  1178
<h4>PHP</h4>
indvdum@0
  1179
<p>A contentious decision has seen the ability to include PHP within the template introduced. This is achieved by enclosing the PHP within relevant tags:</p>
indvdum@0
  1180
indvdum@0
  1181
<div class="codebox"><pre>
indvdum@0
  1182
<span class="comment">&lt;!-- PHP --&gt;</span>
indvdum@0
  1183
	echo &quot;hello!&quot;;
indvdum@0
  1184
<span class="comment">&lt;!-- ENDPHP --&gt;</span>
indvdum@0
  1185
</pre></div>
indvdum@0
  1186
indvdum@0
  1187
<p>You may also include PHP from an external file using:</p>
indvdum@0
  1188
indvdum@0
  1189
<div class="codebox"><pre>
indvdum@0
  1190
<span class="comment">&lt;!-- INCLUDEPHP somefile&#46;php --&gt;</span>
indvdum@0
  1191
</pre></div>
indvdum@0
  1192
indvdum@0
  1193
<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>
indvdum@0
  1194
indvdum@0
  1195
<h4>Conditionals/Control structures</h4>
indvdum@0
  1196
<p>The most significant addition to 3.0.x are conditions or control structures, &quot;if something then do this else do that&quot;. 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>
indvdum@0
  1197
indvdum@0
  1198
<div class="codebox"><pre>
indvdum@0
  1199
<span class="comment">&lt;!-- IF expr --&gt;</span>
indvdum@0
  1200
	markup
indvdum@0
  1201
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1202
</pre></div>
indvdum@0
  1203
indvdum@0
  1204
<p>expr can take many forms, for example:</p>
indvdum@0
  1205
indvdum@0
  1206
<div class="codebox"><pre>
indvdum@0
  1207
<span class="comment">&lt;!-- IF loop&#46;S_ROW_COUNT is even --&gt;</span>
indvdum@0
  1208
	markup
indvdum@0
  1209
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1210
</pre></div>
indvdum@0
  1211
indvdum@0
  1212
<p>This will output the markup if the S_ROW_COUNT variable in the current iteration of loop is an even value (i.e. the expr is TRUE). You can use various comparison methods (standard as well as equivalent textual versions noted in square brackets) including (<code>not, or, and, eq, neq, is</code> should be used if possible for better readability):</p>
indvdum@0
  1213
indvdum@0
  1214
<div class="codebox"><pre>
indvdum@0
  1215
== [eq]
indvdum@0
  1216
!= [neq, ne]
indvdum@0
  1217
&lt;&gt; (same as !=)
indvdum@0
  1218
!== (not equivalent in value and type)
indvdum@0
  1219
=== (equivalent in value and type)
indvdum@0
  1220
&gt; [gt]
indvdum@0
  1221
&lt; [lt]
indvdum@0
  1222
&gt;= [gte]
indvdum@0
  1223
&lt;= [lte]
indvdum@0
  1224
&amp;&amp; [and]
indvdum@0
  1225
|| [or]
indvdum@0
  1226
% [mod]
indvdum@0
  1227
! [not]
indvdum@0
  1228
+
indvdum@0
  1229
-
indvdum@0
  1230
*
indvdum@0
  1231
/
indvdum@0
  1232
,
indvdum@0
  1233
&lt;&lt; (bitwise shift left)
indvdum@0
  1234
&gt;&gt; (bitwise shift right)
indvdum@0
  1235
| (bitwise or)
indvdum@0
  1236
^ (bitwise xor)
indvdum@0
  1237
&amp; (bitwise and)
indvdum@0
  1238
~ (bitwise not)
indvdum@0
  1239
is (can be used to join comparison operations)
indvdum@0
  1240
</pre></div>
indvdum@0
  1241
indvdum@0
  1242
<p>Basic parenthesis can also be used to enforce good old BODMAS rules. Additionally some basic comparison types are defined:</p>
indvdum@0
  1243
indvdum@0
  1244
<div class="codebox"><pre>
indvdum@0
  1245
even
indvdum@0
  1246
odd
indvdum@0
  1247
div
indvdum@0
  1248
</pre></div>
indvdum@0
  1249
indvdum@0
  1250
<p>Beyond the simple use of IF you can also do a sequence of comparisons using the following:</p>
indvdum@0
  1251
indvdum@0
  1252
<div class="codebox"><pre>
indvdum@0
  1253
<span class="comment">&lt;!-- IF expr1 --&gt;</span>
indvdum@0
  1254
	markup
indvdum@0
  1255
<span class="comment">&lt;!-- ELSEIF expr2 --&gt;</span>
indvdum@0
  1256
	markup
indvdum@0
  1257
	&#46;
indvdum@0
  1258
	&#46;
indvdum@0
  1259
	&#46;
indvdum@0
  1260
<span class="comment">&lt;!-- ELSEIF exprN --&gt;</span>
indvdum@0
  1261
	markup
indvdum@0
  1262
<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1263
	markup
indvdum@0
  1264
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1265
</pre></div>
indvdum@0
  1266
indvdum@0
  1267
<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 &quot;everything else&quot;.<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>
indvdum@0
  1268
indvdum@0
  1269
<div class="codebox"><pre>
indvdum@0
  1270
&lt;table&gt;
indvdum@0
  1271
	<span class="comment">&lt;!-- IF loop&#46;S_ROW_COUNT is even --&gt;</span>
indvdum@0
  1272
		&lt;tr class=&quot;row1&quot;&gt;
indvdum@0
  1273
	<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1274
		&lt;tr class=&quot;row2&quot;&gt;
indvdum@0
  1275
	<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1276
	&lt;td&gt;HELLO!&lt;/td&gt;
indvdum@0
  1277
&lt;/tr&gt;
indvdum@0
  1278
&lt;/table&gt;
indvdum@0
  1279
</pre></div>
indvdum@0
  1280
indvdum@0
  1281
<p>This will cause the row cell to be output using class row1 when the row count is even, and class row2 otherwise. The S_ROW_COUNT parameter gets assigned to loops by default. Another example would be the following: </p>
indvdum@0
  1282
indvdum@0
  1283
<div class="codebox"><pre>
indvdum@0
  1284
&lt;table&gt;
indvdum@0
  1285
	<span class="comment">&lt;!-- IF loop&#46;S_ROW_COUNT &gt; 10 --&gt;</span>
indvdum@0
  1286
		&lt;tr bgcolor=&quot;#FF0000&quot;&gt;
indvdum@0
  1287
	<span class="comment">&lt;!-- ELSEIF loop&#46;S_ROW_COUNT &gt; 5 --&gt;</span>
indvdum@0
  1288
		&lt;tr bgcolor=&quot;#00FF00&quot;&gt;
indvdum@0
  1289
	<span class="comment">&lt;!-- ELSEIF loop&#46;S_ROW_COUNT &gt; 2 --&gt;</span>
indvdum@0
  1290
		&lt;tr bgcolor=&quot;#0000FF&quot;&gt;
indvdum@0
  1291
	<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1292
		&lt;tr bgcolor=&quot;#FF00FF&quot;&gt;
indvdum@0
  1293
	<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1294
	&lt;td&gt;hello!&lt;/td&gt;
indvdum@0
  1295
&lt;/tr&gt;
indvdum@0
  1296
&lt;/table&gt;
indvdum@0
  1297
</pre></div>
indvdum@0
  1298
indvdum@0
  1299
<p>This will output the row cell in purple for the first two rows, blue for rows 2 to 5, green for rows 5 to 10 and red for remainder. So, you could produce a &quot;nice&quot; gradient effect, for example.<br /><br />What else can you do? Well, you could use IF to do common checks on for example the login state of a user:</p>
indvdum@0
  1300
indvdum@0
  1301
<div class="codebox"><pre>
indvdum@0
  1302
<span class="comment">&lt;!-- IF S_USER_LOGGED_IN --&gt;</span>
indvdum@0
  1303
	markup
indvdum@0
  1304
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1305
</pre></div>
indvdum@0
  1306
indvdum@0
  1307
<p>This replaces the existing (fudged) method in 2.0.x using a zero length array and BEGIN/END.</p>
indvdum@0
  1308
indvdum@0
  1309
<h4>Extended syntax for Blocks/Loops</h4>
indvdum@0
  1310
indvdum@0
  1311
<p>Back to our loops - they had been extended with the following additions. Firstly you can set the start and end points of the loop. For example:</p>
indvdum@0
  1312
indvdum@0
  1313
<div class="codebox"><pre>
indvdum@0
  1314
<span class="comment">&lt;!-- BEGIN loopname(2) --&gt;</span>
indvdum@0
  1315
	markup
indvdum@0
  1316
<span class="comment">&lt;!-- END loopname --&gt;</span>
indvdum@0
  1317
</pre></div>
indvdum@0
  1318
indvdum@0
  1319
<p>Will start the loop on the third entry (note that indexes start at zero). Extensions of this are:
indvdum@0
  1320
<br /><br />
indvdum@0
  1321
<code>loopname(2)</code>: Will start the loop on the 3rd entry<br />
indvdum@0
  1322
<code>loopname(-2)</code>: Will start the loop two entries from the end<br />
indvdum@0
  1323
<code>loopname(3,4)</code>: Will start the loop on the fourth entry and end it on the fifth<br />
indvdum@0
  1324
<code>loopname(3,-4)</code>: Will start the loop on the fourth entry and end it four from last<br />
indvdum@0
  1325
</p>
indvdum@0
  1326
indvdum@0
  1327
<p>A further extension to begin is BEGINELSE:</p>
indvdum@0
  1328
indvdum@0
  1329
<div class="codebox"><pre>
indvdum@0
  1330
<span class="comment">&lt;!-- BEGIN loop --&gt;</span>
indvdum@0
  1331
	markup
indvdum@0
  1332
<span class="comment">&lt;!-- BEGINELSE --&gt;</span>
indvdum@0
  1333
	markup
indvdum@0
  1334
<span class="comment">&lt;!-- END loop --&gt;</span>
indvdum@0
  1335
</pre></div>
indvdum@0
  1336
indvdum@0
  1337
<p>This will cause the markup between <code>BEGINELSE</code> and <code>END</code> to be output if the loop contains no values. This is useful for forums with no topics (for example) ... in some ways it replaces &quot;bits of&quot; the existing &quot;switch_&quot; type control (the rest being replaced by conditionals).</p>
indvdum@0
  1338
indvdum@0
  1339
<p>Another way of checking if a loop contains values is by prefixing the loops name with a dot:</p>
indvdum@0
  1340
indvdum@0
  1341
<div class="codebox"><pre>
indvdum@0
  1342
<span class="comment">&lt;!-- IF .loop --&gt;</span>
indvdum@0
  1343
	<span class="comment">&lt;!-- BEGIN loop --&gt;</span>
indvdum@0
  1344
		markup
indvdum@0
  1345
	<span class="comment">&lt;!-- END loop --&gt;</span>
indvdum@0
  1346
<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1347
	markup
indvdum@0
  1348
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1349
</pre></div>
indvdum@0
  1350
indvdum@0
  1351
<p>You are even able to check the number of items within a loop by comparing it with values within the IF condition:</p>
indvdum@0
  1352
indvdum@0
  1353
<div class="codebox"><pre>
indvdum@0
  1354
<span class="comment">&lt;!-- IF .loop &gt; 2 --&gt;</span>
indvdum@0
  1355
	<span class="comment">&lt;!-- BEGIN loop --&gt;</span>
indvdum@0
  1356
		markup
indvdum@0
  1357
	<span class="comment">&lt;!-- END loop --&gt;</span>
indvdum@0
  1358
<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1359
	markup
indvdum@0
  1360
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1361
</pre></div>
indvdum@0
  1362
indvdum@0
  1363
<p>Nesting loops cause the conditionals needing prefixed with all loops from the outer one to the inner most. An illustration of this:</p>
indvdum@0
  1364
indvdum@0
  1365
<div class="codebox"><pre>
indvdum@0
  1366
<span class="comment">&lt;!-- BEGIN firstloop --&gt;</span>
indvdum@0
  1367
	{firstloop.MY_VARIABLE_FROM_FIRSTLOOP}
indvdum@0
  1368
indvdum@0
  1369
	<span class="comment">&lt;!-- BEGIN secondloop --&gt;</span>
indvdum@0
  1370
		{firstloop.secondloop.MY_VARIABLE_FROM_SECONDLOOP}
indvdum@0
  1371
	<span class="comment">&lt;!-- END secondloop --&gt;</span>
indvdum@0
  1372
<span class="comment">&lt;!-- END firstloop --&gt;</span>
indvdum@0
  1373
</pre></div>
indvdum@0
  1374
indvdum@0
  1375
<p>Sometimes it is necessary to break out of nested loops to be able to call another loop within the current iteration. This sounds a little bit confusing and it is not used very often. The following (rather complex) example shows this quite good - it also shows how you test for the first and last row in a loop (i will explain the example in detail further down):</p>
indvdum@0
  1376
indvdum@0
  1377
<div class="codebox"><pre>
indvdum@0
  1378
<span class="comment">&lt;!-- BEGIN l_block1 --&gt;</span>
indvdum@0
  1379
	<span class="comment">&lt;!-- IF l_block1.S_SELECTED --&gt;</span>
indvdum@0
  1380
		&lt;strong&gt;{l_block1.L_TITLE}&lt;/strong&gt;
indvdum@0
  1381
		<span class="comment">&lt;!-- IF S_PRIVMSGS --&gt;</span>
indvdum@0
  1382
indvdum@0
  1383
			<span class="comment">&lt;!-- the ! at the beginning of the loop name forces the loop to be not a nested one of l_block1 --&gt;</span>
indvdum@0
  1384
			<span class="comment">&lt;!-- BEGIN !folder --&gt;</span>
indvdum@0
  1385
				<span class="comment">&lt;!-- IF folder.S_FIRST_ROW --&gt;</span>
indvdum@0
  1386
					&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1387
				<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1388
indvdum@0
  1389
				&lt;li&gt;&lt;a href=&quot;{folder.U_FOLDER}&quot;&gt;{folder.FOLDER_NAME}&lt;/a&gt;&lt;/li&gt;
indvdum@0
  1390
indvdum@0
  1391
				<span class="comment">&lt;!-- IF folder.S_LAST_ROW --&gt;</span>
indvdum@0
  1392
					&lt;/ul&gt;
indvdum@0
  1393
				<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1394
			<span class="comment">&lt;!-- END !folder --&gt;</span>
indvdum@0
  1395
indvdum@0
  1396
		<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1397
indvdum@0
  1398
		&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1399
		<span class="comment">&lt;!-- BEGIN l_block2 --&gt;</span>
indvdum@0
  1400
			&lt;li&gt;
indvdum@0
  1401
				<span class="comment">&lt;!-- IF l_block1.l_block2.S_SELECTED --&gt;</span>
indvdum@0
  1402
					&lt;strong&gt;{l_block1.l_block2.L_TITLE}&lt;/strong&gt;
indvdum@0
  1403
				<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1404
					&lt;a href=&quot;{l_block1.l_block2.U_TITLE}&quot;&gt;{l_block1.l_block2.L_TITLE}&lt;/a&gt;
indvdum@0
  1405
				<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1406
			&lt;/li&gt;
indvdum@0
  1407
		<span class="comment">&lt;!-- END l_block2 --&gt;</span>
indvdum@0
  1408
		&lt;/ul&gt;
indvdum@0
  1409
	<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1410
		&lt;a class=&quot;nav&quot; href=&quot;{l_block1.U_TITLE}&quot;&gt;{l_block1.L_TITLE}&lt;/a&gt;
indvdum@0
  1411
	<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1412
<span class="comment">&lt;!-- END l_block1 --&gt;</span>
indvdum@0
  1413
</pre></div>
indvdum@0
  1414
indvdum@0
  1415
<p>Let us first concentrate on this part of the example:</p>
indvdum@0
  1416
indvdum@0
  1417
<div class="codebox"><pre>
indvdum@0
  1418
<span class="comment">&lt;!-- BEGIN l_block1 --&gt;</span>
indvdum@0
  1419
	<span class="comment">&lt;!-- IF l_block1.S_SELECTED --&gt;</span>
indvdum@0
  1420
		markup
indvdum@0
  1421
	<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1422
		&lt;a class=&quot;nav&quot; href=&quot;{l_block1.U_TITLE}&quot;&gt;{l_block1.L_TITLE}&lt;/a&gt;
indvdum@0
  1423
	<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1424
<span class="comment">&lt;!-- END l_block1 --&gt;</span>
indvdum@0
  1425
</pre></div>
indvdum@0
  1426
indvdum@0
  1427
<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>
indvdum@0
  1428
indvdum@0
  1429
<p>Let's have a closer look at the markup:</p>
indvdum@0
  1430
indvdum@0
  1431
<div class="codebox"><pre>
indvdum@0
  1432
<span class="comment">&lt;!-- BEGIN l_block1 --&gt;</span>
indvdum@0
  1433
.
indvdum@0
  1434
.
indvdum@0
  1435
	<span class="comment">&lt;!-- IF S_PRIVMSGS --&gt;</span>
indvdum@0
  1436
indvdum@0
  1437
		<span class="comment">&lt;!-- BEGIN !folder --&gt;</span>
indvdum@0
  1438
			<span class="comment">&lt;!-- IF folder.S_FIRST_ROW --&gt;</span>
indvdum@0
  1439
				&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1440
			<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1441
indvdum@0
  1442
			&lt;li&gt;&lt;a href=&quot;{folder.U_FOLDER}&quot;&gt;{folder.FOLDER_NAME}&lt;/a&gt;&lt;/li&gt;
indvdum@0
  1443
indvdum@0
  1444
			<span class="comment">&lt;!-- IF folder.S_LAST_ROW --&gt;</span>
indvdum@0
  1445
				&lt;/ul&gt;
indvdum@0
  1446
			<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1447
		<span class="comment">&lt;!-- END !folder --&gt;</span>
indvdum@0
  1448
indvdum@0
  1449
	<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1450
.
indvdum@0
  1451
.
indvdum@0
  1452
<span class="comment">&lt;!-- END l_block1 --&gt;</span>
indvdum@0
  1453
</pre></div>
indvdum@0
  1454
indvdum@0
  1455
<p>The <code>&lt;!-- IF S_PRIVMSGS --&gt;</code> statement clearly checks a global variable and not one within the loop, since the loop is not given here. So, if S_PRIVMSGS is true we execute the shown markup. Now, you see the <code>&lt;!-- BEGIN !folder --&gt;</code> statement. The exclamation mark is responsible for instructing the template engine to iterate through the main loop folder. So, we are now within the loop folder - with <code>&lt;!-- BEGIN folder --&gt;</code> we would have been within the loop <code>l_block1.folder</code> automatically as is the case with l_block2:</p>
indvdum@0
  1456
indvdum@0
  1457
<div class="codebox"><pre>
indvdum@0
  1458
<span class="comment">&lt;!-- BEGIN l_block1 --&gt;</span>
indvdum@0
  1459
.
indvdum@0
  1460
.
indvdum@0
  1461
	&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1462
	<span class="comment">&lt;!-- BEGIN l_block2 --&gt;</span>
indvdum@0
  1463
		&lt;li&gt;
indvdum@0
  1464
			<span class="comment">&lt;!-- IF l_block1.l_block2.S_SELECTED --&gt;</span>
indvdum@0
  1465
				&lt;strong&gt;{l_block1.l_block2.L_TITLE}&lt;/strong&gt;
indvdum@0
  1466
			<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1467
				&lt;a href=&quot;{l_block1.l_block2.U_TITLE}&quot;&gt;{l_block1.l_block2.L_TITLE}&lt;/a&gt;
indvdum@0
  1468
			<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1469
		&lt;/li&gt;
indvdum@0
  1470
	<span class="comment">&lt;!-- END l_block2 --&gt;</span>
indvdum@0
  1471
	&lt;/ul&gt;
indvdum@0
  1472
.
indvdum@0
  1473
.
indvdum@0
  1474
<span class="comment">&lt;!-- END l_block1 --&gt;</span>
indvdum@0
  1475
</pre></div>
indvdum@0
  1476
indvdum@0
  1477
<p>You see the difference? The loop l_block2 is a member of the loop l_block1 but the loop folder is a main loop.</p>
indvdum@0
  1478
indvdum@0
  1479
<p>Now back to our folder loop:</p>
indvdum@0
  1480
indvdum@0
  1481
<div class="codebox"><pre>
indvdum@0
  1482
<span class="comment">&lt;!-- IF folder.S_FIRST_ROW --&gt;</span>
indvdum@0
  1483
	&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1484
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1485
indvdum@0
  1486
&lt;li&gt;&lt;a href=&quot;{folder.U_FOLDER}&quot;&gt;{folder.FOLDER_NAME}&lt;/a&gt;&lt;/li&gt;
indvdum@0
  1487
indvdum@0
  1488
<span class="comment">&lt;!-- IF folder.S_LAST_ROW --&gt;</span>
indvdum@0
  1489
	&lt;/ul&gt;
indvdum@0
  1490
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1491
</pre></div>
indvdum@0
  1492
indvdum@0
  1493
<p>You may have wondered what the comparison to S_FIRST_ROW and S_LAST_ROW is about. If you haven't guessed already - it is checking for the first iteration of the loop with <code>S_FIRST_ROW</code> and the last iteration with <code>S_LAST_ROW</code>. This can come in handy quite often if you want to open or close design elements, like the above list. Let us imagine a folder loop build with three iterations, it would go this way:</p>
indvdum@0
  1494
indvdum@0
  1495
<div class="codebox"><pre>
indvdum@0
  1496
&lt;ul class=&quot;nav&quot;&gt; <span class="comment">&lt;!-- written on first iteration --&gt;</span>
indvdum@0
  1497
	&lt;li&gt;first element&lt;/li&gt; <span class="comment">&lt;!-- written on first iteration --&gt;</span>
indvdum@0
  1498
	&lt;li&gt;second element&lt;/li&gt; <span class="comment">&lt;!-- written on second iteration --&gt;</span>
indvdum@0
  1499
	&lt;li&gt;third element&lt;/li&gt; <span class="comment">&lt;!-- written on third iteration --&gt;</span>
indvdum@0
  1500
&lt;/ul&gt; <span class="comment">&lt;!-- written on third iteration --&gt;</span>
indvdum@0
  1501
</pre></div>
indvdum@0
  1502
indvdum@0
  1503
<p>As you can see, all three elements are written down as well as the markup for the first iteration and the last one. Sometimes you want to omit writing the general markup - for example:</p>
indvdum@0
  1504
indvdum@0
  1505
<div class="codebox"><pre>
indvdum@0
  1506
<span class="comment">&lt;!-- IF folder.S_FIRST_ROW --&gt;</span>
indvdum@0
  1507
	&lt;ul class=&quot;nav&quot;&gt;
indvdum@0
  1508
<span class="comment">&lt;!-- ELSEIF folder.S_LAST_ROW --&gt;</span>
indvdum@0
  1509
	&lt;/ul&gt;
indvdum@0
  1510
<span class="comment">&lt;!-- ELSE --&gt;</span>
indvdum@0
  1511
	&lt;li&gt;&lt;a href=&quot;{folder.U_FOLDER}&quot;&gt;{folder.FOLDER_NAME}&lt;/a&gt;&lt;/li&gt;
indvdum@0
  1512
<span class="comment">&lt;!-- ENDIF --&gt;</span>
indvdum@0
  1513
</pre></div>
indvdum@0
  1514
indvdum@0
  1515
<p>would result in the following markup:</p>
indvdum@0
  1516
indvdum@0
  1517
<div class="codebox"><pre>
indvdum@0
  1518
&lt;ul class=&quot;nav&quot;&gt; <span class="comment">&lt;!-- written on first iteration --&gt;</span>
indvdum@0
  1519
	&lt;li&gt;second element&lt;/li&gt; <span class="comment">&lt;!-- written on second iteration --&gt;</span>
indvdum@0
  1520
&lt;/ul&gt; <span class="comment">&lt;!-- written on third iteration --&gt;</span>
indvdum@0
  1521
</pre></div>
indvdum@0
  1522
indvdum@0
  1523
<p>Just always remember that processing is taking place from top to bottom.</p>
indvdum@0
  1524
indvdum@0
  1525
	<h4>Forms</h4>
indvdum@0
  1526
		<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>
indvdum@0
  1527
		<div class="codebox"><pre>
indvdum@0
  1528
&lt;form method=&quot;post&quot; id=&quot;mcp&quot; action=&quot;{U_POST_ACTION}&quot;&gt;
indvdum@0
  1529
indvdum@0
  1530
	&lt;fieldset class="submit-buttons"&gt;
indvdum@0
  1531
		&lt;input type=&quot;reset&quot; value=&quot;{L_RESET}&quot; name=&quot;reset&quot; class=&quot;button2&quot; /&gt;&nbsp;
indvdum@0
  1532
		&lt;input type=&quot;submit&quot; name=&quot;action[add_warning]&quot; value=&quot;{L_SUBMIT}&quot; class=&quot;button1&quot; /&gt;
indvdum@0
  1533
		{S_FORM_TOKEN}
indvdum@0
  1534
	&lt;/fieldset&gt;
indvdum@0
  1535
&lt;/form&gt;
indvdum@0
  1536
		</pre></div><br />
indvdum@0
  1537
indvdum@0
  1538
	<a name="inheritance"></a><h3>4.ii. Template Inheritance</h3>
indvdum@0
  1539
		<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>
indvdum@0
  1540
indvdum@0
  1541
		<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>
indvdum@0
  1542
indvdum@0
  1543
		<p>We strongly encourage the use of inheritance for styles based on the bundled styles, as it will ease the update procedure.</p>
indvdum@0
  1544
indvdum@0
  1545
		<div class="codebox"><pre>
indvdum@0
  1546
        # General Information about this template
indvdum@0
  1547
        name = inherits
indvdum@0
  1548
        copyright = &copy; phpBB Group, 2007
indvdum@0
  1549
        version = 3.0.3
indvdum@0
  1550
indvdum@0
  1551
        # Defining a different template bitfield
indvdum@0
  1552
        template_bitfield = lNg=
indvdum@0
  1553
indvdum@0
  1554
        # Are we inheriting?
indvdum@0
  1555
        inherit_from = prosilver
indvdum@0
  1556
		</pre></div>
indvdum@0
  1557
indvdum@0
  1558
		</div>
indvdum@0
  1559
indvdum@0
  1560
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  1561
indvdum@0
  1562
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  1563
	</div>
indvdum@0
  1564
indvdum@0
  1565
	<hr />
indvdum@0
  1566
indvdum@0
  1567
indvdum@0
  1568
indvdum@0
  1569
<a name="charsets"></a><h2>5. Character Sets and Encodings</h2>
indvdum@0
  1570
indvdum@0
  1571
	<div class="paragraph">
indvdum@0
  1572
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
  1573
indvdum@0
  1574
		<div class="content">
indvdum@0
  1575
indvdum@0
  1576
indvdum@0
  1577
indvdum@0
  1578
<h4>What are Unicode, UCS and UTF-8?</h4>
indvdum@0
  1579
<p>The <a href="http://en.wikipedia.org/wiki/Universal_Character_Set">Universal Character Set (UCS)</a> described in ISO/IEC 10646 consists of a large amount of characters. Each of them has a unique name and a code point which is an integer number. <a href="http://en.wikipedia.org/wiki/Unicode">Unicode</a> - which is an industry standard - complements the Universal Character Set with further information about the characters' properties and alternative character encodings. More information on Unicode can be found on the <a href="http://www.unicode.org/">Unicode Consortium's website</a>. One of the Unicode encodings is the <a href="http://en.wikipedia.org/wiki/UTF-8">8-bit Unicode Transformation Format (UTF-8)</a>. It encodes characters with up to four bytes aiming for maximum compatibility with the <a href="http://en.wikipedia.org/wiki/ASCII">American Standard Code for Information Interchange</a> which is a 7-bit encoding of a relatively small subset of the UCS.</p>
indvdum@0
  1580
indvdum@0
  1581
<h4>phpBB's use of Unicode</h4>
indvdum@0
  1582
<p>Unfortunately PHP does not faciliate the use of Unicode prior to version 6. Most functions simply treat strings as sequences of bytes assuming that each character takes up exactly one byte. This behaviour still allows for storing UTF-8 encoded text in PHP strings but many operations on strings have unexpected results. To circumvent this problem we have created some alternative functions to PHP's native string operations which use code points instead of bytes. These functions can be found in <code>/includes/utf/utf_tools.php</code>. They are also covered in the <a href="http://area51.phpbb.com/docs/code/">phpBB3 Sourcecode Documentation</a>. A lot of native PHP functions still work with UTF-8 as long as you stick to certain restrictions. For example <code>explode</code> still works as long as the first and the last character of the delimiter string are ASCII characters.</p>
indvdum@0
  1583
indvdum@0
  1584
<p>phpBB only uses the ASCII and the UTF-8 character encodings. Still all Strings are UTF-8 encoded because ASCII is a subset of UTF-8. The only exceptions to this rule are code sections which deal with external systems which use other encodings and character sets. Such external data should be converted to UTF-8 using the <code>utf8_recode()</code> function supplied with phpBB. It supports a variety of other character sets and encodings, a full list can be found below.</p>
indvdum@0
  1585
indvdum@0
  1586
<p>With <code>request_var()</code> you can either allow all UCS characters in user input or restrict user input to ASCII characters. This feature is controlled by the function's third parameter called <code>$multibyte</code>. You should allow multibyte characters in posts, PMs, topic titles, forum names, etc. but it's not necessary for internal uses like a <code>$mode</code> variable which should only hold a predefined list of ASCII strings anyway.</p>
indvdum@0
  1587
indvdum@0
  1588
<div class="codebox"><pre>
indvdum@0
  1589
// an input string containing a multibyte character
indvdum@0
  1590
$_REQUEST['multibyte_string'] = 'K&#228;se';
indvdum@0
  1591
indvdum@0
  1592
// print request variable as a UTF-8 string allowing multibyte characters
indvdum@0
  1593
echo request_var('multibyte_string', '', true);
indvdum@0
  1594
// print request variable as ASCII string
indvdum@0
  1595
echo request_var('multibyte_string', '');
indvdum@0
  1596
</pre></div>
indvdum@0
  1597
indvdum@0
  1598
<p>This code snippet will generate the following output:</p>
indvdum@0
  1599
indvdum@0
  1600
<div class="codebox"><pre>
indvdum@0
  1601
K&#228;se
indvdum@0
  1602
K??se
indvdum@0
  1603
</pre></div>
indvdum@0
  1604
indvdum@0
  1605
<h4>Unicode Normalization</h4>
indvdum@0
  1606
indvdum@0
  1607
<p>If you retrieve user input with multibyte characters you should additionally normalize the string using <code>utf8_normalize_nfc()</code> before you work with it. This is necessary to make sure that equal characters can only occur in one particular binary representation. For example the character &#197; can be represented either as <code>U+00C5</code> (LATIN CAPITAL LETTER A WITH RING ABOVE) or as <code>U+212B</code> (ANGSTROM SIGN). phpBB uses Normalization Form Canonical Composition (NFC) for all text. So the correct version of the above example would look like this:</p>
indvdum@0
  1608
indvdum@0
  1609
<div class="codebox"><pre>
indvdum@0
  1610
$_REQUEST['multibyte_string'] = 'K&#228;se';
indvdum@0
  1611
indvdum@0
  1612
// normalize multibyte strings
indvdum@0
  1613
echo utf8_normalize_nfc(request_var('multibyte_string', '', true));
indvdum@0
  1614
// ASCII strings do not need to be normalized
indvdum@0
  1615
echo request_var('multibyte_string', '');
indvdum@0
  1616
</pre></div>
indvdum@0
  1617
indvdum@0
  1618
<h4>Case Folding</h4>
indvdum@0
  1619
indvdum@0
  1620
<p>Case insensitive comparison of strings is no longer possible with <code>strtolower</code> or <code>strtoupper</code> as some characters have multiple lower case or multiple upper case forms depending on their position in a word. The <code>utf8_strtolower</code> and the <code>utf8_strtoupper</code> functions suffer from the same problem so they can only be used to display upper/lower case versions of a string but they cannot be used for case insensitive comparisons either. So instead you should use case folding which gives you a case insensitive version of the string which can be used for case insensitive comparisons. An NFC normalized string can be case folded using <code>utf8_case_fold_nfc()</code>.</p>
indvdum@0
  1621
indvdum@0
  1622
<p class="bad">// Bad - The strings might be the same even if strtolower differs</p>
indvdum@0
  1623
indvdum@0
  1624
<div class="codebox"><pre>
indvdum@0
  1625
if (strtolower($string1) == strtolower($string2))
indvdum@0
  1626
{
indvdum@0
  1627
	echo '$string1 and $string2 are equal or differ in case';
indvdum@0
  1628
}
indvdum@0
  1629
</pre></div>
indvdum@0
  1630
indvdum@0
  1631
<p class="good">// Good - Case folding is really case insensitive</p>
indvdum@0
  1632
indvdum@0
  1633
<div class="codebox"><pre>
indvdum@0
  1634
if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
indvdum@0
  1635
{
indvdum@0
  1636
	echo '$string1 and $string2 are equal or differ in case';
indvdum@0
  1637
}
indvdum@0
  1638
</pre></div>
indvdum@0
  1639
indvdum@0
  1640
<h4>Confusables Detection</h4>
indvdum@0
  1641
indvdum@0
  1642
<p>phpBB offers a special method <code>utf8_clean_string</code> which can be used to make sure string identifiers are unique. This method uses Normalization Form Compatibility Composition (NFKC) instead of NFC and replaces similarly looking characters with a particular representative of the equivalence class. This method is currently used for usernames and group names to avoid confusion with similarly looking names.</p>
indvdum@0
  1643
indvdum@0
  1644
		</div>
indvdum@0
  1645
indvdum@0
  1646
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  1647
indvdum@0
  1648
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  1649
	</div>
indvdum@0
  1650
indvdum@0
  1651
	<hr />
indvdum@0
  1652
indvdum@0
  1653
<a name="translation"></a><h2>6. Translation (<abbr title="Internationalisation">i18n</abbr>/<abbr title="Localisation">L10n</abbr>) Guidelines</h2>
indvdum@0
  1654
indvdum@0
  1655
	<div class="paragraph">
indvdum@0
  1656
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
  1657
indvdum@0
  1658
		<div class="content">
indvdum@0
  1659
indvdum@0
  1660
	<a name="standardisation"></a><h3>6.i. Standardisation</h3>
indvdum@0
  1661
indvdum@0
  1662
	<h4>Reason:</h4>
indvdum@0
  1663
indvdum@0
  1664
	<p>phpBB is one of the most translated open-source projects, with the current stable version being available in over 60 localisations. Whilst the ad hoc approach to the naming of language packs has worked, for phpBB3 and beyond we hope to make this process saner which will allow for better interoperation with current and future web browsers.</p>
indvdum@0
  1665
indvdum@0
  1666
	<h4>Encoding:</h4>
indvdum@0
  1667
indvdum@0
  1668
	<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>
indvdum@0
  1669
indvdum@0
  1670
	<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>
indvdum@0
  1671
indvdum@0
  1672
	<h4>Language Tag:</h4>
indvdum@0
  1673
indvdum@0
  1674
	<p>The <abbr title="Internet Engineering Task Force">IETF</abbr> recently published <a href="http://tools.ietf.org/html/rfc4646">RFC 4646</a> for tags used to identify languages, which in combination with <a href="http://tools.ietf.org/html/rfc4647">RFC 4647</a> obseletes the older <a href="http://tools.ietf.org/html/rfc3066">RFC 3006</a> and older-still <a href="http://tools.ietf.org/html/rfc1766">RFC 1766</a>. <a href="http://tools.ietf.org/html/rfc4646">RFC 4646</a> uses <a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO 639-1/ISO 639-2</a>, <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a>, <a href="http://www.unicode.org/iso15924/iso15924-codes.html">ISO 15924</a> and <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a> to define a language tag. Each complete tag is composed of subtags which are not case sensitive and can also be empty.</p>
indvdum@0
  1675
indvdum@0
  1676
	<p>Ordering of the subtags in the case that they are all non-empty is: <code>language</code>-<code>script</code>-<code>region</code>-<code>variant</code>-<code>extension</code>-<code>privateuse</code>. Should any subtag be empty, its corresponding hyphen would also be ommited. Thus, the language tag for English will be <code>en</code> <strong>and not</strong> <code>en-----</code>.</p>
indvdum@0
  1677
indvdum@0
  1678
	<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>
indvdum@0
  1679
indvdum@0
  1680
	<table summary="Examples of various possible language tags as described by RFC 4646 and RFC 4647">
indvdum@0
  1681
	<caption>Language tag examples</caption>
indvdum@0
  1682
	<thead>
indvdum@0
  1683
	<tr>
indvdum@0
  1684
		<th scope="col">Language tag</th>
indvdum@0
  1685
		<th scope="col">Description</th>
indvdum@0
  1686
		<th scope="col">Component subtags</th>
indvdum@0
  1687
	</tr>
indvdum@0
  1688
	</thead>
indvdum@0
  1689
	<tbody>
indvdum@0
  1690
	<tr>
indvdum@0
  1691
		<td><code>en</code></td>
indvdum@0
  1692
		<td>English</td>
indvdum@0
  1693
		<td><code>language</code></td>
indvdum@0
  1694
	</tr>
indvdum@0
  1695
	<tr>
indvdum@0
  1696
		<td><code>mas</code></td>
indvdum@0
  1697
		<td>Masai</td>
indvdum@0
  1698
		<td><code>language</code></td>
indvdum@0
  1699
	</tr>
indvdum@0
  1700
	<tr>
indvdum@0
  1701
		<td><code>fr-CA</code></td>
indvdum@0
  1702
		<td>French as used in Canada</td>
indvdum@0
  1703
		<td><code>language</code>+<code>region</code></td>
indvdum@0
  1704
	</tr>
indvdum@0
  1705
	<tr>
indvdum@0
  1706
		<td><code>en-833</code></td>
indvdum@0
  1707
		<td>English as used in the Isle of Man</td>
indvdum@0
  1708
		<td><code>language</code>+<code>region</code></td>
indvdum@0
  1709
	</tr>
indvdum@0
  1710
	<tr>
indvdum@0
  1711
		<td><code>zh-Hans</code></td>
indvdum@0
  1712
		<td>Chinese written with Simplified script</td>
indvdum@0
  1713
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1714
	</tr>
indvdum@0
  1715
	<tr>
indvdum@0
  1716
		<td><code>zh-Hant-HK</code></td>
indvdum@0
  1717
		<td>Chinese written with Traditional script as used in Hong Kong</td>
indvdum@0
  1718
		<td><code>language</code>+<code>script</code>+<code>region</code></td>
indvdum@0
  1719
	</tr>
indvdum@0
  1720
	<tr>
indvdum@0
  1721
		<td><code>de-AT-1996</code></td>
indvdum@0
  1722
		<td>German as used in Austria with 1996 orthography</td>
indvdum@0
  1723
		<td><code>language</code>+<code>region</code>+<code>variant</code></td>
indvdum@0
  1724
	</tr>
indvdum@0
  1725
	</tbody>
indvdum@0
  1726
	</table>
indvdum@0
  1727
indvdum@0
  1728
	<p>The ultimate aim of a language tag is to convey the needed <strong>useful distingushing information</strong>, whilst keeping it as <strong>short as possible</strong>. So for example, use <code>en</code>, <code>fr</code> and <code>ja</code> as opposed to <code>en-GB</code>, <code>fr-FR</code> and <code>ja-JP</code>, since we know English, French and Japanese are the native language of Great Britain, France and Japan respectively.</p>
indvdum@0
  1729
indvdum@0
  1730
	<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>
indvdum@0
  1731
indvdum@0
  1732
	<table summary="Examples of using a language subtag in combination with a script subtag">
indvdum@0
  1733
	<caption>Language subtag + script subtag examples</caption>
indvdum@0
  1734
	<thead>
indvdum@0
  1735
	<tr>
indvdum@0
  1736
		<th scope="col">Language tag</th>
indvdum@0
  1737
		<th scope="col">Description</th>
indvdum@0
  1738
		<th scope="col">Component subtags</th>
indvdum@0
  1739
	</tr>
indvdum@0
  1740
	</thead>
indvdum@0
  1741
	<tbody>
indvdum@0
  1742
	<tr>
indvdum@0
  1743
		<td><code>en-Brai</code></td>
indvdum@0
  1744
		<td>English written in Braille script</td>
indvdum@0
  1745
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1746
	</tr>
indvdum@0
  1747
	<tr>
indvdum@0
  1748
		<td><code>en-Dsrt</code></td>
indvdum@0
  1749
		<td>English written in Deseret (Mormon) script</td>
indvdum@0
  1750
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1751
	</tr>
indvdum@0
  1752
	<tr>
indvdum@0
  1753
		<td><code>sr-Latn</code></td>
indvdum@0
  1754
		<td>Serbian written in Latin script</td>
indvdum@0
  1755
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1756
	</tr>
indvdum@0
  1757
	<tr>
indvdum@0
  1758
		<td><code>sr-Cyrl</code></td>
indvdum@0
  1759
		<td>Serbian written in Cyrillic script</td>
indvdum@0
  1760
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1761
	</tr>
indvdum@0
  1762
	<tr>
indvdum@0
  1763
		<td><code>mn-Mong</code></td>
indvdum@0
  1764
		<td>Mongolian written in Mongolian script</td>
indvdum@0
  1765
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1766
	</tr>
indvdum@0
  1767
	<tr>
indvdum@0
  1768
		<td><code>mn-Cyrl</code></td>
indvdum@0
  1769
		<td>Mongolian written in Cyrillic script</td>
indvdum@0
  1770
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1771
	</tr>
indvdum@0
  1772
	<tr>
indvdum@0
  1773
		<td><code>mn-Phag</code></td>
indvdum@0
  1774
		<td>Mongolian written in Phags-pa script</td>
indvdum@0
  1775
		<td><code>language</code>+<code>script</code></td>
indvdum@0
  1776
	</tr>
indvdum@0
  1777
	<tr>
indvdum@0
  1778
		<td><code>az-Cyrl-AZ</code></td>
indvdum@0
  1779
		<td>Azerbaijani written in Cyrillic script as used in Azerbaijan</td>
indvdum@0
  1780
		<td><code>language</code>+<code>script</code>+<code>region</code></td>
indvdum@0
  1781
	</tr>
indvdum@0
  1782
	<tr>
indvdum@0
  1783
		<td><code>az-Latn-AZ</code></td>
indvdum@0
  1784
		<td>Azerbaijani written in Latin script as used in Azerbaijan</td>
indvdum@0
  1785
		<td><code>language</code>+<code>script</code>+<code>region</code></td>
indvdum@0
  1786
	</tr>
indvdum@0
  1787
	<tr>
indvdum@0
  1788
		<td><code>az-Arab-IR</code></td>
indvdum@0
  1789
		<td>Azerbaijani written in Arabic script as used in Iran</td>
indvdum@0
  1790
		<td><code>language</code>+<code>script</code>+<code>region</code></td>
indvdum@0
  1791
	</tr>
indvdum@0
  1792
	</tbody>
indvdum@0
  1793
	</table>
indvdum@0
  1794
indvdum@0
  1795
	<p>Usage of the three-digit <a href="http://unstats.un.org/unsd/methods/m49/m49.htm">UN M.49</a> code over the two-letter <a href="http://www.iso.ch/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/list-en1.html">ISO 3166-1 alpha-2</a> code should hapen if a macro-geographical entity is required and/or 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.</p>
indvdum@0
  1796
indvdum@0
  1797
	<p>Examples of English using marco-geographical regions:</p>
indvdum@0
  1798
indvdum@0
  1799
	<table summary="Examples for English of ISO 3166-1 alpha-2 vs. UN M.49 code">
indvdum@0
  1800
	<caption>Coding for English using macro-geographical regions</caption>
indvdum@0
  1801
	<thead>
indvdum@0
  1802
	<tr>
indvdum@0
  1803
		<th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th>
indvdum@0
  1804
		<th scope="col" colspan="2">ISO 639-1/ISO 639-2 + UN M.49 (Example macro regions)</th>
indvdum@0
  1805
	</tr>
indvdum@0
  1806
	</thead>
indvdum@0
  1807
	<tbody>
indvdum@0
  1808
	<tr>
indvdum@0
  1809
		<td><dl><dt><code>en-AU</code></dt><dd>English as used in <strong>Australia</strong></dd></dl></td>
indvdum@0
  1810
		<td rowspan="2"><dl><dt><code>en-053</code></dt><dd>English as used in <strong>Australia &amp; New Zealand</strong></dd></dl></td>
indvdum@0
  1811
		<td rowspan="3"><dl><dt><code>en-009</code></dt><dd>English as used in <strong>Oceania</strong></dd></dl></td>
indvdum@0
  1812
	</tr>
indvdum@0
  1813
	<tr>
indvdum@0
  1814
		<td><dl><dt><code>en-NZ</code></dt><dd>English as used in <strong>New Zealand</strong></dd></dl></td>
indvdum@0
  1815
	</tr>
indvdum@0
  1816
	<tr>
indvdum@0
  1817
		<td><dl><dt><code>en-FJ</code></dt><dd>English as used in <strong>Fiji</strong></dd></dl></td>
indvdum@0
  1818
		<td><dl><dt><code>en-054 </code></dt><dd>English as used in <strong>Melanesia</strong></dd></dl></td>
indvdum@0
  1819
	</tr>
indvdum@0
  1820
	</tbody>
indvdum@0
  1821
	</table>
indvdum@0
  1822
indvdum@0
  1823
	<p>Examples of Spanish using marco-geographical regions:</p>
indvdum@0
  1824
indvdum@0
  1825
	<table summary="Examples for Spanish of ISO 3166-1 alpha-2 vs. UN M.49 code">
indvdum@0
  1826
	<caption>Coding for Spanish macro-geographical regions</caption>
indvdum@0
  1827
	<thead>
indvdum@0
  1828
	<tr>
indvdum@0
  1829
		<th scope="col">ISO 639-1/ISO 639-2 + ISO 3166-1 alpha-2</th>
indvdum@0
  1830
		<th scope="col" colspan="2">ISO 639-1/ISO 639-2 + UN M.49 (Example macro regions)</th>
indvdum@0
  1831
	</tr>
indvdum@0
  1832
	</thead>
indvdum@0
  1833
	<tbody>
indvdum@0
  1834
	<tr>
indvdum@0
  1835
		<td><dl><dt><code>es-PR</code></dt><dd>Spanish as used in <strong>Puerto Rico</strong></dd></dl></td>
indvdum@0
  1836
		<td rowspan="3"><dl><dt><code>es-419</code></dt><dd>Spanish as used in <strong>Latin America &amp; the Caribbean</strong></dd></dl></td>
indvdum@0
  1837
		<td rowspan="4"><dl><dt><code>es-019</code></dt><dd>Spanish as used in <strong>the Americas</strong></dd></dl></td>
indvdum@0
  1838
	</tr>
indvdum@0
  1839
	<tr>
indvdum@0
  1840
		<td><dl><dt><code>es-HN</code></dt><dd>Spanish as used in <strong>Honduras</strong></dd></dl></td>
indvdum@0
  1841
	</tr>
indvdum@0
  1842
	<tr>
indvdum@0
  1843
		<td><dl><dt><code>es-AR</code></dt><dd>Spanish as used in <strong>Argentina</strong></dd></dl></td>
indvdum@0
  1844
	</tr>
indvdum@0
  1845
	<tr>
indvdum@0
  1846
		<td><dl><dt><code>es-US</code></dt><dd>Spanish as used in <strong>United States of America</strong></dd></dl></td>
indvdum@0
  1847
		<td><dl><dt><code>es-021</code></dt><dd>Spanish as used in <strong>North America</strong></dd></dl></td>
indvdum@0
  1848
	</tr>
indvdum@0
  1849
	</tbody>
indvdum@0
  1850
	</table>
indvdum@0
  1851
indvdum@0
  1852
	<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>
indvdum@0
  1853
indvdum@0
  1854
	<table summary="Example where the ISO 3166-1 alpha-2 is ambiguous">
indvdum@0
  1855
	<caption>Coding for ambiguous ISO 3166-1 alpha-2 regions</caption>
indvdum@0
  1856
	<thead>
indvdum@0
  1857
	<tr>
indvdum@0
  1858
		<th scope="col" colspan="2"><code>CS</code> assignment pre-1994</th>
indvdum@0
  1859
		<th scope="col" colspan="2"><code>CS</code> assignment post-1994</th>
indvdum@0
  1860
	</tr>
indvdum@0
  1861
	</thead>
indvdum@0
  1862
	<tbody>
indvdum@0
  1863
	<tr>
indvdum@0
  1864
		<td colspan="2">
indvdum@0
  1865
		<dl>
indvdum@0
  1866
		<dt><code>CS</code></dt><dd><strong>Czechoslovakia</strong> (ISO 3166-1)</dd>
indvdum@0
  1867
		<dt><code>200</code></dt><dd><strong>Czechoslovakia</strong> (UN M.49)</dd>
indvdum@0
  1868
		</dl>
indvdum@0
  1869
		</td>
indvdum@0
  1870
		<td colspan="2">
indvdum@0
  1871
		<dl>
indvdum@0
  1872
		<dt><code>CS</code></dt><dd><strong>Serbian &amp; Montenegro</strong> (ISO 3166-1)</dd>
indvdum@0
  1873
		<dt><code>891</code></dt><dd><strong>Serbian &amp; Montenegro</strong> (UN M.49)</dd>
indvdum@0
  1874
		</dl>
indvdum@0
  1875
		</td>
indvdum@0
  1876
	</tr>
indvdum@0
  1877
	<tr>
indvdum@0
  1878
		<td>
indvdum@0
  1879
		<dl>
indvdum@0
  1880
		<dt><code>CZ</code></dt><dd><strong>Czech Republic</strong> (ISO 3166-1)</dd>
indvdum@0
  1881
		<dt><code>203</code></dt><dd><strong>Czech Republic</strong> (UN M.49)</dd>
indvdum@0
  1882
		</dl>
indvdum@0
  1883
		</td>
indvdum@0
  1884
		<td>
indvdum@0
  1885
		<dl>
indvdum@0
  1886
		<dt><code>SK</code></dt><dd><strong>Slovakia</strong> (ISO 3166-1)</dd>
indvdum@0
  1887
		<dt><code>703</code></dt><dd><strong>Slovakia</strong> (UN M.49)</dd>
indvdum@0
  1888
		</dl>
indvdum@0
  1889
		</td>
indvdum@0
  1890
		<td>
indvdum@0
  1891
		<dl>
indvdum@0
  1892
		<dt><code>RS</code></dt><dd><strong>Serbia</strong> (ISO 3166-1)</dd>
indvdum@0
  1893
		<dt><code>688</code></dt><dd><strong>Serbia</strong> (UN M.49)</dd>
indvdum@0
  1894
		</dl>
indvdum@0
  1895
		</td>
indvdum@0
  1896
		<td>
indvdum@0
  1897
		<dl>
indvdum@0
  1898
		<dt><code>ME</code></dt><dd><strong>Montenegro</strong> (ISO 3166-1)</dd>
indvdum@0
  1899
		<dt><code>499</code></dt><dd><strong>Montenegro</strong> (UN M.49)</dd>
indvdum@0
  1900
		</dl>
indvdum@0
  1901
		</td>
indvdum@0
  1902
	</tr>
indvdum@0
  1903
	</tbody>
indvdum@0
  1904
	</table>
indvdum@0
  1905
indvdum@0
  1906
	<h4>Macro-languages &amp; Topolects:</h4>
indvdum@0
  1907
indvdum@0
  1908
	<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>
indvdum@0
  1909
indvdum@0
  1910
	<table summary="Examples of macrolanguages used with sub-language subtags">
indvdum@0
  1911
	<caption>Macrolanguage subtag + sub-language subtag examples</caption>
indvdum@0
  1912
	<thead>
indvdum@0
  1913
	<tr>
indvdum@0
  1914
		<th scope="col">Language tag</th>
indvdum@0
  1915
		<th scope="col">Description</th>
indvdum@0
  1916
		<th scope="col">Component subtags</th>
indvdum@0
  1917
	</tr>
indvdum@0
  1918
	</thead>
indvdum@0
  1919
	<tbody>
indvdum@0
  1920
	<tr>
indvdum@0
  1921
		<td><code>zh-cmn</code></td>
indvdum@0
  1922
		<td>Mandarin (Putonghau/Guoyu) Chinese</td>
indvdum@0
  1923
		<td><code>macrolanguage</code>+<code>sublanguage</code></td>
indvdum@0
  1924
	</tr>
indvdum@0
  1925
	<tr>
indvdum@0
  1926
		<td><code>zh-yue</code></td>
indvdum@0
  1927
		<td>Yue (Cantonese) Chinese</td>
indvdum@0
  1928
		<td><code>macrolanguage</code>+<code>sublanguage</code></td>
indvdum@0
  1929
	</tr>
indvdum@0
  1930
	<tr>
indvdum@0
  1931
		<td><code>zh-cmn-Hans</code></td>
indvdum@0
  1932
		<td>Mandarin (Putonghau/Guoyu) Chinese written in Simplified script</td>
indvdum@0
  1933
		<td><code>macrolanguage</code>+<code>sublanguage</code>+<code>script</code></td>
indvdum@0
  1934
	</tr>
indvdum@0
  1935
	<tr>
indvdum@0
  1936
		<td><code>zh-cmn-Hant</code></td>
indvdum@0
  1937
		<td>Mandarin (Putonghau/Guoyu) Chinese written in Traditional script</td>
indvdum@0
  1938
		<td><code>macrolanguage</code>+<code>sublanguage</code>+<code>script</code></td>
indvdum@0
  1939
	</tr>
indvdum@0
  1940
	<tr>
indvdum@0
  1941
		<td><code>zh-nan-Latn-TW</code></td>
indvdum@0
  1942
		<td>Minnan (Hoklo) Chinese written in Latin script (POJ Romanisation) as used in Taiwan</td>
indvdum@0
  1943
		<td><code>macrolanguage</code>+<code>sublanguage</code>+<code>script</code>+<code>region</code></td>
indvdum@0
  1944
	</tr>
indvdum@0
  1945
	</tbody>
indvdum@0
  1946
	</table>
indvdum@0
  1947
indvdum@0
  1948
	<a name="otherconsiderations"></a><h3>6.ii. Other considerations</h3>
indvdum@0
  1949
indvdum@0
  1950
	<h4>Normalisation of language tags for phpBB:</h4>
indvdum@0
  1951
indvdum@0
  1952
	<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>
indvdum@0
  1953
indvdum@0
  1954
	<table summary="Normalisation of language tags for usage in phpBB">
indvdum@0
  1955
	<caption>Language tag normalisation examples</caption>
indvdum@0
  1956
	<thead>
indvdum@0
  1957
	<tr>
indvdum@0
  1958
		<th scope="col">Raw language tag</th>
indvdum@0
  1959
		<th scope="col">Description</th>
indvdum@0
  1960
		<th scope="col">Value of <code>USER_LANG</code><br />in <code>./common.php</code></th>
indvdum@0
  1961
		<th scope="col">Language pack directory<br />name in <code>/language/</code></th>
indvdum@0
  1962
	</tr>
indvdum@0
  1963
	</thead>
indvdum@0
  1964
	<tbody>
indvdum@0
  1965
	<tr>
indvdum@0
  1966
		<td><code>en</code></td>
indvdum@0
  1967
		<td>British English</td>
indvdum@0
  1968
		<td><code>en</code></td>
indvdum@0
  1969
		<td><code>en</code></td>
indvdum@0
  1970
	</tr>
indvdum@0
  1971
	<tr>
indvdum@0
  1972
		<td><code>de-AT</code></td>
indvdum@0
  1973
		<td>German as used in Austria</td>
indvdum@0
  1974
		<td><code>de-at</code></td>
indvdum@0
  1975
		<td><code>de_at</code></td>
indvdum@0
  1976
	</tr>
indvdum@0
  1977
	<tr>
indvdum@0
  1978
		<td><code>es-419</code></td>
indvdum@0
  1979
		<td>Spanish as used in Latin America &amp; Caribbean</td>
indvdum@0
  1980
		<td><code>en-419</code></td>
indvdum@0
  1981
		<td><code>en_419</code></td>
indvdum@0
  1982
	</tr>
indvdum@0
  1983
	<tr>
indvdum@0
  1984
		<td><code>zh-yue-Hant-HK</code></td>
indvdum@0
  1985
		<td>Cantonese written in Traditional script as used in Hong Kong</td>
indvdum@0
  1986
		<td><code>zh-yue-hant-hk</code></td>
indvdum@0
  1987
		<td><code>zh_yue_hant_hk</code></td>
indvdum@0
  1988
	</tr>
indvdum@0
  1989
	</tbody>
indvdum@0
  1990
	</table>
indvdum@0
  1991
indvdum@0
  1992
	<h4>How to use <code>iso.txt</code>:</h4>
indvdum@0
  1993
indvdum@0
  1994
	<p>The <code>iso.txt</code> file is a small UTF-8 encoded plain-text file which consists of three lines:</p>
indvdum@0
  1995
indvdum@0
  1996
	<ol>
indvdum@0
  1997
		<li><code>Language's English name</code></li>
indvdum@0
  1998
		<li><code>Language's local name</code></li>
indvdum@0
  1999
		<li><code>Authors information</code></li>
indvdum@0
  2000
	</ol>
indvdum@0
  2001
indvdum@0
  2002
	<p><code>iso.txt</code> is automatically generated by the language pack submission system on phpBB.com. You don't have to create this file yourself if you plan on releasing your language pack on phpBB.com, but do keep in mind that phpBB itself does require this file to be present.</p>
indvdum@0
  2003
indvdum@0
  2004
	<p>Because language tags themselves are meant to be machine read, they can be rather obtuse to humans and why descriptive strings as provided by <code>iso.txt</code> are needed. Whilst <code>en-US</code> could be fairly easily deduced to be "English as used in the United States", <code>de-CH</code> is more difficult less one happens to know that <code>de</code> is from "<span lang="de">Deutsch</span>", German for "German" and <code>CH</code> is the abbreviation of the official Latin name for Switzerland, "<span lang="la">Confoederatio Helvetica</span>".</p>
indvdum@0
  2005
indvdum@0
  2006
	<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>
indvdum@0
  2007
indvdum@0
  2008
	<table summary="English language description examples of iso.txt for usage in phpBB">
indvdum@0
  2009
	<caption>English language description examples for iso.txt</caption>
indvdum@0
  2010
	<thead>
indvdum@0
  2011
	<tr>
indvdum@0
  2012
		<th scope="col">Raw language tag</th>
indvdum@0
  2013
		<th scope="col">English description within <code>iso.txt</code></th>
indvdum@0
  2014
	</tr>
indvdum@0
  2015
	</thead>
indvdum@0
  2016
	<tbody>
indvdum@0
  2017
	<tr>
indvdum@0
  2018
		<td><code>en</code></td>
indvdum@0
  2019
		<td>British English</td>
indvdum@0
  2020
	</tr>
indvdum@0
  2021
	<tr>
indvdum@0
  2022
		<td><code>en-US</code></td>
indvdum@0
  2023
		<td>English (United States)</td>
indvdum@0
  2024
	</tr>
indvdum@0
  2025
	<tr>
indvdum@0
  2026
		<td><code>en-053</code></td>
indvdum@0
  2027
		<td>English (Australia &amp; New Zealand)</td>
indvdum@0
  2028
	</tr>
indvdum@0
  2029
	<tr>
indvdum@0
  2030
		<td><code>de</code></td>
indvdum@0
  2031
		<td>German</td>
indvdum@0
  2032
	</tr>
indvdum@0
  2033
	<tr>
indvdum@0
  2034
		<td><code>de-CH-1996</code></td>
indvdum@0
  2035
		<td>German (Switzerland, 1996 orthography)</td>
indvdum@0
  2036
	</tr>
indvdum@0
  2037
	<tr>
indvdum@0
  2038
		<td><code>gws-1996</code></td>
indvdum@0
  2039
		<td>Swiss German (1996 orthography)</td>
indvdum@0
  2040
	</tr>
indvdum@0
  2041
	<tr>
indvdum@0
  2042
		<td><code>zh-cmn-Hans-CN</code></td>
indvdum@0
  2043
		<td>Mandarin Chinese (Simplified, Mainland China)</td>
indvdum@0
  2044
	</tr>
indvdum@0
  2045
	<tr>
indvdum@0
  2046
		<td><code>zh-yue-Hant-HK</code></td>
indvdum@0
  2047
		<td>Cantonese Chinese (Traditional, Hong Kong)</td>
indvdum@0
  2048
	</tr>
indvdum@0
  2049
	</tbody>
indvdum@0
  2050
	</table>
indvdum@0
  2051
indvdum@0
  2052
	<p>For the localised language description, just translate the English version though use whatever appropriate punctuation typical for your own locale, assuming the language uses punctuation at all.</p>
indvdum@0
  2053
indvdum@0
  2054
	<h4>Unicode bi-directional considerations:</h4>
indvdum@0
  2055
indvdum@0
  2056
	<p>Because phpBB is now UTF-8, all translators must take into account that certain strings may be shown when the directionality of the document is either opposite to normal or is ambiguous.</p>
indvdum@0
  2057
indvdum@0
  2058
	<p>The various Unicode control characters for bi-directional text and their HTML enquivalents where appropriate are as follows:</p>
indvdum@0
  2059
indvdum@0
  2060
	<table summary="Table of the various Unicode bidirectional control characters">
indvdum@0
  2061
	<caption>Unicode bidirectional control characters &amp; HTML elements/entities</caption>
indvdum@0
  2062
	<thead>
indvdum@0
  2063
	<tr>
indvdum@0
  2064
		<th scope="col">Unicode character<br />abbreviation</th>
indvdum@0
  2065
		<th scope="col">Unicode<br />code-point</th>
indvdum@0
  2066
		<th scope="col">Unicode character<br />name</th>
indvdum@0
  2067
		<th scope="col">Equivalent HTML<br />markup/entity</th>
indvdum@0
  2068
		<th scope="col">Raw character<br />(enclosed between '')</th>
indvdum@0
  2069
	</tr>
indvdum@0
  2070
	</thead>
indvdum@0
  2071
	<tbody>
indvdum@0
  2072
	<tr>
indvdum@0
  2073
		<td><code>LRM</code></td>
indvdum@0
  2074
		<td><code>U+200E</code></td>
indvdum@0
  2075
		<td>Left-to-Right Mark</td>
indvdum@0
  2076
		<td><code>&amp;lrm;</code></td>
indvdum@0
  2077
		<td>'&#x200E;'</td>
indvdum@0
  2078
	</tr>
indvdum@0
  2079
	<tr>
indvdum@0
  2080
		<td><code>RLM</code></td>
indvdum@0
  2081
		<td><code>U+200F</code></td>
indvdum@0
  2082
		<td>Right-to-Left Mark</td>
indvdum@0
  2083
		<td><code>&amp;rlm;</code></td>
indvdum@0
  2084
		<td>'&#x200F;'</td>
indvdum@0
  2085
	</tr>
indvdum@0
  2086
	<tr>
indvdum@0
  2087
		<td><code>LRE</code></td>
indvdum@0
  2088
		<td><code>U+202A</code></td>
indvdum@0
  2089
		<td>Left-to-Right Embedding</td>
indvdum@0
  2090
		<td><code>dir=&quot;ltr&quot;</code></td>
indvdum@0
  2091
		<td>'&#x202A;'</td>
indvdum@0
  2092
	</tr>
indvdum@0
  2093
	<tr>
indvdum@0
  2094
		<td><code>RLE</code></td>
indvdum@0
  2095
		<td><code>U+202B</code></td>
indvdum@0
  2096
		<td>Right-to-Left Embedding</td>
indvdum@0
  2097
		<td><code>dir=&quot;rtl&quot;</code></td>
indvdum@0
  2098
		<td>'&#x202B;'</td>
indvdum@0
  2099
	</tr>
indvdum@0
  2100
	<tr>
indvdum@0
  2101
		<td><code>PDF</code></td>
indvdum@0
  2102
		<td><code>U+202C</code></td>
indvdum@0
  2103
		<td>Pop Directional Formatting</td>
indvdum@0
  2104
		<td><code>&lt;/bdo&gt;</code></td>
indvdum@0
  2105
		<td>'&#x202C;'</td>
indvdum@0
  2106
	</tr>
indvdum@0
  2107
	<tr>
indvdum@0
  2108
		<td><code>LRO</code></td>
indvdum@0
  2109
		<td><code>U+202D</code></td>
indvdum@0
  2110
		<td>Left-to-Right Override</td>
indvdum@0
  2111
		<td><code>&lt;bdo dir=&quot;ltr&quot;&gt;</code></td>
indvdum@0
  2112
		<td>'&#x202D;'</td>
indvdum@0
  2113
	</tr>
indvdum@0
  2114
	<tr>
indvdum@0
  2115
		<td><code>RLO</code></td>
indvdum@0
  2116
		<td><code>U+202E</code></td>
indvdum@0
  2117
		<td>Right-to-Left Override</td>
indvdum@0
  2118
		<td><code>&lt;bdo dir=&quot;rtl&quot;&gt;</code></td>
indvdum@0
  2119
		<td>'&#x202E;'</td>
indvdum@0
  2120
	</tr>
indvdum@0
  2121
	</tbody>
indvdum@0
  2122
	</table>
indvdum@0
  2123
indvdum@0
  2124
	<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>
indvdum@0
  2125
indvdum@0
  2126
	<table summary="Effect of using Unicode bidirectional control characters within iso.txt">
indvdum@0
  2127
	<caption>Unicode bidirectional control characters iso.txt</caption>
indvdum@0
  2128
	<thead>
indvdum@0
  2129
	<tr>
indvdum@0
  2130
		<th scope="col">Directionality</th>
indvdum@0
  2131
		<th scope="col">Raw character view</th>
indvdum@0
  2132
		<th scope="col">Display of localised<br />description in <code>iso.txt</code></th>
indvdum@0
  2133
		<th scope="col">Ordering</th>
indvdum@0
  2134
	</tr>
indvdum@0
  2135
	</thead>
indvdum@0
  2136
	<tbody>
indvdum@0
  2137
	<tr>
indvdum@0
  2138
		<td><code>dir=&quot;ltr&quot;</code></td>
indvdum@0
  2139
		<td>English (Australia &amp; New Zealand)</td>
indvdum@0
  2140
		<td dir="ltr">English (Australia &amp; New Zealand)</td>
indvdum@0
  2141
		<td class="good">Correct</td>
indvdum@0
  2142
	</tr>
indvdum@0
  2143
	<tr>
indvdum@0
  2144
		<td><code>dir=&quot;rtl&quot;</code></td>
indvdum@0
  2145
		<td>English (Australia &amp; New Zealand)</td>
indvdum@0
  2146
		<td dir="rtl">English (Australia &amp; New Zealand)</td>
indvdum@0
  2147
		<td class="bad">Incorrect</td>
indvdum@0
  2148
	</tr>
indvdum@0
  2149
	<tr>
indvdum@0
  2150
		<td><code>dir=&quot;rtl&quot;</code> with <code>LRM</code></td>
indvdum@0
  2151
		<td>English (Australia &amp; New Zealand)<code>U+200E</code></td>
indvdum@0
  2152
		<td dir="rtl">English (Australia &amp; New Zealand)&#x200E;</td>
indvdum@0
  2153
		<td class="good">Correct</td>
indvdum@0
  2154
	</tr>
indvdum@0
  2155
	<tr>
indvdum@0
  2156
		<td><code>dir=&quot;rtl&quot;</code> with <code>LRE</code> &amp; <code>PDF</code></td>
indvdum@0
  2157
		<td><code>U+202A</code>English (Australia &amp; New Zealand)<code>U+202C</code></td>
indvdum@0
  2158
		<td dir="rtl">&#x202A;English (Australia &amp; New Zealand)&#x202C;</td>
indvdum@0
  2159
		<td class="good">Correct</td>
indvdum@0
  2160
	</tr>
indvdum@0
  2161
	<tr>
indvdum@0
  2162
		<td><code>dir=&quot;rtl&quot;</code> with <code>LRO</code> &amp; <code>PDF</code></td>
indvdum@0
  2163
		<td><code>U+202D</code>English (Australia &amp; New Zealand)<code>U+202C</code></td>
indvdum@0
  2164
		<td dir="rtl">&#x202D;English (Australia &amp; New Zealand)&#x202C;</td>
indvdum@0
  2165
		<td class="good">Correct</td>
indvdum@0
  2166
	</tr>
indvdum@0
  2167
	</tbody>
indvdum@0
  2168
	</table>
indvdum@0
  2169
indvdum@0
  2170
	<p>In choosing which of the three methods to use, in the majority of cases, the <code>LRM</code> or <code>RLM</code> to put a &quot;strong&quot; character to fully enclose an ambiguous punctuation character and thus make it inherit the correct directionality is sufficient.</p>
indvdum@0
  2171
	<p>Within some cases, there may be mixed scripts of a left-to-right and right-to-left direction, so using <code>LRE</code> &amp; <code>RLE</code> with <code>PDF</code> may be more appropriate. Lastly, in very rare instances where directionality must be forced, then use <code>LRO</code> &amp; <code>RLO</code> with <code>PDF</code>.</p>
indvdum@0
  2172
	<p>For further information on authoring techniques of bi-directional text, please see the W3C tutorial on <a href="http://www.w3.org/International/tutorials/bidi-xhtml/">authoring techniques for XHTML pages with bi-directional text</a>.</p>
indvdum@0
  2173
indvdum@0
  2174
	<h4>Working with placeholders:</h4>
indvdum@0
  2175
indvdum@0
  2176
	<p>As phpBB is translated into languages with different ordering rules to that of English, it is possible to show specific values in any order deemed appropriate. Take for example the extremely simple &quot;Page <em>X</em> of <em>Y</em>&quot;, whilst in English this could just be coded as:</p>
indvdum@0
  2177
indvdum@0
  2178
	<div class="codebox"><pre>
indvdum@0
  2179
	...
indvdum@0
  2180
'PAGE_OF'	=&gt;	'Page %s of %s',
indvdum@0
  2181
		/* Just grabbing the replacements as they
indvdum@0
  2182
		come and hope they are in the right order */
indvdum@0
  2183
	...
indvdum@0
  2184
	</pre></div>
indvdum@0
  2185
indvdum@0
  2186
	<p>&hellip; a clearer way to show explicit replacement ordering is to do:</p>
indvdum@0
  2187
indvdum@0
  2188
	<div class="codebox"><pre>
indvdum@0
  2189
	...
indvdum@0
  2190
'PAGE_OF'	=&gt;	'Page %1$s of %2$s',
indvdum@0
  2191
		/* Explicit ordering of the replacements,
indvdum@0
  2192
		even if they are the same order as English */
indvdum@0
  2193
	...
indvdum@0
  2194
	</pre></div>
indvdum@0
  2195
indvdum@0
  2196
	<p>Why bother at all? Because some languages, the string transliterated back to English might read something like:</p>
indvdum@0
  2197
indvdum@0
  2198
	<div class="codebox"><pre>
indvdum@0
  2199
	...
indvdum@0
  2200
'PAGE_OF'	=&gt;	'Total of %2$s pages, currently on page %1$s',
indvdum@0
  2201
		/* Explicit ordering of the replacements,
indvdum@0
  2202
		reversed compared to English as the total comes first */
indvdum@0
  2203
	...
indvdum@0
  2204
	</pre></div>
indvdum@0
  2205
indvdum@0
  2206
	<a name="writingstyle"></a><h3>6.iii. Writing Style</h3>
indvdum@0
  2207
indvdum@0
  2208
	<h4>Miscellaneous tips &amp; hints:</h4>
indvdum@0
  2209
indvdum@0
  2210
	<p>As the language files are PHP files, where the various strings for phpBB are stored within an array which in turn are used for display within an HTML page, rules of syntax for both must be considered. Potentially problematic characters are: <code>'</code> (straight quote/apostrophe), <code>&quot;</code> (straight double quote), <code>&lt;</code> (less-than sign), <code>&gt;</code> (greater-than sign) and <code>&amp;</code> (ampersand).</p>
indvdum@0
  2211
indvdum@0
  2212
	<p class="bad">// Bad - The un-escapsed straight-quote/apostrophe will throw a PHP parse error</p>
indvdum@0
  2213
indvdum@0
  2214
	<div class="codebox"><pre>
indvdum@0
  2215
	...
indvdum@0
  2216
'CONV_ERROR_NO_AVATAR_PATH'
indvdum@0
  2217
	=&gt;	'Note to developer: you must specify $convertor['avatar_path'] to use %s.',
indvdum@0
  2218
	...
indvdum@0
  2219
	</pre></div>
indvdum@0
  2220
indvdum@0
  2221
	<p class="good">// Good - Literal straight quotes should be escaped with a backslash, ie: \</p>
indvdum@0
  2222
indvdum@0
  2223
	<div class="codebox"><pre>
indvdum@0
  2224
	...
indvdum@0
  2225
'CONV_ERROR_NO_AVATAR_PATH'
indvdum@0
  2226
	=&gt;	'Note to developer: you must specify $convertor[\'avatar_path\'] to use %s.',
indvdum@0
  2227
	...
indvdum@0
  2228
	</pre></div>
indvdum@0
  2229
indvdum@0
  2230
	<p>However, because phpBB3 now uses UTF-8 as its sole encoding, we can actually use this to our advantage and not have to remember to escape a straight quote when we don't have to:</p>
indvdum@0
  2231
indvdum@0
  2232
	<p class="bad">// Bad - The un-escapsed straight-quote/apostrophe will throw a PHP parse error</p>
indvdum@0
  2233
indvdum@0
  2234
	<div class="codebox"><pre>
indvdum@0
  2235
	...
indvdum@0
  2236
'USE_PERMISSIONS'	=&gt;	'Test out user's permissions',
indvdum@0
  2237
	...
indvdum@0
  2238
	</pre></div>
indvdum@0
  2239
indvdum@0
  2240
	<p class="good">// Okay - However, non-programmers wouldn't type "user\'s" automatically</p>
indvdum@0
  2241
indvdum@0
  2242
	<div class="codebox"><pre>
indvdum@0
  2243
	...
indvdum@0
  2244
'USE_PERMISSIONS'	=&gt;	'Test out user\'s permissions',
indvdum@0
  2245
	...
indvdum@0
  2246
	</pre></div>
indvdum@0
  2247
indvdum@0
  2248
	<p class="good">// Best - Use the Unicode Right-Single-Quotation-Mark character</p>
indvdum@0
  2249
indvdum@0
  2250
	<div class="codebox"><pre>
indvdum@0
  2251
	...
indvdum@0
  2252
'USE_PERMISSIONS'	=&gt;	'Test out user&rsquo;s permissions',
indvdum@0
  2253
	...
indvdum@0
  2254
	</pre></div>
indvdum@0
  2255
indvdum@0
  2256
	<p>The <code>&quot;</code> (straight double quote), <code>&lt;</code> (less-than sign) and <code>&gt;</code> (greater-than sign) characters can all be used as displayed glyphs or as part of HTML markup, for example:</p>
indvdum@0
  2257
indvdum@0
  2258
	<p class="bad">// Bad - Invalid HTML, as segments not part of elements are not entitised</p>
indvdum@0
  2259
indvdum@0
  2260
	<div class="codebox"><pre>
indvdum@0
  2261
	...
indvdum@0
  2262
'FOO_BAR'	=&gt;	'PHP version &lt; 4.3.3.&lt;br /&gt;
indvdum@0
  2263
	Visit &quot;Downloads&quot; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
indvdum@0
  2264
	...
indvdum@0
  2265
	</pre></div>
indvdum@0
  2266
indvdum@0
  2267
	<p class="good">// Okay - No more invalid HTML, but &quot;&amp;quot;&quot; is rather clumsy</p>
indvdum@0
  2268
indvdum@0
  2269
	<div class="codebox"><pre>
indvdum@0
  2270
	...
indvdum@0
  2271
'FOO_BAR'	=&gt;	'PHP version &amp;lt; 4.3.3.&lt;br /&gt;
indvdum@0
  2272
	Visit &amp;quot;Downloads&amp;quot; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
indvdum@0
  2273
	...
indvdum@0
  2274
	</pre></div>
indvdum@0
  2275
indvdum@0
  2276
	<p class="good">// Best - No more invalid HTML, and usage of correct typographical quotation marks</p>
indvdum@0
  2277
indvdum@0
  2278
	<div class="codebox"><pre>
indvdum@0
  2279
	...
indvdum@0
  2280
'FOO_BAR'	=&gt;	'PHP version &amp;lt; 4.3.3.&lt;br /&gt;
indvdum@0
  2281
	Visit &ldquo;Downloads&rdquo; at &lt;a href=&quot;http://www.php.net/&quot;&gt;www.php.net&lt;/a&gt;.',
indvdum@0
  2282
	...
indvdum@0
  2283
	</pre></div>
indvdum@0
  2284
indvdum@0
  2285
	<p>Lastly, the <code>&amp;</code> (ampersand) must always be entitised regardless of where it is used:</p>
indvdum@0
  2286
indvdum@0
  2287
	<p class="bad">// Bad - Invalid HTML, none of the ampersands are entitised</p>
indvdum@0
  2288
indvdum@0
  2289
	<div class="codebox"><pre>
indvdum@0
  2290
	...
indvdum@0
  2291
'FOO_BAR'	=&gt;	'&lt;a href=&quot;http://somedomain.tld/?foo=1&amp;bar=2&quot;&gt;Foo &amp; Bar&lt;/a&gt;.',
indvdum@0
  2292
	...
indvdum@0
  2293
	</pre></div>
indvdum@0
  2294
indvdum@0
  2295
	<p class="good">// Good - Valid HTML, amperands are correctly entitised in all cases</p>
indvdum@0
  2296
indvdum@0
  2297
	<div class="codebox"><pre>
indvdum@0
  2298
	...
indvdum@0
  2299
'FOO_BAR'	=&gt;	'&lt;a href=&quot;http://somedomain.tld/?foo=1&amp;amp;bar=2&quot;&gt;Foo &amp;amp; Bar&lt;/a&gt;.',
indvdum@0
  2300
	...
indvdum@0
  2301
	</pre></div>
indvdum@0
  2302
indvdum@0
  2303
	<p>As for how these charcters are entered depends very much on choice of Operating System, current language locale/keyboard configuration and native abilities of the text editor used to edit phpBB language files. Please see <a href="http://en.wikipedia.org/wiki/Unicode#Input_methods">http://en.wikipedia.org/wiki/Unicode#Input_methods</a> for more information.</p>
indvdum@0
  2304
indvdum@0
  2305
	<h4>Spelling, punctuation, grammar, et cetera:</h4>
indvdum@0
  2306
indvdum@0
  2307
	<p>The default language pack bundled with phpBB is <strong>British English</strong> using <a href="http://www.cambridge.org/">Cambridge University Press</a> spelling and is assigned the language code <code>en</code>. The style and tone of writing tends towards formal and translations <strong>should</strong> emulate this style, at least for the variant using the most compact language code. Less formal translations or those with colloquialisms <strong>must</strong> be denoted as such via either an <code>extension</code> or <code>privateuse</code> tag within its language code.</p>
indvdum@0
  2308
indvdum@0
  2309
		</div>
indvdum@0
  2310
indvdum@0
  2311
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  2312
indvdum@0
  2313
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  2314
	</div>
indvdum@0
  2315
indvdum@0
  2316
	<hr />
indvdum@0
  2317
indvdum@0
  2318
<a name="disclaimer"></a><h2>8. Copyright and disclaimer</h2>
indvdum@0
  2319
indvdum@0
  2320
	<div class="paragraph">
indvdum@0
  2321
		<div class="inner"><span class="corners-top"><span></span></span>
indvdum@0
  2322
indvdum@0
  2323
		<div class="content">
indvdum@0
  2324
indvdum@0
  2325
	<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>
indvdum@0
  2326
indvdum@0
  2327
		</div>
indvdum@0
  2328
indvdum@0
  2329
		<div class="back2top"><a href="#wrap" class="top">Back to Top</a></div>
indvdum@0
  2330
indvdum@0
  2331
		<span class="corners-bottom"><span></span></span></div>
indvdum@0
  2332
	</div>
indvdum@0
  2333
indvdum@0
  2334
<!-- END DOCUMENT -->
indvdum@0
  2335
indvdum@0
  2336
	<div id="page-footer">
indvdum@0
  2337
		<div class="version">&nbsp;</div>
indvdum@0
  2338
	</div>
indvdum@0
  2339
</div></div>
indvdum@0
  2340
indvdum@0
  2341
<div>
indvdum@0
  2342
	<a id="bottom" name="bottom" accesskey="z"></a>
indvdum@0
  2343
</div>
indvdum@0
  2344
indvdum@0
  2345
</body>
indvdum@0
  2346
</html>