From 0d02caa684a4ecad8d69e74007c3f9893303f428 Mon Sep 17 00:00:00 2001
From: Lukas Reschke <lukas@statuscode.ch>
Date: Mon, 21 Jan 2013 20:34:28 +0100
Subject: [PATCH] No inline JS in apps

---
 apps/files/appinfo/routes.php      |  5 ++++-
 apps/files/js/publiclistview.php   | 21 +++++++++++++++++++++
 apps/files/templates/part.list.php |  8 +-------
 3 files changed, 26 insertions(+), 8 deletions(-)
 create mode 100644 apps/files/js/publiclistview.php

diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php
index 043782a9c0..307a4d0320 100644
--- a/apps/files/appinfo/routes.php
+++ b/apps/files/appinfo/routes.php
@@ -8,4 +8,7 @@
 
 $this->create('download', 'download{file}')
 	->requirements(array('file' => '.*'))
-	->actionInclude('files/download.php');
\ No newline at end of file
+	->actionInclude('files/download.php');
+// oC JS config
+$this->create('publicListView', 'js/publiclistview.js')
+	->actionInclude('files/js/publiclistview.php');
\ No newline at end of file
diff --git a/apps/files/js/publiclistview.php b/apps/files/js/publiclistview.php
new file mode 100644
index 0000000000..95e23a9b2b
--- /dev/null
+++ b/apps/files/js/publiclistview.php
@@ -0,0 +1,21 @@
+<?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"); 
+
+if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true )  {
+	echo "var publicListView = true;";
+} else {
+	echo "var publicListView = false;";
+}
+?>
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index dfac43d1b1..78f91467c7 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -1,10 +1,4 @@
-<script type="text/javascript">
-<?php if ( array_key_exists('publicListView', $_) && $_['publicListView'] == true ) :?>
-		var publicListView = true;
-<?php else: ?>
-		var publicListView = false;
-<?php endif; ?>
-</script>
+<script type="text/javascript" src="<?php echo OC_Helper::linkToRoute('publicListView');?>"></script>
 
 <?php foreach($_['files'] as $file):
 	$simple_file_size = OCP\simple_file_size($file['size']);
-- 
GitLab