setUserDefaultBlog($core->auth->userID(), $core->blog->id); $core->adminurl->redirect("admin.home"); } catch (Exception $e) { $core->error->add($e->getMessage()); } } dcPage::check('usage,contentadmin'); if ($core->plugins->disableDepModules($core->adminurl->get('admin.home', []))) { exit; } # Logout if (!empty($_GET['logout'])) { $core->session->destroy(); if (isset($_COOKIE['dc_admin'])) { unset($_COOKIE['dc_admin']); setcookie('dc_admin', false, -600, '', '', DC_ADMIN_SSL); } $core->adminurl->redirect("admin.auth"); exit; } # Plugin install $plugins_install = $core->plugins->installModules(); # Check dashboard module prefs $ws = $core->auth->user_prefs->addWorkspace('dashboard'); if (!$core->auth->user_prefs->dashboard->prefExists('doclinks')) { if (!$core->auth->user_prefs->dashboard->prefExists('doclinks', true)) { $core->auth->user_prefs->dashboard->put('doclinks', true, 'boolean', '', null, true); } $core->auth->user_prefs->dashboard->put('doclinks', true, 'boolean'); } if (!$core->auth->user_prefs->dashboard->prefExists('dcnews')) { if (!$core->auth->user_prefs->dashboard->prefExists('dcnews', true)) { $core->auth->user_prefs->dashboard->put('dcnews', true, 'boolean', '', null, true); } $core->auth->user_prefs->dashboard->put('dcnews', true, 'boolean'); } if (!$core->auth->user_prefs->dashboard->prefExists('quickentry')) { if (!$core->auth->user_prefs->dashboard->prefExists('quickentry', true)) { $core->auth->user_prefs->dashboard->put('quickentry', false, 'boolean', '', null, true); } $core->auth->user_prefs->dashboard->put('quickentry', false, 'boolean'); } if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate')) { if (!$core->auth->user_prefs->dashboard->prefExists('nodcupdate', true)) { $core->auth->user_prefs->dashboard->put('nodcupdate', false, 'boolean', '', null, true); } $core->auth->user_prefs->dashboard->put('nodcupdate', false, 'boolean'); } // Handle folded/unfolded sections in admin from user preferences $ws = $core->auth->user_prefs->addWorkspace('toggles'); if (!$core->auth->user_prefs->toggles->prefExists('unfolded_sections')) { $core->auth->user_prefs->toggles->put('unfolded_sections', '', 'string', 'Folded sections in admin', null, true); } # Dashboard icons $__dashboard_icons = new ArrayObject(); $favs = $core->favs->getUserFavorites(); $core->favs->appendDashboardIcons($__dashboard_icons); # Check plugins and themes update from repository $checkStoreUpdate = function ($mod, $url, $img, $icon) { $repo = new dcStore($mod, $url); $upd = $repo->get(true); if (!empty($upd)) { $icon[0] .= '
' . sprintf(__('An update is available', '%s updates are available.', count($upd)), count($upd)); $icon[1] .= '#update'; $icon[2] = 'images/menu/' . $img . '-b-update.png'; } }; if (isset($__dashboard_icons['plugins'])) { $checkStoreUpdate($core->plugins, $core->blog->settings->system->store_plugin_url, 'plugins', $__dashboard_icons['plugins']); } if (isset($__dashboard_icons['blog_theme'])) { $themes = new dcThemes($core); $themes->loadModules($core->blog->themes_path, null); $checkStoreUpdate($themes, $core->blog->settings->system->store_theme_url, 'blog-theme', $__dashboard_icons['blog_theme']); } # Latest news for dashboard $__dashboard_items = new ArrayObject([new ArrayObject(), new ArrayObject()]); $dashboardItem = 0; # Documentation links if ($core->auth->user_prefs->dashboard->doclinks) { if (!empty($__resources['doc'])) { $doc_links = '

' . __('Documentation and support') . '

'; $__dashboard_items[$dashboardItem][] = $doc_links; $dashboardItem++; } } $core->callBehavior('adminDashboardItems', $core, $__dashboard_items); # Dashboard content $__dashboard_contents = new ArrayObject([new ArrayObject, new ArrayObject]); $core->callBehavior('adminDashboardContents', $core, $__dashboard_contents); # Editor stuff $admin_post_behavior = ''; if ($core->auth->user_prefs->dashboard->quickentry) { if ($core->auth->check('usage,contentadmin', $core->blog->id)) { $post_format = $core->auth->getOption('post_format'); $post_editor = $core->auth->getOption('editor'); if ($post_editor && !empty($post_editor[$post_format])) { // context is not post because of tags not available $admin_post_behavior = $core->callBehavior('adminPostEditor', $post_editor[$post_format], 'quickentry', ['#post_content'], $post_format); } } } # Dashboard drag'n'drop switch for its elements $core->auth->user_prefs->addWorkspace('accessibility'); $dragndrop = ''; $dragndrop_head = ''; $dragndrop_msg = [ 'dragndrop_off' => __('Dashboard area\'s drag and drop is disabled'), 'dragndrop_on' => __('Dashboard area\'s drag and drop is enabled') ]; if (!$core->auth->user_prefs->accessibility->nodragdrop) { $dragndrop_head = dcPage::jsJson('dotclear_dragndrop', $dragndrop_msg); $dragndrop = '' . ''; } /* DISPLAY -------------------------------------------------------- */ dcPage::open(__('Dashboard'), dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . dcPage::jsLoad('js/_index.js') . $dragndrop_head . $admin_post_behavior . # --BEHAVIOR-- adminDashboardHeaders $core->callBehavior('adminDashboardHeaders'), dcPage::breadcrumb( [ __('Dashboard') . ' : ' . html::escapeHTML($core->blog->name) => '' ], ['home_link' => false] ) ); if ($core->auth->getInfo('user_default_blog') != $core->blog->id && $core->auth->getBlogCount() > 1) { echo '

1]) . '" class="button">' . __('Make this blog my default blog') . '

'; } if ($core->blog->status == 0) { echo '

' . __('This blog is offline') . '.

'; } elseif ($core->blog->status == -1) { echo '

' . __('This blog is removed') . '.

'; } if (!defined('DC_ADMIN_URL') || !DC_ADMIN_URL) { echo '

' . sprintf(__('%s is not defined, you should edit your configuration file.'), 'DC_ADMIN_URL') . ' ' . __('See documentation for more information.') . '

'; } if (!defined('DC_ADMIN_MAILFROM') || !DC_ADMIN_MAILFROM) { echo '

' . sprintf(__('%s is not defined, you should edit your configuration file.'), 'DC_ADMIN_MAILFROM') . ' ' . __('See documentation for more information.') . '

'; } $err = []; # Check cache directory if ($core->auth->isSuperAdmin()) { if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { $err[] = '

' . __("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.") . '

'; } } else { if (!is_dir(DC_TPL_CACHE) || !is_writable(DC_TPL_CACHE)) { $err[] = '

' . __("The cache directory does not exist or is not writable. You should contact your administrator.") . '

'; } } # Check public directory if ($core->auth->isSuperAdmin()) { if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { $err[] = '

' . __("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).") . '

'; } } else { if (!is_dir($core->blog->public_path) || !is_writable($core->blog->public_path)) { $err[] = '

' . __("There is no writable root directory for the media manager. You should contact your administrator.") . '

'; } } # Error list if (count($err) > 0) { echo '

' . __('Error:') . '

' . '
'; } # Plugins install messages if (!empty($plugins_install['success'])) { echo '
' . __('Following plugins have been installed:') . '
'; } if (!empty($plugins_install['failure'])) { echo '
' . __('Following plugins have not been installed:') . '
'; } # Errors modules notifications if ($core->auth->isSuperAdmin()) { $list = $core->plugins->getErrors(); if (!empty($list)) { echo '

' . __('Errors have occured with following plugins:') . '

' . '
'; } } # Get current main orders $main_order = $core->auth->user_prefs->dashboard->main_order; $main_order = ($main_order != '' ? explode(',', $main_order) : []); # Get current boxes orders $boxes_order = $core->auth->user_prefs->dashboard->boxes_order; $boxes_order = ($boxes_order != '' ? explode(',', $boxes_order) : []); # Get current boxes items orders $boxes_items_order = $core->auth->user_prefs->dashboard->boxes_items_order; $boxes_items_order = ($boxes_items_order != '' ? explode(',', $boxes_items_order) : []); # Get current boxes contents orders $boxes_contents_order = $core->auth->user_prefs->dashboard->boxes_contents_order; $boxes_contents_order = ($boxes_contents_order != '' ? explode(',', $boxes_contents_order) : []); $composeItems = function ($list, $blocks, $flat = false) { $ret = []; $items = []; if ($flat) { $items = $blocks; } else { foreach ($blocks as $i) { foreach ($i as $v) { $items[] = $v; } } } # First loop to find ordered indexes $order = []; $index = 0; foreach ($items as $v) { if (preg_match('//ms', $v, $match)) { $id = $match[1]; $position = array_search($id, $list, true); if ($position !== false) { $order[$position] = $index; } } $index++; } # Second loop to combine ordered items $index = 0; foreach ($items as $v) { $position = array_search($index, $order, true); if ($position !== false) { $ret[$position] = $v; } $index++; } # Reorder items on their position (key) ksort($ret); # Third loop to combine unordered items $index = 0; foreach ($items as $v) { $position = array_search($index, $order, true); if ($position === false) { $ret[count($ret)] = $v; } $index++; } return join('', $ret); }; # Compose dashboard items (doc, …) $dashboardItems = $composeItems($boxes_items_order, $__dashboard_items); # Compose dashboard contents (plugin's modules) $dashboardContents = $composeItems($boxes_contents_order, $__dashboard_contents); $__dashboard_boxes = []; if ($dashboardItems != '') { $__dashboard_boxes[] = '
' . $dashboardItems . '
'; } if ($dashboardContents != '') { $__dashboard_boxes[] = '
' . $dashboardContents . '
'; } $dashboardBoxes = $composeItems($boxes_order, $__dashboard_boxes, true); # Compose main area $__dashboard_main = []; if (!$core->auth->user_prefs->dashboard->nofavicons) { # Dashboard icons $dashboardIcons = '
'; foreach ($__dashboard_icons as $i) { $dashboardIcons .= '

' . '
' . $i[0] . '

'; } $dashboardIcons .= '
'; $__dashboard_main[] = $dashboardIcons; } if ($core->auth->user_prefs->dashboard->quickentry) { if ($core->auth->check('usage,contentadmin', $core->blog->id)) { # Getting categories $categories_combo = dcAdminCombos::getCategoriesCombo( $core->blog->getCategories([]) ); $dashboardQuickEntry = '
' . '

' . __('Quick entry') . sprintf(' › %s', $core->auth->getOption('post_format')) . '

' . '
' . '

' . __('New entry') . '

' . '

' . form::field('post_title', 20, 255, [ 'class' => 'maximal', 'extra_html' => 'required placeholder="' . __('Title') . '"' ]) . '

' . '
' . form::textarea('post_content', 50, 10, ['extra_html' => 'required placeholder="' . __('Content') . '"']) . '
' . '

' . form::combo('cat_id', $categories_combo) . '

' . ($core->auth->check('categories', $core->blog->id) ? '
' . '

' . __('Add a new category') . '

' . '

' . form::field('new_cat_title', 30, 255) . '

' . '

' . form::combo('new_cat_parent', $categories_combo) . '

' . '

' . __('This category will be created when you will save your post.') . '

' . '
' : '') . '

' . ($core->auth->check('publish', $core->blog->id) ? '' : '') . $core->formNonce() . form::hidden('post_status', -2) . form::hidden('post_format', $core->auth->getOption('post_format')) . form::hidden('post_excerpt', '') . form::hidden('post_lang', $core->auth->getInfo('user_lang')) . form::hidden('post_notes', '') . '

' . '
' . '
'; $__dashboard_main[] = $dashboardQuickEntry; } } if ($dashboardBoxes != '') { $__dashboard_main[] = '
' . $dashboardBoxes . '
'; } $dashboardMain = $composeItems($main_order, $__dashboard_main, true); echo $dragndrop . '
' . $dashboardMain . '
'; dcPage::helpBlock('core_dashboard'); dcPage::close();