| [ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # DotClear is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 23 if (!empty($_GET['pf'])) { 24 require dirname(__FILE__).'/../inc/load_plugin_file.php'; 25 exit; 26 } 27 28 $__dashboard_icons = array(); 29 $__dashboard_items = array(array(),array()); 30 31 require dirname(__FILE__).'/../inc/admin/prepend.php'; 32 33 if (!empty($_GET['default_blog'])) { 34 try { 35 $core->setUserDefaultBlog($core->auth->userID(),$core->blog->id); 36 http::redirect('index.php'); 37 } catch (Exception $e) { 38 $core->error->add($e->getMessage()); 39 } 40 } 41 42 dcPage::check('usage,contentadmin'); 43 44 # Logout 45 if (!empty($_GET['logout'])) { 46 $core->session->destroy(); 47 if (isset($_COOKIE['dc_admin'])) { 48 unset($_COOKIE['dc_admin']); 49 setcookie('dc_admin',null,0,'/'); 50 } 51 http::redirect('auth.php'); 52 exit; 53 } 54 55 # Dashboard icons 56 $rs = $core->blog->getPosts(array(),true); 57 $post_count = $rs->f(0); 58 $str_entries = ($post_count > 1) ? __('%d entries') : __('%d entry'); 59 60 $rs = $core->blog->getComments(array(),true); 61 $comment_count = $rs->f(0); 62 $str_comments = ($comment_count > 1) ? __('%d comments') : __('%d comment'); 63 64 unset($rs); 65 66 if ($core->auth->check('admin',$core->blog->id)) 67 { 68 array_unshift($__dashboard_icons,array(__('Blog settings'),'blog_pref.php','images/menu/blog-pref-b.png')); 69 array_unshift($__dashboard_icons,array(__('Theme settings'),'blog_theme.php','images/menu/blog-theme-b.png')); 70 } 71 72 array_unshift($__dashboard_icons,array(__('User preferences'),'preferences.php','images/menu/user-pref-b.png')); 73 74 array_unshift($__dashboard_icons,array(sprintf($str_comments,$comment_count),'comments.php','images/menu/comments-b.png')); 75 array_unshift($__dashboard_icons,array(sprintf($str_entries,$post_count),'posts.php','images/menu/entries-b.png')); 76 array_unshift($__dashboard_icons,array(__('New entry'),'post.php','images/menu/edit-b.png')); 77 78 # Latest news for dashboard 79 try 80 { 81 if (empty($__ressources['rss_news'])) { 82 throw new Exception('No feed'); 83 } 84 85 $feed_reader = new feedReader; 86 $feed_reader->setCacheDir(DC_TPL_CACHE); 87 $feed_reader->setTimeout(2); 88 $feed_reader->setUserAgent('Dotclear - http://www.dotclear.net/'); 89 $feed = $feed_reader->parse($__ressources['rss_news']); 90 if ($feed) 91 { 92 $latest_news = '<h3>'.__('Latest news').'</h3><ul>'; 93 $i = 1; 94 foreach ($feed->items as $item) { 95 $latest_news .= '<li><a href="'.$item->link.'">'.$item->title.'</a></li>'; 96 $i++; 97 if ($i > 5) { break; } 98 } 99 $latest_news .= '</ul>'; 100 $__dashboard_items[0][] = $latest_news; 101 } 102 } 103 catch (Exception $e) {} 104 105 106 # Documentation links 107 if (!empty($__ressources['doc'])) 108 { 109 $doc_links = '<h3>'.__('Documentation').'</h3><ul>'; 110 111 foreach ($__ressources['doc'] as $k => $v) { 112 $doc_links .= '<li><a href="'.$v.'">'.$k.'</a></li>'; 113 } 114 115 $doc_links .= '</ul>'; 116 $__dashboard_items[1][] = $doc_links; 117 } 118 119 /* DISPLAY 120 -------------------------------------------------------- */ 121 dcPage::open(__('Dashboard')); 122 123 echo '<h2>'.html::escapeHTML($core->blog->name).' > '.__('Dashboard').'</h2>'; 124 125 if ($core->auth->getInfo('user_default_blog') != $core->blog->id 126 && count($core->blogs) > 1) { 127 echo 128 '<p id="default-blog"><a href="index.php?default_blog=1">'. 129 __('Make this blog my default blog').'</a></p>'; 130 } 131 132 if ($core->blog->status == 0) { 133 echo '<p class="static-msg">'.__('This blog is offline').'</p>'; 134 } elseif ($core->blog->status == -1) { 135 echo '<p class="static-msg">'.__('This blog is removed').'</p>'; 136 } 137 138 if (!DC_ADMIN_URL) { 139 echo 140 '<p class="static-msg">'. 141 __('DC_ADMIN_URL is not defined, you should edit your configuration file.'). 142 '</p>'; 143 } 144 145 # Dashboard icons 146 echo '<div id="dashboard-icons">'; 147 foreach ($__dashboard_icons as $i) 148 { 149 echo 150 '<p><a href="'.$i[1].'"><img src="'.$i[2].'" alt="'.$i[0].'" /></a>'. 151 '<span><a href="'.$i[1].'">'.$i[0].'</a></span></p>'; 152 } 153 echo '</div>'; 154 155 # Dashboard columns 156 echo 157 '<div id="dashboard" class="two-cols">'. 158 '<div class="col">'; 159 160 foreach ($__dashboard_items[0] as $v) { 161 echo $v; 162 } 163 164 echo 165 '</div>'. 166 '<div class="col">'; 167 168 foreach ($__dashboard_items[1] as $v) { 169 echo $v; 170 } 171 172 echo '</div></div>'; 173 174 ?> 175 <?php dcPage::close(); ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |