]> git.wh0rd.org - tt-rss.git/blob - index.php
handle_rpc_json: fix netalert button never appearing on JSON parse error
[tt-rss.git] / index.php
1 <?php
2 if (file_exists("install") && !file_exists("config.php")) {
3 header("Location: install/");
4 }
5
6 if (!file_exists("config.php")) {
7 print "<b>Fatal Error</b>: You forgot to copy
8 <b>config.php-dist</b> to <b>config.php</b> and edit it.\n";
9 exit;
10 }
11
12 // we need a separate check here because functions.php might get parsed
13 // incorrectly before 5.3 because of :: syntax.
14 if (version_compare(PHP_VERSION, '5.3.0', '<')) {
15 print "<b>Fatal Error</b>: PHP version 5.3.0 or newer required.\n";
16 exit;
17 }
18
19 set_include_path(dirname(__FILE__) ."/include" . PATH_SEPARATOR .
20 get_include_path());
21
22 require_once "autoload.php";
23 require_once "sessions.php";
24 require_once "functions.php";
25 require_once "sanity_check.php";
26 require_once "version.php";
27 require_once "config.php";
28 require_once "db-prefs.php";
29 require_once "lib/Mobile_Detect.php";
30
31 $mobile = new Mobile_Detect();
32
33 if (!init_plugins()) return;
34
35 if (!$_REQUEST['mobile']) {
36 if ($mobile->isTablet() && PluginHost::getInstance()->get_plugin("digest")) {
37 header('Location: backend.php?op=digest');
38 exit;
39 } else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("mobile")) {
40 header('Location: backend.php?op=mobile');
41 exit;
42 } else if ($mobile->isMobile() && PluginHost::getInstance()->get_plugin("digest")) {
43 header('Location: backend.php?op=digest');
44 exit;
45 }
46 }
47
48 login_sequence();
49
50 header('Content-Type: text/html; charset=utf-8');
51
52 ?>
53 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
54 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
55 <html>
56 <head>
57 <title>Tiny Tiny RSS</title>
58
59 <script type="text/javascript">
60 var __ttrss_version = "<?php echo VERSION ?>"
61 </script>
62
63 <?php echo stylesheet_tag("lib/dijit/themes/claro/claro.css"); ?>
64 <?php echo stylesheet_tag("css/layout.css"); ?>
65
66 <?php if ($_SESSION["uid"]) {
67 $theme = get_pref( "USER_CSS_THEME", $_SESSION["uid"], false);
68 if ($theme && theme_valid("$theme")) {
69 echo stylesheet_tag(get_theme_path($theme));
70 } else {
71 echo stylesheet_tag("themes/default.php");
72 }
73 }
74 ?>
75
76 <?php print_user_stylesheet() ?>
77
78 <style type="text/css">
79 <?php
80 foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
81 if (method_exists($p, "get_css")) {
82 echo $p->get_css();
83 }
84 }
85 ?>
86 </style>
87
88 <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
89 <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
90
91 <script>
92 dojoConfig = {
93 async: true,
94 cacheBust: new Date(),
95 packages: [
96 { name: "fox", location: "../../js" },
97 ]
98 };
99 </script>
100
101 <?php
102 foreach (array("lib/prototype.js",
103 "lib/scriptaculous/scriptaculous.js?load=effects,controls",
104 "lib/dojo/dojo.js",
105 "lib/dojo/tt-rss-layer.js",
106 "errors.php?mode=js") as $jsfile) {
107
108 echo javascript_tag($jsfile);
109
110 } ?>
111
112 <script type="text/javascript">
113 require({cache:{}});
114 <?php
115 require_once 'lib/jshrink/Minifier.php';
116
117 print get_minified_js(array("tt-rss",
118 "functions", "feedlist", "viewfeed", "PluginHost"));
119
120 foreach (PluginHost::getInstance()->get_plugins() as $n => $p) {
121 if (method_exists($p, "get_js")) {
122 echo "try {";
123 echo JShrink\Minifier::minify($p->get_js());
124 echo "} catch (e) {
125 console.warn('failed to initialize plugin JS: $n');
126 console.warn(e);
127 }";
128 }
129 }
130
131 init_js_translations();
132 ?>
133 </script>
134
135 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
136 <meta name="referrer" content="no-referrer"/>
137
138 <script type="text/javascript">
139 Event.observe(window, 'load', function() {
140 init();
141 });
142 </script>
143 </head>
144
145 <body id="ttrssMain" class="claro">
146
147 <div id="overlay" style="display : block">
148 <div id="overlay_inner">
149 <div class="insensitive"><?php echo __("Loading, please wait...") ?></div>
150 <div dojoType="dijit.ProgressBar" places="0" style="width : 300px" id="loading_bar"
151 progress="0" maximum="100">
152 </div>
153 <noscript><br/><?php print_error('Javascript is disabled. Please enable it.') ?></noscript>
154 </div>
155 </div>
156
157 <div id="notify" class="notify"></div>
158 <div id="cmdline" style="display : none"></div>
159
160 <div id="main" dojoType="dijit.layout.BorderContainer">
161
162 <div id="feeds-holder" dojoType="dijit.layout.ContentPane" region="leading" style="width : 20%" splitter="true">
163 <div id="feedlistLoading">
164 <img src='images/indicator_tiny.gif'/>
165 <?php echo __("Loading, please wait..."); ?></div>
166 <div id="feedTree"></div>
167 </div>
168
169 <div dojoType="dijit.layout.BorderContainer" region="center" id="header-wrap" gutters="false">
170 <div dojoType="dijit.layout.BorderContainer" region="center" id="content-wrap">
171
172 <div id="toolbar" dojoType="dijit.layout.ContentPane" region="top">
173 <div id="main-toolbar" dojoType="dijit.Toolbar">
174
175 <?php
176 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_MAIN_TOOLBAR_BUTTON) as $p) {
177 echo $p->hook_main_toolbar_button();
178 }
179 ?>
180
181 <form id="headlines-toolbar" action="" onsubmit='return false'>
182
183 </form>
184
185 <form id="main_toolbar_form" action="" onsubmit='return false'>
186
187 <select name="view_mode" title="<?php echo __('Show articles') ?>"
188 onchange="viewModeChanged()"
189 dojoType="dijit.form.Select">
190 <option selected="selected" value="adaptive"><?php echo __('Adaptive') ?></option>
191 <option value="all_articles"><?php echo __('All Articles') ?></option>
192 <option value="marked"><?php echo __('Starred') ?></option>
193 <option value="published"><?php echo __('Published') ?></option>
194 <option value="unread"><?php echo __('Unread') ?></option>
195 <option value="has_note"><?php echo __('With Note') ?></option>
196 <!-- <option value="noscores"><?php echo __('Ignore Scoring') ?></option> -->
197 </select>
198
199 <select title="<?php echo __('Sort articles') ?>"
200 onchange="viewModeChanged()"
201 dojoType="dijit.form.Select" name="order_by">
202 <option selected="selected" value="default"><?php echo __('Default') ?></option>
203 <option value="feed_dates"><?php echo __('Newest first') ?></option>
204 <option value="date_reverse"><?php echo __('Oldest first') ?></option>
205 <option value="title"><?php echo __('Title') ?></option>
206 </select>
207
208 <div dojoType="dijit.form.ComboButton" onclick="catchupCurrentFeed()">
209 <span><?php echo __('Mark as read') ?></span>
210 <div dojoType="dijit.DropDownMenu">
211 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1day')">
212 <?php echo __('Older than one day') ?>
213 </div>
214 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1week')">
215 <?php echo __('Older than one week') ?>
216 </div>
217 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('2week')">
218 <?php echo __('Older than two weeks') ?>
219 </div>
220 </div>
221 </div>
222
223 </form>
224
225 <div class="actionChooser">
226
227 <?php
228 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_TOOLBAR_BUTTON) as $p) {
229 echo $p->hook_toolbar_button();
230 }
231 ?>
232
233 <button id="net-alert" dojoType="dijit.form.Button" style="display : none" disabled="true"
234 title="<?php echo __("Communication problem with server.") ?>">
235 <img src="images/error.png" />
236 </button>
237
238 <div dojoType="dijit.form.DropDownButton">
239 <span><?php echo __('Actions...') ?></span>
240 <div dojoType="dijit.Menu" style="display: none">
241 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcPrefs')"><?php echo __('Preferences...') ?></div>
242 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcSearch')"><?php echo __('Search...') ?></div>
243 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div>
244 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
245 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
246 <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRescoreFeed')"><?php echo __('Rescore feed') ?></div> -->
247 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
248 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
249 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
250 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
251 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
252 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
253 <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
254 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
255 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
256
257 <?php
258 foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ACTION_ITEM) as $p) {
259 echo $p->hook_action_item();
260 }
261 ?>
262
263 <?php if (!$_SESSION["hide_logout"]) { ?>
264 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout') ?></div>
265 <?php } ?>
266 </div>
267 </div>
268
269 <button id="updatesIcon" dojoType="dijit.form.Button" style="display : none">
270 <img src="images/new_version.png" title="<?php echo __('Updates are available from Git.') ?>"/>
271 </button>
272 </div>
273 </div> <!-- toolbar -->
274 </div> <!-- toolbar pane -->
275
276 <div id="headlines-wrap-inner" dojoType="dijit.layout.BorderContainer" region="center">
277
278 <div id="floatingTitle" style="visibility : hidden"></div>
279
280 <div id="headlines-frame" dojoType="dijit.layout.ContentPane"
281 onscroll="headlines_scroll_handler(this)" region="center">
282 <div id="headlinesInnerContainer">
283 <div class="whiteBox"><?php echo __('Loading, please wait...') ?></div>
284 </div>
285 </div>
286
287 <div id="content-insert" dojoType="dijit.layout.ContentPane" region="bottom"
288 style="height : 50%" splitter="true"></div>
289
290 </div>
291 </div>
292 </div>
293 </div>
294
295 </body>
296 </html>