1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | |
---|
13 | if (!empty($_GET['pf'])) { |
---|
14 | require dirname(__FILE__).'/../inc/load_plugin_file.php'; |
---|
15 | exit; |
---|
16 | } |
---|
17 | |
---|
18 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
---|
19 | |
---|
20 | if (!empty($_GET['default_blog'])) { |
---|
21 | try { |
---|
22 | $core->setUserDefaultBlog($core->auth->userID(),$core->blog->id); |
---|
23 | http::redirect('index.php'); |
---|
24 | } catch (Exception $e) { |
---|
25 | $core->error->add($e->getMessage()); |
---|
26 | } |
---|
27 | } |
---|
28 | |
---|
29 | dcPage::check('usage,contentadmin'); |
---|
30 | |
---|
31 | # Logout |
---|
32 | if (!empty($_GET['logout'])) { |
---|
33 | $core->session->destroy(); |
---|
34 | if (isset($_COOKIE['dc_admin'])) { |
---|
35 | unset($_COOKIE['dc_admin']); |
---|
36 | setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL); |
---|
37 | } |
---|
38 | http::redirect('auth.php'); |
---|
39 | exit; |
---|
40 | } |
---|
41 | |
---|
42 | # Plugin install |
---|
43 | $plugins_install = $core->plugins->installModules(); |
---|
44 | |
---|
45 | # Dashboard icons |
---|
46 | $__dashboard_icons = new ArrayObject(); |
---|
47 | |
---|
48 | $post_count = $core->blog->getPosts(array(),true)->f(0); |
---|
49 | $str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); |
---|
50 | |
---|
51 | $comment_count = $core->blog->getComments(array(),true)->f(0); |
---|
52 | $str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment'); |
---|
53 | |
---|
54 | $__dashboard_icons['new_post'] = new ArrayObject(array(__('New entry'),'post.php','images/menu/edit-b.png')); |
---|
55 | $__dashboard_icons['posts'] = new ArrayObject(array(sprintf($str_entries,$post_count),'posts.php','images/menu/entries-b.png')); |
---|
56 | $__dashboard_icons['comments'] = new ArrayObject(array(sprintf($str_comments,$comment_count),'comments.php','images/menu/comments-b.png')); |
---|
57 | $__dashboard_icons['prefs'] = new ArrayObject(array(__('User preferences'),'preferences.php','images/menu/user-pref-b.png')); |
---|
58 | |
---|
59 | if ($core->auth->check('admin',$core->blog->id)) |
---|
60 | { |
---|
61 | $__dashboard_icons['blog_pref'] = new ArrayObject(array(__('Blog settings'),'blog_pref.php','images/menu/blog-pref-b.png')); |
---|
62 | $__dashboard_icons['blog_theme'] = new ArrayObject(array(__('Blog appearance'),'blog_theme.php','images/menu/blog-theme-b.png')); |
---|
63 | } |
---|
64 | |
---|
65 | $core->callBehavior('adminDashboardIcons', $core, $__dashboard_icons); |
---|
66 | |
---|
67 | |
---|
68 | # Latest news for dashboard |
---|
69 | $__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); |
---|
70 | |
---|
71 | # Documentation links |
---|
72 | if (!empty($__resources['doc'])) |
---|
73 | { |
---|
74 | $doc_links = '<h3>'.__('Documentation').'</h3><ul>'; |
---|
75 | |
---|
76 | foreach ($__resources['doc'] as $k => $v) { |
---|
77 | $doc_links .= '<li><a href="'.$v.'">'.$k.'</a></li>'; |
---|
78 | } |
---|
79 | |
---|
80 | $doc_links .= '</ul>'; |
---|
81 | $__dashboard_items[0][] = $doc_links; |
---|
82 | } |
---|
83 | |
---|
84 | try |
---|
85 | { |
---|
86 | if (empty($__resources['rss_news'])) { |
---|
87 | throw new Exception(); |
---|
88 | } |
---|
89 | |
---|
90 | $feed_reader = new feedReader; |
---|
91 | $feed_reader->setCacheDir(DC_TPL_CACHE); |
---|
92 | $feed_reader->setTimeout(2); |
---|
93 | $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); |
---|
94 | $feed = $feed_reader->parse($__resources['rss_news']); |
---|
95 | if ($feed) |
---|
96 | { |
---|
97 | $latest_news = '<h3>'.__('Latest news').'</h3><dl id="news">'; |
---|
98 | $i = 1; |
---|
99 | foreach ($feed->items as $item) |
---|
100 | { |
---|
101 | $dt = isset($item->link) ? '<a href="'.$item->link.'">'.$item->title.'</a>' : $item->title; |
---|
102 | |
---|
103 | if ($i < 3) { |
---|
104 | $latest_news .= |
---|
105 | '<dt>'.$dt.'</dt>'. |
---|
106 | '<dd><p><strong>'.dt::dt2str('%d %B %Y',$item->pubdate,'Europe/Paris').'</strong>: '. |
---|
107 | '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>'; |
---|
108 | } else { |
---|
109 | $latest_news .= |
---|
110 | '<dt>'.$dt.'</dt>'. |
---|
111 | '<dd>'.dt::dt2str('%d %B %Y',$item->pubdate,'Europe/Paris').'</dd>'; |
---|
112 | } |
---|
113 | $i++; |
---|
114 | if ($i > 7) { break; } |
---|
115 | } |
---|
116 | $latest_news .= '</dl>'; |
---|
117 | $__dashboard_items[1][] = $latest_news; |
---|
118 | } |
---|
119 | } |
---|
120 | catch (Exception $e) {} |
---|
121 | |
---|
122 | $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); |
---|
123 | |
---|
124 | /* DISPLAY |
---|
125 | -------------------------------------------------------- */ |
---|
126 | dcPage::open(__('Dashboard'), |
---|
127 | dcPage::jsToolBar(). |
---|
128 | dcPage::jsLoad('js/_index.js'). |
---|
129 | # --BEHAVIOR-- adminDashboardHeaders |
---|
130 | $core->callBehavior('adminDashboardHeaders') |
---|
131 | ); |
---|
132 | |
---|
133 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Dashboard'); |
---|
134 | |
---|
135 | if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { |
---|
136 | echo |
---|
137 | ' - <a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a>'; |
---|
138 | } |
---|
139 | |
---|
140 | echo '</h2>'; |
---|
141 | |
---|
142 | if ($core->blog->status == 0) { |
---|
143 | echo '<p class="static-msg">'.__('This blog is offline').'</p>'; |
---|
144 | } elseif ($core->blog->status == -1) { |
---|
145 | echo '<p class="static-msg">'.__('This blog is removed').'</p>'; |
---|
146 | } |
---|
147 | |
---|
148 | if (!DC_ADMIN_URL) { |
---|
149 | echo |
---|
150 | '<p class="static-msg">'. |
---|
151 | __('DC_ADMIN_URL is not defined, you should edit your configuration file.'). |
---|
152 | '</p>'; |
---|
153 | } |
---|
154 | |
---|
155 | # Plugins install messages |
---|
156 | if (!empty($plugins_install['success'])) |
---|
157 | { |
---|
158 | echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; |
---|
159 | foreach ($plugins_install['success'] as $k => $v) { |
---|
160 | echo '<li>'.$k.'</li>'; |
---|
161 | } |
---|
162 | echo '</ul></div>'; |
---|
163 | } |
---|
164 | if (!empty($plugins_install['failure'])) |
---|
165 | { |
---|
166 | echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; |
---|
167 | foreach ($plugins_install['failure'] as $k => $v) { |
---|
168 | echo '<li>'.$k.' ('.$v.')</li>'; |
---|
169 | } |
---|
170 | echo '</ul></div>'; |
---|
171 | } |
---|
172 | |
---|
173 | # Dashboard icons |
---|
174 | echo '<div id="dashboard-main"><div id="icons">'; |
---|
175 | foreach ($__dashboard_icons as $i) |
---|
176 | { |
---|
177 | echo |
---|
178 | '<p><a href="'.$i[1].'"><img src="'.$i[2].'" alt="" /></a>'. |
---|
179 | '<span><a href="'.$i[1].'">'.$i[0].'</a></span></p>'; |
---|
180 | } |
---|
181 | echo '</div>'; |
---|
182 | |
---|
183 | if ($core->auth->check('usage,contentadmin',$core->blog->id)) |
---|
184 | { |
---|
185 | $categories_combo = array(' ' => ''); |
---|
186 | try { |
---|
187 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
188 | while ($categories->fetch()) { |
---|
189 | $categories_combo[] = new formSelectOption( |
---|
190 | str_repeat(' ',$categories->level-1).'• '.html::escapeHTML($categories->cat_title), |
---|
191 | $categories->cat_id |
---|
192 | ); |
---|
193 | } |
---|
194 | } catch (Exception $e) { } |
---|
195 | |
---|
196 | echo |
---|
197 | '<div id="quick">'. |
---|
198 | '<h3>'.__('Quick entry').'</h3>'. |
---|
199 | '<form id="quick-entry" action="post.php" method="post">'. |
---|
200 | '<fieldset>'. |
---|
201 | '<p class="col"><label class="required" title="'.__('Required field').'">'.__('Title:'). |
---|
202 | form::field('post_title',20,255,'','maximal',2). |
---|
203 | '</label></p>'. |
---|
204 | '<p class="area"><label class="required" title="'.__('Required field').'" '. |
---|
205 | 'for="post_content">'.__('Content:').'</label> '. |
---|
206 | form::textarea('post_content',50,7,'','',2). |
---|
207 | '</p>'. |
---|
208 | '<p><label class="classic">'.__('Category:').' '. |
---|
209 | form::combo('cat_id',$categories_combo,'','',2).'</label></p>'. |
---|
210 | '<p><input type="submit" value="'.__('save').'" name="save" tabindex="3" /> '. |
---|
211 | ($core->auth->check('publish',$core->blog->id) |
---|
212 | ? '<input type="hidden" value="'.__('save and publish').'" name="save-publish" />' |
---|
213 | : ''). |
---|
214 | $core->formNonce(). |
---|
215 | form::hidden('post_status',-2). |
---|
216 | form::hidden('post_format',$core->auth->getOption('post_format')). |
---|
217 | form::hidden('post_excerpt',''). |
---|
218 | form::hidden('post_lang',$core->auth->getInfo('user_lang')). |
---|
219 | form::hidden('post_notes',''). |
---|
220 | '</p>'. |
---|
221 | '</fieldset>'. |
---|
222 | '</form>'. |
---|
223 | '</div>'; |
---|
224 | } |
---|
225 | |
---|
226 | echo '</div>'; |
---|
227 | |
---|
228 | # Dashboard columns |
---|
229 | echo '<div id="dashboard-items">'; |
---|
230 | |
---|
231 | # Dotclear updates notifications |
---|
232 | if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) |
---|
233 | { |
---|
234 | $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); |
---|
235 | $new_v = $updater->check(DC_VERSION); |
---|
236 | |
---|
237 | if ($updater->getNotify() && $new_v) { |
---|
238 | echo |
---|
239 | '<div id="upg-notify" class="static-msg"><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. |
---|
240 | '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. |
---|
241 | '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. |
---|
242 | '</li></ul></div>'; |
---|
243 | } |
---|
244 | } |
---|
245 | |
---|
246 | # Errors modules notifications |
---|
247 | if ($core->auth->isSuperAdmin()) |
---|
248 | { |
---|
249 | $list = array(); |
---|
250 | foreach ($core->plugins->getErrors() as $k => $error) { |
---|
251 | $list[] = '<li>'.$error.'</li>'; |
---|
252 | } |
---|
253 | |
---|
254 | if (count($list) > 0) { |
---|
255 | echo |
---|
256 | '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. |
---|
257 | '<ul>'.implode("\n",$list).'</ul></div>'; |
---|
258 | } |
---|
259 | |
---|
260 | } |
---|
261 | |
---|
262 | foreach ($__dashboard_items as $i) |
---|
263 | { |
---|
264 | echo '<div>'; |
---|
265 | foreach ($i as $v) { |
---|
266 | echo $v; |
---|
267 | } |
---|
268 | echo '</div>'; |
---|
269 | } |
---|
270 | echo '</div>'; |
---|
271 | |
---|
272 | dcPage::close(); |
---|
273 | ?> |
---|