public function addLanguage() { ipRequest()->mustBePost(); $data = ipRequest()->getPost(); if (empty($data['code'])) { throw new \Ip\Exception('Missing required parameter'); } $code = $data['code']; $abbreviation = strtoupper($code); $url = $code; $languages = ipContent()->getLanguages(); foreach ($languages as $language) { if ($language->getCode() == $code) { return new \Ip\Response\Json(array('error' => 1, 'errorMessage' => __('This language already exist.', 'Ip-admin', false))); } } $languages = Fixture::languageList(); $directionality = Service::TEXT_DIRECTION_LTR; if (!empty($languages[$code])) { $language = $languages[$code]; $title = $language['nativeName']; if (!empty($language['directionality']) && $language['directionality'] == 'rtl') { $directionality = Service::TEXT_DIRECTION_RTL; } } else { $title = $code; } Service::addLanguage($title, $abbreviation, $code, $url, 1, $directionality); return new \Ip\Response\Json(array()); }
private static function getLanguageSelectValues() { $answer = array(); $languages = Fixture::languageList(); foreach ($languages as $key => $language) { $answer[] = array($key, $language['name'] . ' (' . $language['nativeName'] . ')'); } usort($answer, array(__CLASS__, 'cmp')); return $answer; }