function wrs_get_string($lang, $key)
{
    global $CFG;
    static $cache_text = array();
    if (!isset($wrs_text[$lang])) {
        if (isset($CFG) && isset($CFG->dirroot)) {
            $path = $CFG->dirroot . '/pluginwiris/lang/';
        } else {
            $path = '../lang/';
        }
        $path .= $lang . '/pluginwiris.php';
        if (file_exists($path)) {
            $string = array();
            include $path;
            $cache_text[$lang] =& $string;
        }
    }
    if (isset($cache_text[$lang]) && isset($cache_text[$lang][$key])) {
        return $cache_text[$lang][$key];
    } else {
        if ($lang != 'en') {
            return wrs_get_string('en', $key);
        } else {
            return '[[' . $key . ']]';
        }
    }
}
_wiris_formula_class ='<?php 
echo $CFG->wirisformulaimageclass;
?>
';
_wiris_cas_class ='<?php 
echo $CFG->wiriscasimageclass;
?>
';

<?php 
$lang = current_language();
$lang = substr($lang, 0, 2);
?>
_wiris_title_text ='<?php 
echo wrs_get_string($lang, 'wiristitletext');
?>
';


//Set the initial valor of current CAS inserted 
if(typeof window.WirisCasCounter =="undefined"){ WirisCasCounter=0;} 
newWindow=null;

function Wiris(editor) {
  Wiris.register(editor.config);
}

Wiris.register = function(config){
	if(typeof window.WirisImgCache =="undefined"){ WirisImgCache=new WrsImgCache();} //We only create the cache if it isn't already created
示例#3
0
<!-- Controls -->
<tr><td id="wirisdialog_controls">
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="wirisdialog_controls1">
<button id="button_Apply"><?php 
echo wrs_get_string($lang, 'apply');
?>
</button>
<!-- <button id="button_Remove"><?php 
echo wrs_get_string($lang, 'remove');
?>
</button> -->
</td>
<td class="wirisdialog_controls2">
<button id="button_Ok"><?php 
echo wrs_get_string($lang, 'ok');
?>
</button>
<button id="button_Cancel"><?php 
echo wrs_get_string($lang, 'cancel');
?>
</button>
</td></tr>
</tbody></table>
</td></tr>

</tbody></table>
</td></tr>
</html>
function WF_math_image($mathml, $editor)
{
    global $CFG;
    global $TAGS;
    global $lang;
    $output = '';
    if ($mathml) {
        // creating cache entry in database
        // The MD5 hashcode identify a formula, so it is generated with all
        // the parameters of a formula (mathml, size, color)
        $idformula = isset($CFG->wirisimagebgcolor) ? $CFG->wirisimagebgcolor : '';
        if (isset($CFG->wirisimagesymbolcolor)) {
            $idformula .= $CFG->wirisimagesymbolcolor;
        }
        if (isset($CFG->wiristransparency)) {
            $idformula .= $CFG->wiristransparency;
        }
        if (isset($CFG->wirisimagefontsize)) {
            $idformula .= $CFG->wirisimagefontsize;
        }
        $idformula .= $mathml;
        $md5 = md5($idformula);
        if (!($wrscache = get_record("cache_filters", "filter", "wiris", "md5key", $md5))) {
            $wrscache->filter = 'wiris';
            $wrscache->version = 1;
            $wrscache->md5key = $md5;
            // convert the xml to UTF-8
            //We only need to convert it if it comes from the database, otherwise, it will come from the editor and will already be in utf-8
            if ($editor !== TRUE) {
                if ($CFG->version > 2005060240) {
                    require_once $CFG->libdir . '/textlib.class.php';
                    $convertor = textlib_get_instance();
                    $mathml = $convertor->convert($mathml, $TAGS->lcharset, 'utf-8');
                } else {
                    $mathml = utf8_encode($mathml);
                    // ISO_8859_1 to UTF_8
                }
            }
            // update the database record entry
            $wrscache->rawtext = $mathml;
            $wrscache->timemodified = time();
            insert_record("cache_filters", $wrscache, false);
        }
        $filename = $md5 . ".png";
        $source = $CFG->wwwroot . '/pluginwiris/filter/wrs_showimage.php';
        if ($CFG->slasharguments) {
            // Use this method if possible for better caching
            $source .= '/' . $filename;
        } else {
            $source .= '?file=' . $filename;
        }
        $output .= '<img align="middle" src="';
        $output .= $source;
        //We add the title tooltip only when the function is called to insert images to the editor
        if ($editor === TRUE) {
            if ($CFG->wirisformulaeditorenabled) {
                $title = wrs_get_string($lang, 'wiristitletext');
                $title = utf8_encode($title);
                // ISO_8859_1 to UTF_8
                $output .= '" title ="' . $title;
            }
        }
        $output .= '" class="' . $CFG->wirisformulaimageclass;
        $output .= '" />';
    }
    return $output;
}