Blame view

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