function tr2($str, $lang)
{
    global $language;
    load_language_file($lang);
    if (@$language[$lang][$str]) {
        $ref =& $language[$lang][$str];
        if (strpos($ref, "{") !== false) {
            return tpl_do_replace($ref, true);
        } else {
            return $ref;
        }
    } else {
        return $str . "No translation available (identifier: {$str})-todo";
    }
}
Example #2
0
function tpl_BuildTemplate($dbdisconnect = true)
{
    //template handling vars
    global $style, $stylepath, $tplname, $vars, $langpath, $locale, $opt, $oc_nodeid, $translate, $usr;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    // country dropdown
    global $tpl_usercountries;
    tpl_set_var('screen_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen.css"));
    tpl_set_var('screen_msie_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_screen_msie.css"));
    tpl_set_var('print_css_time', filemtime($opt['rootpath'] . "resource2/" . $style . "/css/style_print.css"));
    if (isset($bScriptExecution)) {
        $bScriptExecution->Stop();
        tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    } else {
        tpl_set_var('scripttime', sprintf('%1.3f', 0));
    }
    tpl_set_var('sponsorbottom', $opt['page']['sponsor']['bottom']);
    if (isset($opt['locale'][$locale]['page']['subtitle1'])) {
        $opt['page']['subtitle1'] = $opt['locale'][$locale]['page']['subtitle1'];
    }
    if (isset($opt['locale'][$locale]['page']['subtitle2'])) {
        $opt['page']['subtitle2'] = $opt['locale'][$locale]['page']['subtitle2'];
    }
    tpl_set_var('opt_page_subtitle1', $opt['page']['subtitle1']);
    tpl_set_var('opt_page_subtitle2', $opt['page']['subtitle2']);
    tpl_set_var('opt_page_title', $opt['page']['title']);
    if ($opt['logic']['license']['disclaimer']) {
        if (isset($opt['locale'][$locale]['page']['license_url'])) {
            $lurl = $opt['locale'][$locale]['page']['license_url'];
        } else {
            $lurl = $opt['locale']['EN']['page']['license_url'];
        }
        if (isset($opt['locale'][$locale]['page']['license'])) {
            $ltext = $opt['locale'][$locale]['page']['license'];
        } else {
            $ltext = $opt['locale']['EN']['page']['license'];
        }
        $ltext = mb_ereg_replace('%1', $lurl, $ltext);
        $ltext = mb_ereg_replace('{site}', $opt['page']['sitename'], $ltext);
        $ld = '<p class="sidebar-maintitle">' . $translate->t('Datalicense', '', '', 0) . '</p>' . '<div style="margin:20px 0 16px 0; width:100%; text-align:center;">' . $ltext . '</div>';
        tpl_set_var('license_disclaimer', $ld);
    } else {
        tpl_set_var('license_disclaimer', '');
    }
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    /* prepare user country selection
     */
    $tpl_usercountries = array();
    $rsUserCountries = sql("SELECT `countries_options`.`country`,\n\t\t                  IF(`countries_options`.`nodeId`='&1', 1, IF(`countries_options`.`nodeId`!=0, 2, 3)) AS `group`,\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name`\n\t\t             FROM `countries_options`\n\t\t       INNER JOIN `countries` ON `countries_options`.`country`=`countries`.`short`\n\t\t        LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`\n\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\n\t\t            WHERE `countries_options`.`display`=1\n\t\t         ORDER BY `group` ASC,\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) ASC", $oc_nodeid, $locale);
    while ($rUserCountries = sql_fetch_assoc($rsUserCountries)) {
        $tpl_usercountries[] = $rUserCountries;
    }
    sql_free_result($rsUserCountries);
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    tpl_set_var('backgroundimage', '<div id="bg1">&nbsp;</div><div id="bg2">&nbsp;</div>');
    tpl_set_var('bodystyle', '');
    if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
        $sCode = read_file($stylepath . '/main_print.tpl.php');
    } else {
        if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
            $sCode = read_file($stylepath . '/popup.tpl.php');
        } else {
            $sCode = read_file($stylepath . '/main.tpl.php');
        }
    }
    $sCode = '?>' . $sCode;
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process translations
    $sCode = tpl_do_translation($sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}
Example #3
0
function tpl_BuildTemplate($dbdisconnect = true)
{
    //template handling vars
    global $stylepath, $tplname, $vars, $langpath, $locale, $opt;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    // country dropdown
    global $tpl_usercountries;
    if (isset($bScriptExecution)) {
        $bScriptExecution->Stop();
        tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    } else {
        tpl_set_var('scripttime', sprintf('%1.3f', 0));
    }
    tpl_set_var('sponsortopright', $opt['page']['sponsor']['topright']);
    tpl_set_var('sponsorbottom', $opt['page']['sponsor']['bottom']);
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    /* prepare user country selection
     */
    $tpl_usercountries = array();
    $rsUserCountries = sql("SELECT `countries_options`.`country`, `countries_options`.`group`, \r\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) AS `name` \r\n\t\t             FROM `countries_options` \r\n\t\t       INNER JOIN `countries` ON `countries_options`.`country`=`countries`.`short`\r\n\t\t        LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` \r\n\t\t        LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1' \r\n\t\t            WHERE `countries_options`.`display`=1 \r\n\t\t         ORDER BY `countries_options`.`group` ASC,\r\n\t\t                  IFNULL(`sys_trans_text`.`text`, `countries`.`name`) ASC", $locale);
    while ($rUserCountries = sql_fetch_assoc($rsUserCountries)) {
        $tpl_usercountries[] = $rUserCountries;
    }
    sql_free_result($rsUserCountries);
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
        $sCode = read_file($stylepath . '/main_print.tpl.php');
    } else {
        if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
            $sCode = read_file($stylepath . '/popup.tpl.php');
        } else {
            $sCode = read_file($stylepath . '/main.tpl.php');
        }
    }
    $sCode = '?>' . $sCode;
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process translations
    $sCode = tpl_do_translation($sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}
function tpl_BuildTemplate($dbdisconnect = true, $minitpl = false, $noCommonTemplate = false)
{
    //template handling vars
    global $stylepath, $tplname, $vars, $langpath, $lang_array, $lang, $language;
    //language specific expression
    global $error_pagenotexist;
    //only for debbuging
    global $b, $bScriptExecution;
    $bScriptExecution->Stop();
    tpl_set_var('scripttime', sprintf('%1.3f', $bScriptExecution->Diff()));
    tpl_set_var('language_flags', writeLanguageFlags($lang_array));
    $bTemplateBuild = new Cbench();
    $bTemplateBuild->Start();
    //set {functionsbox}
    global $page_functions, $functionsbox_start_tag, $functionsbox_middle_tag, $functionsbox_end_tag;
    if (isset($page_functions)) {
        $functionsbox = $functionsbox_start_tag;
        foreach ($page_functions as $func) {
            if ($functionsbox != $functionsbox_start_tag) {
                $functionsbox .= $functionsbox_middle_tag;
            }
            $functionsbox .= $func;
        }
        $functionsbox .= $functionsbox_end_tag;
        tpl_set_var('functionsbox', $functionsbox);
    }
    //include language specific expressions, so that they are available in the template code
    include $langpath . '/expressions.inc.php';
    //load main template
    if ($minitpl) {
        $sCode = read_file($stylepath . '/mini.tpl.php');
    } else {
        if ($noCommonTemplate) {
            $sCode = '{template}';
        } else {
            if (isset($_REQUEST['print']) && $_REQUEST['print'] == 'y') {
                $sCode = read_file($stylepath . '/main_print.tpl.php');
            } else {
                if (isset($_REQUEST['popup']) && $_REQUEST['popup'] == 'y') {
                    $sCode = read_file($stylepath . '/popup.tpl.php');
                } else {
                    $sCode = read_file($stylepath . '/main.tpl.php');
                }
            }
        }
    }
    $sCode = '?>' . $sCode . '<?';
    //does template exist?
    if (!file_exists($stylepath . '/' . $tplname . '.tpl.php')) {
        //set up the error template
        $error = true;
        tpl_set_var('error_msg', htmlspecialchars($error_pagenotexist, ENT_COMPAT, 'UTF-8'));
        tpl_set_var('tplname', $tplname);
        $tplname = 'error';
    }
    //read the template
    $sTemplate = read_file($stylepath . '/' . $tplname . '.tpl.php');
    $sCode = mb_ereg_replace('{template}', $sTemplate, $sCode);
    //process the template replacements
    $sCode = tpl_do_replace($sCode);
    $sCode = tpl_do_translate($sCode);
    //store the cookie
    write_cookie_settings();
    //send http-no-caching-header
    http_write_no_cache();
    // write UTF8-Header
    header('Content-type: text/html; charset=utf-8');
    //run the template code
    eval($sCode);
    //disconnect the database
    if ($dbdisconnect) {
        db_disconnect();
    }
}