config.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Lukas Reschke <lukas@statuscode.ch>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. // Set the content type to Javascript
  9. header("Content-type: text/javascript");
  10. // Disallow caching
  11. header("Cache-Control: no-cache, must-revalidate");
  12. header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
  13. // Enable l10n support
  14. $l = \OC::$server->getL10N('core');
  15. // Enable OC_Defaults support
  16. $defaults = new OC_Defaults();
  17. // Get the config
  18. $apps_paths = array();
  19. foreach(OC_App::getEnabledApps() as $app) {
  20. $apps_paths[$app] = OC_App::getAppWebPath($app);
  21. }
  22. $value = \OCP\Config::getAppValue('core', 'shareapi_default_expire_date', 'no');
  23. $defaultExpireDateEnabled = ($value === 'yes') ? true :false;
  24. $defaultExpireDate = $enforceDefaultExpireDate = null;
  25. if ($defaultExpireDateEnabled) {
  26. $defaultExpireDate = (int)\OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
  27. $value = \OCP\Config::getAppValue('core', 'shareapi_enforce_expire_date', 'no');
  28. $enforceDefaultExpireDate = ($value === 'yes') ? true : false;
  29. }
  30. $array = array(
  31. "oc_debug" => (defined('DEBUG') && DEBUG) ? 'true' : 'false',
  32. "oc_isadmin" => OC_User::isAdminUser(OC_User::getUser()) ? 'true' : 'false',
  33. "oc_webroot" => "\"".OC::$WEBROOT."\"",
  34. "oc_appswebroots" => str_replace('\\/', '/', json_encode($apps_paths)), // Ugly unescape slashes waiting for better solution
  35. "datepickerFormatDate" => json_encode($l->getDateFormat()),
  36. "dayNames" => json_encode(
  37. array(
  38. (string)$l->t('Sunday'),
  39. (string)$l->t('Monday'),
  40. (string)$l->t('Tuesday'),
  41. (string)$l->t('Wednesday'),
  42. (string)$l->t('Thursday'),
  43. (string)$l->t('Friday'),
  44. (string)$l->t('Saturday')
  45. )
  46. ),
  47. "monthNames" => json_encode(
  48. array(
  49. (string)$l->t('January'),
  50. (string)$l->t('February'),
  51. (string)$l->t('March'),
  52. (string)$l->t('April'),
  53. (string)$l->t('May'),
  54. (string)$l->t('June'),
  55. (string)$l->t('July'),
  56. (string)$l->t('August'),
  57. (string)$l->t('September'),
  58. (string)$l->t('October'),
  59. (string)$l->t('November'),
  60. (string)$l->t('December')
  61. )
  62. ),
  63. "firstDay" => json_encode($l->getFirstWeekDay()) ,
  64. "oc_config" => json_encode(
  65. array(
  66. 'session_lifetime' => min(\OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), ini_get('session.gc_maxlifetime')),
  67. 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true),
  68. 'version' => implode('.', OC_Util::getVersion()),
  69. 'versionstring' => OC_Util::getVersionString(),
  70. 'enable_avatars' => \OC::$server->getConfig()->getSystemValue('enable_avatars', true),
  71. )
  72. ),
  73. "oc_appconfig" => json_encode(
  74. array("core" => array(
  75. 'defaultExpireDateEnabled' => $defaultExpireDateEnabled,
  76. 'defaultExpireDate' => $defaultExpireDate,
  77. 'defaultExpireDateEnforced' => $enforceDefaultExpireDate,
  78. 'enforcePasswordForPublicLink' => \OCP\Util::isPublicLinkPasswordRequired(),
  79. 'sharingDisabledForUser' => \OCP\Util::isSharingDisabledForUser(),
  80. 'resharingAllowed' => \OCP\Share::isResharingAllowed(),
  81. )
  82. )
  83. ),
  84. "oc_defaults" => json_encode(
  85. array(
  86. 'entity' => $defaults->getEntity(),
  87. 'name' => $defaults->getName(),
  88. 'title' => $defaults->getTitle(),
  89. 'baseUrl' => $defaults->getBaseUrl(),
  90. 'syncClientUrl' => $defaults->getSyncClientUrl(),
  91. 'docBaseUrl' => $defaults->getDocBaseUrl(),
  92. 'slogan' => $defaults->getSlogan(),
  93. 'logoClaim' => $defaults->getLogoClaim(),
  94. 'shortFooter' => $defaults->getShortFooter(),
  95. 'longFooter' => $defaults->getLongFooter()
  96. )
  97. )
  98. );
  99. // Allow hooks to modify the output values
  100. OC_Hook::emit('\OCP\Config', 'js', array('array' => &$array));
  101. // Echo it
  102. foreach ($array as $setting => $value) {
  103. echo("var ". $setting ."=".$value.";\n");
  104. }