Navigation Menu

Skip to content

Commit

Permalink
feature 2564: small changes in infos list
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@13086 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
mistic100 committed Feb 10, 2012
1 parent 69a704f commit b82ddfb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 21 deletions.
7 changes: 4 additions & 3 deletions admin/picture_modify.php
Expand Up @@ -301,9 +301,10 @@

$intro_vars = array(
'file' => sprintf(l10n('Original file : %s'), $row['file']),
'added' => sprintf(l10n('Posted %s on %s by %s'), time_since($row['date_available'], 'month'), format_date($row['date_available'], false, false), $row['added_by']),
'add_date' => sprintf(l10n('Posted %s on %s'), time_since($row['date_available'], 'year'), format_date($row['date_available'], false, false)),
'added_by' => sprintf(l10n('Added by %s'), $row['added_by']),
'size' => $row['width'].'×'.$row['height'].' pixels, '.sprintf('%.2f', $row['filesize']/1024).'MB',
'hits' => sprintf(l10n('%d visits'), $row['hit']),
'stats' => sprintf(l10n('Visited %d times'), $row['hit']),
'id' => sprintf(l10n('Numeric identifier : %d'), $row['id']),
);

Expand All @@ -317,7 +318,7 @@
;';
list($row['nb_rates']) = pwg_db_fetch_row(pwg_query($query));

$intro_vars['rate'] = sprintf(l10n('Rated %d times, score : %f'), $row['nb_rates'], $row['rating_score']);
$intro_vars['stats'].= ', '.sprintf(l10n('Rated %d times, score : %.2f'), $row['nb_rates'], $row['rating_score']);
}

$template->assign('INTRO', $intro_vars);
Expand Down
12 changes: 6 additions & 6 deletions admin/themes/default/template/picture_modify.tpl
Expand Up @@ -46,18 +46,18 @@ pwg_initialization_datepicker("#date_creation_day", "#date_creation_month", "#da
<td id="albumThumbnail">
<img src="{$TN_SRC}" alt="{'Thumbnail'|@translate}" class="Thumbnail">
</td>
<td id="albumLinks" style="width:500px;vertical-align:top;">
<ul>
<td id="albumLinks" style="width:400px;vertical-align:top;">
<ul style="padding-left:15px;margin:0;">
<li>{$INTRO.file}</li>
<li>{$INTRO.added}</li>
<li>{$INTRO.add_date}</li>
<li>{$INTRO.added_by}</li>
<li>{$INTRO.size}</li>
<li>{$INTRO.hits}</li>
{if $INTRO.rate}<li>{$INTRO.rate}</li>{/if}
<li>{$INTRO.stats}</li>
<li>{$INTRO.id}</li>
</ul>
</td>
<td style="vertical-align:top;">
<ul style="padding-left:15px;">
<ul style="padding-left:15px;margin:0;">
{if isset($U_JUMPTO) }
<li><a href="{$U_JUMPTO}">{'jump to photo'|@translate} →</a></li>
{/if}
Expand Down
27 changes: 15 additions & 12 deletions include/functions.inc.php
Expand Up @@ -546,34 +546,37 @@ function time_since($original, $stop = 'minute')
$ymdhms[] = $tok;
$tok = strtok('- :');
}

if ($ymdhms[0] < 1970) return false;
if (!isset($ymdhms[3])) $ymdhms[3] = 12;
if (!isset($ymdhms[4])) $ymdhms[4] = 0;
if (!isset($ymdhms[5])) $ymdhms[5] = 0;
$original = mktime($ymdhms[3],$ymdhms[4],$ymdhms[5],$ymdhms[1],$ymdhms[2],$ymdhms[0]);
}

// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , 'year'),
array(60 * 60 * 24 * 30 , 'month'),
array(60 * 60 * 24 * 7, 'week'),
array(60 * 60 * 24 , 'day'),
array(60 * 60 , 'hour'),
array(60 , 'minute'),
array(1 , 'second'),
'year' => 60 * 60 * 24 * 365,
'month' => 60 * 60 * 24 * 30,
'week' => 60 * 60 * 24 * 7,
'day' => 60 * 60 * 24,
'hour' => 60 * 60,
'minute' => 60,
'second' => 1,
);

$today = time(); /* Current unix time */
$since = abs($today - $original);

$print = null;
for ($i = 0, $j = count($chunks); $i < $j; $i++)
foreach ($chunks as $name => $seconds)
{
$seconds = $chunks[$i][0];
$name = $chunks[$i][1];
if (($count = floor($since / $seconds)) != 0)
{
$print.= ($count == 1) ? '1 '.l10n($name).' ' : $count.' '.l10n($name.'s').' ';
$print.= l10n_dec('%d '.$name, '%d '.$name.'s', $count);
$since-= $count*$seconds;
}
if ($name == $stop)
if (!empty($print) and $chunks[$name] <= $chunks[$stop])
{
break;
}
Expand Down

0 comments on commit b82ddfb

Please sign in to comment.