From: Chris S. <san...@us...> - 2005-07-14 18:53:56
|
Update of /cvsroot/stack/stack-1-0/api/moodlelib/Stack In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14993/api/moodlelib/Stack Added Files: _scripts_moodlelib_php.html Log Message: Updated API --- NEW FILE: _scripts_moodlelib_php.html --- <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- template designed by Marco Von Ballmoos --> <title>Docs for page moodlelib.php</title> <link rel="stylesheet" href="../../media/stylesheet.css" /> <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'/> </head> <body> <div class="page-body"> <h2 class="file-name"><img src="../../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/scripts/moodlelib.php</h2> <a name="sec-description"></a> <div class="info-box"> <div class="info-box-title">Description</div> <div class="nav-bar"> <span class="disabled">Description</span> | <a href="#sec-functions">Functions</a> </div> <div class="info-box-body"> <!-- ========== Info from phpDoc block ========= --> <p class="short-description">This file contains functions of the same name as those provided by Moodle.</p> <p class="description"><p>These functions do the same kinds of things as those in Moodle, to allow later integration of STACK into moodle. In particular, they are designed for language support.</p></p> </div> </div> <a name="sec-functions"></a> <div class="info-box"> <div class="info-box-title">Functions</div> <div class="nav-bar"> <a href="#sec-description">Description</a> | <span class="disabled">Functions</span> </div> <div class="info-box-body"> <a name="functionget_string" id="functionget_string"><!-- --></a> <div class="evenrow"> <div> <img src="../../media/images/Function.png" /> <span class="method-title">get_string</span> (line <span class="line-number">93</span>) </div> <!-- ========== Info from phpDoc block ========= --> <p class="short-description">Returns a localized string.</p> <p class="description"><p>Returns the translated string specified by $identifier as for $module. Uses the same format files as STphp. $a is an object, string or number that can be used within translation strings</p><p>eg "hello \$a->firstname \$a->lastname" or "hello \$a"</p><p>If you would like to directly echo the localized string use the function <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionprint_string">print_string()</a></p><p>Example usage of this function involves finding the string you would like a local equivalent of and using its identifier and module information to retrive it.<br /> If you open moodle/lang/en/moodle.php and look near line 1031 you will find a string to prompt a user for their word for student <pre><code><pre><br />1 <span class="src-var">$string</span><span class="src-sym">[</span><span class="src-str">'wordforstudent'</span><span class="src-sym">]</span> = <span class="src-str">'Your word for Student'</span>;</pre></code></pre> So if you want to display the string 'Your word for student' in any language that supports it on your site you just need to use the identifier 'wordforstudent' <pre><code><pre><br />1 <span class="src-var">$mystring</span> = <span class="src-str">'<strong>'</span>. <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionget_string">get_string</a><span class="src-sym">(</span><span class="src-str">'wordforstudent'</span><span class="src-sym">)</span> .<span class="src-str">'</strong>'</span>;<br />2 <span class="src-key">or</span></pre></code></pre> If the string you want is in another file you'd take a slightly different approach. Looking in moodle/lang/en/calendar.php you find around line 75: <pre><code><pre><br />1 <span class="src-var">$string</span><span class="src-sym">[</span><span class="src-str">'typecourse'</span><span class="src-sym">]</span> = <span class="src-str">'Course event'</span>;</pre></code></pre> If you want to display the string "Course event" in any language supported you would use the identifier 'typecourse' and the module 'calendar' (because it is in the file calendar.php): <pre><code><pre><br />1 <span class="src-var">$mystring</span> = <span class="src-str">'<h1>'</span>. <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionget_string">get_string</a><span class="src-sym">(</span><span class="src-str">'typecourse'</span><span class="src-sym">,</span> <span class="src-str">'calendar'</span><span class="src-sym">)</span> .<span class="src-str">'</h1>'</span>;</pre></code></pre></p><p>As a last resort, should the identifier fail to map to a string the returned string will be [[ $identifier ]]</p></p> <ul class="tags"> <li><span class="field">return:</span> The localized string.</li> <li><span class="field">uses:</span> $CFG</li> </ul> <div class="method-signature"> <span class="method-result">string</span> <span class="method-name"> get_string </span> (<span class="var-type">string</span> <span class="var-name">$identifier</span>, [<span class="var-type">string</span> <span class="var-name">$module</span> = <span class="var-default">''</span>], [<span class="var-type">mixed</span> <span class="var-name">$a</span> = <span class="var-default">NULL</span>]) </div> <ul class="parameters"> <li> <span class="var-type">string</span> <span class="var-name">$identifier</span><span class="var-description">: The key identifier for the localized string</span> </li> <li> <span class="var-type">string</span> <span class="var-name">$module</span><span class="var-description">: The module where the key identifier is stored. If none is specified then moodle.php is used.</span> </li> <li> <span class="var-type">mixed</span> <span class="var-name">$a</span><span class="var-description">: An object, string or number that can be used within translation strings.</span> </li> </ul> </div> <a name="functionget_strings" id="functionget_strings"><!-- --></a> <div class="oddrow"> <div> <img src="../../media/images/Function.png" /> <span class="method-title">get_strings</span> (line <span class="line-number">159</span>) </div> <!-- ========== Info from phpDoc block ========= --> <p class="short-description">Converts an array of strings to their localized value.</p> <div class="method-signature"> <span class="method-result">string</span> <span class="method-name"> get_strings </span> (<span class="var-type">array</span> <span class="var-name">$array</span>, [<span class="var-type">string</span> <span class="var-name">$module</span> = <span class="var-default">''</span>]) </div> <ul class="parameters"> <li> <span class="var-type">array</span> <span class="var-name">$array</span><span class="var-description">: An array of strings</span> </li> <li> <span class="var-type">string</span> <span class="var-name">$module</span><span class="var-description">: The language module that these strings can be found in.</span> </li> </ul> </div> <a name="functionprint_string" id="functionprint_string"><!-- --></a> <div class="evenrow"> <div> <img src="../../media/images/Function.png" /> <span class="method-title">print_string</span> (line <span class="line-number">38</span>) </div> <!-- ========== Info from phpDoc block ========= --> <p class="short-description">Prints out a translated string.</p> <p class="description"><p>Prints out a translated string using the return value from the <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionget_string">get_string()</a> function.</p><p>Example usage of this function when the string is in the moodle.php file:<br /> <pre><code><pre><br />1 echo <span class="src-str">'<strong>'</span>;<br />2 <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionprint_string">print_string</a><span class="src-sym">(</span><span class="src-str">'wordforstudent'</span><span class="src-sym">)</span>;<br />3 echo <span class="src-str">'</strong>'</span>;</pre></code></pre></p><p>Example usage of this function when the string is not in the moodle.php file:<br /> <pre><code><pre><br />1 echo <span class="src-str">'<h1>'</span>;<br />2 <a href="../../moodlelib/Stack/_scripts_moodlelib_php.html#functionprint_string">print_string</a><span class="src-sym">(</span><span class="src-str">'typecourse'</span><span class="src-sym">,</span> <span class="src-str">'calendar'</span><span class="src-sym">)</span>;<br />3 echo <span class="src-str">'</h1>'</span>;</pre></code></pre></p></p> <div class="method-signature"> <span class="method-result">void</span> <span class="method-name"> print_string </span> (<span class="var-type">string</span> <span class="var-name">$identifier</span>, [<span class="var-type">string</span> <span class="var-name">$module</span> = <span class="var-default">''</span>], [<span class="var-type">mixed</span> <span class="var-name">$a</span> = <span class="var-default">NULL</span>]) </div> <ul class="parameters"> <li> <span class="var-type">string</span> <span class="var-name">$identifier</span><span class="var-description">: The key identifier for the localized string</span> </li> <li> <span class="var-type">string</span> <span class="var-name">$module</span><span class="var-description">: The module where the key identifier is stored. If none is specified then moodle.php is used.</span> </li> <li> <span class="var-type">mixed</span> <span class="var-name">$a</span><span class="var-description">: An object, string or number that can be used within translation strings</span> </li> </ul> </div> </div> </div> <p class="notes" id="credit"> Documentation generated on Thu, 14 Jul 2005 19:45:14 +0100 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.2.3</a> </p> </div></body> </html> |