aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/Router.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2020-07-06 08:04:35 +0200
committerArthurHoaro <arthur@hoa.ro>2020-07-23 21:19:21 +0200
commit1a8ac737e52cb25a5c346232ee398f5908cee7d7 (patch)
tree31954c4e106b5743e2005d72c2d548a0be8d6dce /application/Router.php
parent6132d64748dfc6806ed25f71d2e078a5ed29d071 (diff)
downloadShaarli-1a8ac737e52cb25a5c346232ee398f5908cee7d7.tar.gz
Shaarli-1a8ac737e52cb25a5c346232ee398f5908cee7d7.tar.zst
Shaarli-1a8ac737e52cb25a5c346232ee398f5908cee7d7.zip
Process main page (linklist) through Slim controller
Including a bunch of improvements on the container, and helper used across new controllers.
Diffstat (limited to 'application/Router.php')
-rw-r--r--application/Router.php184
1 files changed, 0 insertions, 184 deletions
diff --git a/application/Router.php b/application/Router.php
deleted file mode 100644
index d7187487..00000000
--- a/application/Router.php
+++ /dev/null
@@ -1,184 +0,0 @@
1<?php
2namespace Shaarli;
3
4/**
5 * Class Router
6 *
7 * (only displayable pages here)
8 */
9class Router
10{
11 public static $AJAX_THUMB_UPDATE = 'ajax_thumb_update';
12
13 public static $PAGE_LOGIN = 'login';
14
15 public static $PAGE_PICWALL = 'picwall';
16
17 public static $PAGE_TAGCLOUD = 'tagcloud';
18
19 public static $PAGE_TAGLIST = 'taglist';
20
21 public static $PAGE_DAILY = 'daily';
22
23 public static $PAGE_FEED_ATOM = 'atom';
24
25 public static $PAGE_FEED_RSS = 'rss';
26
27 public static $PAGE_TOOLS = 'tools';
28
29 public static $PAGE_CHANGEPASSWORD = 'changepasswd';
30
31 public static $PAGE_CONFIGURE = 'configure';
32
33 public static $PAGE_CHANGETAG = 'changetag';
34
35 public static $PAGE_ADDLINK = 'addlink';
36
37 public static $PAGE_EDITLINK = 'edit_link';
38
39 public static $PAGE_DELETELINK = 'delete_link';
40
41 public static $PAGE_CHANGE_VISIBILITY = 'change_visibility';
42
43 public static $PAGE_PINLINK = 'pin';
44
45 public static $PAGE_EXPORT = 'export';
46
47 public static $PAGE_IMPORT = 'import';
48
49 public static $PAGE_OPENSEARCH = 'opensearch';
50
51 public static $PAGE_LINKLIST = 'linklist';
52
53 public static $PAGE_PLUGINSADMIN = 'pluginadmin';
54
55 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
56
57 public static $PAGE_THUMBS_UPDATE = 'thumbs_update';
58
59 public static $GET_TOKEN = 'token';
60
61 /**
62 * Reproducing renderPage() if hell, to avoid regression.
63 *
64 * This highlights how bad this needs to be rewrite,
65 * but let's focus on plugins for now.
66 *
67 * @param string $query $_SERVER['QUERY_STRING'].
68 * @param array $get $_SERVER['GET'].
69 * @param bool $loggedIn true if authenticated user.
70 *
71 * @return string page found.
72 */
73 public static function findPage($query, $get, $loggedIn)
74 {
75 $loggedIn = ($loggedIn === true) ? true : false;
76
77 if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
78 return self::$PAGE_LINKLIST;
79 }
80
81 if (startsWith($query, 'do=' . self::$PAGE_LOGIN) && $loggedIn === false) {
82 return self::$PAGE_LOGIN;
83 }
84
85 if (startsWith($query, 'do=' . self::$PAGE_PICWALL)) {
86 return self::$PAGE_PICWALL;
87 }
88
89 if (startsWith($query, 'do=' . self::$PAGE_TAGCLOUD)) {
90 return self::$PAGE_TAGCLOUD;
91 }
92
93 if (startsWith($query, 'do=' . self::$PAGE_TAGLIST)) {
94 return self::$PAGE_TAGLIST;
95 }
96
97 if (startsWith($query, 'do=' . self::$PAGE_OPENSEARCH)) {
98 return self::$PAGE_OPENSEARCH;
99 }
100
101 if (startsWith($query, 'do=' . self::$PAGE_DAILY)) {
102 return self::$PAGE_DAILY;
103 }
104
105 if (startsWith($query, 'do=' . self::$PAGE_FEED_ATOM)) {
106 return self::$PAGE_FEED_ATOM;
107 }
108
109 if (startsWith($query, 'do=' . self::$PAGE_FEED_RSS)) {
110 return self::$PAGE_FEED_RSS;
111 }
112
113 if (startsWith($query, 'do=' . self::$PAGE_THUMBS_UPDATE)) {
114 return self::$PAGE_THUMBS_UPDATE;
115 }
116
117 if (startsWith($query, 'do=' . self::$AJAX_THUMB_UPDATE)) {
118 return self::$AJAX_THUMB_UPDATE;
119 }
120
121 // At this point, only loggedin pages.
122 if (!$loggedIn) {
123 return self::$PAGE_LINKLIST;
124 }
125
126 if (startsWith($query, 'do=' . self::$PAGE_TOOLS)) {
127 return self::$PAGE_TOOLS;
128 }
129
130 if (startsWith($query, 'do=' . self::$PAGE_CHANGEPASSWORD)) {
131 return self::$PAGE_CHANGEPASSWORD;
132 }
133
134 if (startsWith($query, 'do=' . self::$PAGE_CONFIGURE)) {
135 return self::$PAGE_CONFIGURE;
136 }
137
138 if (startsWith($query, 'do=' . self::$PAGE_CHANGETAG)) {
139 return self::$PAGE_CHANGETAG;
140 }
141
142 if (startsWith($query, 'do=' . self::$PAGE_ADDLINK)) {
143 return self::$PAGE_ADDLINK;
144 }
145
146 if (isset($get['edit_link']) || isset($get['post'])) {
147 return self::$PAGE_EDITLINK;
148 }
149
150 if (isset($get['delete_link'])) {
151 return self::$PAGE_DELETELINK;
152 }
153
154 if (isset($get[self::$PAGE_CHANGE_VISIBILITY])) {
155 return self::$PAGE_CHANGE_VISIBILITY;
156 }
157
158 if (startsWith($query, 'do=' . self::$PAGE_PINLINK)) {
159 return self::$PAGE_PINLINK;
160 }
161
162 if (startsWith($query, 'do=' . self::$PAGE_EXPORT)) {
163 return self::$PAGE_EXPORT;
164 }
165
166 if (startsWith($query, 'do=' . self::$PAGE_IMPORT)) {
167 return self::$PAGE_IMPORT;
168 }
169
170 if (startsWith($query, 'do=' . self::$PAGE_PLUGINSADMIN)) {
171 return self::$PAGE_PLUGINSADMIN;
172 }
173
174 if (startsWith($query, 'do=' . self::$PAGE_SAVE_PLUGINSADMIN)) {
175 return self::$PAGE_SAVE_PLUGINSADMIN;
176 }
177
178 if (startsWith($query, 'do=' . self::$GET_TOKEN)) {
179 return self::$GET_TOKEN;
180 }
181
182 return self::$PAGE_LINKLIST;
183 }
184}