public static function delete($id) { //We know for sure that languages and sites can refer to the culture. //Other entities should place CultureOnBeforeDelete event handler. $result = new Entity\DeleteResult(); $res = LanguageTable::getList(array('filter' => array('=CULTURE_ID' => $id))); while ($language = $res->fetch()) { $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_lang", array("#LID#" => $language["LID"])))); } $res = \Freetrix\Main\SiteTable::getList(array('filter' => array('=CULTURE_ID' => $id))); while ($site = $res->fetch()) { $result->addError(new Entity\EntityError(Loc::getMessage("culture_err_del_site", array("#LID#" => $site["LID"])))); } if (!$result->isSuccess()) { return $result; } return parent::delete($id); }
protected function getCurrentLanguage() { $request = $this->getRequest(); $defaultLang = $request->get("lang"); if (empty($defaultLang)) { $defaultLang = Config\Option::get("main", "admin_lid", 'en'); } if (!empty($defaultLang)) { $recordset = LanguageTable::getById($defaultLang); if ($record = $recordset->fetch()) { return $record; } } $recordset = LanguageTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('DEF' => 'DESC', 'SORT' => 'ASC'), 'select' => array('*'))); if ($record = $recordset->fetch()) { return $record; } throw new SystemException('Language is not found'); }
function GetLangSwitcherArray() { /** @global CMain $APPLICATION */ global $APPLICATION; $result = array(); $db_res = \Freetrix\Main\Localization\LanguageTable::getList(array('filter' => array('ACTIVE' => 'Y'), 'order' => array('SORT' => 'ASC'))); while ($ar = $db_res->fetch()) { $ar["NAME"] = htmlspecialcharsbx($ar["NAME"]); $ar["SELECTED"] = $ar["LID"] == LANG; global $QUERY_STRING; $p = rtrim(str_replace("&#", "#", preg_replace("/lang=[^&#]*&*/", "", $QUERY_STRING)), "&"); $ar["PATH"] = $APPLICATION->GetCurPage() . "?lang=" . $ar["LID"] . ($p != '' ? '&' . htmlspecialcharsbx($p) : ''); $result[] = $ar; } return $result; }