/**
     * Get all the available languages for backoffice use (no module specified) or for a module backoffice.
     * Static function.
     *
     * @param string $module The codename of a module we want the languages of.
     * @param string $orderBy The ordering key to use (default : label_lng)
     * @return array(CMS_language) The available languages sorted by label
     * @access public
     */
    static function getAllLanguages($module = false, $orderBy = "label_lng")
    {
        static $languagesCatalog;
        if (isset($languagesCatalog[$module ? $module : 'all'])) {
            return $languagesCatalog[$module ? $module : 'all'];
        }
        $sql = "\n\t\t\tselect\n\t\t\t\tcode_lng\n\t\t\tfrom\n\t\t\t\tlanguages\n\t\t";
        if (!$module && $module != 'all') {
            $sql .= 'where availableForBackoffice_lng=1';
        }
        if ($orderBy) {
            $sql .= '
				order by
					' . $orderBy . '
			';
        }
        $q = new CMS_query($sql);
        $languages = array();
        while ($code = $q->getValue("code_lng")) {
            $lng = new CMS_language($code);
            if (!$lng->hasError() && (!$module || !in_array($module, $lng->getModulesDenied()))) {
                $languages[$code] = $lng;
            }
        }
        $languagesCatalog[$module ? $module : 'all'] = $languages;
        return $languages;
    }
Exemple #2
0
        $view->show();
    }
} else {
    $language = new CMS_language();
}
$winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_LANGUAGE_MANAGEMENT) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_CREATE_UPDATE));
$languagesCodes = CMS_languagesCatalog::getAllLanguagesCodes();
$comboLanguages = array(array('format' => '', 'label' => '-'));
foreach ($languagesCodes as $languageCode => $label) {
    $comboLanguages[] = array('code' => $languageCode, 'label' => $languageCode . ' : ' . $label);
}
$comboLanguages = sensitiveIO::jsonEncode($comboLanguages);
$datesFormat = array(array('format' => '', 'label' => '-'), array('format' => 'd/m/Y', 'label' => date('d/m/Y') . ' (d/m/Y)'), array('format' => 'm/d/Y', 'label' => date('m/d/Y') . ' (m/d/Y)'), array('format' => 'Y/m/d', 'label' => date('Y/m/d') . ' (Y/m/d)'));
$datesFormat = sensitiveIO::jsonEncode($datesFormat);
$modules = CMS_modulesCatalog::getAll();
$modulesDenied = $language->getModulesDenied();
$availableModules = $excludedModules = array();
foreach ($modules as $codename => $module) {
    if (in_array($codename, $modulesDenied)) {
        $excludedModules[] = array($codename, $module->getLabel($cms_language));
    } else {
        $availableModules[] = array($codename, $module->getLabel($cms_language));
    }
}
$availableModules = sensitiveIO::jsonEncode($availableModules);
$excludedModules = sensitiveIO::jsonEncode($excludedModules);
$selectLanguageDisabled = $language->getCode() ? 'true' : 'false';
$isAvailableForBackoffice = $language->isAvailableForBackoffice() ? 'true' : 'false';
$itemFields = "{\n\txtype:\t\t\t\t'combo',\n\tname:\t\t\t\t'selectedCode',\n\thiddenName:\t\t \t'selectedCode',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_LANGUAGE)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'code',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getCode()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['code', 'label'],\n\t\tdata:\t\t\t\t{$comboLanguages}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\ttrue,\n\ttypeAhead:\t\t\ttrue,\n\tvalidateOnBlur:\t\tfalse,\n\tdisabled:\t\t\t{$selectLanguageDisabled}\n},{\n\txtype:\t\t\t\t'atmCombo',\n\tname:\t\t\t\t'dateformat',\n\thiddenName:\t\t \t'dateformat',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_DATE_FORMAT)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'format',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getDateFormat()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['format', 'label'],\n\t\tdata:\t\t\t\t{$datesFormat}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\tfalse,\n\tvalidateOnBlur:\t\tfalse\n},{\n\txtype:\t\t\t'itemselector',\n\tname:\t\t\t'modulesDenied',\n\tfieldLabel:\t\t'<span class=\"atm-help\" ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_SELECT_MODULES)}\">{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED_MODULES)}</span>',\n\tdataFields:\t\t['code', 'label'],\n\ttoData:\t\t\t{$excludedModules},\n\tmsWidth:\t\t250,\n\tmsHeight:\t\t130,\n\theight:\t\t\t140,\n\tvalueField:\t\t'code',\n\tdisplayField:\t'label',\n\ttoLegend:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED)}',\n\tfromLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_AVAILABLE)}',\n\tfromData:\t\t{$availableModules}\n},{\n\txtype: \t\t'checkbox', \n\tboxLabel: \t'{$cms_language->getJSMessage(MESSAGE_PAGE_LANGUE_AVAILABLE_FOR_ADMIN)}', \n\tinputValue:\t'1',\n\tchecked:\t{$isAvailableForBackoffice},\n\tname: \t\t'admin'\n},";
//remove last comma
$itemFields = io::substr($itemFields, 0, -1);