From db4111f6d50d5bf2195d4a082ffc9dcea1d911ce Mon Sep 17 00:00:00 2001
From: Bart Visscher <bartv@thisnet.nl>
Date: Sun, 12 Aug 2012 16:52:36 +0200
Subject: [PATCH] Routing: Add some core routes

---
 core/routes.php | 19 +++++++++++++++++++
 lib/base.php    |  3 ++-
 lib/router.php  |  2 ++
 3 files changed, 23 insertions(+), 1 deletion(-)
 create mode 100644 core/routes.php

diff --git a/core/routes.php b/core/routes.php
new file mode 100644
index 0000000000..04b42d2059
--- /dev/null
+++ b/core/routes.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+$this->create('app_css', '/apps/{app}/{file}')
+	->requirements(array('file' => '.*.css'))
+	->action('OC', 'loadCSSFile');
+$this->create('app_index_script', '/apps/{app}/')
+	->defaults(array('file' => 'index.php'))
+	//->requirements(array('file' => '.*.php'))
+	->action('OC', 'loadAppScriptFile');
+$this->create('app_script', '/apps/{app}/{file}')
+	->defaults(array('file' => 'index.php'))
+	->requirements(array('file' => '.*.php'))
+	->action('OC', 'loadAppScriptFile');
diff --git a/lib/base.php b/lib/base.php
index 0d7e224d35..3abfdb3566 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -440,8 +440,8 @@ class OC{
 		}
 		// Someone is logged in :
 		if(OC_User::isLoggedIn()) {
-			OC_App::loadApps();
 			if(isset($_GET["logout"]) and ($_GET["logout"])) {
+				OC_App::loadApps();
 				OC_User::logout();
 				header("Location: ".OC::$WEBROOT.'/');
 			}else{
@@ -461,6 +461,7 @@ class OC{
 	}
 
 	public static function loadAppScriptFile($param) {
+		OC_App::loadApps();
 		$app = $param['app'];
 		$file = $param['file'];
 		$app_path = OC_App::getAppPath($app);
diff --git a/lib/router.php b/lib/router.php
index eca59d6dc3..65fc51aff2 100644
--- a/lib/router.php
+++ b/lib/router.php
@@ -34,6 +34,8 @@ class OC_Router {
 				$this->root->addCollection($collection, '/apps/'.$app);
 			}
 		}
+		$this->useCollection('root');
+		require_once('core/routes.php');
 	}
 
 	protected function getCollection($name) {
-- 
GitLab