SettingsController.php 20 KB

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