From 2d40d06bf9c14e587e76b767670547ee4847340c Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Wed, 23 Jan 2013 12:28:03 +0100 Subject: [PATCH 1/3] Move inline JS to external file --- index.php | 1 - js/js-contacts.php | 33 +++++++++++++++++++++++++++++++++ js/js-index.php | 26 ++++++++++++++++++++++++++ templates/contacts.php | 7 +------ templates/index.php | 7 +------ 5 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 js/js-contacts.php create mode 100644 js/js-index.php diff --git a/index.php b/index.php index 4e80db04..5add285b 100644 --- a/index.php +++ b/index.php @@ -77,5 +77,4 @@ $tmpl->assign('categories', $categories, false); $tmpl->assign('im_protocols', $im_protocols, false); $tmpl->assign('has_contacts', $has_contacts, false); $tmpl->assign('id', $id); -$tmpl->assign('is_indexed', OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no')); $tmpl->printPage(); diff --git a/js/js-contacts.php b/js/js-contacts.php new file mode 100644 index 00000000..d4c25e7b --- /dev/null +++ b/js/js-contacts.php @@ -0,0 +1,33 @@ + + * 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"); + +$is_indexed = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no'); +if ($is_indexed == 1) { + $is_indexed = "true"; +} else { + $is_indexed = "false"; +} + +$array = array( + "is_indexed" => $is_indexed, + "totalurl" => "\"".OCP\Util::linkToRemote('carddav')."addressbooks\"", + "id" => "\"".$_GET['id']."\"", + "lang" => "\"".OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en')."\"", + ); + +// Echo it +foreach ($array as $setting => $value) { + echo("var ". $setting ."=".$value.";\n"); +} \ No newline at end of file diff --git a/js/js-index.php b/js/js-index.php new file mode 100644 index 00000000..76982fd7 --- /dev/null +++ b/js/js-index.php @@ -0,0 +1,26 @@ + + * 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"); + +$array = array( + "totalurl" => "\"".OCP\Util::linkToRemote('carddav')."\"", + "categories" => json_encode(OCA\Contacts\App::getCategories()), + "id" => "\"".$_GET['id']."\"", + "lang" => "\"".OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en')."\"", + ); + +// Echo it +foreach ($array as $setting => $value) { + echo("var ". $setting ."=".$value.";\n"); +} \ No newline at end of file diff --git a/templates/contacts.php b/templates/contacts.php index 945e198c..6c6dbeaf 100644 --- a/templates/contacts.php +++ b/templates/contacts.php @@ -1,10 +1,5 @@
- +
diff --git a/templates/index.php b/templates/index.php index f328d393..cffefb6d 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,10 +1,5 @@
- +
From 5159a5b8f6afc835fb09920f62bd368fbe1fe897 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 16:30:14 +0100 Subject: [PATCH 2/3] Undo uneeded changes --- js/js-contacts.php | 33 --------------------------------- js/js-index.php | 26 -------------------------- templates/index.php | 1 - 3 files changed, 60 deletions(-) delete mode 100644 js/js-contacts.php delete mode 100644 js/js-index.php diff --git a/js/js-contacts.php b/js/js-contacts.php deleted file mode 100644 index d4c25e7b..00000000 --- a/js/js-contacts.php +++ /dev/null @@ -1,33 +0,0 @@ - - * 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"); - -$is_indexed = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no'); -if ($is_indexed == 1) { - $is_indexed = "true"; -} else { - $is_indexed = "false"; -} - -$array = array( - "is_indexed" => $is_indexed, - "totalurl" => "\"".OCP\Util::linkToRemote('carddav')."addressbooks\"", - "id" => "\"".$_GET['id']."\"", - "lang" => "\"".OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en')."\"", - ); - -// Echo it -foreach ($array as $setting => $value) { - echo("var ". $setting ."=".$value.";\n"); -} \ No newline at end of file diff --git a/js/js-index.php b/js/js-index.php deleted file mode 100644 index 76982fd7..00000000 --- a/js/js-index.php +++ /dev/null @@ -1,26 +0,0 @@ - - * 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"); - -$array = array( - "totalurl" => "\"".OCP\Util::linkToRemote('carddav')."\"", - "categories" => json_encode(OCA\Contacts\App::getCategories()), - "id" => "\"".$_GET['id']."\"", - "lang" => "\"".OCP\Config::getUserValue(OCP\USER::getUser(), 'core', 'lang', 'en')."\"", - ); - -// Echo it -foreach ($array as $setting => $value) { - echo("var ". $setting ."=".$value.";\n"); -} \ No newline at end of file diff --git a/templates/index.php b/templates/index.php index cffefb6d..d107e450 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,5 +1,4 @@
-
From f10118ff2324f8db2eba638a5498fd982b7730b2 Mon Sep 17 00:00:00 2001 From: Lukas Reschke Date: Fri, 25 Jan 2013 16:33:41 +0100 Subject: [PATCH 3/3] Undo uneeded changes --- templates/index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/index.php b/templates/index.php index d107e450..f328d393 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,4 +1,10 @@
+