mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-27 11:49:56 +03:00
feature #534, modernize admin homepage {wip}
* add tab * display the pending comments as a "message" (new blue box) * remove anything related to environment #532 * display stats as big icon + big number + caption * new stat "storage used"
This commit is contained in:
parent
41fe517590
commit
5dbc6c85a9
5 changed files with 200 additions and 121 deletions
|
@ -219,6 +219,7 @@ SELECT COUNT(*)
|
|||
if ($nb_comments > 0)
|
||||
{
|
||||
$template->assign('NB_PENDING_COMMENTS', $nb_comments);
|
||||
$page['nb_pending_comments'] = $nb_comments;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,10 @@ function add_core_tabs($sheets, $tab_id)
|
|||
{
|
||||
switch($tab_id)
|
||||
{
|
||||
case 'admin_home':
|
||||
$sheets[''] = array('caption' => l10n('Administration Home'), 'url' => 'admin.php');
|
||||
break;
|
||||
|
||||
case 'album':
|
||||
global $admin_album_base_url;
|
||||
$sheets['properties'] = array('caption' => '<span class="icon-pencil"></span>'.l10n('Properties'), 'url' => $admin_album_base_url.'-properties');
|
||||
|
|
|
@ -3006,3 +3006,29 @@ UPDATE '.IMAGES_TABLE.'
|
|||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a more human friendly representation of big numbers. Like 17.8k instead of 17832
|
||||
*
|
||||
* @since 2.9
|
||||
* @param float $numbers
|
||||
*/
|
||||
function number_format_human_readable($numbers)
|
||||
{
|
||||
$readable = array("", "k", "M");
|
||||
$index = 0;
|
||||
|
||||
while ($numbers >= 1000)
|
||||
{
|
||||
$numbers /= 1000;
|
||||
$index++;
|
||||
|
||||
if ($index > count($readable) - 1)
|
||||
{
|
||||
$index--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return number_format($numbers, 1).$readable[$index];
|
||||
}
|
||||
|
|
141
admin/intro.php
141
admin/intro.php
|
@ -29,13 +29,26 @@ if (!defined('PHPWG_ROOT_PATH'))
|
|||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/check_integrity.class.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/c13y_internal.class.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/image.class.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
check_status(ACCESS_ADMINISTRATOR);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | tabs |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
|
||||
|
||||
$my_base_url = get_root_url().'admin.php?page=';
|
||||
|
||||
$tabsheet = new tabsheet();
|
||||
$tabsheet->set_id('admin_home');
|
||||
$tabsheet->select('');
|
||||
$tabsheet->assign();
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | actions |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
@ -91,11 +104,15 @@ if (isset($_GET['action']) and 'check_upgrade' == $_GET['action'])
|
|||
}
|
||||
}
|
||||
}
|
||||
// Show phpinfo() output
|
||||
else if (isset($_GET['action']) and 'phpinfo' == $_GET['action'])
|
||||
|
||||
if (isset($page['nb_pending_comments']))
|
||||
{
|
||||
phpinfo();
|
||||
exit();
|
||||
$message = l10n('User comments').' <i class="icon-chat"></i> ';
|
||||
$message.= '<a href="'.$link_start.'comments">';
|
||||
$message.= l10n('%d waiting for validation', $page['nb_pending_comments']);
|
||||
$message.= ' <i class="icon-right"></i></a>';
|
||||
|
||||
$page['messages'][] = $message;
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
@ -113,9 +130,6 @@ if ($conf['show_newsletter_subscription']) {
|
|||
);
|
||||
}
|
||||
|
||||
$php_current_timestamp = date("Y-m-d H:i:s");
|
||||
$db_version = pwg_get_db_version();
|
||||
list($db_current_date) = pwg_db_fetch_row(pwg_query('SELECT now();'));
|
||||
|
||||
$query = '
|
||||
SELECT COUNT(*)
|
||||
|
@ -129,26 +143,6 @@ SELECT COUNT(*)
|
|||
;';
|
||||
list($nb_categories) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT COUNT(*)
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
WHERE dir IS NULL
|
||||
;';
|
||||
list($nb_virtual) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT COUNT(*)
|
||||
FROM '.CATEGORIES_TABLE.'
|
||||
WHERE dir IS NOT NULL
|
||||
;';
|
||||
list($nb_physical) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT COUNT(*)
|
||||
FROM '.IMAGE_CATEGORY_TABLE.'
|
||||
;';
|
||||
list($nb_image_category) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT COUNT(*)
|
||||
FROM '.TAGS_TABLE.'
|
||||
|
@ -179,29 +173,43 @@ SELECT COUNT(*)
|
|||
;';
|
||||
list($nb_rates) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
SUM(nb_pages)
|
||||
FROM '.HISTORY_SUMMARY_TABLE.'
|
||||
WHERE month IS NULL
|
||||
;';
|
||||
list($nb_views) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
SUM(filesize)
|
||||
FROM '.IMAGES_TABLE.'
|
||||
;';
|
||||
list($disk_usage) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
SUM(filesize)
|
||||
FROM '.IMAGE_FORMAT_TABLE.'
|
||||
;';
|
||||
list($formats_disk_usage) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$disk_usage+= $formats_disk_usage;
|
||||
|
||||
$template->assign(
|
||||
array(
|
||||
'PHPWG_URL' => PHPWG_URL,
|
||||
'PWG_VERSION' => PHPWG_VERSION,
|
||||
'OS' => PHP_OS,
|
||||
'PHP_VERSION' => phpversion(),
|
||||
'DB_ENGINE' => 'MySQL',
|
||||
'DB_VERSION' => $db_version,
|
||||
'DB_ELEMENTS' => l10n_dec('%d photo', '%d photos', $nb_elements),
|
||||
'DB_CATEGORIES' =>
|
||||
l10n_dec('%d album including', '%d albums including', $nb_categories).
|
||||
l10n_dec('%d physical', '%d physicals', $nb_physical).
|
||||
l10n_dec(' and %d virtual', ' and %d virtuals', $nb_virtual),
|
||||
'DB_IMAGE_CATEGORY' => l10n_dec('%d association', '%d associations', $nb_image_category),
|
||||
'DB_TAGS' => l10n_dec('%d tag', '%d tags', $nb_tags),
|
||||
'DB_IMAGE_TAG' => l10n_dec('%d association', '%d associations', $nb_image_tag),
|
||||
'DB_USERS' => l10n_dec('%d user', '%d users', $nb_users),
|
||||
'DB_GROUPS' => l10n_dec('%d group', '%d groups', $nb_groups),
|
||||
'DB_RATES' => ($nb_rates == 0) ? l10n('no rate') : l10n('%d rates', $nb_rates),
|
||||
'NB_PHOTOS' => number_format($nb_elements, 0, '.', ','),
|
||||
'NB_ALBUMS' => $nb_categories,
|
||||
'NB_TAGS' => $nb_tags,
|
||||
'NB_IMAGE_TAG' => $nb_image_tag,
|
||||
'NB_USERS' => $nb_users,
|
||||
'NB_GROUPS' => $nb_groups,
|
||||
'NB_RATES' => $nb_rates,
|
||||
'NB_VIEWS' => number_format_human_readable($nb_views),
|
||||
'NB_PLUGINS' => count($pwg_loaded_plugins),
|
||||
'STORAGE_USED' => l10n('%sGB', number_format($disk_usage/(1024*1024), 1)),
|
||||
'U_CHECK_UPGRADE' => PHPWG_ROOT_PATH.'admin.php?action=check_upgrade',
|
||||
'U_PHPINFO' => PHPWG_ROOT_PATH.'admin.php?action=phpinfo',
|
||||
'PHP_DATATIME' => $php_current_timestamp,
|
||||
'DB_DATATIME' => $db_current_date,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -212,7 +220,7 @@ SELECT COUNT(*)
|
|||
FROM '.COMMENTS_TABLE.'
|
||||
;';
|
||||
list($nb_comments) = pwg_db_fetch_row(pwg_query($query));
|
||||
$template->assign('DB_COMMENTS', l10n_dec('%d comment', '%d comments', $nb_comments));
|
||||
$template->assign('NB_COMMENTS', $nb_comments);
|
||||
}
|
||||
|
||||
if ($nb_elements > 0)
|
||||
|
@ -224,44 +232,13 @@ SELECT MIN(date_available)
|
|||
list($first_date) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$template->assign(
|
||||
'first_added',
|
||||
array(
|
||||
'DB_DATE' =>
|
||||
l10n('first photo added on %s', format_date($first_date))
|
||||
'first_added_date' => format_date($first_date),
|
||||
'first_added_age' => time_since($first_date, 'year', null, false, false),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// graphics library
|
||||
switch (pwg_image::get_library())
|
||||
{
|
||||
case 'imagick':
|
||||
$library = 'ImageMagick';
|
||||
$img = new Imagick();
|
||||
$version = $img->getVersion();
|
||||
if (preg_match('/ImageMagick \d+\.\d+\.\d+-?\d*/', $version['versionString'], $match))
|
||||
{
|
||||
$library = $match[0];
|
||||
}
|
||||
$template->assign('GRAPHICS_LIBRARY', $library);
|
||||
break;
|
||||
|
||||
case 'ext_imagick':
|
||||
$library = 'External ImageMagick';
|
||||
exec($conf['ext_imagick_dir'].'convert -version', $returnarray);
|
||||
if (preg_match('/Version: ImageMagick (\d+\.\d+\.\d+-?\d*)/', $returnarray[0], $match))
|
||||
{
|
||||
$library .= ' ' . $match[1];
|
||||
}
|
||||
$template->assign('GRAPHICS_LIBRARY', $library);
|
||||
break;
|
||||
|
||||
case 'gd':
|
||||
$gd_info = gd_info();
|
||||
$template->assign('GRAPHICS_LIBRARY', 'GD '.@$gd_info['GD Version']);
|
||||
break;
|
||||
}
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | sending html code |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
{include file='include/colorbox.inc.tpl'}
|
||||
|
||||
{combine_script id='jquery.cluetip' load='async' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
|
||||
|
||||
{footer_script require='jquery.cluetip'}
|
||||
var piwigo_need_update_msg = '<a href="admin.php?page=updates">{'A new version of Piwigo is available.'|@translate|@escape:"javascript"}</a>';
|
||||
var ext_need_update_msg = '<a href="admin.php?page=updates&tab=ext">{'Some upgrades are available for extensions.'|@translate|@escape:"javascript"}</a>';
|
||||
var piwigo_need_update_msg = '<a href="admin.php?page=updates">{'A new version of Piwigo is available.'|@translate|@escape:"javascript"} <i class="icon-right"></i></a>';
|
||||
var ext_need_update_msg = '<a href="admin.php?page=updates&tab=ext">{'Some upgrades are available for extensions.'|@translate|@escape:"javascript"} <i class="icon-right"></i></a>';
|
||||
|
||||
{literal}
|
||||
jQuery().ready(function(){
|
||||
|
@ -23,7 +25,7 @@ jQuery().ready(function(){
|
|||
piwigo_update = data['result']['piwigo_need_update'];
|
||||
ext_update = data['result']['ext_need_update']
|
||||
if ((piwigo_update || ext_update) && !jQuery(".warnings").is('div'))
|
||||
jQuery("#content").prepend('<div class="warnings"><i class="eiw-icon icon-attention"></i><ul></ul></div>');
|
||||
jQuery(".eiw").prepend('<div class="warnings"><i class="eiw-icon icon-attention"></i><ul></ul></div>');
|
||||
if (piwigo_update)
|
||||
jQuery(".warnings ul").append('<li>'+piwigo_need_update_msg+'</li>');
|
||||
if (ext_update)
|
||||
|
@ -34,12 +36,114 @@ jQuery().ready(function(){
|
|||
{/literal}
|
||||
{/footer_script}
|
||||
|
||||
{html_style}
|
||||
.stat-boxes {
|
||||
text-align:left;
|
||||
margin:10px;
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
display:inline-block;
|
||||
width:200px;
|
||||
margin:10px;
|
||||
cursor:help;
|
||||
}
|
||||
|
||||
.stat-box:hover {
|
||||
color:#ff7700;
|
||||
}
|
||||
|
||||
.stat-box i {
|
||||
font-size:50px;
|
||||
float:left;
|
||||
margin-right:5px;
|
||||
}
|
||||
|
||||
.stat-box .number, .stat-box .caption {
|
||||
display:inline-block;
|
||||
width:120px;
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
.stat-box .number {
|
||||
margin-top:10px;
|
||||
font-size:20px;
|
||||
}
|
||||
|
||||
.eiw .messages ul li {
|
||||
list-style-type:none !important;
|
||||
}
|
||||
|
||||
.eiw .messages .eiw-icon {
|
||||
margin-right:10px !important;
|
||||
}
|
||||
{/html_style}
|
||||
|
||||
<h2>{'Piwigo Administration'|@translate}</h2>
|
||||
|
||||
<div class="stat-boxes">
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-picture"></i>
|
||||
<span class="number">{$NB_PHOTOS}</span><span class="caption">{'Photos'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-sitemap"></i>
|
||||
<span class="number">{$NB_ALBUMS}</span><span class="caption">{'Albums'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-tags"></i>
|
||||
<span class="number">{$NB_TAGS}</span><span class="caption" title="{'%d associations'|translate:$NB_IMAGE_TAG}">{'Tags'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-users"></i>
|
||||
<span class="number">{$NB_USERS}</span><span class="caption">{'Users'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-group"></i>
|
||||
<span class="number">{$NB_GROUPS}</span><span class="caption">{'Groups'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-chat"></i>
|
||||
<span class="number">{$NB_COMMENTS}</span><span class="caption">{'Comments'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-star"></i>
|
||||
<span class="number">{$NB_RATES}</span><span class="caption">{'Rating'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-signal"></i>
|
||||
<span class="number">{$NB_VIEWS}</span><span class="caption">{'Pages seen'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-puzzle"></i>
|
||||
<span class="number">{$NB_PLUGINS}</span><span class="caption">{'Plugins'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-hdd"></i>
|
||||
<span class="number">{$STORAGE_USED}</span><span class="caption">{'Storage used'|translate}</span>
|
||||
</div>
|
||||
|
||||
<div class="stat-box">
|
||||
<i class="icon-back-in-time"></i>
|
||||
<span class="number">{$first_added_age}</span><span class="caption" title="{'first photo added on %s'|translate:$first_added_date}">{'First photo added'|translate}</span>
|
||||
</div>
|
||||
|
||||
</div> {* .stat-boxes *}
|
||||
|
||||
<dl style="padding-top: 30px;">
|
||||
<dt>{'Piwigo version'|@translate}</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li><a href="{$PHPWG_URL}" class="externalLink">Piwigo</a> {$PWG_VERSION}</li>
|
||||
<li><a href="{$U_CHECK_UPGRADE}">{'Check for upgrade'|@translate}</a></li>
|
||||
{if isset($SUBSCRIBE_BASE_URL)}
|
||||
<li><a href="{$SUBSCRIBE_BASE_URL}{$EMAIL}" class="externalLink cluetip" title="{'Piwigo Announcements Newsletter'|@translate}|{'Keep in touch with Piwigo project, subscribe to Piwigo Announcement Newsletter. You will receive emails when a new release is available (sometimes including a security bug fix, it\'s important to know and upgrade) and when major events happen to the project. Only a few emails a year.'|@translate|@htmlspecialchars|@nl2br}">{'Subscribe %s to Piwigo Announcements Newsletter'|@translate:$EMAIL}</a></li>
|
||||
|
@ -47,39 +151,6 @@ jQuery().ready(function(){
|
|||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt>{'Environment'|@translate}</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>{'Operating system'|@translate}: {$OS}</li>
|
||||
<li>PHP: {$PHP_VERSION} (<a href="{$U_PHPINFO}" class="externalLink">{'Show info'|@translate}</a>) [{$PHP_DATATIME}]</li>
|
||||
<li>{$DB_ENGINE}: {$DB_VERSION} [{$DB_DATATIME}]</li>
|
||||
{if isset($GRAPHICS_LIBRARY)}
|
||||
<li>{'Graphics Library'|@translate}: {$GRAPHICS_LIBRARY}</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</dd>
|
||||
|
||||
<dt>{'Database'|@translate}</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<li>
|
||||
{$DB_ELEMENTS}
|
||||
{if isset($first_added)}
|
||||
({$first_added.DB_DATE})
|
||||
{/if}
|
||||
</li>
|
||||
<li>{$DB_CATEGORIES} ({$DB_IMAGE_CATEGORY})</li>
|
||||
<li>{$DB_TAGS} ({$DB_IMAGE_TAG})</li>
|
||||
<li>{$DB_USERS}</li>
|
||||
<li>{$DB_GROUPS}</li>
|
||||
{if isset($DB_COMMENTS)}
|
||||
<li>
|
||||
{$DB_COMMENTS}{if $NB_PENDING_COMMENTS > 0} (<a href="{$U_COMMENTS}">{'%d waiting for validation'|translate:$NB_PENDING_COMMENTS}</a>){/if}
|
||||
</li>
|
||||
{/if}
|
||||
<li>{$DB_RATES}</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
{if $ENABLE_SYNCHRONIZATION}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue