SettingsController.php 27 KB

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