SettingsController.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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. # if plugin is not active, then skip required
  308. $skiprequired = false;
  309. if($objectType == 'plugins' && !isset($userInput['active']))
  310. {
  311. $skiprequired = true;
  312. }
  313. /* take the user input data and iterate over all fields and values */
  314. foreach($userInput as $fieldName => $fieldValue)
  315. {
  316. /* get the corresponding field definition from original plugin settings */
  317. $fieldDefinition = isset($originalFields[$fieldName]) ? $originalFields[$fieldName] : false;
  318. if($fieldDefinition)
  319. {
  320. /* validate user input for this field */
  321. $validate->objectField($fieldName, $fieldValue, $objectName, $fieldDefinition, $skiprequired);
  322. }
  323. if(!$fieldDefinition && $fieldName != 'active')
  324. {
  325. $_SESSION['errors'][$objectName][$fieldName] = array('This field is not defined!');
  326. }
  327. }
  328. }
  329. }
  330. /***********************
  331. ** USER MANAGEMENT **
  332. ***********************/
  333. public function showUser($request, $response, $args)
  334. {
  335. if($_SESSION['role'] == 'editor' && $_SESSION['user'] !== $args['username'])
  336. {
  337. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  338. }
  339. $validate = new Validation();
  340. if($validate->username($args['username']))
  341. {
  342. $user = new User();
  343. $users = $user->getUsers();
  344. $userrole = $user->getUserroles();
  345. $userdata = $user->getUser($args['username']);
  346. $settings = $this->c->get('settings');
  347. if($userdata)
  348. {
  349. return $this->render($response, 'settings/user.twig', array('settings' => $settings, 'users' => $users, 'userdata' => $userdata, 'userrole' => $userrole, 'username' => $args['username'] ));
  350. }
  351. }
  352. $this->c->flash->addMessage('error', 'User does not exists');
  353. return $response->withRedirect($this->c->router->pathFor('user.list'));
  354. }
  355. public function listUser($request, $response)
  356. {
  357. $user = new User();
  358. $users = $user->getUsers();
  359. $userdata = array();
  360. $route = $request->getAttribute('route');
  361. $settings = $this->c->get('settings');
  362. foreach($users as $username)
  363. {
  364. $userdata[] = $user->getUser($username);
  365. }
  366. return $this->render($response, 'settings/userlist.twig', array('settings' => $settings, 'users' => $users, 'userdata' => $userdata, 'route' => $route->getName() ));
  367. }
  368. public function newUser($request, $response, $args)
  369. {
  370. $user = new User();
  371. $users = $user->getUsers();
  372. $userrole = $user->getUserroles();
  373. $route = $request->getAttribute('route');
  374. $settings = $this->c->get('settings');
  375. return $this->render($response, 'settings/usernew.twig', array('settings' => $settings, 'users' => $users, 'userrole' => $userrole, 'route' => $route->getName() ));
  376. }
  377. public function createUser($request, $response, $args)
  378. {
  379. if($request->isPost())
  380. {
  381. $referer = $request->getHeader('HTTP_REFERER');
  382. $uri = $request->getUri();
  383. $base_url = $uri->getBaseUrl();
  384. # security, users should not be able to fake post with settings from other typemill pages.
  385. if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/user/new' )
  386. {
  387. $this->c->flash->addMessage('error', 'illegal referer');
  388. return $response->withRedirect($this->c->router->pathFor('user.new'));
  389. }
  390. $params = $request->getParams();
  391. $user = new User();
  392. $userroles = $user->getUserroles();
  393. $validate = new Validation();
  394. if($validate->newUser($params, $userroles))
  395. {
  396. $userdata = array('username' => $params['username'], 'firstname' => $params['firstname'], 'lastname' => $params['lastname'], 'email' => $params['email'], 'userrole' => $params['userrole'], 'password' => $params['password']);
  397. $user->createUser($userdata);
  398. $this->c->flash->addMessage('info', 'Welcome, there is a new user!');
  399. return $response->withRedirect($this->c->router->pathFor('user.list'));
  400. }
  401. $this->c->flash->addMessage('error', 'Please correct your input');
  402. return $response->withRedirect($this->c->router->pathFor('user.new'));
  403. }
  404. }
  405. public function updateUser($request, $response, $args)
  406. {
  407. if($request->isPost())
  408. {
  409. $referer = $request->getHeader('HTTP_REFERER');
  410. $uri = $request->getUri();
  411. $base_url = $uri->getBaseUrl();
  412. # security, users should not be able to fake post with settings from other typemill pages.
  413. if(!isset($referer[0]) OR strpos($referer[0], $base_url . '/tm/user/') === false )
  414. {
  415. $this->c->flash->addMessage('error', 'illegal referer');
  416. return $response->withRedirect($this->c->router->pathFor('user.list'));
  417. }
  418. $params = $request->getParams();
  419. $user = new User();
  420. $userroles = $user->getUserroles();
  421. $validate = new Validation();
  422. /* non admins have different update rights */
  423. if($_SESSION['role'] !== 'administrator')
  424. {
  425. /* if an editor tries to update other userdata than its own */
  426. if($_SESSION['user'] !== $params['username'])
  427. {
  428. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  429. }
  430. /* non admins cannot change his userrole */
  431. $params['userrole'] = $_SESSION['role'];
  432. }
  433. if($validate->existingUser($params, $userroles))
  434. {
  435. $userdata = array('username' => $params['username'], 'firstname' => $params['firstname'], 'lastname' => $params['lastname'], 'email' => $params['email'], 'userrole' => $params['userrole']);
  436. if(empty($params['password']) AND empty($params['newpassword']))
  437. {
  438. $user->updateUser($userdata);
  439. $this->c->flash->addMessage('info', 'Saved all changes');
  440. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  441. }
  442. elseif($validate->newPassword($params))
  443. {
  444. $userdata['password'] = $params['newpassword'];
  445. $user->updateUser($userdata);
  446. $this->c->flash->addMessage('info', 'Saved all changes');
  447. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  448. }
  449. }
  450. $this->c->flash->addMessage('error', 'Please correct your input');
  451. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  452. }
  453. }
  454. public function deleteUser($request, $response, $args)
  455. {
  456. if($request->isPost())
  457. {
  458. $referer = $request->getHeader('HTTP_REFERER');
  459. $uri = $request->getUri();
  460. $base_url = $uri->getBaseUrl();
  461. # security, users should not be able to fake post with settings from other typemill pages.
  462. if(!isset($referer[0]) OR strpos($referer[0], $base_url . '/tm/user/') === false )
  463. {
  464. $this->c->flash->addMessage('error', 'illegal referer');
  465. return $response->withRedirect($this->c->router->pathFor('user.list'));
  466. }
  467. $params = $request->getParams();
  468. $validate = new Validation();
  469. $user = new User();
  470. /* non admins have different update rights */
  471. if($_SESSION['role'] !== 'administrator')
  472. {
  473. /* if an editor tries to delete other user than its own */
  474. if($_SESSION['user'] !== $params['username'])
  475. {
  476. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $_SESSION['user']] ));
  477. }
  478. }
  479. if($validate->username($params['username']))
  480. {
  481. $user->deleteUser($params['username']);
  482. # if user deleted his own account
  483. if($_SESSION['user'] == $params['username'])
  484. {
  485. session_destroy();
  486. return $response->withRedirect($this->c->router->pathFor('auth.show'));
  487. }
  488. $this->c->flash->addMessage('info', 'Say goodbye, the user is gone!');
  489. return $response->withRedirect($this->c->router->pathFor('user.list'));
  490. }
  491. $this->c->flash->addMessage('error', 'Ups, we did not find that user');
  492. return $response->withRedirect($this->c->router->pathFor('user.show', ['username' => $params['username']]));
  493. }
  494. }
  495. private function getThemes()
  496. {
  497. $themeFolder = $this->c->get('settings')['rootPath'] . $this->c->get('settings')['themeFolder'];
  498. $themeFolderC = scandir($themeFolder);
  499. $themes = array();
  500. foreach ($themeFolderC as $key => $theme)
  501. {
  502. if (!in_array($theme, array(".","..")))
  503. {
  504. if (is_dir($themeFolder . DIRECTORY_SEPARATOR . $theme))
  505. {
  506. $themes[] = $theme;
  507. }
  508. }
  509. }
  510. return $themes;
  511. }
  512. private function getCopyright()
  513. {
  514. return array(
  515. "©",
  516. "CC-BY",
  517. "CC-BY-NC",
  518. "CC-BY-NC-ND",
  519. "CC-BY-NC-SA",
  520. "CC-BY-ND",
  521. "CC-BY-SA",
  522. "None"
  523. );
  524. }
  525. private function getLanguages()
  526. {
  527. return array(
  528. 'nl' => 'Dutch, Flemish',
  529. 'en' => 'English',
  530. 'de' => 'German',
  531. 'it' => 'Italian',
  532. );
  533. }
  534. }