]> git.wh0rd.org - tt-rss.git/blob - index.php
more work on singleton-based DB
[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 $link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
34
35 if (!init_plugins($link)) return;
36
37 global $pluginhost;
38
39 if (!$_REQUEST['mobile']) {
40 if ($mobile->isTablet() && $pluginhost->get_plugin("digest")) {
41 header('Location: backend.php?op=digest');
42 exit;
43 } else if ($mobile->isMobile() && $pluginhost->get_plugin("mobile")) {
44 header('Location: backend.php?op=mobile');
45 exit;
46 } else if ($mobile->isMobile() && $pluginhost->get_plugin("digest")) {
47 header('Location: backend.php?op=digest');
48 exit;
49 }
50 }
51
52 login_sequence($link);
53
54 header('Content-Type: text/html; charset=utf-8');
55
56 ?>
57 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
58 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
59 <html>
60 <head>
61 <title>Tiny Tiny RSS</title>
62
63 <?php echo stylesheet_tag("lib/dijit/themes/claro/claro.css"); ?>
64 <?php echo stylesheet_tag("tt-rss.css"); ?>
65 <?php echo stylesheet_tag("cdm.css"); ?>
66
67 <?php if ($_SESSION["uid"]) {
68 $theme = get_pref($link, "USER_CSS_THEME", $_SESSION["uid"], false);
69 if ($theme) {
70 echo stylesheet_tag("themes/$theme");
71 }
72 }
73 ?>
74
75 <?php print_user_stylesheet($link) ?>
76
77 <style type="text/css">
78 <?php
79 foreach ($pluginhost->get_plugins() as $n => $p) {
80 if (method_exists($p, "get_css")) {
81 echo $p->get_css();
82 }
83 }
84 ?>
85 </style>
86
87 <link rel="shortcut icon" type="image/png" href="images/favicon.png"/>
88 <link rel="icon" type="image/png" sizes="72x72" href="images/favicon-72px.png" />
89
90 <?php
91 foreach (array("lib/prototype.js",
92 "lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls",
93 "lib/dojo/dojo.js",
94 "lib/dijit/dijit.js",
95 "lib/dojo/tt-rss-layer.js",
96 "errors.php?mode=js") as $jsfile) {
97
98 echo javascript_tag($jsfile);
99
100 } ?>
101
102 <script type="text/javascript">
103 <?php
104 require 'lib/jshrink/Minifier.php';
105
106 print get_minified_js(array("tt-rss",
107 "functions", "feedlist", "viewfeed", "FeedTree"));
108
109 global $pluginhost;
110
111 foreach ($pluginhost->get_plugins() as $n => $p) {
112 if (method_exists($p, "get_js")) {
113 echo JShrink\Minifier::minify($p->get_js());
114 }
115 }
116
117 init_js_translations();
118 ?>
119 </script>
120
121 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
122
123 <script type="text/javascript">
124 Event.observe(window, 'load', function() {
125 init();
126 });
127 </script>
128 </head>
129
130 <body id="ttrssMain" class="claro">
131
132 <div id="overlay" style="display : block">
133 <div id="overlay_inner">
134 <div class="insensitive"><?php echo __("Loading, please wait...") ?></div>
135 <div dojoType="dijit.ProgressBar" places="0" style="width : 300px" id="loading_bar"
136 progress="0" maximum="100">
137 </div>
138 <noscript><br/><?php print_error('Javascript is disabled. Please enable it.') ?></noscript>
139 </div>
140 </div>
141
142 <div id="notify" class="notify" style="display : none"></div>
143 <div id="cmdline" style="display : none"></div>
144 <div id="headlines-tmp" style="display : none"></div>
145
146 <div id="main" dojoType="dijit.layout.BorderContainer">
147
148 <div id="feeds-holder" dojoType="dijit.layout.ContentPane" region="leading" style="width : 20%" splitter="true">
149 <div id="feedlistLoading">
150 <img src='images/indicator_tiny.gif'/>
151 <?php echo __("Loading, please wait..."); ?></div>
152 <div id="feedTree"></div>
153 </div>
154
155 <div dojoType="dijit.layout.BorderContainer" region="center" id="header-wrap" gutters="false">
156 <div dojoType="dijit.layout.BorderContainer" region="center" id="content-wrap">
157
158 <div id="toolbar" dojoType="dijit.layout.ContentPane" region="top">
159 <div id="main-toolbar" dojoType="dijit.Toolbar">
160
161 <form id="main_toolbar_form" action="" onsubmit='return false'>
162
163 <button dojoType="dijit.form.Button" id="collapse_feeds_btn"
164 onclick="collapse_feedlist()"
165 title="<?php echo __('Collapse feedlist') ?>" style="display : inline">
166 &lt;&lt;</button>
167
168 <select name="view_mode" title="<?php echo __('Show articles') ?>"
169 onchange="viewModeChanged()"
170 dojoType="dijit.form.Select">
171 <option selected="selected" value="adaptive"><?php echo __('Adaptive') ?></option>
172 <option value="all_articles"><?php echo __('All Articles') ?></option>
173 <option value="marked"><?php echo __('Starred') ?></option>
174 <option value="published"><?php echo __('Published') ?></option>
175 <option value="unread"><?php echo __('Unread') ?></option>
176 <option value="unread_first"><?php echo __('Unread First') ?></option>
177 <option value="has_note"><?php echo __('With Note') ?></option>
178 <!-- <option value="noscores"><?php echo __('Ignore Scoring') ?></option> -->
179 </select>
180
181 <select title="<?php echo __('Sort articles') ?>"
182 onchange="viewModeChanged()"
183 dojoType="dijit.form.Select" name="order_by">
184 <option selected="selected" value="default"><?php echo __('Default') ?></option>
185 <option value="feed_dates"><?php echo __('Newest first') ?></option>
186 <option value="date_reverse"><?php echo __('Oldest first') ?></option>
187 <option value="title"><?php echo __('Title') ?></option>
188 </select>
189
190 <div dojoType="dijit.form.ComboButton" onclick="catchupCurrentFeed()">
191 <span><?php echo __('Mark as read') ?></span>
192 <div dojoType="dijit.DropDownMenu">
193 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1day')">
194 <?php echo __('Older than one day') ?>
195 </div>
196 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('1week')">
197 <?php echo __('Older than one week') ?>
198 </div>
199 <div dojoType="dijit.MenuItem" onclick="catchupCurrentFeed('2week')">
200 <?php echo __('Older than two weeks') ?>
201 </div>
202 </div>
203 </div>
204
205 </form>
206
207 <div class="actionChooser">
208
209 <?php
210 global $pluginhost;
211 foreach ($pluginhost->get_hooks($pluginhost::HOOK_TOOLBAR_BUTTON) as $p) {
212 echo $p->hook_toolbar_button();
213 }
214 ?>
215
216 <button id="net-alert" dojoType="dijit.form.Button" style="display : none" disabled="true"
217 title="<?php echo __("Communication problem with server.") ?>">
218 <img
219 src="images/alert.png" />
220 </button>
221
222 <button id="newVersionIcon" dojoType="dijit.form.Button" style="display : none">
223 <img onclick="newVersionDlg()"
224 src="images/new_version.png"
225 title="<?php echo __('New version of Tiny Tiny RSS is available!') ?>" />
226 </button>
227
228
229 <div dojoType="dijit.form.DropDownButton">
230 <span><?php echo __('Actions...') ?></span>
231 <div dojoType="dijit.Menu" style="display: none">
232 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcPrefs')"><?php echo __('Preferences...') ?></div>
233 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcSearch')"><?php echo __('Search...') ?></div>
234 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Feed actions:') ?></div>
235 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFeed')"><?php echo __('Subscribe to feed...') ?></div>
236 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcEditFeed')"><?php echo __('Edit this feed...') ?></div>
237 <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRescoreFeed')"><?php echo __('Rescore feed') ?></div> -->
238 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcRemoveFeed')"><?php echo __('Unsubscribe') ?></div>
239 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('All feeds:') ?></div>
240 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcCatchupAll')"><?php echo __('Mark as read') ?></div>
241 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcShowOnlyUnread')"><?php echo __('(Un)hide read feeds') ?></div>
242 <div dojoType="dijit.MenuItem" disabled="1"><?php echo __('Other actions:') ?></div>
243 <!-- <?php if ($pluginhost->get_plugin("digest")) { ?>
244 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcDigest')"><?php echo __('Switch to digest...') ?></div>
245 <?php } ?> -->
246 <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagCloud')"><?php echo __('Show tag cloud...') ?></div> -->
247 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcToggleWidescreen')"><?php echo __('Toggle widescreen mode') ?></div>
248 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcTagSelect')"><?php echo __('Select by tags...') ?></div>
249 <!-- <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddLabel')"><?php echo __('Create label...') ?></div>
250 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcAddFilter')"><?php echo __('Create filter...') ?></div> -->
251 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcHKhelp')"><?php echo __('Keyboard shortcuts help') ?></div>
252
253 <?php
254 foreach ($pluginhost->get_hooks($pluginhost::HOOK_ACTION_ITEM) as $p) {
255 echo $p->hook_action_item();
256 }
257 ?>
258
259 <?php if (!$_SESSION["hide_logout"]) { ?>
260 <div dojoType="dijit.MenuItem" onclick="quickMenuGo('qmcLogout')"><?php echo __('Logout') ?></div>
261 <?php } ?>
262 </div>
263 </div>
264 </div>
265 </div> <!-- toolbar -->
266 </div> <!-- toolbar pane -->
267
268 <div id="headlines-wrap-inner" dojoType="dijit.layout.BorderContainer" region="center">
269
270 <div id="headlines-toolbar" dojoType="dijit.layout.ContentPane" region="top">
271 </div>
272
273 <div id="headlines-frame" dojoType="dijit.layout.ContentPane"
274 onscroll="headlines_scroll_handler(this)" region="center">
275 <div id="headlinesInnerContainer">
276 <div class="whiteBox"><?php echo __('Loading, please wait...') ?></div>
277 </div>
278 </div>
279
280 <div id="content-insert" dojoType="dijit.layout.ContentPane" region="bottom"
281 style="height : 50%" splitter="true"></div>
282
283 </div>
284 </div>
285 </div>
286 </div>
287
288 <?php db_close($link); ?>
289
290 </body>
291 </html>