[0] | 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 | |
---|
[13] | 45 | # Check dashboard module prefs |
---|
| 46 | if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { |
---|
| 47 | if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) { |
---|
| 48 | $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean','',null,true); |
---|
| 49 | } |
---|
| 50 | $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean'); |
---|
| 51 | } |
---|
| 52 | if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { |
---|
| 53 | if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) { |
---|
| 54 | $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean','',null,true); |
---|
| 55 | } |
---|
| 56 | $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean'); |
---|
| 57 | } |
---|
| 58 | if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { |
---|
| 59 | if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) { |
---|
| 60 | $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean','',null,true); |
---|
| 61 | } |
---|
| 62 | $core->auth->user_prefs->dashboard->put('quickentry',true,'boolean'); |
---|
| 63 | } |
---|
| 64 | |
---|
[0] | 65 | # Dashboard icons |
---|
| 66 | $__dashboard_icons = new ArrayObject(); |
---|
| 67 | |
---|
[3] | 68 | # Dashboard favorites |
---|
[0] | 69 | $post_count = $core->blog->getPosts(array(),true)->f(0); |
---|
| 70 | $str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); |
---|
| 71 | |
---|
| 72 | $comment_count = $core->blog->getComments(array(),true)->f(0); |
---|
| 73 | $str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment'); |
---|
| 74 | |
---|
[3] | 75 | $ws = $core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 76 | $count = 0; |
---|
| 77 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 78 | // User favorites only |
---|
| 79 | if (!$v['global']) { |
---|
| 80 | $fav = unserialize($v['value']); |
---|
| 81 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 82 | $count++; |
---|
| 83 | $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : |
---|
| 84 | ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); |
---|
| 85 | $__dashboard_icons[$fav['name']] = new ArrayObject(array($title,$fav['url'],$fav['large-icon'])); |
---|
[130] | 86 | |
---|
| 87 | # Let plugins set their own title for favorite on dashboard |
---|
| 88 | $core->callBehavior('adminDashboardFavsIcon',$core,$fav['name'],$__dashboard_icons[$fav['name']]); |
---|
[3] | 89 | } |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | if (!$count) { |
---|
| 93 | // Global favorites if any |
---|
| 94 | foreach ($ws->dumpPrefs() as $k => $v) { |
---|
| 95 | $fav = unserialize($v['value']); |
---|
| 96 | if (($fav['permissions'] == '*') || $core->auth->check($fav['permissions'],$core->blog->id)) { |
---|
| 97 | $count++; |
---|
| 98 | $title = ($fav['name'] == 'posts' ? sprintf($str_entries,$post_count) : |
---|
| 99 | ($fav['name'] == 'comments' ? sprintf($str_comments,$comment_count) : $fav['title'])); |
---|
| 100 | $__dashboard_icons[$fav['name']] = new ArrayObject(array($title,$fav['url'],$fav['large-icon'])); |
---|
[130] | 101 | |
---|
| 102 | # Let plugins set their own title for favorite on dashboard |
---|
| 103 | $core->callBehavior('adminDashboardFavsIcon',$core,$fav['name'],$__dashboard_icons[$fav['name']]); |
---|
[3] | 104 | } |
---|
| 105 | } |
---|
[0] | 106 | } |
---|
[3] | 107 | if (!$count) { |
---|
| 108 | // No user or global favorites, add "user pref" and "new entry" fav |
---|
| 109 | if ($core->auth->check('usage,contentadmin',$core->blog->id)) { |
---|
| 110 | $__dashboard_icons['new_post'] = new ArrayObject(array(__('New entry'),'post.php','images/menu/edit-b.png')); |
---|
| 111 | } |
---|
| 112 | $__dashboard_icons['prefs'] = new ArrayObject(array(__('My preferences'),'preferences.php','images/menu/user-pref-b.png')); |
---|
| 113 | } |
---|
[0] | 114 | |
---|
| 115 | # Latest news for dashboard |
---|
| 116 | $__dashboard_items = new ArrayObject(array(new ArrayObject,new ArrayObject)); |
---|
| 117 | |
---|
| 118 | # Documentation links |
---|
[13] | 119 | $dashboardItem = 0; |
---|
| 120 | if ($core->auth->user_prefs->dashboard->doclinks) { |
---|
| 121 | if (!empty($__resources['doc'])) |
---|
| 122 | { |
---|
| 123 | $doc_links = '<h3>'.__('Documentation').'</h3><ul>'; |
---|
[0] | 124 | |
---|
[13] | 125 | foreach ($__resources['doc'] as $k => $v) { |
---|
| 126 | $doc_links .= '<li><a href="'.$v.'">'.$k.'</a></li>'; |
---|
| 127 | } |
---|
| 128 | |
---|
| 129 | $doc_links .= '</ul>'; |
---|
| 130 | $__dashboard_items[$dashboardItem][] = $doc_links; |
---|
| 131 | $dashboardItem++; |
---|
[0] | 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
[13] | 135 | if ($core->auth->user_prefs->dashboard->dcnews) { |
---|
| 136 | try |
---|
| 137 | { |
---|
| 138 | if (empty($__resources['rss_news'])) { |
---|
| 139 | throw new Exception(); |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | $feed_reader = new feedReader; |
---|
| 143 | $feed_reader->setCacheDir(DC_TPL_CACHE); |
---|
| 144 | $feed_reader->setTimeout(2); |
---|
| 145 | $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/'); |
---|
| 146 | $feed = $feed_reader->parse($__resources['rss_news']); |
---|
| 147 | if ($feed) |
---|
| 148 | { |
---|
| 149 | $latest_news = '<h3>'.__('Latest news').'</h3><dl id="news">'; |
---|
| 150 | $i = 1; |
---|
| 151 | foreach ($feed->items as $item) |
---|
| 152 | { |
---|
| 153 | $dt = isset($item->link) ? '<a href="'.$item->link.'">'.$item->title.'</a>' : $item->title; |
---|
| 154 | |
---|
| 155 | if ($i < 3) { |
---|
| 156 | $latest_news .= |
---|
| 157 | '<dt>'.$dt.'</dt>'. |
---|
| 158 | '<dd><p><strong>'.dt::dt2str('%d %B %Y',$item->pubdate,'Europe/Paris').'</strong>: '. |
---|
| 159 | '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>'; |
---|
| 160 | } else { |
---|
| 161 | $latest_news .= |
---|
| 162 | '<dt>'.$dt.'</dt>'. |
---|
| 163 | '<dd>'.dt::dt2str('%d %B %Y',$item->pubdate,'Europe/Paris').'</dd>'; |
---|
| 164 | } |
---|
| 165 | $i++; |
---|
| 166 | if ($i > 3) { break; } |
---|
| 167 | } |
---|
| 168 | $latest_news .= '</dl>'; |
---|
| 169 | $__dashboard_items[$dashboardItem][] = $latest_news; |
---|
| 170 | $dashboardItem++; |
---|
| 171 | } |
---|
[0] | 172 | } |
---|
[13] | 173 | catch (Exception $e) {} |
---|
[0] | 174 | } |
---|
| 175 | |
---|
| 176 | $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); |
---|
| 177 | |
---|
| 178 | /* DISPLAY |
---|
| 179 | -------------------------------------------------------- */ |
---|
| 180 | dcPage::open(__('Dashboard'), |
---|
| 181 | dcPage::jsToolBar(). |
---|
| 182 | dcPage::jsLoad('js/_index.js'). |
---|
| 183 | # --BEHAVIOR-- adminDashboardHeaders |
---|
| 184 | $core->callBehavior('adminDashboardHeaders') |
---|
| 185 | ); |
---|
| 186 | |
---|
| 187 | echo '<h2>'.html::escapeHTML($core->blog->name).' › '.__('Dashboard'); |
---|
| 188 | |
---|
| 189 | if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->blog_count > 1) { |
---|
| 190 | echo |
---|
| 191 | ' - <a href="index.php?default_blog=1" class="button">'.__('Make this blog my default blog').'</a>'; |
---|
| 192 | } |
---|
| 193 | |
---|
| 194 | echo '</h2>'; |
---|
| 195 | |
---|
| 196 | if ($core->blog->status == 0) { |
---|
| 197 | echo '<p class="static-msg">'.__('This blog is offline').'</p>'; |
---|
| 198 | } elseif ($core->blog->status == -1) { |
---|
| 199 | echo '<p class="static-msg">'.__('This blog is removed').'</p>'; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | if (!DC_ADMIN_URL) { |
---|
| 203 | echo |
---|
| 204 | '<p class="static-msg">'. |
---|
| 205 | __('DC_ADMIN_URL is not defined, you should edit your configuration file.'). |
---|
| 206 | '</p>'; |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | # Plugins install messages |
---|
| 210 | if (!empty($plugins_install['success'])) |
---|
| 211 | { |
---|
| 212 | echo '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; |
---|
| 213 | foreach ($plugins_install['success'] as $k => $v) { |
---|
| 214 | echo '<li>'.$k.'</li>'; |
---|
| 215 | } |
---|
| 216 | echo '</ul></div>'; |
---|
| 217 | } |
---|
| 218 | if (!empty($plugins_install['failure'])) |
---|
| 219 | { |
---|
| 220 | echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; |
---|
| 221 | foreach ($plugins_install['failure'] as $k => $v) { |
---|
| 222 | echo '<li>'.$k.' ('.$v.')</li>'; |
---|
| 223 | } |
---|
| 224 | echo '</ul></div>'; |
---|
| 225 | } |
---|
| 226 | |
---|
[112] | 227 | # Dashboard columns (processed first, as we need to know the result before displaying the icons.) |
---|
| 228 | $dashboardItems = ''; |
---|
| 229 | |
---|
| 230 | # Dotclear updates notifications |
---|
| 231 | if ($core->auth->isSuperAdmin() && is_readable(DC_DIGESTS)) |
---|
| 232 | { |
---|
| 233 | $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions'); |
---|
| 234 | $new_v = $updater->check(DC_VERSION); |
---|
| 235 | |
---|
| 236 | if ($updater->getNotify() && $new_v) { |
---|
| 237 | $dashboardItems .= |
---|
| 238 | '<div id="upg-notify" class="static-msg"><p>'.sprintf(__('Dotclear %s is available!'),$new_v).'</p> '. |
---|
| 239 | '<ul><li><strong><a href="update.php">'.sprintf(__('Upgrade now'),$new_v).'</a></strong>'. |
---|
| 240 | '</li><li><a href="update.php?hide_msg=1">'.__('Remind me later').'</a>'. |
---|
| 241 | '</li></ul></div>'; |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | # Errors modules notifications |
---|
| 246 | if ($core->auth->isSuperAdmin()) |
---|
| 247 | { |
---|
| 248 | $list = array(); |
---|
| 249 | foreach ($core->plugins->getErrors() as $k => $error) { |
---|
| 250 | $list[] = '<li>'.$error.'</li>'; |
---|
| 251 | } |
---|
| 252 | |
---|
| 253 | if (count($list) > 0) { |
---|
| 254 | $dashboardItems .= |
---|
| 255 | '<div id="module-errors" class="error"><p>'.__('Some plugins are installed twice:').'</p> '. |
---|
| 256 | '<ul>'.implode("\n",$list).'</ul></div>'; |
---|
| 257 | } |
---|
| 258 | |
---|
| 259 | } |
---|
| 260 | |
---|
| 261 | foreach ($__dashboard_items as $i) |
---|
| 262 | { |
---|
| 263 | if ($i->count() > 0) |
---|
| 264 | { |
---|
| 265 | $dashboardItems .= '<div>'; |
---|
| 266 | foreach ($i as $v) { |
---|
| 267 | $dashboardItems .= $v; |
---|
| 268 | } |
---|
| 269 | $dashboardItems .= '</div>'; |
---|
| 270 | } |
---|
| 271 | } |
---|
| 272 | |
---|
[0] | 273 | # Dashboard icons |
---|
[152] | 274 | <<<<<<< local |
---|
[119] | 275 | echo '<div id="dashboard-main"'.($dashboardItems ? '' : ' class="fullwidth"').'><div id="icons">'; |
---|
[152] | 276 | ======= |
---|
| 277 | echo '<div id="dashboard-main"><div id="icons"'.($dashboardItems ? '' : 'class="fullwidth"').'>'; |
---|
| 278 | >>>>>>> other |
---|
[0] | 279 | foreach ($__dashboard_icons as $i) |
---|
| 280 | { |
---|
| 281 | echo |
---|
| 282 | '<p><a href="'.$i[1].'"><img src="'.$i[2].'" alt="" /></a>'. |
---|
| 283 | '<span><a href="'.$i[1].'">'.$i[0].'</a></span></p>'; |
---|
| 284 | } |
---|
| 285 | echo '</div>'; |
---|
| 286 | |
---|
[13] | 287 | if ($core->auth->user_prefs->dashboard->quickentry) { |
---|
| 288 | if ($core->auth->check('usage,contentadmin',$core->blog->id)) |
---|
| 289 | { |
---|
| 290 | $categories_combo = array(' ' => ''); |
---|
| 291 | try { |
---|
| 292 | $categories = $core->blog->getCategories(array('post_type'=>'post')); |
---|
| 293 | while ($categories->fetch()) { |
---|
| 294 | $categories_combo[] = new formSelectOption( |
---|
| 295 | str_repeat(' ',$categories->level-1).'• '.html::escapeHTML($categories->cat_title), |
---|
| 296 | $categories->cat_id |
---|
| 297 | ); |
---|
| 298 | } |
---|
| 299 | } catch (Exception $e) { } |
---|
[0] | 300 | |
---|
[13] | 301 | echo |
---|
| 302 | '<div id="quick">'. |
---|
| 303 | '<h3>'.__('Quick entry').'</h3>'. |
---|
| 304 | '<form id="quick-entry" action="post.php" method="post">'. |
---|
| 305 | '<fieldset>'. |
---|
[45] | 306 | '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:'). |
---|
[13] | 307 | form::field('post_title',20,255,'','maximal',2). |
---|
| 308 | '</label></p>'. |
---|
[45] | 309 | '<p class="area"><label class="required" '. |
---|
| 310 | 'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '. |
---|
[13] | 311 | form::textarea('post_content',50,7,'','',2). |
---|
| 312 | '</p>'. |
---|
[45] | 313 | '<p><label for="cat_id" class="classic">'.__('Category:').' '. |
---|
[13] | 314 | form::combo('cat_id',$categories_combo,'','',2).'</label></p>'. |
---|
| 315 | '<p><input type="submit" value="'.__('save').'" name="save" tabindex="3" /> '. |
---|
| 316 | ($core->auth->check('publish',$core->blog->id) |
---|
| 317 | ? '<input type="hidden" value="'.__('save and publish').'" name="save-publish" />' |
---|
| 318 | : ''). |
---|
| 319 | $core->formNonce(). |
---|
| 320 | form::hidden('post_status',-2). |
---|
| 321 | form::hidden('post_format',$core->auth->getOption('post_format')). |
---|
| 322 | form::hidden('post_excerpt',''). |
---|
| 323 | form::hidden('post_lang',$core->auth->getInfo('user_lang')). |
---|
| 324 | form::hidden('post_notes',''). |
---|
| 325 | '</p>'. |
---|
| 326 | '</fieldset>'. |
---|
| 327 | '</form>'. |
---|
| 328 | '</div>'; |
---|
| 329 | } |
---|
[0] | 330 | } |
---|
| 331 | |
---|
| 332 | echo '</div>'; |
---|
| 333 | |
---|
[109] | 334 | echo ($dashboardItems ? '<div id="dashboard-items">'.$dashboardItems.'</div>' : ''); |
---|
[0] | 335 | |
---|
| 336 | dcPage::close(); |
---|
| 337 | ?> |
---|