Dotclear

source: admin/index.php @ 3639:fe9f4d94f86b

Revision 3639:fe9f4d94f86b, 11.9 KB checked in by franck <carnet.franck.paul@…>, 8 years ago (diff)

Add required attribute for mandatory fields

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}
[3557]74if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate')) {
75     if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate',true)) {
76          $core->auth->user_prefs->dashboard->put('nodcupdate',false,'boolean','',null,true);
77     }
78     $core->auth->user_prefs->dashboard->put('nodcupdate',false,'boolean');
79}
[13]80
[1699]81// Handle folded/unfolded sections in admin from user preferences
82$ws = $core->auth->user_prefs->addWorkspace('toggles');
83if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) {
84     $core->auth->user_prefs->toggles->put('unfolded_sections','','string','Folded sections in admin',null,true);
85}
86
87
[0]88# Dashboard icons
89$__dashboard_icons = new ArrayObject();
90
[2229]91$favs = $core->favs->getUserFavorites();
92$core->favs->appendDashboardIcons($__dashboard_icons);
[0]93
[2174]94# Check plugins and themes update from repository
[3491]95$checkStoreUpdate = function($mod, $url, $img, $icon)
[2174]96{
[2216]97     $repo = new dcStore($mod, $url);
[2174]98     $upd = $repo->get(true);
99     if (!empty($upd)) {
100          $icon[0] .= '<br />'.sprintf(__('An update is available', '%s updates are available.', count($upd)),count($upd));
101          $icon[1] .= '#update';
102          $icon[2] = 'images/menu/'.$img.'-b-update.png';
103     }
[3491]104};
[2174]105if (isset($__dashboard_icons['plugins'])) {
[3491]106     $checkStoreUpdate($core->plugins, $core->blog->settings->system->store_plugin_url, 'plugins', $__dashboard_icons['plugins']);
[2174]107}
108if (isset($__dashboard_icons['blog_theme'])) {
109     $themes = new dcThemes($core);
110     $themes->loadModules($core->blog->themes_path, null);
[3491]111     $checkStoreUpdate($themes, $core->blog->settings->system->store_theme_url, 'blog-theme', $__dashboard_icons['blog_theme']);
[2174]112}
113
[0]114# Latest news for dashboard
[2229]115$__dashboard_items = new ArrayObject(array(new ArrayObject(),new ArrayObject()));
[0]116
[13]117$dashboardItem = 0;
[0]118
[1378]119# Documentation links
120if ($core->auth->user_prefs->dashboard->doclinks) {
121     if (!empty($__resources['doc']))
122     {
[2085]123          $doc_links = '<div class="box small dc-box"><h3>'.__('Documentation and support').'</h3><ul>';
[2566]124
[1378]125          foreach ($__resources['doc'] as $k => $v) {
[2225]126               $doc_links .= '<li><a class="outgoing" href="'.$v.'" title="'.$k.'">'.$k.
[1728]127               ' <img src="images/outgoing-blue.png" alt="" /></a></li>';
[1378]128          }
[2566]129
[2085]130          $doc_links .= '</ul></div>';
[1378]131          $__dashboard_items[$dashboardItem][] = $doc_links;
132          $dashboardItem++;
133     }
134}
135
[0]136$core->callBehavior('adminDashboardItems', $core, $__dashboard_items);
137
[480]138# Dashboard content
139$__dashboard_contents = new ArrayObject(array(new ArrayObject,new ArrayObject));
140$core->callBehavior('adminDashboardContents', $core, $__dashboard_contents);
141
[2842]142# Editor stuff
143$admin_post_behavior = '';
144if ($core->auth->user_prefs->dashboard->quickentry) {
145     if ($core->auth->check('usage,contentadmin',$core->blog->id))
146     {
147          $post_format = $core->auth->getOption('post_format');
148          $post_editor = $core->auth->getOption('editor');
149          if ($post_editor && !empty($post_editor[$post_format])) {
[2854]150               // context is not post because of tags not available
[3024]151               $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'quickentry', array('#post_content'),$post_format);
[2842]152          }
153     }
154}
155
[0]156/* DISPLAY
157-------------------------------------------------------- */
158dcPage::open(__('Dashboard'),
159     dcPage::jsLoad('js/_index.js').
[2842]160     $admin_post_behavior.
[0]161     # --BEHAVIOR-- adminDashboardHeaders
[1358]162     $core->callBehavior('adminDashboardHeaders'),
163     dcPage::breadcrumb(
164          array(
[2166]165          __('Dashboard').' : '.html::escapeHTML($core->blog->name) => ''
[1358]166          ),
[2166]167          array('home_link' =>false)
168     )
[0]169);
170
[2159]171if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) {
[0]172     echo
[2720]173     '<p><a href="'.$core->adminurl->get("admin.home",array('default_blog' => 1)).'" class="button">'.__('Make this blog my default blog').'</a></p>';
[0]174}
175
176if ($core->blog->status == 0) {
[1558]177     echo '<p class="static-msg">'.__('This blog is offline').'.</p>';
[0]178} elseif ($core->blog->status == -1) {
[1558]179     echo '<p class="static-msg">'.__('This blog is removed').'.</p>';
[0]180}
181
[374]182if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) {
[0]183     echo
184     '<p class="static-msg">'.
[1077]185     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_URL').
186     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
[373]187     '</p>';
188}
189
[374]190if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) {
[373]191     echo
192     '<p class="static-msg">'.
[1077]193     sprintf(__('%s is not defined, you should edit your configuration file.'),'DC_ADMIN_MAILFROM').
194     ' '.__('See <a href="http://dotclear.org/documentation/2.0/admin/config">documentation</a> for more information.').
[0]195     '</p>';
196}
197
[1535]198$err = array();
199
200# Check cache directory
[1705]201if ( $core->auth->isSuperAdmin() ) {
202     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
[1708]203          $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]204     }
205} else {
206     if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) {
[1708]207          $err[] = '<p>'.__("The cache directory does not exist or is not writable. You should contact your administrator.").'</p>';
[1705]208     }
[1535]209}
210
211# Check public directory
[1705]212if ( $core->auth->isSuperAdmin() ) {
213     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
[1708]214          $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]215     }
216} else {
217     if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) {
[1708]218          $err[] = '<p>'.__("There is no writable root directory for the media manager. You should contact your administrator.").'</p>';
[1705]219     }
[1535]220}
221
222# Error list
223if (count($err) > 0) {
[2515]224     echo '<div class="error"><p><strong>'.__('Error:').'</strong></p>'.
[1535]225     '<ul><li>'.implode("</li><li>",$err).'</li></ul></div>';
226}
227
[0]228# Plugins install messages
229if (!empty($plugins_install['success']))
230{
[2116]231     echo '<div class="success">'.__('Following plugins have been installed:').'<ul>';
[0]232     foreach ($plugins_install['success'] as $k => $v) {
233          echo '<li>'.$k.'</li>';
234     }
235     echo '</ul></div>';
236}
237if (!empty($plugins_install['failure']))
238{
239     echo '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
240     foreach ($plugins_install['failure'] as $k => $v) {
241          echo '<li>'.$k.' ('.$v.')</li>';
242     }
243     echo '</ul></div>';
244}
[112]245# Errors modules notifications
246if ($core->auth->isSuperAdmin())
247{
[2239]248     $list = $core->plugins->getErrors();
249     if (!empty($list)) {
[2566]250          echo
[2239]251          '<div class="error" id="module-errors" class="error"><p>'.__('Errors have occured with following plugins:').'</p> '.
252          '<ul><li>'.implode("</li>\n<li>", $list).'</li></ul></div>';
[112]253     }
254}
255
[3412]256# Dashboard items and contents (processed first, as we need to know the result before displaying the icons.)
[1729]257$dashboardItems = '';
[112]258foreach ($__dashboard_items as $i)
[2566]259{
[3412]260     foreach ($i as $v) {
261          $dashboardItems .= $v;
262     }
263}
264$dashboardContents = '';
265foreach ($__dashboard_contents as $i)
266{
267     foreach ($i as $v) {
268          $dashboardContents .= $v;
[112]269     }
270}
271
[3412]272# Dashboard elements: icons then boxes (items then contents)
[2116]273echo '<div id="dashboard-main">';
274
[3238]275if (!$core->auth->user_prefs->dashboard->nofavicons) {
276     # Dashboard icons
277     echo '<div id="icons">';
278     foreach ($__dashboard_icons as $i)
279     {
280          echo
281          '<p><a href="'.$i[1].'"><img src="'.dc_admin_icon_url($i[2]).'" alt="" />'.
282          '<br /><span>'.$i[0].'</span></a></p>';
283     }
284     echo '</div>';
[0]285}
286
[13]287if ($core->auth->user_prefs->dashboard->quickentry) {
288     if ($core->auth->check('usage,contentadmin',$core->blog->id))
289     {
[1391]290          # Getting categories
[1719]291          $categories_combo = dcAdminCombos::getCategoriesCombo(
[3209]292               $core->blog->getCategories(array())
[1719]293          );
[2566]294
[13]295          echo
296          '<div id="quick">'.
[2929]297          '<h3>'.__('Quick entry').sprintf(' &rsaquo; %s',$core->auth->getOption('post_format')).'</h3>'.
[2708]298          '<form id="quick-entry" action="'.$core->adminurl->get('admin.post').'" method="post" class="fieldset">'.
[1499]299          '<h4>'.__('New entry').'</h4>'.
[1399]300          '<p class="col"><label for="post_title" class="required"><abbr title="'.__('Required field').'">*</abbr> '.__('Title:').'</label>'.
[3639]301          form::field('post_title',20,255,'','maximal','',false,'required placeholder="'.__('Title').'"').
[1399]302          '</p>'.
[45]303          '<p class="area"><label class="required" '.
304          'for="post_content"><abbr title="'.__('Required field').'">*</abbr> '.__('Content:').'</label> '.
[3639]305          form::textarea('post_content',50,10,'','','',false,'required placeholder="'.__('Content').'"').
[13]306          '</p>'.
[1521]307          '<p><label for="cat_id" class="classic">'.__('Category:').'</label> '.
308          form::combo('cat_id',$categories_combo).'</p>'.
[1418]309          ($core->auth->check('categories', $core->blog->id)
310               ? '<div>'.
[1521]311               '<p id="new_cat" class="q-cat">'.__('Add a new category').'</p>'.
312               '<p class="q-cat"><label for="new_cat_title">'.__('Title:').'</label> '.
313               form::field('new_cat_title',30,255,'','').'</p>'.
314               '<p class="q-cat"><label for="new_cat_parent">'.__('Parent:').'</label> '.
315               form::combo('new_cat_parent',$categories_combo,'','').
316               '</p>'.
[1488]317               '<p class="form-note info clear">'.__('This category will be created when you will save your post.').'</p>'.
[1418]318               '</div>'
319               : '').
[454]320          '<p><input type="submit" value="'.__('Save').'" name="save" /> '.
[13]321          ($core->auth->check('publish',$core->blog->id)
[536]322               ? '<input type="hidden" value="'.__('Save and publish').'" name="save-publish" />'
[13]323               : '').
324          $core->formNonce().
325          form::hidden('post_status',-2).
326          form::hidden('post_format',$core->auth->getOption('post_format')).
327          form::hidden('post_excerpt','').
328          form::hidden('post_lang',$core->auth->getInfo('user_lang')).
329          form::hidden('post_notes','').
330          '</p>'.
331          '</form>'.
332          '</div>';
333     }
[0]334}
335
[1728]336if ($dashboardContents != '' || $dashboardItems != '') {
[2566]337     echo
[2116]338     '<div id="dashboard-boxes">'.
[3476]339     ($dashboardItems != '' ? '<div class="db-items">'.$dashboardItems.'</div>' : '').
340     ($dashboardContents != '' ? '<div class="db-contents">'.$dashboardContents.'</div>' : '').
[2566]341     '</div>';
[1728]342}
[480]343
[2116]344echo '</div>'; #end dashboard-main
[2314]345dcPage::helpBlock('core_dashboard');
[0]346dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map