/** * function translateFN: used to handle message translations * based on user language * * @param string $message - the message to be translated * @param string $language_from * @param string $language_to 2 char string * @return string the translated message, if a translation was found, the original message otherwise */ function translateFN($message, $language_from = null, $language_to = null) { if (is_null($language_to)) { $sess_userObj = $_SESSION['sess_userObj']; $languageId = $sess_userObj->getLanguage(); } else { $languageId = $language_to; } if ($languageId != 0) { $languageInfo = Translator::getLanguageInfoForLanguageId($languageId); $user_language_code = $languageInfo['codice_lingua']; } else { if (!isset($_SESSION['sess_user_language'])) { $user_language_code = ADA_LOGIN_PAGE_DEFAULT_LANGUAGE; } else { $user_language_code = $_SESSION['sess_user_language']; } } return Translator::translate($message, $user_language_code); }
require_once realpath(dirname(__FILE__)) . '/../config_path.inc.php'; /** * Clear node and layout variable in $_SESSION */ $variableToClearAR = array('node', 'layout', 'course', 'course_instance'); /** * Users (types) allowed to access this module. */ $allowedUsersAr = array(AMA_TYPE_SWITCHER); /** * Performs basic controls before entering this module */ $neededObjAr = array(AMA_TYPE_SWITCHER => array('layout', 'course')); require_once ROOT_DIR . '/include/module_init.inc.php'; $self = whoami(); include_once 'include/switcher_functions.inc.php'; /* * YOUR CODE HERE */ if (!$courseObj instanceof Course || !$courseObj->isFull()) { $data = new CText(translateFN('Corso non trovato')); } else { $authorObj = MultiPort::findUser($courseObj->getAuthorId()); $language_info = Translator::getLanguageInfoForLanguageId($courseObj->getLanguageId()); $formData = array('id corso' => $courseObj->getId(), 'autore' => $authorObj->getFullName(), 'lingua' => $language_info['nome_lingua'], 'codice corso' => $courseObj->getCode(), 'titolo' => $courseObj->getTitle(), 'descrizione' => $courseObj->getDescription(), 'id nodo iniziale' => $courseObj->getRootNodeId(), 'id nodo toc' => $courseObj->getTableOfContentsNodeId(), 'media path' => $courseObj->getMediaPath(), 'data di creazione' => $courseObj->getCreationDate(), 'data di pubblicazione' => $courseObj->getPublicationDate(), 'crediti' => $courseObj->getCredits()); $data = BaseHtmlLib::labeledListElement('class:view_info', $formData); } $label = translateFN('Visualizzazione dei dati del corso'); $help = translateFN('Da qui il provider admin può visualizzare i dati di un corso esistente'); $content_dataAr = array('user_name' => $user_name, 'user_type' => $user_type, 'status' => $status, 'label' => $label, 'edit_profile' => $userObj->getEditProfilePage(), 'help' => $help, 'data' => $data->getHtml(), 'module' => isset($module) ? $module : '', 'messages' => $user_messages->getHtml()); ARE::render($layout_dataAr, $content_dataAr);
$extension = '.' . end($exploded_filename); $underscoreDelimited = explode('_', reset($exploded_filename)); /** * If the last piece of $underscoreDelimited has length 2 * it's assumed to be lang part of the file name, remove it */ if (strlen(end($underscoreDelimited)) === 2) { unset($underscoreDelimited[count($underscoreDelimited) - 1]); } /* * attempt to find the file in the user actual language */ if (is_object($userObj)) { $userActualLangId = $userObj->getLanguage(); if ($userActualLangId != false) { $userActualLang = Translator::getLanguageInfoForLanguageId($userActualLangId); $userActualLangCod = $userActualLang['codice_lingua']; } if (isset($userActualLangCod)) { $filename = implode('_', $underscoreDelimited) . '_' . $userActualLangCod . $extension; $foundFile = is_file(ROOT_DIR . '/docs/' . $filename) && is_readable(ROOT_DIR . '/docs/' . $filename); } } /** * build the array of candidate languages */ $tryLangs = array($login_page_language_code = Translator::negotiateLoginPageLanguage()); if (!in_array(ADA_LOGIN_PAGE_DEFAULT_LANGUAGE, $tryLangs)) { $tryLangs[] = ADA_LOGIN_PAGE_DEFAULT_LANGUAGE; } /**