]>
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_DAILY = 'daily';
18 public static $PAGE_FEED_ATOM = 'atom';
20 public static $PAGE_FEED_RSS = 'rss';
22 public static $PAGE_TOOLS = 'tools';
24 public static $PAGE_CHANGEPASSWORD = 'changepasswd';
26 public static $PAGE_CONFIGURE = 'configure';
28 public static $PAGE_CHANGETAG = 'changetag';
30 public static $PAGE_ADDLINK = 'addlink';
32 public static $PAGE_EDITLINK = 'edit_link';
34 public static $PAGE_DELETELINK = 'delete_link';
36 public static $PAGE_EXPORT = 'export';
38 public static $PAGE_IMPORT = 'import';
40 public static $PAGE_OPENSEARCH = 'opensearch';
42 public static $PAGE_LINKLIST = 'linklist';
44 public static $PAGE_PLUGINSADMIN = 'pluginadmin';
46 public static $PAGE_SAVE_PLUGINSADMIN = 'save_pluginadmin';
48 public static $GET_TOKEN = 'token';
51 * Reproducing renderPage() if hell, to avoid regression.
53 * This highlights how bad this needs to be rewrite,
54 * but let's focus on plugins for now.
56 * @param string $query $_SERVER['QUERY_STRING'].
57 * @param array $get $_SERVER['GET'].
58 * @param bool $loggedIn true if authenticated user.
60 * @return string page found.
62 public static function findPage($query, $get, $loggedIn)
64 $loggedIn = ($loggedIn === true) ? true : false;
66 if (empty($query) && !isset($get['edit_link']) && !isset($get['post'])) {
67 return self
::$PAGE_LINKLIST;
70 if (startsWith($query, 'do='. self
::$PAGE_LOGIN) && $loggedIn === false) {
71 return self
::$PAGE_LOGIN;
74 if (startsWith($query, 'do='. self
::$PAGE_PICWALL)) {
75 return self
::$PAGE_PICWALL;
78 if (startsWith($query, 'do='. self
::$PAGE_TAGCLOUD)) {
79 return self
::$PAGE_TAGCLOUD;
82 if (startsWith($query, 'do='. self
::$PAGE_OPENSEARCH)) {
83 return self
::$PAGE_OPENSEARCH;
86 if (startsWith($query, 'do='. self
::$PAGE_DAILY)) {
87 return self
::$PAGE_DAILY;
90 if (startsWith($query, 'do='. self
::$PAGE_FEED_ATOM)) {
91 return self
::$PAGE_FEED_ATOM;
94 if (startsWith($query, 'do='. self
::$PAGE_FEED_RSS)) {
95 return self
::$PAGE_FEED_RSS;
98 // At this point, only loggedin pages.
100 return self
::$PAGE_LINKLIST;
103 if (startsWith($query, 'do='. self
::$PAGE_TOOLS)) {
104 return self
::$PAGE_TOOLS;
107 if (startsWith($query, 'do='. self
::$PAGE_CHANGEPASSWORD)) {
108 return self
::$PAGE_CHANGEPASSWORD;
111 if (startsWith($query, 'do='. self
::$PAGE_CONFIGURE)) {
112 return self
::$PAGE_CONFIGURE;
115 if (startsWith($query, 'do='. self
::$PAGE_CHANGETAG)) {
116 return self
::$PAGE_CHANGETAG;
119 if (startsWith($query, 'do='. self
::$PAGE_ADDLINK)) {
120 return self
::$PAGE_ADDLINK;
123 if (isset($get['edit_link']) || isset($get['post'])) {
124 return self
::$PAGE_EDITLINK;
127 if (isset($get['delete_link'])) {
128 return self
::$PAGE_DELETELINK;
131 if (startsWith($query, 'do='. self
::$PAGE_EXPORT)) {
132 return self
::$PAGE_EXPORT;
135 if (startsWith($query, 'do='. self
::$PAGE_IMPORT)) {
136 return self
::$PAGE_IMPORT;
139 if (startsWith($query, 'do='. self
::$PAGE_PLUGINSADMIN)) {
140 return self
::$PAGE_PLUGINSADMIN;
143 if (startsWith($query, 'do='. self
::$PAGE_SAVE_PLUGINSADMIN)) {
144 return self
::$PAGE_SAVE_PLUGINSADMIN;
147 if (startsWith($query, 'do='. self
::$GET_TOKEN)) {
148 return self
::$GET_TOKEN;
151 return self
::$PAGE_LINKLIST;