]> git.immae.eu Git - github/shaarli/Shaarli.git/blame_incremental - application/Router.php
Update release archive generation
[github/shaarli/Shaarli.git] / application / Router.php
... / ...
CommitLineData
1<?php
2
3/**
4 * Class Router
5 *
6 * (only displayable pages here)
7 */
8class Router
9{
10 public static $PAGE_LOGIN = 'login';
11
12 public static $PAGE_PICWALL = 'picwall';
13
14 public static $PAGE_TAGCLOUD = 'tagcloud';
15
16 public static $PAGE_DAILY = 'daily';
17
18 public static $PAGE_FEED_ATOM = 'atom';
19
20 public static $PAGE_FEED_RSS = 'rss';
21
22 public static $PAGE_TOOLS = 'tools';
23
24 public static $PAGE_CHANGEPASSWORD = 'changepasswd';
25
26 public static $PAGE_CONFIGURE = 'configure';
27
28 public static $PAGE_CHANGETAG = 'changetag';
29
30 public static $PAGE_ADDLINK = 'addlink';
31
32 public static $PAGE_EDITLINK = 'edit_link';
33
34 public static $PAGE_EXPORT = 'export';
35
36 public static $PAGE_IMPORT = 'import';
37
38 public static $PAGE_OPENSEARCH = 'opensearch';
39
40 public static $PAGE_LINKLIST = 'linklist';
41
42 public static $PAGE_PLUGINSADMIN = 'pluginadmin';
43
44 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
45
46 /**
47 * Reproducing renderPage() if hell, to avoid regression.
48 *
49 * This highlights how bad this needs to be rewrite,
50 * but let's focus on plugins for now.
51 *
52 * @param string $query $_SERVER['QUERY_STRING'].
53 * @param array $get $_SERVER['GET'].
54 * @param bool $loggedIn true if authenticated user.
55 *
56 * @return string page found.
57 */
58 public static function findPage($query, $get, $loggedIn)
59 {
60 $loggedIn = ($loggedIn === true) ? true : false;
61
62 if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
63 return self::$PAGE_LINKLIST;
64 }
65
66 if (startsWith($query, 'do='. self::$PAGE_LOGIN) && $loggedIn === false) {
67 return self::$PAGE_LOGIN;
68 }
69
70 if (startsWith($query, 'do='. self::$PAGE_PICWALL)) {
71 return self::$PAGE_PICWALL;
72 }
73
74 if (startsWith($query, 'do='. self::$PAGE_TAGCLOUD)) {
75 return self::$PAGE_TAGCLOUD;
76 }
77
78 if (startsWith($query, 'do='. self::$PAGE_OPENSEARCH)) {
79 return self::$PAGE_OPENSEARCH;
80 }
81
82 if (startsWith($query, 'do='. self::$PAGE_DAILY)) {
83 return self::$PAGE_DAILY;
84 }
85
86 if (startsWith($query, 'do='. self::$PAGE_FEED_ATOM)) {
87 return self::$PAGE_FEED_ATOM;
88 }
89
90 if (startsWith($query, 'do='. self::$PAGE_FEED_RSS)) {
91 return self::$PAGE_FEED_RSS;
92 }
93
94 // At this point, only loggedin pages.
95 if (!$loggedIn) {
96 return self::$PAGE_LINKLIST;
97 }
98
99 if (startsWith($query, 'do='. self::$PAGE_TOOLS)) {
100 return self::$PAGE_TOOLS;
101 }
102
103 if (startsWith($query, 'do='. self::$PAGE_CHANGEPASSWORD)) {
104 return self::$PAGE_CHANGEPASSWORD;
105 }
106
107 if (startsWith($query, 'do='. self::$PAGE_CONFIGURE)) {
108 return self::$PAGE_CONFIGURE;
109 }
110
111 if (startsWith($query, 'do='. self::$PAGE_CHANGETAG)) {
112 return self::$PAGE_CHANGETAG;
113 }
114
115 if (startsWith($query, 'do='. self::$PAGE_ADDLINK)) {
116 return self::$PAGE_ADDLINK;
117 }
118
119 if (isset($get['edit_link']) || isset($get['post'])) {
120 return self::$PAGE_EDITLINK;
121 }
122
123 if (startsWith($query, 'do='. self::$PAGE_EXPORT)) {
124 return self::$PAGE_EXPORT;
125 }
126
127 if (startsWith($query, 'do='. self::$PAGE_IMPORT)) {
128 return self::$PAGE_IMPORT;
129 }
130
131 if (startsWith($query, 'do='. self::$PAGE_PLUGINSADMIN)) {
132 return self::$PAGE_PLUGINSADMIN;
133 }
134
135 if (startsWith($query, 'do='. self::$PAGE_SAVE_PLUGINSADMIN)) {
136 return self::$PAGE_SAVE_PLUGINSADMIN;
137 }
138
139 return self::$PAGE_LINKLIST;
140 }
141}