Dotclear

source: admin/index.php @ 3260:cf9f7abdac2e

Revision 3260:cf9f7abdac2e, 13.6 KB checked in by franck <carnet.franck.paul@…>, 9 years ago (diff)

Add /var directory, closes #236 (until further needs)

RevLine 
[0]1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
[1179]6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
[0]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
13if (!empty($_GET['pf'])) {
14     require dirname(__FILE__).'/../inc/load_plugin_file.php';
15     exit;
16}
17
[3260]18if (!empty($_GET['vf'])) {
19     require dirname(__FILE__).'/../inc/load_var_file.php';
20     exit;
21}
22
[0]23require dirname(__FILE__).'/../inc/admin/prepend.php';
24
25if (!empty($_GET['default_blog'])) {
26     try {
27          $core->setUserDefaultBlog($core->auth->userID(),$core->blog->id);
[2852]28          $core->adminurl->redirect("admin.home");
[0]29     } catch (Exception $e) {
30          $core->error->add($e->getMessage());
31     }
32}
33
34dcPage::check('usage,contentadmin');
35
[3066]36if ($core->plugins->disableDepModules($core->adminurl->get('admin.home',array()))) {
37     exit;
38}
39
[0]40# Logout
41if (!empty($_GET['logout'])) {
42     $core->session->destroy();
43     if (isset($_COOKIE['dc_admin'])) {
44          unset($_COOKIE['dc_admin']);
45          setcookie('dc_admin',false,-600,'','',DC_ADMIN_SSL);
46     }
[2852]47     $core->adminurl->redirect("admin.auth");
[0]48     exit;
49}
50
51# Plugin install
52$plugins_install = $core->plugins->installModules();
53
[13]54# Check dashboard module prefs
[157]55$ws = $core->auth->user_prefs->addWorkspace('dashboard');
[13]56if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) {
57     if (!$core->auth->user_prefs->dashboard->prefExists('doclinks',true)) {
58          $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean','',null,true);
59     }
60     $core->auth->user_prefs->dashboard->put('doclinks',true,'boolean');
61}
62if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) {
63     if (!$core->auth->user_prefs->dashboard->prefExists('dcnews',true)) {
64          $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean','',null,true);
65     }
66     $core->auth->user_prefs->dashboard->put('dcnews',true,'boolean');
67}
68if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) {
69     if (!$core->auth->user_prefs->dashboard->prefExists('quickentry',true)) {
[1247]70          $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean','',null,true);
[13]71     }
[1247]72     $core->auth->user_prefs->dashboard->put('quickentry',false,'boolean');
[13]73}
74
[1699]75// Handle folded/unfolded sections in admin from user preferences
76$ws = $core->auth->user_prefs->addWorkspace('toggles');
77if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) {
78     $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true);
79}
80
81
[0]82# Dashboard icons
83$__dashboard_icons = new ArrayObject();
84
[2229]85$favs = $core->favs->getUserFavorites();
86$core->favs->appendDashboardIcons($__dashboard_icons);
[0]87
[2174]88# Check plugins and themes update from repository
[2216]89function dc_check_store_update($mod, $url, $img, $icon)
[2174]90{
[2216]91     $repo = new dcStore($mod, $url);
[2174]92     $upd = $repo->get(true);
93     if (!empty($upd)) {
94          $icon[0] .= '<br />'.sprintf(__('An update is available', '%s updates are available.', count($upd)),count($upd));
95          $icon[1] .= '#update';
96          $icon[2] = 'images/menu/'.$img.'-b-update.png';
97     }
98}
99if (isset($__dashboard_icons['plugins'])) {
[2216]100     dc_check_store_update($core->plugins, $core->blog->settings->system->store_plugin_url, 'plugins', $__dashboard_icons['plugins']);
[2174]101}
102if (isset($__dashboard_icons['blog_theme'])) {
103     $themes = new dcThemes($core);
104     $themes->loadModules($core->blog->themes_path, null);
[2216]105     dc_check_store_update($themes, $core->blog->settings->system->store_theme_url, 'blog-theme', $__dashboard_icons['blog_theme']);
[2174]106}
107
[0]108# Latest news for dashboard
[2229]109$__dashboard_items = new ArrayObject(array(new ArrayObject(),new ArrayObject()));
[0]110
[13]111$dashboardItem = 0;
[0]112
[13]113if ($core->auth->user_prefs->dashboard->dcnews) {
114     try
115     {
116          if (empty($__resources['rss_news'])) {
117               throw new Exception();
118          }
[2566]119
[13]120          $feed_reader = new feedReader;
121          $feed_reader->setCacheDir(DC_TPL_CACHE);
122          $feed_reader->setTimeout(2);
123          $feed_reader->setUserAgent('Dotclear - http://www.dotclear.org/');
124          $feed = $feed_reader->parse($__resources['rss_news']);
125          if ($feed)
126          {
[2085]127               $latest_news = '<div class="box medium dc-box"><h3>'.__('Dotclear news').'</h3><dl id="news">';
[13]128               $i = 1;
129               foreach ($feed->items as $item)
130               {
[2225]131                    $dt = isset($item->link) ? '<a href="'.$item->link.'" class="outgoing" title="'.$item->title.'">'.
[1728]132                         $item->title.' <img src="images/outgoing-blue.png" alt="" /></a>' : $item->title;
[2566]133
[13]134                    if ($i < 3) {
135                         $latest_news .=
136                         '<dt>'.$dt.'</dt>'.
[1000]137                         '<dd><p><strong>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</strong> '.
[13]138                         '<em>'.text::cutString(html::clean($item->content),120).'...</em></p></dd>';
139                    } else {
140                         $latest_news .=
141                         '<dt>'.$dt.'</dt>'.
[1000]142                         '<dd>'.dt::dt2str(__('%d %B %Y:'),$item->pubdate,'Europe/Paris').'</dd>';
[13]143                    }
144                    $i++;
[1788]145                    if ($i > 2) { break; }
[13]146               }
[2085]147               $latest_news .= '</dl></div>';
[13]148               $__dashboard_items[$dashboardItem][] = $latest_news;
149               $dashboardItem++;
150          }
[0]151     }
[13]152     catch (Exception $e) {}
[0]153}
154
[1378]155# Documentation links
156if ($core->auth->user_prefs->dashboard->doclinks) {
157     if (!empty($__resources['doc']))
158     {
[2085]159          $doc_links = '<div class="box small dc-box"><h3>'.__('Documentation and support').'</h3><ul>';
[2566]160
[1378]161          foreach ($__resources['doc'] as $k => $v) {
[2225]162               $doc_links .= '<li><a class="outgoing" href="'.$v.'" title="'.$k.'">'.$k.
[1728]163               ' <img src="images/outgoing-blue.png" alt="" /></a></li>';
[1378]164          }
[2566]165
[2085]166          $doc_links .= '</ul></div>';
[1378]167          $__dashboard_items[$dashboardItem][] = $doc_links;
168          $dashboardItem++;
169     }
170}
171
[0]172$core->callBehavior('adminDashboardItems', $core, $__dashboard_items);
173
[480]174# Dashboard content
175$dashboardContents = '';
176$__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject));
177$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents);
178
[2842]179# Editor stuff
180$admin_post_behavior = '';
181if ($core->auth->user_prefs->dashboard->quickentry) {
182     if ($core->auth->check('usage,contentadmin',$core->blog->id))
183     {
184          $post_format = $core->auth->getOption('post_format');
185          $post_editor = $core->auth->getOption('editor');
186          if ($post_editor && !empty($post_editor[$post_format])) {
[2854]187               // context is not post because of tags not available
[3024]188               $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'quickentry', array('#post_content'),$post_format);
[2842]189          }
190     }
191}
192
[0]193/* DISPLAY
194-------------------------------------------------------- */
195dcPage::open(__('Dashboard'),
196     dcPage::jsLoad('js/_index.js').
[2842]197     $admin_post_behavior.
[0]198     # --BEHAVIOR-- adminDashboardHeaders
[1358]199     $core->callBehavior('adminDashboardHeaders'),
200     dcPage::breadcrumb(
201          array(
[2166]202          __('Dashboard').' : '.html::escapeHTML($core->blog->name) => ''
[1358]203          ),
[2166]204          array('home_link' =>false)
205     )
[0]206);
207
[1422]208# Dotclear updates notifications
[3189]209if ($core->auth->isSuperAdmin() && !DC_NOT_UPDATE && is_readable(DC_DIGESTS))
[1422]210{
211     $updater = new dcUpdate(DC_UPDATE_URL,'dotclear',DC_UPDATE_VERSION,DC_TPL_CACHE.'/versions');
212     $new_v = $updater->check(DC_VERSION);
213     $version_info = $new_v ? $updater->getInfoURL() : '';
214
215     if ($updater->getNotify() && $new_v) {
[1697]216          echo
[1698]217          '<div class="dc-update"><h3>'.sprintf(__('Dotclear %s is available!'),$new_v).'</h3> '.
[2720]218          '<p><a class="button submit" href="'.$core->adminurl->get("admin.update").'">'.sprintf(__('Upgrade now'),$new_v).'</a> '.
219          '<a class="button" href="'.$core->adminurl->get("admin.update", array('hide_msg' => 1)).'">'.__('Remind me later').'</a>'.
[1697]220          ($version_info ? ' </p>'.
[1811]221          '<p class="updt-info"><a href="'.$version_info.'">'.__('Information about this version').'</a>' : '').'</p>'.
[1697]222          '</div>';
[1422]223     }
224}
[0]225
[2159]226if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) {
[0]227     echo
[2720]228     '<p><a href="'.$core->adminurl->get("admin.home",array('default_blog' => 1)).'" class="button">'.__('Make this blog my default blog').'</a></p>';
[0]229}
230
231if ($core->blog->status == 0) {
[1558]232     echo '<p class="static-msg">'.__('This blog is offline').'.</p>';
[0]233} elseif ($core->blog->status == -1) {
[1558]234     echo '<p class="static-msg">'.__('This blog is removed').'.</p>';
[0]235}
236
[374]237if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) {
[0]238     echo
239     '<p class="static-msg">'.
[1077]240     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').
241     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
[373]242     '</p>';
243}
244
[374]245if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) {
[373]246     echo
247     '<p class="static-msg">'.
[1077]248     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').
249     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
[0]250     '</p>';
251}
252
[1535]253$err = array();
254
255# Check cache directory
[1705]256if ( $core->auth->isSuperAdmin() ) {
257     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
[1708]258          $err[] = '<p>'.__("The cache directory does not exist or is not writable. You must create this directory with sufficient rights and affect this location to \"DC_TPL_CACHE\" in inc/config.php file.").'</p>';
[1705]259     }
260} else {
261     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
[1708]262          $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>';
[1705]263     }
[1535]264}
265
266# Check public directory
[1705]267if ( $core->auth->isSuperAdmin() ) {
268     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
[1708]269          $err[] = '<p>'.__("There is no writable directory /public/ at the location set in about:config \"public_path\". You must create this directory with sufficient rights (or change this setting).").'</p>';
[1705]270     }
271} else {
272     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
[1708]273          $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>';
[1705]274     }
[1535]275}
276
277# Error list
278if (count($err) > 0) {
[2515]279     echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'.
[1535]280     '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>';
281}
282
[0]283# Plugins install messages
284if (!empty($plugins_install['success']))
285{
[2116]286     echo '<div class="success">'.__('Following plugins have been installed:').'<ul>';
[0]287     foreach ($plugins_install['success'] as $k => $v) {
288          echo '<li>'.$k.'</li>';
289     }
290     echo '</ul></div>';
291}
292if (!empty($plugins_install['failure']))
293{
294     echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
295     foreach ($plugins_install['failure'] as $k => $v) {
296          echo '<li>'.$k.' ('.$v.')</li>';
297     }
298     echo '</ul></div>';
299}
[112]300# Errors modules notifications
301if ($core->auth->isSuperAdmin())
302{
[2239]303     $list = $core->plugins->getErrors();
304     if (!empty($list)) {
[2566]305          echo
[2239]306          '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '.
307          '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>';
[112]308     }
309}
310
[1729]311# Dashboard columns (processed first, as we need to know the result before displaying the icons.)
312$dashboardItems = '';
313
[112]314foreach ($__dashboard_items as $i)
[2566]315{
[112]316     if ($i->count() > 0)
317     {
[2085]318          $dashboardItems .= '';
[112]319          foreach ($i as $v) {
320               $dashboardItems .= $v;
321          }
[2085]322          $dashboardItems .= '';
[112]323     }
324}
325
[2116]326# Dashboard elements
327echo '<div id="dashboard-main">';
328
[3238]329if (!$core->auth->user_prefs->dashboard->nofavicons) {
330     # Dashboard icons
331     echo '<div id="icons">';
332     foreach ($__dashboard_icons as $i)
333     {
334          echo
335          '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'.
336          '<br /><span>'.$i[0].'</span></a></p>';
337     }
338     echo '</div>';
[0]339}
340
[13]341if ($core->auth->user_prefs->dashboard->quickentry) {
342     if ($core->auth->check('usage,contentadmin',$core->blog->id))
343     {
[1391]344          # Getting categories
[1719]345          $categories_combo = dcAdminCombos::getCategoriesCombo(
[3209]346               $core->blog->getCategories(array())
[1719]347          );
[2566]348
[13]349          echo
350          '<div id="quick">'.
[2929]351          '<h3>'.__('Quick entry').sprintf(' &rsaquo; %s',$core->auth->getOption('post_format')).'</h3>'.
[2708]352          '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'.
[1499]353          '<h4>'.__('New entry').'</h4>'.
[1399]354          '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'.
[454]355          form::field('post_title',20,255,'','maximal').
[1399]356          '</p>'.
[45]357          '<p class="area"><label class="required" '.
358          'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
[2358]359          form::textarea('post_content',50,10).
[13]360          '</p>'.
[1521]361          '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '.
362          form::combo('cat_id',$categories_combo).'</p>'.
[1418]363          ($core->auth->check('categories', $core->blog->id)
364               ? '<div>'.
[1521]365               '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'.
366               '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '.
367               form::field('new_cat_title',30,255,'','').'</p>'.
368               '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '.
369               form::combo('new_cat_parent',$categories_combo,'','').
370               '</p>'.
[1488]371               '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</p>'.
[1418]372               '</div>'
373               : '').
[454]374          '<p><input type="submit" value="'.__('Save').'" name="save" /> '.
[13]375          ($core->auth->check('publish',$core->blog->id)
[536]376               ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />'
[13]377               : '').
378          $core->formNonce().
379          form::hidden('post_status',-2).
380          form::hidden('post_format',$core->auth->getOption('post_format')).
381          form::hidden('post_excerpt','').
382          form::hidden('post_lang',$core->auth->getInfo('user_lang')).
383          form::hidden('post_notes','').
384          '</p>'.
385          '</form>'.
386          '</div>';
387     }
[0]388}
389
[480]390foreach ($__dashboard_contents as $i)
[2566]391{
[480]392     if ($i->count() > 0)
393     {
[2085]394          $dashboardContents .= '';
[480]395          foreach ($i as $v) {
396               $dashboardContents .= $v;
397          }
[2085]398          $dashboardContents .= '';
[480]399     }
400}
[1728]401
402if ($dashboardContents != '' || $dashboardItems != '') {
[2566]403     echo
[2116]404     '<div id="dashboard-boxes">'.
405     '<div class="db-items">'.$dashboardItems.$dashboardContents.'</div>'.
[2566]406     '</div>';
[1728]407}
[480]408
[2116]409echo '</div>'; #end dashboard-main
[2314]410dcPage::helpBlock('core_dashboard');
[0]411dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map