]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/legacy/LegacyRouter.php
3 namespace Shaarli\Legacy
;
8 * (only displayable pages here)
14 public static $AJAX_THUMB_UPDATE = 'ajax_thumb_update';
16 public static $PAGE_LOGIN = 'login';
18 public static $PAGE_PICWALL = 'picwall';
20 public static $PAGE_TAGCLOUD = 'tagcloud';
22 public static $PAGE_TAGLIST = 'taglist';
24 public static $PAGE_DAILY = 'daily';
26 public static $PAGE_FEED_ATOM = 'atom';
28 public static $PAGE_FEED_RSS = 'rss';
30 public static $PAGE_TOOLS = 'tools';
32 public static $PAGE_CHANGEPASSWORD = 'changepasswd';
34 public static $PAGE_CONFIGURE = 'configure';
36 public static $PAGE_CHANGETAG = 'changetag';
38 public static $PAGE_ADDLINK = 'addlink';
40 public static $PAGE_EDITLINK = 'edit_link';
42 public static $PAGE_DELETELINK = 'delete_link';
44 public static $PAGE_CHANGE_VISIBILITY = 'change_visibility';
46 public static $PAGE_PINLINK = 'pin';
48 public static $PAGE_EXPORT = 'export';
50 public static $PAGE_IMPORT = 'import';
52 public static $PAGE_OPENSEARCH = 'opensearch';
54 public static $PAGE_LINKLIST = 'linklist';
56 public static $PAGE_PLUGINSADMIN = 'pluginadmin';
58 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
60 public static $PAGE_THUMBS_UPDATE = 'thumbs_update';
62 public static $GET_TOKEN = 'token';
65 * Reproducing renderPage() if hell, to avoid regression.
67 * This highlights how bad this needs to be rewrite,
68 * but let's focus on plugins for now.
70 * @param string $query $_SERVER['QUERY_STRING'].
71 * @param array $get $_SERVER['GET'].
72 * @param bool $loggedIn true if authenticated user.
74 * @return string page found.
76 public static function findPage($query, $get, $loggedIn)
78 $loggedIn = ($loggedIn === true) ? true : false;
80 if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
81 return self
::$PAGE_LINKLIST;
84 if (startsWith($query, 'do=' . self
::$PAGE_LOGIN) && $loggedIn === false) {
85 return self
::$PAGE_LOGIN;
88 if (startsWith($query, 'do=' . self
::$PAGE_PICWALL)) {
89 return self
::$PAGE_PICWALL;
92 if (startsWith($query, 'do=' . self
::$PAGE_TAGCLOUD)) {
93 return self
::$PAGE_TAGCLOUD;
96 if (startsWith($query, 'do=' . self
::$PAGE_TAGLIST)) {
97 return self
::$PAGE_TAGLIST;
100 if (startsWith($query, 'do=' . self
::$PAGE_OPENSEARCH)) {
101 return self
::$PAGE_OPENSEARCH;
104 if (startsWith($query, 'do=' . self
::$PAGE_DAILY)) {
105 return self
::$PAGE_DAILY;
108 if (startsWith($query, 'do=' . self
::$PAGE_FEED_ATOM)) {
109 return self
::$PAGE_FEED_ATOM;
112 if (startsWith($query, 'do=' . self
::$PAGE_FEED_RSS)) {
113 return self
::$PAGE_FEED_RSS;
116 if (startsWith($query, 'do=' . self
::$PAGE_THUMBS_UPDATE)) {
117 return self
::$PAGE_THUMBS_UPDATE;
120 if (startsWith($query, 'do=' . self
::$AJAX_THUMB_UPDATE)) {
121 return self
::$AJAX_THUMB_UPDATE;
124 // At this point, only loggedin pages.
126 return self
::$PAGE_LINKLIST;
129 if (startsWith($query, 'do=' . self
::$PAGE_TOOLS)) {
130 return self
::$PAGE_TOOLS;
133 if (startsWith($query, 'do=' . self
::$PAGE_CHANGEPASSWORD)) {
134 return self
::$PAGE_CHANGEPASSWORD;
137 if (startsWith($query, 'do=' . self
::$PAGE_CONFIGURE)) {
138 return self
::$PAGE_CONFIGURE;
141 if (startsWith($query, 'do=' . self
::$PAGE_CHANGETAG)) {
142 return self
::$PAGE_CHANGETAG;
145 if (startsWith($query, 'do=' . self
::$PAGE_ADDLINK)) {
146 return self
::$PAGE_ADDLINK;
149 if (isset($get['edit_link']) || isset($get['post'])) {
150 return self
::$PAGE_EDITLINK;
153 if (isset($get['delete_link'])) {
154 return self
::$PAGE_DELETELINK;
157 if (isset($get[self
::$PAGE_CHANGE_VISIBILITY])) {
158 return self
::$PAGE_CHANGE_VISIBILITY;
161 if (startsWith($query, 'do=' . self
::$PAGE_PINLINK)) {
162 return self
::$PAGE_PINLINK;
165 if (startsWith($query, 'do=' . self
::$PAGE_EXPORT)) {
166 return self
::$PAGE_EXPORT;
169 if (startsWith($query, 'do=' . self
::$PAGE_IMPORT)) {
170 return self
::$PAGE_IMPORT;
173 if (startsWith($query, 'do=' . self
::$PAGE_PLUGINSADMIN)) {
174 return self
::$PAGE_PLUGINSADMIN;
177 if (startsWith($query, 'do=' . self
::$PAGE_SAVE_PLUGINSADMIN)) {
178 return self
::$PAGE_SAVE_PLUGINSADMIN;
181 if (startsWith($query, 'do=' . self
::$GET_TOKEN)) {
182 return self
::$GET_TOKEN;
185 return self
::$PAGE_LINKLIST;