summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/js/config.php42
-rw-r--r--core/templates/layout.base.php7
-rw-r--r--core/templates/layout.guest.php11
-rw-r--r--core/templates/layout.user.php19
4 files changed, 45 insertions, 34 deletions
diff --git a/core/js/config.php b/core/js/config.php
new file mode 100644
index 00000000000..bab9e6fd7e6
--- /dev/null
+++ b/core/js/config.php
@@ -0,0 +1,42 @@
+<?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
+header("Cache-Control: no-cache, must-revalidate");
+header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
+
+// Enable l10n support
+$l = OC_L10N::get('core');
+
+// Get the config
+$debug = (defined('DEBUG') && DEBUG) ? 'true' : 'false';
+$array = array(
+ "oc_debug" => $debug,
+ "oc_webroot" => "\"".OC::$WEBROOT."\"",
+ "oc_appswebroots" => "\"".$_['apps_paths']. "\"",
+ "oc_current_user" => "\"".OC_User::getUser(). "\"",
+ "oc_requesttoken" => "\"".$_['requesttoken']. "\"",
+ "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')) ,
+ );
+
+// Echo it
+foreach ($array as $setting => $value) {
+ echo("var ". $setting ."=".$value.";\n");
+}
+?>
+requesttoken = '<?php echo $_['requesttoken']; ?>';
+OC.EventSource.requesttoken=requesttoken;
+$(document).bind('ajaxSend', function(elm, xhr, s) {
+ xhr.setRequestHeader('requesttoken', requesttoken);
+}); \ No newline at end of file
diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php
index 47f4b423b3e..47fb75612cf 100644
--- a/core/templates/layout.base.php
+++ b/core/templates/layout.base.php
@@ -7,12 +7,7 @@
<?php foreach ($_['cssfiles'] as $cssfile): ?>
<link rel="stylesheet" href="<?php echo $cssfile; ?>" type="text/css" media="screen" />
<?php endforeach; ?>
- <script type="text/javascript">
- var oc_debug = <?php echo (defined('DEBUG') && DEBUG) ? 'true' : 'false'; ?>;
- var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
- var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
- var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
- </script>
+ <script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('js_config');?>"></script>
<?php foreach ($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
<?php endforeach; ?>
diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php
index 8395426e4e4..499d49e445d 100644
--- a/core/templates/layout.guest.php
+++ b/core/templates/layout.guest.php
@@ -7,16 +7,7 @@
<?php foreach($_['cssfiles'] as $cssfile): ?>
<link rel="stylesheet" href="<?php echo $cssfile; ?>" type="text/css" media="screen" />
<?php endforeach; ?>
- <script type="text/javascript">
- var oc_debug = <?php echo (defined('DEBUG') && DEBUG) ? 'true' : 'false'; ?>;
- var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
- var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
- var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
- var datepickerFormatDate = <?php echo json_encode($l->l('jsdate', 'jsdate')) ?>;
- var dayNames = <?php echo 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'))) ?>;
- var monthNames = <?php echo 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'))) ?>;
- var firstDay = <?php echo json_encode($l->l('firstday', 'firstday')) ?>;
- </script>
+ <script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('js_config');?>"></script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
<?php endforeach; ?>
diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php
index a16d2c9e55d..0e130c76d83 100644
--- a/core/templates/layout.user.php
+++ b/core/templates/layout.user.php
@@ -7,27 +7,10 @@
<?php foreach($_['cssfiles'] as $cssfile): ?>
<link rel="stylesheet" href="<?php echo $cssfile; ?>" type="text/css" media="screen" />
<?php endforeach; ?>
- <script type="text/javascript">
- var oc_debug = <?php echo (defined('DEBUG') && DEBUG) ? 'true' : 'false'; ?>;
- var oc_webroot = '<?php echo OC::$WEBROOT; ?>';
- var oc_appswebroots = <?php echo $_['apps_paths'] ?>;
- var oc_current_user = '<?php echo OC_User::getUser() ?>';
- var oc_requesttoken = '<?php echo $_['requesttoken']; ?>';
- var datepickerFormatDate = <?php echo json_encode($l->l('jsdate', 'jsdate')) ?>;
- var dayNames = <?php echo 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'))) ?>;
- var monthNames = <?php echo 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'))) ?>;
- var firstDay = <?php echo json_encode($l->l('firstday', 'firstday')) ?>;
- </script>
+ <script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('js_config');?>"></script>
<?php foreach($_['jsfiles'] as $jsfile): ?>
<script type="text/javascript" src="<?php echo $jsfile; ?>"></script>
<?php endforeach; ?>
- <script type="text/javascript">
- requesttoken = '<?php echo $_['requesttoken']; ?>';
- OC.EventSource.requesttoken=requesttoken;
- $(document).bind('ajaxSend', function(elm, xhr, s) {
- xhr.setRequestHeader('requesttoken', requesttoken);
- });
- </script>
<?php foreach($_['headers'] as $header): ?>
<?php
echo '<'.$header['tag'].' ';