コード例 #1
0
 function getSwitcherLanguage()
 {
     $sContent = '';
     $iLangsCount = count(getLangsArr());
     if ($iLangsCount <= 1) {
         return '';
     }
     $sLangName = getCurrentLangName();
     $aTmplVars = array();
     $aTmplVars[] = array('caption' => _t('_sys_bm_language', $sLangName), 'link' => 'javascript:void(0)', 'script' => 'onclick="javascript:showPopupLanguage()"', 'target' => '');
     $sContent .= $GLOBALS['oSysTemplate']->parseHtmlByName('extra_' . $this->sName . '_menu.html', array('bx_repeat:items' => $aTmplVars));
     $sContent .= $GLOBALS['oFunctions']->getLanguageSwitcher($sLangName);
     return $sContent;
 }
コード例 #2
0
 public static function getTopMenu()
 {
     $sTmplVarsAddons = '';
     $aTmplVarsItems = array();
     $aItems = array();
     if (count(getLangsArr()) > 1) {
         $aItems[] = array('caption' => '_adm_tmi_language', 'url' => 'javascript:void(0)', 'onclick' => 'showPopupLanguage()', 'target' => '', 'icon' => 'language');
         $sLangName = getCurrentLangName();
         $sTmplVarsAddons .= $GLOBALS['oFunctions']->getLanguageSwitcher($sLangName);
     }
     $aItems = array_merge($aItems, $GLOBALS['MySQL']->getAll("SELECT `caption`, `url`, `target`, `icon` FROM `sys_menu_admin_top` ORDER BY `Order`"));
     foreach ($aItems as $aItem) {
         $aTmplVarsItems[] = array('caption' => _t($aItem['caption']), 'url' => str_replace(array('{site_url}', '{admin_url}'), array($GLOBALS['site']['url'], $GLOBALS['site']['url_admin']), $aItem['url']), 'target' => !empty($aItem['target']) ? $aItem['target'] : '_self', 'bx_if:show_onclick' => array('condition' => isset($aItem['onclick']) && !empty($aItem['onclick']), 'content' => array('onclick' => isset($aItem['onclick']) ? $aItem['onclick'] : '')), 'icon' => false === strpos($aItem['icon'], '.') ? '<i class="sys-icon ' . $aItem['icon'] . '"></i>' : '<img src="' . $GLOBALS['oAdmTemplate']->getIconUrl($aItem['icon']) . '" alt="' . _t($aItem['caption']) . '" />');
     }
     return $GLOBALS['oAdmTemplate']->parseHtmlByName('top_menu.html', array('bx_repeat:items' => $aTmplVarsItems, 'addons' => $sTmplVarsAddons));
 }
コード例 #3
0
ファイル: BxBaseMenuBottom.php プロジェクト: noormcs/studoro
 function getListLanguage($sCurrent)
 {
     $sOutputCode = '';
     $aLangs = getLangsArr();
     if (count($aLangs) < 2) {
         return $sOutputCode;
     }
     $sGetTransfer = bx_encode_url_params($_GET, array('lang'));
     $aTmplVars = array();
     foreach ($aLangs as $sName => $sLang) {
         $sFlag = $GLOBALS['site']['flags'] . $sName . '.gif';
         $aTmplVars[] = array('bx_if:show_icon' => array('condition' => $sFlag, 'content' => array('icon_src' => $sFlag, 'icon_alt' => $sName, 'icon_width' => 18, 'icon_height' => 12)), 'class' => $sName == $sCurrent ? 'sys-bm-sub-item-selected' : '', 'link' => bx_html_attribute($_SERVER['PHP_SELF']) . '?' . $sGetTransfer . 'lang=' . $sName, 'onclick' => '', 'title' => $sLang);
     }
     $sOutputCode .= $GLOBALS['oSysTemplate']->parseHtmlByName('extra_bottom_menu_sub_items.html', array('name_method' => 'Language', 'name_block' => 'language', 'bx_repeat:items' => $aTmplVars));
     return PopupBox('sys-bm-switcher-language', _t('_sys_bm_popup_cpt_language'), $sOutputCode);
 }
コード例 #4
0
function displayLanguageSettings()
{
    ?>
    <center>
    <form method="post" action="<?php 
    echo $_SERVER[PHP_SELF] . '?cat=ls';
    ?>
">
    <input type="hidden" name="save_settings" value="yes">
    <table width="100%" cellspacing="2" cellpadding="3" class="text">
        <tr class="table">
            <td align="right" width="50%"> <?php 
    echo getParamDesc("lang_default");
    ?>
: </td>
            <td align="left">
                <select name="lang_default">
                    <?php 
    $aLangs = getLangsArr();
    $sCurLang = getParam('lang_default');
    foreach ($aLangs as $sName => $sTitle) {
        $sSelected = $sName == $sCurLang ? 'selected="selected"' : '';
        ?>
						<option value="<?php 
        echo $sName;
        ?>
" <?php 
        echo $sSelected;
        ?>
><?php 
        echo htmlspecialchars_adv($sTitle);
        ?>
</option>
						<?php 
    }
    ?>
                </select>
            </td>
        </tr>
    </table>
    <br />
    <input class=no type="submit" value="Save changes" name="saveLangChanges" class=text>
    </form>
    </center>
    <?php 
    return 'Languages';
}
コード例 #5
0
ファイル: lang_file.php プロジェクト: Prashank25/dolphin.pro
function _getLanguageSettingsForm($mixedResult, $bActive = false)
{
    global $oSettingsLanguage;
    $oForm = $oSettingsLanguage->getFormObject();
    // re-format 'default language' form field
    foreach ($oForm->aInputs as $k => $r) {
        if ('lang_default' != $r['name']) {
            continue;
        }
        $oForm->aInputs[$k] = array('type' => 'select', 'name' => 'lang_default', 'caption' => _t('_adm_txt_langs_def_lang'), 'values' => array(), 'value' => getParam('lang_default'));
        $aLangs = getLangsArr();
        foreach ($aLangs as $sName => $sTitle) {
            $oForm->aInputs[$k]['values'][] = array('key' => $sName, 'value' => htmlspecialchars_adv($sTitle));
        }
    }
    // get form code
    $oForm->initChecker();
    $sResult = $oForm->getCode();
    // add operation result
    if ($mixedResult !== true && !empty($mixedResult)) {
        $bActive = true;
        $sResult = $mixedResult . $sResult;
    }
    // display
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('langs_form_settings.html', array('display' => $bActive ? 'block' : 'none', 'form' => $sResult));
}
コード例 #6
0
function getLangSwitcher()
{
    global $sCurrentLanguage;
    global $site;
    $aLangs = getLangsArr(true);
    if (count($aLangs) < 2) {
        return '';
    }
    $sCurLink = $_SERVER['REQUEST_URI'];
    $sCurLink = preg_replace('/[\\?&]lang=[a-z-]{2,5}/i', '', $sCurLink);
    //remove old lang from uri
    $sCurLink .= strpos($sCurLink, '?', 1) ? '&' : '?';
    $sRet = '';
    foreach ($aLangs as $sName => $sLang) {
        $sTitle = htmlspecialchars(substr($sLang, 0, -2));
        $sFlag = $site['flags'] . substr($sLang, -2) . '.gif';
        if ($sCurrentLanguage == $sName) {
            $sRet .= '
				<img class="lang_selected" src="' . $sFlag . '" alt="' . $sTitle . '" title="' . $sTitle . '" />';
        } else {
            $sLink = $sCurLink . 'lang=' . $sName;
            $sRet .= <<<EOF
<a href="{$sLink}" title="{$sTitle}">
\t<img class="lang_not_selected" src="{$sFlag}" alt="{$sTitle}" title="{$sTitle}" /></a>
EOF;
        }
    }
    return $sRet;
}
コード例 #7
0
ファイル: languages.inc.php プロジェクト: dalinhuang/shopexts
/**
 * Function will generate list of installed languages list;
 *
 * @return : Html presentation data;
 */
function getLangSwitcher()
{
    global $site;
    $aLangs = getLangsArr();
    if (count($aLangs) < 2) {
        return;
    }
    $sOutputCode = null;
    foreach ($aLangs as $sName => $sLang) {
        $sFlag = $site['flags'] . $sName . '.gif';
        $aTemplateKeys = array('bx_if:item_img' => array('condition' => $sFlag, 'content' => array('item_img_src' => $sFlag, 'item_img_alt' => $sName, 'item_img_width' => 18, 'item_img_height' => 12)), 'item_link' => BX_DOL_URL_ROOT . 'index.php?lang=' . $sName, 'item_onclick' => null, 'item_title' => $sLang, 'extra_info' => null);
        $sOutputCode .= $GLOBALS['oSysTemplate']->parseHtmlByName('member_menu_sub_item.html', $aTemplateKeys);
    }
    return $sOutputCode;
}
コード例 #8
0
ファイル: lang_file.php プロジェクト: dalinhuang/shopexts
function _getLanguageCreateForm()
{
    if (isset($_POST['action']) && $_POST['action'] == 'get_edit_form_language' && isset($_POST['id'])) {
        $aLanguage = $GLOBALS['MySQL']->getRow("SELECT `ID` AS `id`, `Name` AS `name`, `Flag` AS `flag`, `Title` AS `title` FROM `sys_localization_languages` WHERE `ID`='" . (int) $_POST['id'] . "' LIMIT 1");
    }
    //--- Create language form ---//
    $aFormCreate = array('form_attrs' => array('id' => 'adm-settings-form-files', 'name' => 'adm-settings-form-files', 'action' => $GLOBALS['site']['url_admin'] . 'lang_file.php', 'method' => 'post', 'enctype' => 'multipart/form-data'), 'inputs' => array('CopyLanguage_Title' => array('type' => 'text', 'name' => 'CopyLanguage_Title', 'caption' => _t('_adm_txt_langs_title'), 'value' => isset($aLanguage['title']) ? $aLanguage['title'] : ''), 'CopyLanguage_Name' => array('type' => 'text', 'name' => 'CopyLanguage_Name', 'caption' => _t('_adm_txt_langs_code'), 'value' => isset($aLanguage['name']) ? $aLanguage['name'] : ''), 'Flag' => array('type' => 'select', 'name' => 'Flag', 'caption' => _t('_adm_txt_langs_flag'), 'values' => array(), 'value' => isset($aLanguage['flag']) ? $aLanguage['flag'] : strtolower(getParam('default_country'))), 'CopyLanguage_SourceLangID' => array('type' => 'select', 'name' => 'CopyLanguage_SourceLangID', 'caption' => _t('_adm_txt_langs_copy_from'), 'values' => array()), 'create_language' => array('type' => 'submit', 'name' => 'create_language', 'value' => _t("_adm_btn_lang_save"))));
    //--- Copy from ---//
    $aLangs = getLangsArr(false, true);
    foreach ($aLangs as $iId => $sName) {
        $aFormCreate['inputs']['CopyLanguage_SourceLangID']['values'][] = array('key' => $iId, 'value' => htmlspecialchars_adv($sName));
    }
    //--- Flags ---//
    $aCountries = $GLOBALS['MySQL']->getAll("SELECT `ISO2` AS `code`, `Country` AS `title` FROM `sys_countries` ORDER BY `Country`");
    foreach ($aCountries as $aCountry) {
        $sCode = strtolower($aCountry['code']);
        $aFormCreate['inputs']['Flag']['values'][] = array('key' => $sCode, 'value' => $aCountry['title']);
    }
    if (!empty($aLanguage)) {
        unset($aFormCreate['inputs']['CopyLanguage_SourceLangID']);
        $aFormCreate['inputs']['id'] = array('type' => 'hidden', 'name' => 'id', 'value' => $aLanguage['id']);
    }
    $oForm = new BxTemplFormView($aFormCreate);
    return $GLOBALS['oAdmTemplate']->parseHtmlByName('langs_form_create.html', array('display' => !empty($aLanguage) ? 'block' : 'none', 'form' => $oForm->getCode()));
}
コード例 #9
0
ファイル: BxBaseMenu.php プロジェクト: dalinhuang/shopexts
 function genMoreLanguagesElement()
 {
     $aExistedLanguages = getLangsArr();
     if (count($aExistedLanguages) <= 1) {
         return;
     }
     $sCurLanguage = strlen($_GET['lang']) ? $_GET['lang'] : $_COOKIE['lang'];
     $sLanguageElement = '';
     foreach ($aExistedLanguages as $sLanguageID => $sLanguageVal) {
         $sIActiveClass = $sCurLanguage == $sLanguageID ? ' active' : '';
         $sLanguageUrl = '';
         if ($sCurLanguage == $sLanguageID) {
             $sLanguageUrl = 'javascript: void(0)';
         } else {
             $sGetTransfer = bx_encode_url_params($_GET, array('lang'));
             $sLanguageUrl = bx_html_attribute($_SERVER['PHP_SELF']) . '?' . $sGetTransfer . 'lang=' . $sLanguageID;
         }
         $sLanguageElement .= '<li><a href="' . $sLanguageUrl . '" value="' . $sLanguageVal . '" class="button more_ntop_element' . $sIActiveClass . '">' . $sLanguageVal . '</a>';
     }
     if ($sLanguageElement == '') {
         return;
     }
     return array('icon_url' => getTemplateIcon('tm_item_languages.png'), 'element_content' => $sLanguageElement);
 }