DokuWikiSetup.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. namespace Hestia\WebApp\Installers\DokuWiki;
  3. use Hestia\System\Util;
  4. use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
  5. class DokuWikiSetup extends BaseSetup {
  6. protected $appInfo = [
  7. 'name' => 'DokuWiki',
  8. 'group' => 'wiki',
  9. 'enabled' => true,
  10. 'version' => 'stable_2020-07-29',
  11. 'thumbnail' => 'dokuwiki-logo.svg'
  12. ];
  13. protected $appname = 'dokuwiki';
  14. protected $extractsubdir = "/tmp-dokuwiki";
  15. protected $config = [
  16. 'form' => [
  17. 'wiki_name' => 'text',
  18. 'superuser' => 'text',
  19. 'real_name' => 'text',
  20. 'email' => 'text',
  21. 'password' => 'password',
  22. 'initial_ACL_policy' => [
  23. 'type' => 'select',
  24. 'options' => [
  25. '0: Open Wiki (read, write, upload for everyone)', // 0
  26. '1: Public Wiki (read for everyone, write and upload for registered users)', // 1
  27. '2: Closed Wiki (read, write, upload for registered users only)' // 3
  28. ],
  29. ],
  30. 'content_license' => [
  31. 'type' => 'select',
  32. 'options' => [
  33. 'cc-zero: CC0 1.0 Universal',
  34. 'publicdomain: Public Domain',
  35. 'cc-by: CC Attribution 4.0 International',
  36. 'cc-by-sa: CC Attribution-Share Alike 4.0 International',
  37. 'gnufdl: GNU Free Documentation License 1.3',
  38. 'cc-by-nc: CC Attribution-Noncommercial 4.0 International',
  39. 'cc-by-nc-sa: CC Attribution-Noncommercial-Share Alike 4.0 International',
  40. '0: Do not show any license information',
  41. ]
  42. ],
  43. ],
  44. 'resources' => [
  45. 'archive' => [ 'src' => 'https://github.com/splitbrain/dokuwiki/archive/refs/tags/release_stable_2020-07-29.zip' ],
  46. ],
  47. ];
  48. public function install(array $options = null)
  49. {
  50. parent::install($options);
  51. $webDomain = "https://" . $this->domain . "/";
  52. $this->appcontext->runUser('v-copy-fs-directory',[
  53. $this->getDocRoot($this->extractsubdir . "/dokuwiki-release_stable_2020-07-29/."),
  54. $this->getDocRoot()], $result);
  55. $installUrl = $webDomain . "install.php";
  56. $cmd = "curl --request POST "
  57. . "--url $installUrl "
  58. . "--header 'Content-Type: application/x-www-form-urlencoded' "
  59. . "--data l=en "
  60. . "--data 'd[title]=" . $options['wiki_name'] . "' "
  61. . "--data 'd[acl]=on' "
  62. . "--data 'd[superuser]=" . $options['superuser'] . "' "
  63. . "--data 'd[fullname]=" . $options['real_name'] . "' "
  64. . "--data 'd[email]=" . $options['email'] . "' "
  65. . "--data 'd[password]=" . $options['password'] . "' "
  66. . "--data 'd[confirm]=" . $options['password'] . "' "
  67. . "--data 'd[policy]=" . substr($options['initial_ACL_policy'], 0, 1) . "' "
  68. . "--data 'd[license]=" . explode(":", $options['content_license'])[0] . "' "
  69. . "--data submit=";
  70. exec($cmd, $msg, $code);
  71. // remove temp folder
  72. $this->cleanup();
  73. return ($code === 0);
  74. }
  75. }