<p class="description"><p>Class allows storing and retrieving all the strings on multilingual site in a database. The class connects to any database using PEAR::DB extension - so it needs PEAR to be installed to work correctly. The object should be created for every page. While creation all the strings connected with specific page and the strings connected with all the pages on the site are loaded into variable, so accessing them is quite fast and does not overload database server connection. The class can reuse existing DB connections. To do so just pass to the constructor the handle for the connection instead of DSN.</p></p>
<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">The array with table and column names</p>
<p class="description"><p>The table may have following items:</p><p>'langsavail' - table, in which all the information of the possible languages is kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items: 'name' - the name of the table - default is 'tr_langsavail' 'lang_id' - the column that stores the language identifier - default is 'lang_id' 'lang_name' - the column that stores the language name - default is 'name' 'metatags' - the column that stores meta tags for the pages in specified language - default is 'metatags' 'errortext' - the column that stores the text that will be displayed in case if some text will not be found in the DB - default is 'errortext'</p><p>'strings_XX' - table, in which the strings of language "XX" (the corresponding lang_id) are kept. This array item may be the string - then the structure of the table remains as original, but the name is specified here; or the array with the following items: 'name' - the name of the table - default is 'tr_strings_XX' 'page_id' - the page identifier - default is 'page_id'. 'string_id' - the string indetifier - default is 'string_id'. 'string' - the string itself - default is 'string'.</p><p>This parameter in fact has impact only if the DB is used as the strings repository. The defaults are set in the way that the method is compatible with lower versions.</p></p>
<span class="var-name">$PageName</span><span class="var-description">: the page identifier. It identifies strings connected with specific page on the site</span> </li>
<li>
<span class="var-type">string</span>
<span class="var-name">$LanguageID</span><span class="var-description">: language id. All the languages are stored on the database on specific ID's.</span> </li>
<li>
<span class="var-type">string</span>
<span class="var-name">$pear_DSN</span><span class="var-description">: This might be 3 types: the PEAR DSN string form making the connection; the PEAR DB connection handle; the string has the following format: gettext://LOCALE:LANG:BINDTXTDOMAIN:TXTDOMAINFILE:TXTDOMAIN:CFGFILE for using the native PHP gettext support.</span> </li>
<li>
<span class="var-type">array</span>
<span class="var-name">$CustomTables</span><span class="var-description">: This is the array of the names of the tables and optionally the names of columns. It contains the following elements:</span> </li>
<p class="description"><p>Retrievs the META tags that should be added on the top of translated page, so the translated characters will be correctly displayed on client's browser.</p></p>
<ul class="tags">
<li><span class="field">return:</span> with configured in DB META tags for selected language. In case of DB error - returns PEAR_ERROR object.</li>
<!-- ========== Info from phpDoc block ========= -->
<p class="short-description">Other languages retrieval</p>
<p class="description"><p>Retrieves names of all other languages, not the active.</p></p>
<ul class="tags">
<li><span class="field">return:</span> 2-dimensional array (0..)('id', 'name') for all the languages defined in DB but the current selected one. In case of DB error - returns PEAR_ERROR object.</li>
<p class="description"><p>Retrieves the string basing on string identifier (string_id) or by page_id.string_id. It means the strings_id may be specified in 2 ways: <ul><li>as normal string_id - then the string is retrieved from the cached version</li></ul> of strings in the current page_id <ul><li>as [page_id].[string_id] - then teh strings is retrieved from the DB by getting</li></ul> it from the given page_id. The additional optimization mechanism checks if the page_id is not the same, as the current - if it is - the string will still be retrieved from the cached version. Also in the Params array there can be the item 'lang_id'. If not 'action' has been given then the string from specified lang_id (in specified language) will be retrieved. This solution is not recommended for common usage (e.g. for the whole pages) as this will not use the cached in the constructor strings, but will make another query to the DB for the specified query. Another item that can be this array is 'action'. This specified special actions that should be performed. The special actions can be the following: 'normal' - this is default setting. It means that method will act as if this item was not given. 'translate' - this will couse, that the $StringName will not be the string_id, but the string itself. This must be set only together with 'lang_id' item. Method will try to find the specified string in the foreign (specified in lang_id) language and will retrieve the corresponding string in the current language. This solution is not recommended for common usage (e.g. for the whole pages) as this will not use the cached in the constructor strings, but will make another query to the DB for the specified query. Item 'optimization' is used to specify the optimization of the queries - if the main load should be performed by the PHP server (by doing more, but less complicated queries) or DB server (PHP is sending only one, but complicated query). This one is used only together with specified 'lang_id' and 'action'=>'translate' - as this performs more operations, then other queries. It can have following values: 'php' - the default setting, cousing PHP to make 2 (or 3 if the string will be found in some other page_id then the current) uncomplicated queries. This is recommened if the DB server is the same machine as the PHP server. 'db' - this couses PHP to make only 1, but comlicated query. This is recommended if the DB server is separate machine, then PHP server. WARNING: This will not work with MySQL DB server and Db servers, that does not supports nested SELECTs (SELECT ... FROM ... WHERE sth = (SELECT...)) Another parameters that might be specified in the $Params array are: 'ParameterPrefix' - is the prefix string for parameter - default is '&&' 'ParameterPostfix' - is the postfix string for parameter - default is '&&'</p></p>
<span class="var-name">$StringName</span><span class="var-description">: string identifier - unique for the page as well as for the strings, that are available on all the pages.</span> </li>
<li>
<span class="var-type">array</span>
<span class="var-name">$Params</span><span class="var-description">: string $Params string may be parametrized - and the paraters, that will be "inserted" into string may be typen into this array. It means, that &&1&& string will be replaced by 1st array element; string &&2&& will be replaced by 2nd array element; string &&3&& will be replaced by 3rd array element etc.</span> </li>
</ul>
<hr class="separator" />
<div class="notes">Redefined in descendants as:</div>