SettingsController.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792
  1. <?php
  2. namespace Typemill\Controllers;
  3. use \Symfony\Component\Yaml\Yaml;
  4. use Typemill\Models\Fields;
  5. use Typemill\Models\Validation;
  6. use Typemill\Models\User;
  7. class SettingsController extends Controller
  8. {
  9. /*********************
  10. ** BASIC SETTINGS **
  11. *********************/
  12. public function showSettings($request, $response, $args)
  13. {
  14. $user = new User();
  15. $settings = $this->c->get('settings');
  16. $copyright = $this->getCopyright();
  17. $languages = $this->getLanguages();
  18. $locale = isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2) : 'en';
  19. $users = $user->getUsers();
  20. $route = $request->getAttribute('route');
  21. $this->render($response, 'settings/system.twig', array('settings' => $settings, 'copyright' => $copyright, 'languages' => $languages, 'locale' => $locale, 'users' => $users, 'route' => $route->getName() ));
  22. }
  23. public function saveSettings($request, $response, $args)
  24. {
  25. if($request->isPost())
  26. {
  27. $referer = $request->getHeader('HTTP_REFERER');
  28. $uri = $request->getUri();
  29. $base_url = $uri->getBaseUrl();
  30. # security, users should not be able to fake post with settings from other typemill pages.
  31. if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/settings' )
  32. {
  33. $this->c->flash->addMessage('error', 'illegal referer');
  34. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  35. }
  36. $settings = \Typemill\Settings::getUserSettings();
  37. $params = $request->getParams();
  38. $newSettings = isset($params['settings']) ? $params['settings'] : false;
  39. $validate = new Validation();
  40. if($newSettings)
  41. {
  42. /* make sure only allowed fields are stored */
  43. $newSettings = array(
  44. 'title' => $newSettings['title'],
  45. 'author' => $newSettings['author'],
  46. 'copyright' => $newSettings['copyright'],
  47. 'year' => $newSettings['year'],
  48. 'startpage' => isset($newSettings['startpage']) ? true : false,
  49. 'editor' => $newSettings['editor'],
  50. );
  51. $copyright = $this->getCopyright();
  52. $validate->settings($newSettings, $copyright, 'settings');
  53. }
  54. else
  55. {
  56. $this->c->flash->addMessage('error', 'Wrong Input');
  57. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  58. }
  59. if(isset($_SESSION['errors']))
  60. {
  61. $this->c->flash->addMessage('error', 'Please correct the errors');
  62. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  63. }
  64. /* store updated settings */
  65. \Typemill\Settings::updateSettings(array_merge($settings, $newSettings));
  66. $this->c->flash->addMessage('info', 'Settings are stored');
  67. return $response->withRedirect($this->c->router->pathFor('settings.show'));
  68. }
  69. }
  70. /*********************
  71. ** THEME SETTINGS **
  72. *********************/
  73. public function showThemes($request, $response, $args)
  74. {
  75. $userSettings = $this->c->get('settings');
  76. $themes = $this->getThemes();
  77. $themedata = array();
  78. $fieldsModel = new Fields();
  79. foreach($themes as $themeName)
  80. {
  81. /* if theme is active, list it first */
  82. if($userSettings['theme'] == $themeName)
  83. {
  84. $themedata = array_merge(array($themeName => null), $themedata);
  85. }
  86. else
  87. {
  88. $themedata[$themeName] = null;
  89. }
  90. $themeSettings = \Typemill\Settings::getObjectSettings('themes', $themeName);
  91. if($themeSettings)
  92. {
  93. /* store them as default theme data with author, year, default settings and field-definitions */
  94. $themedata[$themeName] = $themeSettings;
  95. }
  96. if(isset($themeSettings['forms']['fields']))
  97. {
  98. $fields = $fieldsModel->getFields($userSettings, 'themes', $themeName, $themeSettings);
  99. /* overwrite original theme form definitions with enhanced form objects */
  100. $themedata[$themeName]['forms']['fields'] = $fields;
  101. }
  102. /* add the preview image */
  103. $img = getcwd() . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeName . DIRECTORY_SEPARATOR . $themeName . '.jpg';
  104. $img = file_exists($img) ? $img : false;
  105. $themedata[$themeName]['img'] = $img;
  106. }
  107. /* add the users for navigation */
  108. $user = new User();
  109. $users = $user->getUsers();
  110. $route = $request->getAttribute('route');
  111. $this->render($response, 'settings/themes.twig', array('settings' => $userSettings, 'themes' => $themedata, 'users' => $users, 'route' => $route->getName() ));
  112. }
  113. public function showPlugins($request, $response, $args)
  114. {
  115. $userSettings = $this->c->get('settings');
  116. $plugins = array();
  117. $fieldsModel = new Fields();
  118. $fields = array();
  119. /* iterate through the plugins in the stored user settings */
  120. foreach($userSettings['plugins'] as $pluginName => $pluginUserSettings)
  121. {
  122. /* add plugin to plugin Data, if active, set it first */
  123. /* if plugin is active, list it first */
  124. if($userSettings['plugins'][$pluginName]['active'] == true)
  125. {
  126. $plugins = array_merge(array($pluginName => null), $plugins);
  127. }
  128. else
  129. {
  130. $plugins[$pluginName] = Null;
  131. }
  132. /* Check if the user has deleted a plugin. Then delete it in the settings and store the updated settings. */
  133. if(!is_dir($userSettings['rootPath'] . 'plugins' . DIRECTORY_SEPARATOR . $pluginName))
  134. {
  135. /* remove the plugin settings and store updated settings */
  136. \Typemill\Settings::removePluginSettings($pluginName);
  137. continue;
  138. }
  139. /* load the original plugin definitions from the plugin folder (author, version and stuff) */
  140. $pluginOriginalSettings = \Typemill\Settings::getObjectSettings('plugins', $pluginName);
  141. if($pluginOriginalSettings)
  142. {
  143. /* store them as default plugin data with plugin author, plugin year, default settings and field-definitions */
  144. $plugins[$pluginName] = $pluginOriginalSettings;
  145. }
  146. /* check, if the plugin has been disabled in the form-session-data */
  147. if(isset($_SESSION['old']) && !isset($_SESSION['old'][$pluginName]['active']))
  148. {
  149. $plugins[$pluginName]['settings']['active'] = false;
  150. }
  151. /* if the plugin defines forms and fields, so that the user can edit the plugin settings in the frontend */
  152. if(isset($pluginOriginalSettings['forms']['fields']))
  153. {
  154. # if the plugin defines frontend fields
  155. if(isset($pluginOriginalSettings['public']))
  156. {
  157. $pluginOriginalSettings['forms']['fields']['recaptcha'] = ['type' => 'checkbox', 'label' => 'Google Recaptcha', 'checkboxlabel' => 'Activate Recaptcha' ];
  158. $pluginOriginalSettings['forms']['fields']['recaptcha_webkey'] = ['type' => 'text', 'label' => 'Recaptcha Website Key', 'help' => 'Add the recaptcha website key here. You can get the key from the recaptcha website.', 'description' => 'The website key is mandatory if you activate the recaptcha field'];
  159. $pluginOriginalSettings['forms']['fields']['recaptcha_secretkey'] = ['type' => 'text', 'label' => 'Recaptcha Secret Key', 'help' => 'Add the recaptcha secret key here. You can get the key from the recaptcha website.', 'description' => 'The secret key is mandatory if you activate the recaptcha field'];
  160. }
  161. /* get all the fields and prefill them with the dafault-data, the user-data or old input data */
  162. $fields = $fieldsModel->getFields($userSettings, 'plugins', $pluginName, $pluginOriginalSettings);
  163. /* overwrite original plugin form definitions with enhanced form objects */
  164. $plugins[$pluginName]['forms']['fields'] = $fields;
  165. }
  166. }
  167. $user = new User();
  168. $users = $user->getUsers();
  169. $route = $request->getAttribute('route');
  170. $this->render($response, 'settings/plugins.twig', array('settings' => $userSettings, 'plugins' => $plugins, 'users' => $users, 'route' => $route->getName() ));
  171. }
  172. /*************************************
  173. ** SAVE THEME- AND PLUGIN-SETTINGS **
  174. *************************************/
  175. public function saveThemes($request, $response, $args)
  176. {
  177. if($request->isPost())
  178. {
  179. $referer = $request->getHeader('HTTP_REFERER');
  180. $uri = $request->getUri();
  181. $base_url = $uri->getBaseUrl();
  182. # security, users should not be able to fake post with settings from other typemill pages.
  183. if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/themes' )
  184. {
  185. $this->c->flash->addMessage('error', 'illegal referer');
  186. return $response->withRedirect($this->c->router->pathFor('themes.show'));
  187. }
  188. $userSettings = \Typemill\Settings::getUserSettings();
  189. $params = $request->getParams();
  190. $themeName = isset($params['theme']) ? $params['theme'] : false;
  191. $userInput = isset($params[$themeName]) ? $params[$themeName] : false;
  192. $validate = new Validation();
  193. $themeSettings = \Typemill\Settings::getObjectSettings('themes', $themeName);
  194. if(isset($themeSettings['settings']['images']))
  195. {
  196. $userSettings = ['images' => $themeSettings['settings']['images']];
  197. }
  198. /* set theme name and delete theme settings from user settings for the case, that the new theme has no settings */
  199. $userSettings['theme'] = $themeName;
  200. if($userInput)
  201. {
  202. /* validate the user-input */
  203. $this->validateInput('themes', $themeName, $userInput, $validate);
  204. /* set user input as theme settings */
  205. $userSettings['themes'][$themeName] = $userInput;
  206. }
  207. /* check for errors and redirect to path, if errors found */
  208. if(isset($_SESSION['errors']))
  209. {
  210. $this->c->flash->addMessage('error', 'Please correct the errors');
  211. return $response->withRedirect($this->c->router->pathFor('themes.show'));
  212. }
  213. /* store updated settings */
  214. \Typemill\Settings::updateSettings($userSettings);
  215. $this->c->flash->addMessage('info', 'Settings are stored');
  216. return $response->withRedirect($this->c->router->pathFor('themes.show'));
  217. }
  218. }
  219. public function savePlugins($request, $response, $args)
  220. {
  221. if($request->isPost())
  222. {
  223. $referer = $request->getHeader('HTTP_REFERER');
  224. $uri = $request->getUri();
  225. $base_url = $uri->getBaseUrl();
  226. # security, users should not be able to fake post with settings from other typemill pages.
  227. if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/plugins' )
  228. {
  229. $this->c->flash->addMessage('error', 'illegal referer');
  230. return $response->withRedirect($this->c->router->pathFor('plugins.show'));
  231. }
  232. $userSettings = \Typemill\Settings::getUserSettings();
  233. $pluginSettings = array();
  234. $userInput = $request->getParams();
  235. $validate = new Validation();
  236. /* use the stored user settings and iterate over all original plugin settings, so we do not forget any... */
  237. foreach($userSettings['plugins'] as $pluginName => $pluginUserSettings)
  238. {
  239. /* if there are no input-data for this plugin, then use the stored plugin settings */
  240. if(!isset($userInput[$pluginName]))
  241. {
  242. $pluginSettings[$pluginName] = $pluginUserSettings;
  243. }
  244. else
  245. {
  246. /* validate the user-input */
  247. $this->validateInput('plugins', $pluginName, $userInput[$pluginName], $validate);
  248. /* use the input data */
  249. $pluginSettings[$pluginName] = $userInput[$pluginName];
  250. }
  251. /* deactivate the plugin, if there is no active flag */
  252. if(!isset($userInput[$pluginName]['active']))
  253. {
  254. $pluginSettings[$pluginName]['active'] = false;
  255. }
  256. }
  257. if(isset($_SESSION['errors']))
  258. {
  259. $this->c->flash->addMessage('error', 'Please correct the errors below');
  260. }
  261. else
  262. {
  263. /* if everything is valid, add plugin settings to base settings again */
  264. $userSettings['plugins'] = $pluginSettings;
  265. /* store updated settings */
  266. \Typemill\Settings::updateSettings($userSettings);
  267. $this->c->flash->addMessage('info', 'Settings are stored');
  268. }
  269. return $response->withRedirect($this->c->router->pathFor('plugins.show'));
  270. }
  271. }
  272. private function validateInput($objectType, $objectName, $userInput, $validate)
  273. {
  274. /* fetch the original settings from the folder (plugin or theme) to get the field definitions */
  275. $originalSettings = \Typemill\Settings::getObjectSettings($objectType, $objectName);
  276. if(isset($originalSettings['forms']['fields']))
  277. {
  278. /* flaten the multi-dimensional array with fieldsets to a one-dimensional array */
  279. $originalFields = array();
  280. foreach($originalSettings['forms']['fields'] as $fieldName => $fieldValue)
  281. {
  282. if(isset($fieldValue['fields']))
  283. {
  284. foreach($fieldValue['fields'] as $subFieldName => $subFieldValue)
  285. {
  286. $originalFields[$subFieldName] = $subFieldValue;
  287. }
  288. }
  289. else
  290. {
  291. $originalFields[$fieldName] = $fieldValue;
  292. }
  293. }
  294. # if the plugin defines frontend fields
  295. if(isset($originalSettings['public']))
  296. {
  297. $originalFields['recaptcha'] = ['type' => 'checkbox', 'label' => 'Google Recaptcha', 'checkboxlabel' => 'Activate Recaptcha' ];
  298. $originalFields['recaptcha_webkey'] = ['type' => 'text', 'label' => 'Recaptcha Website Key', 'help' => 'Add the recaptcha website key here. You can get the key from the recaptcha website.', 'description' => 'The website key is mandatory if you activate the recaptcha field'];
  299. $originalFields['recaptcha_secretkey'] = ['type' => 'text', 'label' => 'Recaptcha Secret Key', 'help' => 'Add the recaptcha secret key here. You can get the key from the recaptcha website.', 'description' => 'The secret key is mandatory if you activate the recaptcha field'];
  300. }
  301. /* take the user input data and iterate over all fields and values */
  302. foreach($userInput as $fieldName => $fieldValue)
  303. {
  304. /* get the corresponding field definition from original plugin settings */
  305. $fieldDefinition = isset($originalFields[$fieldName]) ? $originalFields[$fieldName] : false;
  306. if($fieldDefinition)
  307. {
  308. /* validate user input for this field */
  309. $validate->objectField($fieldName, $fieldValue, $objectName, $fieldDefinition);
  310. }
  311. if(!$fieldDefinition && $fieldName != 'active')
  312. {
  313. $_SESSION['errors'][$objectName][$fieldName] = array('This field is not defined!');
  314. }
  315. }
  316. }
  317. }
  318. /***********************
  319. ** USER MANAGEMENT **
  320. ***********************/
  321. public function showUser($request, $response, $args)
  322. {
  323. if($_SESSION['role'] == 'editor' && $_SESSION['user'] !== $args['username'])
  324. {
  325. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  326. }
  327. $validate = new Validation();
  328. if($validate->username($args['username']))
  329. {
  330. $user = new User();
  331. $users = $user->getUsers();
  332. $userrole = $user->getUserroles();
  333. $userdata = $user->getUser($args['username']);
  334. $settings = $this->c->get('settings');
  335. if($userdata)
  336. {
  337. return $this->render($response, 'settings/user.twig', array('settings' => $settings, 'users' => $users, 'userdata' => $userdata, 'userrole' => $userrole, 'username' => $args['username'] ));
  338. }
  339. }
  340. $this->c->flash->addMessage('error', 'User does not exists');
  341. return $response->withRedirect($this->c->router->pathFor('user.list'));
  342. }
  343. public function listUser($request, $response)
  344. {
  345. $user = new User();
  346. $users = $user->getUsers();
  347. $userdata = array();
  348. $route = $request->getAttribute('route');
  349. $settings = $this->c->get('settings');
  350. foreach($users as $username)
  351. {
  352. $userdata[] = $user->getUser($username);
  353. }
  354. $this->render($response, 'settings/userlist.twig', array('settings' => $settings, 'users' => $users, 'userdata' => $userdata, 'route' => $route->getName() ));
  355. }
  356. public function newUser($request, $response, $args)
  357. {
  358. $user = new User();
  359. $users = $user->getUsers();
  360. $userrole = $user->getUserroles();
  361. $route = $request->getAttribute('route');
  362. $settings = $this->c->get('settings');
  363. $this->render($response, 'settings/usernew.twig', array('settings' => $settings, 'users' => $users, 'userrole' => $userrole, 'route' => $route->getName() ));
  364. }
  365. public function createUser($request, $response, $args)
  366. {
  367. if($request->isPost())
  368. {
  369. $referer = $request->getHeader('HTTP_REFERER');
  370. $uri = $request->getUri();
  371. $base_url = $uri->getBaseUrl();
  372. # security, users should not be able to fake post with settings from other typemill pages.
  373. if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/user/new' )
  374. {
  375. $this->c->flash->addMessage('error', 'illegal referer');
  376. return $response->withRedirect($this->c->router->pathFor('user.new'));
  377. }
  378. $params = $request->getParams();
  379. $user = new User();
  380. $userroles = $user->getUserroles();
  381. $validate = new Validation();
  382. if($validate->newUser($params, $userroles))
  383. {
  384. $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole'], 'password' => $params['password']);
  385. $user->createUser($userdata);
  386. $this->c->flash->addMessage('info', 'Welcome, there is a new user!');
  387. return $response->withRedirect($this->c->router->pathFor('user.list'));
  388. }
  389. $this->c->flash->addMessage('error', 'Please correct your input');
  390. return $response->withRedirect($this->c->router->pathFor('user.new'));
  391. }
  392. }
  393. public function updateUser($request, $response, $args)
  394. {
  395. if($request->isPost())
  396. {
  397. $referer = $request->getHeader('HTTP_REFERER');
  398. $uri = $request->getUri();
  399. $base_url = $uri->getBaseUrl();
  400. # security, users should not be able to fake post with settings from other typemill pages.
  401. if(!isset($referer[0]) OR strpos($referer[0], $base_url . '/tm/user/') === false )
  402. {
  403. $this->c->flash->addMessage('error', 'illegal referer');
  404. return $response->withRedirect($this->c->router->pathFor('user.list'));
  405. }
  406. $params = $request->getParams();
  407. $user = new User();
  408. $userroles = $user->getUserroles();
  409. $validate = new Validation();
  410. /* non admins have different update rights */
  411. if($_SESSION['role'] !== 'administrator')
  412. {
  413. /* if an editor tries to update other userdata than its own */
  414. if($_SESSION['user'] !== $params['username'])
  415. {
  416. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  417. }
  418. /* non admins cannot change his userrole */
  419. $params['userrole'] = $_SESSION['role'];
  420. }
  421. if($validate->existingUser($params, $userroles))
  422. {
  423. $userdata = array('username' => $params['username'], 'email' => $params['email'], 'userrole' => $params['userrole']);
  424. if(empty($params['password']) AND empty($params['newpassword']))
  425. {
  426. $user->updateUser($userdata);
  427. $this->c->flash->addMessage('info', 'Saved all changes');
  428. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  429. }
  430. elseif($validate->newPassword($params))
  431. {
  432. $userdata['password'] = $params['newpassword'];
  433. $user->updateUser($userdata);
  434. $this->c->flash->addMessage('info', 'Saved all changes');
  435. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  436. }
  437. }
  438. $this->c->flash->addMessage('error', 'Please correct your input');
  439. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  440. }
  441. }
  442. public function deleteUser($request, $response, $args)
  443. {
  444. if($request->isPost())
  445. {
  446. $referer = $request->getHeader('HTTP_REFERER');
  447. $uri = $request->getUri();
  448. $base_url = $uri->getBaseUrl();
  449. # security, users should not be able to fake post with settings from other typemill pages.
  450. if(!isset($referer[0]) OR strpos($referer[0], $base_url . '/tm/user/') === false )
  451. {
  452. $this->c->flash->addMessage('error', 'illegal referer');
  453. return $response->withRedirect($this->c->router->pathFor('user.list'));
  454. }
  455. $params = $request->getParams();
  456. $validate = new Validation();
  457. $user = new User();
  458. /* non admins have different update rights */
  459. if($_SESSION['role'] !== 'administrator')
  460. {
  461. /* if an editor tries to delete other user than its own */
  462. if($_SESSION['user'] !== $params['username'])
  463. {
  464. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  465. }
  466. }
  467. if($validate->username($params['username']))
  468. {
  469. $user->deleteUser($params['username']);
  470. $this->c->flash->addMessage('info', 'Say goodbye, the user is gone!');
  471. return $response->withRedirect($this->c->router->pathFor('user.list'));
  472. }
  473. $this->c->flash->addMessage('error', 'Ups, we did not find that user');
  474. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  475. }
  476. }
  477. private function getThemes()
  478. {
  479. $themeFolder = $this->c->get('settings')['rootPath'] . $this->c->get('settings')['themeFolder'];
  480. $themeFolderC = scandir($themeFolder);
  481. $themes = array();
  482. foreach ($themeFolderC as $key => $theme)
  483. {
  484. if (!in_array($theme, array(".","..")))
  485. {
  486. if (is_dir($themeFolder . DIRECTORY_SEPARATOR . $theme))
  487. {
  488. $themes[] = $theme;
  489. }
  490. }
  491. }
  492. return $themes;
  493. }
  494. private function getCopyright()
  495. {
  496. return array(
  497. "©",
  498. "CC-BY",
  499. "CC-BY-NC",
  500. "CC-BY-NC-ND",
  501. "CC-BY-NC-SA",
  502. "CC-BY-ND",
  503. "CC-BY-SA",
  504. "None"
  505. );
  506. }
  507. private function getLanguages()
  508. {
  509. return array(
  510. 'ab' => 'Abkhazian',
  511. 'aa' => 'Afar',
  512. 'af' => 'Afrikaans',
  513. 'ak' => 'Akan',
  514. 'sq' => 'Albanian',
  515. 'am' => 'Amharic',
  516. 'ar' => 'Arabic',
  517. 'an' => 'Aragonese',
  518. 'hy' => 'Armenian',
  519. 'as' => 'Assamese',
  520. 'av' => 'Avaric',
  521. 'ae' => 'Avestan',
  522. 'ay' => 'Aymara',
  523. 'az' => 'Azerbaijani',
  524. 'bm' => 'Bambara',
  525. 'ba' => 'Bashkir',
  526. 'eu' => 'Basque',
  527. 'be' => 'Belarusian',
  528. 'bn' => 'Bengali',
  529. 'bh' => 'Bihari languages',
  530. 'bi' => 'Bislama',
  531. 'bs' => 'Bosnian',
  532. 'br' => 'Breton',
  533. 'bg' => 'Bulgarian',
  534. 'my' => 'Burmese',
  535. 'ca' => 'Catalan, Valencian',
  536. 'km' => 'Central Khmer',
  537. 'ch' => 'Chamorro',
  538. 'ce' => 'Chechen',
  539. 'ny' => 'Chichewa, Chewa, Nyanja',
  540. 'zh' => 'Chinese',
  541. 'cu' => 'Church Slavonic, Old Bulgarian, Old Church Slavonic',
  542. 'cv' => 'Chuvash',
  543. 'kw' => 'Cornish',
  544. 'co' => 'Corsican',
  545. 'cr' => 'Cree',
  546. 'hr' => 'Croatian',
  547. 'cs' => 'Czech',
  548. 'da' => 'Danish',
  549. 'dv' => 'Divehi, Dhivehi, Maldivian',
  550. 'nl' => 'Dutch, Flemish',
  551. 'dz' => 'Dzongkha',
  552. 'en' => 'English',
  553. 'eo' => 'Esperanto',
  554. 'et' => 'Estonian',
  555. 'ee' => 'Ewe',
  556. 'fo' => 'Faroese',
  557. 'fj' => 'Fijian',
  558. 'fi' => 'Finnish',
  559. 'fr' => 'French',
  560. 'ff' => 'Fulah',
  561. 'gd' => 'Gaelic, Scottish Gaelic',
  562. 'gl' => 'Galician',
  563. 'lg' => 'Ganda',
  564. 'ka' => 'Georgian',
  565. 'de' => 'German',
  566. 'ki' => 'Gikuyu, Kikuyu',
  567. 'el' => 'Greek (Modern)',
  568. 'kl' => 'Greenlandic, Kalaallisut',
  569. 'gn' => 'Guarani',
  570. 'gu' => 'Gujarati',
  571. 'ht' => 'Haitian, Haitian Creole',
  572. 'ha' => 'Hausa',
  573. 'he' => 'Hebrew',
  574. 'hz' => 'Herero',
  575. 'hi' => 'Hindi',
  576. 'ho' => 'Hiri Motu',
  577. 'hu' => 'Hungarian',
  578. 'is' => 'Icelandic',
  579. 'io' => 'Ido',
  580. 'ig' => 'Igbo',
  581. 'id' => 'Indonesian',
  582. 'ia' => 'Interlingua (International Auxiliary Language Association)',
  583. 'ie' => 'Interlingue',
  584. 'iu' => 'Inuktitut',
  585. 'ik' => 'Inupiaq',
  586. 'ga' => 'Irish',
  587. 'it' => 'Italian',
  588. 'ja' => 'Japanese',
  589. 'jv' => 'Javanese',
  590. 'kn' => 'Kannada',
  591. 'kr' => 'Kanuri',
  592. 'ks' => 'Kashmiri',
  593. 'kk' => 'Kazakh',
  594. 'rw' => 'Kinyarwanda',
  595. 'kv' => 'Komi',
  596. 'kg' => 'Kongo',
  597. 'ko' => 'Korean',
  598. 'kj' => 'Kwanyama, Kuanyama',
  599. 'ku' => 'Kurdish',
  600. 'ky' => 'Kyrgyz',
  601. 'lo' => 'Lao',
  602. 'la' => 'Latin',
  603. 'lv' => 'Latvian',
  604. 'lb' => 'Letzeburgesch, Luxembourgish',
  605. 'li' => 'Limburgish, Limburgan, Limburger',
  606. 'ln' => 'Lingala',
  607. 'lt' => 'Lithuanian',
  608. 'lu' => 'Luba-Katanga',
  609. 'mk' => 'Macedonian',
  610. 'mg' => 'Malagasy',
  611. 'ms' => 'Malay',
  612. 'ml' => 'Malayalam',
  613. 'mt' => 'Maltese',
  614. 'gv' => 'Manx',
  615. 'mi' => 'Maori',
  616. 'mr' => 'Marathi',
  617. 'mh' => 'Marshallese',
  618. 'ro' => 'Moldovan, Moldavian, Romanian',
  619. 'mn' => 'Mongolian',
  620. 'na' => 'Nauru',
  621. 'nv' => 'Navajo, Navaho',
  622. 'nd' => 'Northern Ndebele',
  623. 'ng' => 'Ndonga',
  624. 'ne' => 'Nepali',
  625. 'se' => 'Northern Sami',
  626. 'no' => 'Norwegian',
  627. 'nb' => 'Norwegian Bokmål',
  628. 'nn' => 'Norwegian Nynorsk',
  629. 'ii' => 'Nuosu, Sichuan Yi',
  630. 'oc' => 'Occitan (post 1500)',
  631. 'oj' => 'Ojibwa',
  632. 'or' => 'Oriya',
  633. 'om' => 'Oromo',
  634. 'os' => 'Ossetian, Ossetic',
  635. 'pi' => 'Pali',
  636. 'pa' => 'Panjabi, Punjabi',
  637. 'ps' => 'Pashto, Pushto',
  638. 'fa' => 'Persian',
  639. 'pl' => 'Polish',
  640. 'pt' => 'Portuguese',
  641. 'qu' => 'Quechua',
  642. 'rm' => 'Romansh',
  643. 'rn' => 'Rundi',
  644. 'ru' => 'Russian',
  645. 'sm' => 'Samoan',
  646. 'sg' => 'Sango',
  647. 'sa' => 'Sanskrit',
  648. 'sc' => 'Sardinian',
  649. 'sr' => 'Serbian',
  650. 'sn' => 'Shona',
  651. 'sd' => 'Sindhi',
  652. 'si' => 'Sinhala, Sinhalese',
  653. 'sk' => 'Slovak',
  654. 'sl' => 'Slovenian',
  655. 'so' => 'Somali',
  656. 'st' => 'Sotho, Southern',
  657. 'nr' => 'South Ndebele',
  658. 'es' => 'Spanish, Castilian',
  659. 'su' => 'Sundanese',
  660. 'sw' => 'Swahili',
  661. 'ss' => 'Swati',
  662. 'sv' => 'Swedish',
  663. 'tl' => 'Tagalog',
  664. 'ty' => 'Tahitian',
  665. 'tg' => 'Tajik',
  666. 'ta' => 'Tamil',
  667. 'tt' => 'Tatar',
  668. 'te' => 'Telugu',
  669. 'th' => 'Thai',
  670. 'bo' => 'Tibetan',
  671. 'ti' => 'Tigrinya',
  672. 'to' => 'Tonga (Tonga Islands)',
  673. 'ts' => 'Tsonga',
  674. 'tn' => 'Tswana',
  675. 'tr' => 'Turkish',
  676. 'tk' => 'Turkmen',
  677. 'tw' => 'Twi',
  678. 'ug' => 'Uighur, Uyghur',
  679. 'uk' => 'Ukrainian',
  680. 'ur' => 'Urdu',
  681. 'uz' => 'Uzbek',
  682. 've' => 'Venda',
  683. 'vi' => 'Vietnamese',
  684. 'vo' => 'Volap_k',
  685. 'wa' => 'Walloon',
  686. 'cy' => 'Welsh',
  687. 'fy' => 'Western Frisian',
  688. 'wo' => 'Wolof',
  689. 'xh' => 'Xhosa',
  690. 'yi' => 'Yiddish',
  691. 'yo' => 'Yoruba',
  692. 'za' => 'Zhuang, Chuang',
  693. 'zu' => 'Zulu'
  694. );
  695. }
  696. }