]>
git.immae.eu Git - github/shaarli/Shaarli.git/blob - application/Router.php
6 * (only displayable pages here)
10 public static $PAGE_LOGIN = 'login';
12 public static $PAGE_PICWALL = 'picwall';
14 public static $PAGE_TAGCLOUD = 'tagcloud';
16 public static $PAGE_TAGLIST = 'taglist';
18 public static $PAGE_DAILY = 'daily';
20 public static $PAGE_FEED_ATOM = 'atom';
22 public static $PAGE_FEED_RSS = 'rss';
24 public static $PAGE_TOOLS = 'tools';
26 public static $PAGE_CHANGEPASSWORD = 'changepasswd';
28 public static $PAGE_CONFIGURE = 'configure';
30 public static $PAGE_CHANGETAG = 'changetag';
32 public static $PAGE_ADDLINK = 'addlink';
34 public static $PAGE_EDITLINK = 'edit_link';
36 public static $PAGE_DELETELINK = 'delete_link';
38 public static $PAGE_EXPORT = 'export';
40 public static $PAGE_IMPORT = 'import';
42 public static $PAGE_OPENSEARCH = 'opensearch';
44 public static $PAGE_LINKLIST = 'linklist';
46 public static $PAGE_PLUGINSADMIN = 'pluginadmin';
48 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
50 public static $GET_TOKEN = 'token';
53 * Reproducing renderPage() if hell, to avoid regression.
55 * This highlights how bad this needs to be rewrite,
56 * but let's focus on plugins for now.
58 * @param string $query $_SERVER['QUERY_STRING'].
59 * @param array $get $_SERVER['GET'].
60 * @param bool $loggedIn true if authenticated user.
62 * @return string page found.
64 public static function findPage($query, $get, $loggedIn)
66 $loggedIn = ($loggedIn === true) ? true : false;
68 if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
69 return self
::$PAGE_LINKLIST;
72 if (startsWith($query, 'do='. self
::$PAGE_LOGIN) && $loggedIn === false) {
73 return self
::$PAGE_LOGIN;
76 if (startsWith($query, 'do='. self
::$PAGE_PICWALL)) {
77 return self
::$PAGE_PICWALL;
80 if (startsWith($query, 'do='. self
::$PAGE_TAGCLOUD)) {
81 return self
::$PAGE_TAGCLOUD;
84 if (startsWith($query, 'do='. self
::$PAGE_TAGLIST)) {
85 return self
::$PAGE_TAGLIST;
88 if (startsWith($query, 'do='. self
::$PAGE_OPENSEARCH)) {
89 return self
::$PAGE_OPENSEARCH;
92 if (startsWith($query, 'do='. self
::$PAGE_DAILY)) {
93 return self
::$PAGE_DAILY;
96 if (startsWith($query, 'do='. self
::$PAGE_FEED_ATOM)) {
97 return self
::$PAGE_FEED_ATOM;
100 if (startsWith($query, 'do='. self
::$PAGE_FEED_RSS)) {
101 return self
::$PAGE_FEED_RSS;
104 // At this point, only loggedin pages.
106 return self
::$PAGE_LINKLIST;
109 if (startsWith($query, 'do='. self
::$PAGE_TOOLS)) {
110 return self
::$PAGE_TOOLS;
113 if (startsWith($query, 'do='. self
::$PAGE_CHANGEPASSWORD)) {
114 return self
::$PAGE_CHANGEPASSWORD;
117 if (startsWith($query, 'do='. self
::$PAGE_CONFIGURE)) {
118 return self
::$PAGE_CONFIGURE;
121 if (startsWith($query, 'do='. self
::$PAGE_CHANGETAG)) {
122 return self
::$PAGE_CHANGETAG;
125 if (startsWith($query, 'do='. self
::$PAGE_ADDLINK)) {
126 return self
::$PAGE_ADDLINK;
129 if (isset($get['edit_link']) || isset($get['post'])) {
130 return self
::$PAGE_EDITLINK;
133 if (isset($get['delete_link'])) {
134 return self
::$PAGE_DELETELINK;
137 if (startsWith($query, 'do='. self
::$PAGE_EXPORT)) {
138 return self
::$PAGE_EXPORT;
141 if (startsWith($query, 'do='. self
::$PAGE_IMPORT)) {
142 return self
::$PAGE_IMPORT;
145 if (startsWith($query, 'do='. self
::$PAGE_PLUGINSADMIN)) {
146 return self
::$PAGE_PLUGINSADMIN;
149 if (startsWith($query, 'do='. self
::$PAGE_SAVE_PLUGINSADMIN)) {
150 return self
::$PAGE_SAVE_PLUGINSADMIN;
153 if (startsWith($query, 'do='. self
::$GET_TOKEN)) {
154 return self
::$GET_TOKEN;
157 return self
::$PAGE_LINKLIST;