-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes-theme.php
70 lines (53 loc) · 2.24 KB
/
routes-theme.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
67
68
69
70
<?php if(!defined("CONF_PATH")) { die("No direct script access allowed."); } /*
--------------------------------------
------ About the "Theme" Routes ------
--------------------------------------
The "Theme" Routes are essentially identical to the standard routes, but are used on sites that want multiple themes (particularly those that enable you to switch between themes).
Instead of instantly using the default theme, the "Theme" routing system will check to see if there is an alternative theme available and attempt to use that one instead.
*/
// If there is more than one route used in the URL, we need to look for the page to load in /controller/
$home = !(count($url) > 0 && $url[0] != "");
// Check if a non-default theme is active
if(Theme::$theme != "default")
{
// Cycle Through Theme Controllers
$checkPath = ($home ? "home" : $url_relative);
while(true)
{
// Check if the appropriate path exists. Load it if it does.
if(File::exists(Theme::$dir . "/controller/" . $checkPath . ".php"))
{
require(Theme::$dir . "/controller/" . $checkPath . ".php"); exit;
}
// Make sure there's still paths to check
if(strpos($checkPath, "/") === false) { break; }
$checkPath = substr($checkPath, 0, strrpos($checkPath, '/'));
}
}
// Cycle Through Default Theme Controllers
$checkPath = ($home ? "home" : $url_relative);
while(true)
{
// Check if the appropriate path exists. Load it if it does.
if(File::exists(APP_PATH . "/themes/default/controller/" . $checkPath . ".php"))
{
require(APP_PATH . "/themes/default/controller/" . $checkPath . ".php"); exit;
}
// Make sure there's still paths to check
if(strpos($checkPath, "/") === false) { break; }
$checkPath = substr($checkPath, 0, strrpos($checkPath, '/'));
}
/****** Check for Admin Operations ******/
// This section tracks any reusable controller and loads those system pages
$checkPath = $url_relative;
while(true)
{
// Check if the appropriate path exists. Load it if it does.
if(File::exists(SYS_PATH . "/controller/" . $checkPath . ".php"))
{
require(SYS_PATH . "/controller/" . $checkPath . ".php"); exit;
}
// Make sure there's still paths to check
if(strpos($checkPath, "/") === false) { break; }
$checkPath = substr($checkPath, 0, strrpos($checkPath, '/'));
}